User: vharcq  
  Date: 02/04/16 16:01:05

  Modified:    core/src/xdoclet DocletTask.java XDocletTagSupport.java
  Log:
  ejb:persistence table-name="abc" on CLASS Level
  ejb:persistence column-name="abc" jdbc-type="VARCHAR" sql-type="VARCHAR(50)" on 
METHOD Level
  JBoss CMP and Jaws implement them keeping backward compatibility (see AccountBean)
  Thanks to Marcus :)
  
  Revision  Changes    Path
  1.37      +330 -323  xdoclet/core/src/xdoclet/DocletTask.java
  
  Index: DocletTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/DocletTask.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -w -r1.36 -r1.37
  --- DocletTask.java   16 Apr 2002 20:36:48 -0000      1.36
  +++ DocletTask.java   16 Apr 2002 23:01:05 -0000      1.37
  @@ -1,37 +1,6 @@
   /*
  - * Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
  + * Copyright (c) 2001,2002 The XDoclet team
    * All rights reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without modification,
  - * are permitted provided that the following conditions are met:
  - *
  - * - Redistributions of source code must retain the above copyright notice,
  - *   this list of conditions and the following disclaimer.
  - *
  - * - Redistributions in binary form must reproduce the above copyright
  - *   notice, this list of conditions and the following disclaimer in the
  - *   documentation and/or other materials provided with the distribution.
  - *
  - * - Neither the name of BEKK Consulting nor the names of its
  - *   contributors may be used to endorse or promote products derived from
  - *   this software without specific prior written permission.
  - *
  - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
  - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  - * DAMAGE.
  - */
  -
  -/*
  - * Change log
  - *
    */
   package xdoclet;
   
  @@ -39,6 +8,7 @@
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.AntClassLoader;
  +import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
  @@ -66,9 +36,15 @@
    * @author Ara Abrahamian ([EMAIL PROTECTED])
    * @author <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created June 19, 2001
  - * @version $Revision: 1.36 $
  + * @version   $Revision: 1.37 $
    */
  -public class DocletTask extends Task {
  +public class DocletTask extends Task
  +{
  +     // ant will replace the tag with the version propperty specified in build.xml
  +     /**
  +      * @todo-javadoc   Describe the field
  +      */
  +     public final static String XDOCLET_VERSION = "@VERSION@";
   
        /**
         * @todo-javadoc Describe the field
  @@ -116,195 +92,191 @@
         * @todo-javadoc Describe the field
         */
        private ArrayList configParams = new ArrayList();
  -     // ant will replace the tag with the version propperty specified in build.xml
  -     /**
  -      * @todo-javadoc Describe the field
  -      */
  -     public final static String XDOCLET_VERSION = "@VERSION@";
  -
   
        /**
  -      * Sets the Classpath attribute of the DocletTask object
  +      * Gets the Classpath attribute of the DocletTask object
         *
  -      * @param src The new Classpath value
  +      * @return   The Classpath value
         */
  -     public void setClasspath(Path src) {
  -             if (classpath == null) {
  -                     classpath = src;
  -             }
  -             else {
  -                     classpath.append(src);
  -             }
  +     public Path getClasspath()
  +     {
  +             return classpath;
        }
   
  -
        /**
  -      * Sets the ClasspathRef attribute of the DocletTask object
  +      * Gets the ClasspathRef attribute of the DocletTask object
         *
  -      * @param ref The new ClasspathRef value
  +      * @return   The ClasspathRef value
         */
  -     public void setClasspathRef(org.apache.tools.ant.types.Reference ref) {
  -             this.classpathRef = ref;
  -             createClasspath().setRefid(ref);
  +     public Reference getClasspathRef()
  +     {
  +             return classpathRef;
        }
   
  -
        /**
  -      * Sets the Sourcepath attribute of the DocletTask object
  +      * Gets the ConfigParams attribute of the DocletTask object
         *
  -      * @param path The new Sourcepath value
  +      * @return   The ConfigParams value
         */
  -     public void setSourcepath(Path path) {
  -             System.out.println("sourcepath is deprecated. the preferred way to 
design sources is via nested <fileset>");
  -
  -             String dir = path.toString();
  -             FileSet fileSet = new FileSet();
  -
  -             fileSet.setDir(new File(dir));
  -             fileSet.setIncludes("**/*.java");
  +     public ArrayList getConfigParams()
  +     {
  +             return configParams;
        }
   
  -
        /**
  -      * Sets the PackageNames attribute of the DocletTask object
  +      * Gets the MergeDir attribute of the DocletTask object
         *
  -      * @param src The new PackageNames value
  +      * @return   The MergeDir value
         */
  -     public void setPackageNames(String src) {
  -             throw new BuildException("packageNames is obsolete since xjavadoc was 
introduced. Use a fileset instead");
  +     public File getMergeDir()
  +     {
  +             return mergeDir;
        }
   
  -
        /**
  -      * Sets the ExcludePackageNames attribute of the DocletTask object
  +      * Gets the ExcludedTags attribute of the DocletTask object
         *
  -      * @param src The new ExcludePackageNames value
  +      * @return   The ExcludedTags value
         */
  -     public void setExcludePackageNames(String src) {
  -             throw new BuildException("excludePackageNames is obsolete since 
xjavadoc was introduced. Use a fileset instead");
  +     public String getExcludedTags()
  +     {
  +             return excludedTags;
        }
   
  -
        /**
  -      * Sets the ExcludedTags attribute of the DocletTask object
  +      * Gets the Templates attribute of the DocletTask object
         *
  -      * @param tags The new ExcludedTags value
  +      * @return   The Templates value
         */
  -     public void setExcludedTags(String tags) {
  -             excludedTags = tags;
  +     public ArrayList getTemplates()
  +     {
  +             return templates;
        }
   
  -
        /**
  -      * Sets the DestDir attribute of the DocletTask object
  +      * Gets the DestDir attribute of the DocletTask object
         *
  -      * @param dir The new DestDir value
  +      * @return   The DestDir value
         */
  -     public void setDestDir(File dir) {
  -             destDir = dir;
  +     public File getDestDir()
  +     {
  +             return destDir;
        }
   
  -
        /**
  -      * Sets the MergeDir attribute of the DocletTask object
  +      * Gets the Force attribute of the DocletTask object
         *
  -      * @param dir The new MergeDir value
  +      * @return   The Force value
         */
  -     public void setMergeDir(File dir) {
  -             mergeDir = dir;
  +     public boolean isForce()
  +     {
  +             return force;
        }
   
  -
        /**
  -      * Sets the Force attribute of the DocletTask object
  +      * Sets the Classpath attribute of the DocletTask object
         *
  -      * @param force The new Force value
  +      * @param src  The new Classpath value
         */
  -     public void setForce(boolean force) {
  -             this.force = force;
  +     public void setClasspath( Path src )
  +     {
  +             if( classpath == null )
  +             {
  +                     classpath = src;
  +             }
  +             else
  +             {
  +                     classpath.append( src );
  +             }
        }
  -
   
        /**
  -      * Gets the Classpath attribute of the DocletTask object
  +      * Sets the ClasspathRef attribute of the DocletTask object
         *
  -      * @return The Classpath value
  +      * @param ref  The new ClasspathRef value
         */
  -     public Path getClasspath() {
  -             return classpath;
  +     public void setClasspathRef( org.apache.tools.ant.types.Reference ref )
  +     {
  +             this.classpathRef = ref;
  +             createClasspath().setRefid( ref );
        }
   
  -
        /**
  -      * Gets the ClasspathRef attribute of the DocletTask object
  +      * Sets the Sourcepath attribute of the DocletTask object
         *
  -      * @return The ClasspathRef value
  +      * @param path  The new Sourcepath value
         */
  -     public Reference getClasspathRef() {
  -             return classpathRef;
  -     }
  +     public void setSourcepath( Path path )
  +     {
  +             log( "sourcepath is deprecated. The preferred way to design sources is 
via nested <fileset>", Project.MSG_WARN );
   
  +             String dir = path.toString();
  +             FileSet fileSet = new FileSet();
  +
  +             fileSet.setDir( new File( dir ) );
  +             fileSet.setIncludes( "**/*.java" );
  +     }
   
        /**
  -      * Gets the ConfigParams attribute of the DocletTask object
  +      * Sets the PackageNames attribute of the DocletTask object
         *
  -      * @return The ConfigParams value
  +      * @param src  The new PackageNames value
         */
  -     public ArrayList getConfigParams() {
  -             return configParams;
  +     public void setPackageNames( String src )
  +     {
  +             throw new BuildException( "packageNames is obsolete since xjavadoc was 
introduced. Use a fileset instead" );
        }
   
  -
        /**
  -      * Gets the MergeDir attribute of the DocletTask object
  +      * Sets the ExcludePackageNames attribute of the DocletTask object
         *
  -      * @return The MergeDir value
  +      * @param src  The new ExcludePackageNames value
         */
  -     public File getMergeDir() {
  -             return mergeDir;
  +     public void setExcludePackageNames( String src )
  +     {
  +             throw new BuildException( "excludePackageNames is obsolete since 
xjavadoc was introduced. Use a fileset instead" );
        }
   
  -
        /**
  -      * Gets the ExcludedTags attribute of the DocletTask object
  +      * Sets the ExcludedTags attribute of the DocletTask object
         *
  -      * @return The ExcludedTags value
  +      * @param tags  The new ExcludedTags value
         */
  -     public String getExcludedTags() {
  -             return excludedTags;
  +     public void setExcludedTags( String tags )
  +     {
  +             excludedTags = tags;
        }
   
  -
        /**
  -      * Gets the Templates attribute of the DocletTask object
  +      * Sets the DestDir attribute of the DocletTask object
         *
  -      * @return The Templates value
  +      * @param dir  The new DestDir value
         */
  -     public ArrayList getTemplates() {
  -             return templates;
  +     public void setDestDir( File dir )
  +     {
  +             destDir = dir;
        }
   
  -
        /**
  -      * Gets the DestDir attribute of the DocletTask object
  +      * Sets the MergeDir attribute of the DocletTask object
         *
  -      * @return The DestDir value
  +      * @param dir  The new MergeDir value
         */
  -     public File getDestDir() {
  -             return destDir;
  +     public void setMergeDir( File dir )
  +     {
  +             mergeDir = dir;
        }
   
  -
        /**
  -      * Gets the Force attribute of the DocletTask object
  +      * Sets the Force attribute of the DocletTask object
         *
  -      * @return The Force value
  +      * @param force  The new Force value
         */
  -     public boolean isForce() {
  -             return force;
  +     public void setForce( boolean force )
  +     {
  +             this.force = force;
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -312,15 +284,16 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for return value
         */
  -     public Path createClasspath() {
  -             if (classpath == null) {
  +     public Path createClasspath()
  +     {
  +             if( classpath == null )
  +             {
                        classpath = new Path(project);
                }
   
                return classpath.createPath();
        }
   
  -
        /**
         * Describe the method
         *
  @@ -328,11 +301,11 @@
         * @todo-javadoc Describe the method
         * @todo-javadoc Describe the method parameter
         */
  -     public void addFileset(FileSet set) {
  +     public void addFileset( FileSet set )
  +     {
                filesets.addElement(set);
        }
   
  -
        /**
         * Describe the method
         *
  @@ -340,11 +313,11 @@
         * @todo-javadoc Describe the method
         * @todo-javadoc Describe the method parameter
         */
  -     public void addTemplate(TemplateSubTask subtask) {
  +     public void addTemplate( TemplateSubTask subtask )
  +     {
                templates.add(subtask);
        }
   
  -
        /**
         * Describe the method
         *
  @@ -352,11 +325,11 @@
         * @todo-javadoc Describe the method
         * @todo-javadoc Describe the method parameter
         */
  -     public void addXmlTemplate(XmlSubTask subtask) {
  +     public void addXmlTemplate( XmlSubTask subtask )
  +     {
                templates.add(subtask);
        }
   
  -
        /**
         * Describe the method
         *
  @@ -364,11 +337,11 @@
         * @todo-javadoc Describe the method
         * @todo-javadoc Describe the method parameter
         */
  -     public void addConfigParam(ConfigParameter config_param) {
  +     public void addConfigParam( ConfigParameter config_param )
  +     {
                configParams.add(config_param);
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -376,8 +349,10 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     public void execute() throws BuildException {
  -             try {
  +     public void execute() throws BuildException
  +     {
  +             try
  +             {
                        AntClassLoader loader = new AntClassLoader(project, classpath);
   
                        XJavaDoc.getInstance().reset();
  @@ -387,46 +362,53 @@
                        // save the context and pass its filename as an arg to the main
                        SourceSet[] sourceSets = new SourceSet[filesets.size()];
   
  -                     for (int i = 0; i < filesets.size(); i++) {
  +                     for( int i = 0; i < filesets.size(); i++ )
  +                     {
                                FileSet fs = (FileSet)filesets.elementAt(i);
                                File dir = fs.getDir(project);
   
                                DirectoryScanner ds = fs.getDirectoryScanner(project);
                                String[] files = ds.getIncludedFiles();
   
  -                             for (int j = 0; j < files.length; j++) {
  -                                     System.out.println("Adding " + dir + " " + 
files[j]);
  +                             for( int j = 0; j < files.length; j++ )
  +                             {
  +                                     log( "Adding " + dir + " " + files[j], 
Project.MSG_VERBOSE );
                                }
                                sourceSets[i] = new SourceSet(dir, files);
                        }
   
  -                     for (int i = 0; i < sourceSets.length; i++) {
  +                     for( int i = 0; i < sourceSets.length; i++ )
  +                     {
                                XJavaDoc.getInstance().addSourceSet(sourceSets[i]);
                        }
   
                        executeSubTasks();
  -             } catch (Exception e) {
  +             }
  +             catch( Exception e )
  +             {
                        e.printStackTrace();
                        throw new BuildException(e);
                }
        }
   
  -
        /**
         * Gets the SubTasks attribute of the DocletTask object
         *
         * @return The SubTasks value
         */
  -     protected List getSubTasks() {
  +     protected List getSubTasks()
  +     {
                ArrayList true_subtasks = new ArrayList();
   
  -             for (int i = 0; i < templates.size(); i++) {
  +             for( int i = 0; i < templates.size(); i++ )
  +             {
                        TemplateSubTask holder = (TemplateSubTask)templates.get(i);
   
                        SubTask subtask = getSubTaskFromPlaceHolder(holder);
   
  -                     if (subtask == null) {
  -                             
System.out.println(Translator.getString("couldnt_instantiate_subtask", new 
String[]{holder.getSubTaskClassName()}));
  +                     if( subtask == null )
  +                     {
  +                             log( Translator.getString( 
"couldnt_instantiate_subtask", new String[]{holder.getSubTaskClassName()} ), 
Project.MSG_ERR );
                                continue;
                        }
   
  @@ -436,7 +418,6 @@
                return true_subtasks;
        }
   
  -
        /**
         * Gets the SubTaskFromPlaceHolder attribute of the DocletTask object
         *
  @@ -444,13 +425,16 @@
         * @return The SubTaskFromPlaceHolder value
         * @todo-javadoc Write javadocs for method parameter
         */
  -     protected SubTask getSubTaskFromPlaceHolder(TemplateSubTask holder) {
  +     protected SubTask getSubTaskFromPlaceHolder( TemplateSubTask holder )
  +     {
                //no subtask class specified
  -             if (holder.getSubTaskClassName() == null) {
  +             if( holder.getSubTaskClassName() == null )
  +             {
                        return holder;
                }
   
  -             try {
  +             try
  +             {
                        Class subtask_class = 
Class.forName(holder.getSubTaskClassName());
                        TemplateSubTask subtask = 
(TemplateSubTask)subtask_class.newInstance();
   
  @@ -458,24 +442,31 @@
                        subtask.copyAttributesFrom(holder);
   
                        return subtask;
  -             } catch (ClassNotFoundException e) {
  +             }
  +             catch( ClassNotFoundException e )
  +             {
                        return null;
  -             } catch (InstantiationException e) {
  +             }
  +             catch( InstantiationException e )
  +             {
                        return null;
  -             } catch (IllegalAccessException e) {
  +             }
  +             catch( IllegalAccessException e )
  +             {
                        return null;
                }
        }
   
  -
        /**
         * Returns the singleton context object and creates it if not already created
         * and registers it as the single instance.
         *
         * @return the singleton context object
         */
  -     protected DocletContext getContext() {
  -             if (context != null) {
  +     protected DocletContext getContext()
  +     {
  +             if( context != null )
  +             {
                        return context;
                }
   
  @@ -498,7 +489,6 @@
                return context;
        }
   
  -
        /**
         * Gets the ConfigParams attribute of the DocletTask object
         *
  @@ -506,17 +496,20 @@
         * @return The ConfigParams value
         * @todo-javadoc Write javadocs for method parameter
         */
  -     protected HashMap getConfigParams(List subtasks) {
  +     protected HashMap getConfigParams( List subtasks )
  +     {
                HashMap configs = new HashMap();
   
                //config params of task
                ConfigParamIntrospector.fillConfigParamsFor(this, configs);
   
                //config params of substask
  -             for (int i = 0; i < subtasks.size(); i++) {
  +             for( int i = 0; i < subtasks.size(); i++ )
  +             {
                        SubTask sub_task = (SubTask)subtasks.get(i);
   
  -                     if (sub_task != null) {
  +                     if( sub_task != null )
  +                     {
                                ConfigParamIntrospector.fillConfigParamsFor(sub_task, 
configs);
   
                                //user defined params of SubTask
  @@ -530,7 +523,6 @@
                return configs;
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -538,23 +530,26 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void validateOptions() throws BuildException {
  -             if (filesets.size() == 0) {
  +     protected void validateOptions() throws BuildException
  +     {
  +             if( filesets.size() == 0 )
  +             {
                        throw new BuildException("At least one fileset must be 
specified", location);
                }
   
  -             if (destDir == null) {
  +             if( destDir == null )
  +             {
                        throw new 
BuildException(Translator.getString("attribute_not_present_error", new 
String[]{"destDir"}), location);
                }
   
  -             if (classpath == null) {
  +             if( classpath == null )
  +             {
                        classpath = org.apache.tools.ant.types.Path.systemClasspath;
                }
   
                validateSubTasks();
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -562,67 +557,78 @@
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for exception
         */
  -     protected void validateSubTasks() throws BuildException {
  +     protected void validateSubTasks() throws BuildException
  +     {
                DocletContext context = getContext();
                SubTask[] subtasks = context.getSubTasks();
   
  -             for (int i = 0; i < subtasks.length; i++) {
  +             for( int i = 0; i < subtasks.length; i++ )
  +             {
                        SubTask subtask = subtasks[i];
   
  -                     if (subtask != null) {
  -                             try {
  +                     if( subtask != null )
  +                     {
  +                             try
  +                             {
                                        subtask.validateOptions();
  -                             } catch (XDocletException ex) {
  +                             }
  +                             catch( XDocletException ex )
  +                             {
                                        new BuildException(subtask.getSubTaskName() + 
": " + ex.getMessage(), location);
                                }
                        }
                }
        }
   
  -
        /**
         * Describe what the method does
         *
         * @todo-javadoc Write javadocs for method
         */
  -     private void executeSubTasks() {
  +     private void executeSubTasks()
  +     {
                Category cat = Log.getCategory(DocletTask.class, "executeSubTasks");
   
                DocletContext context = getContext();
                SubTask[] subtasks = context.getSubTasks();
   
  -             for (int i = 0; i < subtasks.length; i++) {
  +             for( int i = 0; i < subtasks.length; i++ )
  +             {
                        SubTask subtask = subtasks[i];
   
  -                     if (subtask != null) {
  -                             if (cat.isDebugEnabled()) {
  -                                     cat.debug("SubTask " + 
subtasks[i].getSubTaskName() + "Initialized.");
  -                             }
  -
  -                             try {
  +                     if( subtask != null )
  +                     {
  +                             try
  +                             {
                                        subtasks[i].init();
                                        
DocletContext.getInstance().setActiveSubTask(subtasks[i]);
   
  -                                     
System.out.println(Translator.getString("running_taskname", new String[]{"<" + 
subtasks[i].getSubTaskName() + "/>"}));
  +                                     log( Translator.getString( "running_taskname", 
new String[]{"<" + subtasks[i].getSubTaskName() + "/>"} ), Project.MSG_INFO );
                                        subtasks[i].execute();
  -                             } catch (XDocletException e) {
  -                                     
System.out.println(Translator.getString("running_failed"));
  -                                     System.out.println("<<" + e.getMessage() + 
">>");
  +                             }
  +                             catch( XDocletException e )
  +                             {
  +                                     log( Translator.getString( "running_failed" ), 
Project.MSG_ERR );
  +                                     log( "<<" + e.getMessage() + ">>", 
Project.MSG_ERR );
   
  -                                     if (e.getNestedException() != null) {
  +                                     if( e.getNestedException() != null )
  +                                     {
                                                
e.getNestedException().printStackTrace();
                                        }
   
  -                                     if (e.getNestedException() instanceof 
TemplateException) {
  +                                     if( e.getNestedException() instanceof 
TemplateException )
  +                                     {
                                                TemplateException template_ex = 
(TemplateException)e.getNestedException();
   
  -                                             if (cat.isDebugEnabled()) {
  +                                             if( cat.isDebugEnabled() )
  +                                             {
                                                        cat.error("Template Exception 
= " + template_ex);
                                                        cat.error("Nested Exception = 
" + template_ex.getNestedException());
                                                }
                                        }
   
  -                                     if (cat.isDebugEnabled()) {
  +                                     if( cat.isDebugEnabled() )
  +                                     {
                                                cat.error("Exception trace:\n" + 
e.getPrintStackTrace());
                                        }
   
  @@ -634,7 +640,6 @@
                }
        }
   
  -
        /**
         * Describe what the method does
         *
  @@ -646,9 +651,11 @@
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for method parameter
         */
  -     private void fillWithUserDefinedConfigParams(HashMap configs, ArrayList 
config_params, String prefix) {
  +     private void fillWithUserDefinedConfigParams( HashMap configs, ArrayList 
config_params, String prefix )
  +     {
                //config params declared with <configParam name="nnn" value="val"/>
  -             for (int i = 0; i < config_params.size(); i++) {
  +             for( int i = 0; i < config_params.size(); i++ )
  +             {
                        ConfigParameter config_param = 
(ConfigParameter)config_params.get(i);
   
                        configs.put((prefix + config_param.getName()).toLowerCase(), 
config_param.getValue());
  
  
  
  1.36      +72 -26    xdoclet/core/src/xdoclet/XDocletTagSupport.java
  
  Index: XDocletTagSupport.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/XDocletTagSupport.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -w -r1.35 -r1.36
  --- XDocletTagSupport.java    12 Apr 2002 22:32:45 -0000      1.35
  +++ XDocletTagSupport.java    16 Apr 2002 23:01:05 -0000      1.36
  @@ -38,7 +38,7 @@
    *
    * @author    Dmitri Colebatch ([EMAIL PROTECTED])
    * @created   October 12, 2001
  - * @version   $Revision: 1.35 $
  + * @version   $Revision: 1.36 $
    */
   public abstract class XDocletTagSupport extends TemplateTagHandler
   {
  @@ -389,12 +389,50 @@
                String param_name = attributes.getProperty( "paramName" );
                String valid_values = attributes.getProperty( "values" );
                String default_value = attributes.getProperty( "default" );
  +             String param_num = attributes.getProperty( "paramNum" );
                boolean superclasses = TypeConversionUtil.stringToBoolean( 
attributes.getProperty( "superclasses" ), true );
                boolean is_mandatory = TypeConversionUtil.stringToBoolean( 
attributes.getProperty( "mandatory" ), false );
  -             String tagValue = getTagValue(
  +
  +             /*
  +              * Handles multiple tags/parameters. Multiple tags/parameter are 
specified
  +              * as alternatives, and are meant to be used as a "backward 
compatibility"
  +              * helper. So, if the template has <hasTag tagName="tag1,tag2"
  +              * paramName="param1,param2">, xDoclet will first look for param1 in 
tag1.
  +              * If it's not found, it will look for param2 in tag2 and so on, until
  +              * it finds a valid tag/parameter.
  +              *
  +              * If tagName has more alternatives than paramName, it is assumed that 
the
  +              * corresponding paramName is null. If paramNum is supplied (it also 
can have
  +              * multiple alternatives), the tag value is checked.
  +              * (This is mainly to support jboss:table-name and friends. Ugly hack!)
  +              */
  +             StringTokenizer tagTokenizer = new StringTokenizer( tag_name, "," );
  +             StringTokenizer paramTokenizer = new StringTokenizer( param_name != 
null ? param_name : "", "," );
  +             StringTokenizer paramNumTokenizer = new StringTokenizer( param_num != 
null ? param_num : "", "," );
  +
  +             // We can't have more parameters then tags
  +             if( paramTokenizer.countTokens() > tagTokenizer.countTokens() )
  +             {
  +                     throw new XDocletException( "paramName can't contain more 
alternatives than tagName" );
  +             }
  +
  +             // Loop until we get a non-null tag/parameter or there aren't any more 
alternatives
  +             String tagValue = null;
  +
  +             while( tagTokenizer.hasMoreTokens() && tagValue == null )
  +             {
  +                     String current_tag = tagTokenizer.nextToken().trim();
  +                     String current_param = null;
  +
  +                     if( paramTokenizer.hasMoreTokens() )
  +                     {
  +                             current_param = paramTokenizer.nextToken().trim();
  +                     }
  +
  +                     tagValue = getTagValue(
                        for_type,
  -                     tag_name,
  -                     param_name,
  +                             current_tag,
  +                             current_param,
                        valid_values,
                        default_value,
                        superclasses,
  @@ -402,15 +440,20 @@
                         );
   
                // Case of jboss:table-name "abc"
  -             if( tagValue == null )
  +                     if( tagValue == null && current_param == null )
  +                     {
  +                             String current_param_num = null;
  +
  +                             if( paramNumTokenizer.hasMoreTokens() )
                {
  -                     String paramNum = attributes.getProperty( "paramNum" );
  +                                     current_param_num = 
paramNumTokenizer.nextToken().trim();
  +                             }
   
  -                     if( paramNum != null )
  +                             if( current_param_num != null )
                        {
                                XProgramElement prg_elem = getPrgElem( for_type );
                                XDoc doc = prg_elem.doc();
  -                             XTag tag = doc.tag( tag_name, superclasses );
  +                                     XTag tag = doc.tag( current_tag, superclasses 
);
   
                                if( tag != null )
                                {
  @@ -420,13 +463,16 @@
                                {
                                        tagValue = null;
                                }
  +                             }
  +                     }
  +                     // end of hack
  +
                                if( tagValue != null && tagValue.startsWith( "\"" ) )
                                {
                                        tagValue = tagValue.substring( 1, 
tagValue.length() - 1 );
                                }
  +
                        }
  -             }
  -             // end of hack
   
                tagValue = delimit( tagValue, attributes );
                return tagValue;
  
  
  

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

Reply via email to