User: rinkrank
  Date: 02/04/08 17:07:18

  Modified:    core/src/xdoclet/template TemplateParser.java
  Log:
  -Dynamic loading of optional modules is partially working (subtasks work. 
registering tag handlers doesn't)
  -Translator no longer throws XDocletException
  
  Revision  Changes    Path
  1.10      +102 -80   xdoclet/core/src/xdoclet/template/TemplateParser.java
  
  Index: TemplateParser.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/template/TemplateParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- TemplateParser.java       4 Apr 2002 01:03:11 -0000       1.9
  +++ TemplateParser.java       9 Apr 2002 00:07:18 -0000       1.10
  @@ -28,57 +28,73 @@
    *
    * @author Vincent Harcq ([EMAIL PROTECTED])
    * @created December 27, 2001
  - * @version $Revision: 1.9 $
  + * @version   $Revision: 1.10 $
    */
   public class TemplateParser
  -              extends TemplateEngine {
  +      extends TemplateEngine
  +{
  +
  +     /**
  +      * @todo-javadoc   Describe the field
  +      */
  +     private static TemplateParser instance = new TemplateParser();
        /**
         * @todo-javadoc Describe the field
         */
        private List mergeFiles;
   
  -
        /**
         * Initialize the Template Engine. Reads the XDoclet properties file, and loads
         * any XTag handler classes specified.
  -      *
  -      * @exception TemplateException Description of Exception
         */
  -     public TemplateParser() throws TemplateException {
  +     protected TemplateParser()
  +     {
                super();
                mergeFiles = new ArrayList();
                output = null;
        }
   
  +     /**
  +      * Gets the ParserInstance attribute of the TemplateParser class
  +      *
  +      * @return   The ParserInstance value
  +      */
  +     public static TemplateParser getParserInstance()
  +     {
  +             return instance;
  +     }
   
        /**
         * Return the list of merge files involved in the generation.
         *
         * @return an array of File
         */
  -     public String[] getMergeFiles() {
  +     public String[] getMergeFiles()
  +     {
                return (String[])mergeFiles.toArray(new String[mergeFiles.size()]);
        }
   
  -
        /**
         * A utility method used for generating the dest_file based on template_file
         * template file.
         *
         * @exception TemplateException Description of Exception
         */
  -     public void start() throws TemplateException {
  +     public void start() throws TemplateException
  +     {
                Category cat = Log.getCategory(TemplateParser.class, "start");
   
                String content = FileManager.getURLContent(getTemplateURL());
   
  -             if (content != null) {
  +             if( content != null )
  +             {
                        cat.debug("content.length()=" + content.length());
   
                        setCurrentLineNum(0);
                        generate(content);
                }
  -             else {
  +             else
  +             {
                        String msg = Translator.getString("template_not_found", new 
String[]{getTemplateURL().toString()});
   
                        cat.error(msg);
  @@ -86,7 +102,6 @@
                }
        }
   
  -
        /**
         * In this class, this method does not -generate- anything but only parse the
         * files. Callback to this class can be made by specific TagHandlers during the
  @@ -95,38 +110,41 @@
         * @param template Description of Parameter
         * @exception TemplateException Description of Exception
         */
  -     public void generate(final String template) throws TemplateException {
  +     public void generate( final String template ) throws TemplateException
  +     {
                Category cat = Log.getCategory(TemplateEngine.class, "generate");
                int index = 0;
                int prev_index = 0;
                int i = 0;
   
  -             while (true) {
  +             while( true )
  +             {
                        // Look for the next tag that we haven't yet handled.
                        index = template.indexOf(XDOCLET_HEAD, prev_index);
   
  -                     if (index == -1) {
  +                     if( index == -1 )
  +                     {
                                break;
                        }
  -                     else {
  +                     else
  +                     {
                                prev_index = handleTag(index, template);
                        }
                }
   
        }
   
  -
        /**
         * Callback by the MergeTagsHandler to give the parser the list of merge files
         * involved.
         *
         * @param file one merge file involved
         */
  -     public void addMergeFile(String file) {
  +     public void addMergeFile( String file )
  +     {
                mergeFiles.add(file);
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -142,11 +160,11 @@
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void invokeContentMethod(String cmd, Properties attributes, String 
template, int i) throws TemplateException {
  +     protected void invokeContentMethod( String cmd, Properties attributes, String 
template, int i ) throws TemplateException
  +     {
                // We do not need anything when parsing (e.g. isGenerationNeeded run)
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -167,21 +185,25 @@
         * @todo-javadoc Write javadocs for exception
         */
        protected Object invoke(Method m, Object cmdImplProvider, Object[] params1)
  -                      throws InvocationTargetException, IllegalAccessException, 
TemplateException {
  +              throws InvocationTargetException, IllegalAccessException, 
TemplateException
  +     {
                Category cat = Log.getCategory(TemplateParser.class, "invoke");
   
  -             if (cat.isDebugEnabled()) {
  +             if( cat.isDebugEnabled() )
  +             {
                        cat.debug(m.getName() + params1[0]);
                }
   
                // The trick to have a quick parsing is to only take care of merging.
                // The rest is not important and the tag handlers are bypassed by 
simply
                // calling generate()
  -             if (!m.getName().equals("merge")) {
  +             if( !m.getName().equals( "merge" ) )
  +             {
                        generate((String)params1[0]);
                        return null;
                }
  -             else {
  +             else
  +             {
                        return m.invoke(cmdImplProvider, params1);
                }
        }
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Sponsored by http://www.ThinkGeek.com/

Reply via email to