avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet AvalonTagHandler.java componentinfo.xdt
Date Sun, 25 Aug 2002 14:03:14 GMT
donaldp     2002/08/25 07:03:14

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet
                        AvalonTagHandler.java componentinfo.xdt
  Log:
  Final conversion to javabean standards and general cleanup.
  
  Revision  Changes    Path
  1.6       +56 -120   jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet/AvalonTagHandler.java
  
  Index: AvalonTagHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet/AvalonTagHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AvalonTagHandler.java	25 Aug 2002 13:40:04 -0000	1.5
  +++ AvalonTagHandler.java	25 Aug 2002 14:03:14 -0000	1.6
  @@ -88,18 +88,42 @@
                                          final Properties attributes )
           throws XDocletException
       {
  +        setupClass( attributes );
           final XTag tag = getCurrentClassTag();
           forAllAttributes( tag, template, attributes );
       }
   
  +    private void setupClass( final Properties attributes )
  +    {
  +        final String property = attributes.getProperty( "tag", null );
  +        if( null != property )
  +        {
  +            final XClass currentClass = getCurrentClass();
  +            final XTag xTag = currentClass.getDoc().getTag( property );
  +            setCurrentClassTag( xTag );
  +        }
  +    }
  +
       public void forAllMethodAttributes( final String template,
                                           final Properties attributes )
           throws XDocletException
       {
  +        setupMethod( attributes );
           final XTag tag = getCurrentMethodTag();
           forAllAttributes( tag, template, attributes );
       }
   
  +    private void setupMethod( final Properties attributes )
  +    {
  +        final String attribute = attributes.getProperty( "tag", null );
  +        if( null != attribute )
  +        {
  +            final XMethod method = getCurrentMethod();
  +            final XTag xTag = method.getDoc().getTag( attribute );
  +            setCurrentMethodTag( xTag );
  +        }
  +    }
  +
       private void forAllAttributes( final XTag tag,
                                      final String template,
                                      final Properties attributes )
  @@ -141,12 +165,14 @@
   
       public String getClassAttributeValueAsType( final Properties attributes )
       {
  +        setupClass( attributes );
           final XTag tag = getCurrentClassTag();
           return getAttributeValueAsType( tag, attributes );
       }
   
       public String getMethodAttributeValueAsType( final Properties attributes )
       {
  +        setupMethod( attributes );
           final XTag tag = getCurrentMethodTag();
           return getAttributeValueAsType( tag, attributes );
       }
  @@ -222,74 +248,53 @@
           }
       }
   
  -    public void setCurrentClassTag( final Properties atributes )
  -        throws XDocletException
  +    public String getAttributeName()
       {
  -        final String property = atributes.getProperty( "name", "" );
  -        final XClass currentClass = getCurrentClass();
  -        final XTag xTag = currentClass.getDoc().getTag( property );
  -        setCurrentClassTag( xTag );
  -    }
  -
  -    public void setCurrentMethodTag( final Properties attributes )
  -        throws XDocletException
  -    {
  -        final String attribute = attributes.getProperty( "name", "" );
  -        final XMethod method = getCurrentMethod();
  -        if( null == method )
  -        {
  -            return;
  -        }
  -        final XTag xTag = method.getDoc().getTag( attribute );
  -        setCurrentMethodTag( xTag );
  +        return c_attribute;
       }
   
  -    public void unsetCurrentMethodTag()
  -        throws XDocletException
  +    public String getClassAttributeValue( final Properties attributes )
       {
  -        setCurrentMethodTag( (XTag)null );
  +        final XTag tag = getCurrentClassTag();
  +        return getAttributeValue( tag );
       }
   
  -    public void setCurrentAttribute( final Properties atributes )
  -        throws XDocletException
  +    public String getMethodAttributeValue( final Properties attributes )
       {
  -        final String attribute = atributes.getProperty( "name", "" );
  -        c_attribute = attribute;
  +        final XTag tag = getCurrentMethodTag();
  +        return getAttributeValue( tag );
       }
   
  -    public void unsetCurrentAttribute()
  -        throws XDocletException
  +    private String getAttributeValue( final XTag tag )
       {
  -        c_attribute = null;
  +        if( null == c_attribute )
  +        {
  +            return "";
  +        }
  +        else
  +        {
  +            return tag.getAttributeValue( c_attribute );
  +        }
       }
   
       /**
  -     * Iterates over the attributes of current tag.
  +     * Splits the string on every token into an array of strings.
  +     *
  +     * @param string the string
  +     * @param onToken the token
  +     * @return the resultant array
        */
  -    public void forAllAttributes( final String template,
  -                                  final Properties attributes )
  -        throws XDocletException
  +    private static final String[] split( final String string, final String onToken )
       {
  -        final XTag tag = getCurrentTag( attributes );
  -        final Iterator attributeNames = tag.getAttributeNames().iterator();
  -        while( attributeNames.hasNext() )
  +        final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
  +        final String[] result = new String[ tokenizer.countTokens() ];
  +
  +        for( int i = 0; i < result.length; i++ )
           {
  -            c_attribute = (String)attributeNames.next();
  -            generate( template );
  +            result[ i ] = tokenizer.nextToken();
           }
  -        c_attribute = null;
  -    }
  -
  -    public String attributeName()
  -    {
  -        return c_attribute;
  -    }
   
  -    public String attributeValueAsType( final Properties attributes )
  -    {
  -        final String typeName =
  -            attributeValue( attributes );
  -        return getQualifiedTypeName( typeName );
  +        return result;
       }
   
       private XPackage getDefaultPackage()
  @@ -321,75 +326,6 @@
               }
           }
           return xClass;
  -    }
  -
  -    public String attributeValue( final Properties attributes )
  -    {
  -        final XTag tag = getCurrentTag( attributes );
  -        if( null == c_attribute )
  -        {
  -            return "";
  -        }
  -        else
  -        {
  -            return tag.getAttributeValue( c_attribute );
  -        }
  -    }
  -
  -    public void ifAttributeNameNotEquals( final String template,
  -                                          final Properties attributes )
  -        throws XDocletException
  -    {
  -        final String value = attributes.getProperty( "value", "" );
  -        if( !value.equals( c_attribute ) )
  -        {
  -            generate( template );
  -        }
  -    }
  -
  -    private XTag getCurrentTag( final Properties attributes )
  -    {
  -        final String isMethodProp = attributes.getProperty( "isMethod", null );
  -        if( null == isMethodProp )
  -        {
  -            final XTag tag = getCurrentMethodTag();
  -            if( null != tag )
  -            {
  -                return tag;
  -            }
  -            else
  -            {
  -                return getCurrentClassTag();
  -            }
  -        }
  -        else if( isMethodProp.equalsIgnoreCase( "false" ) )
  -        {
  -            return getCurrentClassTag();
  -        }
  -        else
  -        {
  -            return getCurrentMethodTag();
  -        }
  -    }
  -
  -    /**
  -     * Splits the string on every token into an array of strings.
  -     *
  -     * @param string the string
  -     * @param onToken the token
  -     * @return the resultant array
  -     */
  -    private static final String[] split( final String string, final String onToken )
  -    {
  -        final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
  -        final String[] result = new String[ tokenizer.countTokens() ];
  -
  -        for( int i = 0; i < result.length; i++ )
  -        {
  -            result[ i ] = tokenizer.nextToken();
  -        }
  -
  -        return result;
       }
   }
   
  
  
  
  1.6       +8 -10     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet/componentinfo.xdt
  
  Index: componentinfo.xdt
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/tools/xdoclet/componentinfo.xdt,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- componentinfo.xdt	25 Aug 2002 13:39:37 -0000	1.5
  +++ componentinfo.xdt	25 Aug 2002 14:03:14 -0000	1.6
  @@ -12,24 +12,22 @@
       <XDtClass:ifHasClassTag tagName="avalon.component" paramName="name"><name><XDtClass:classTagValue
tagName="avalon.component" paramName="name"/></name></XDtClass:ifHasClassTag>
       <version><XDtClass:classTagValue tagName="avalon.component" paramName="version"
default="1.0"/></version>
       <attributes>
  -      <XDtAvalon:setCurrentClassTag name="avalon.component"/>
  -      <XDtAvalon:forAllClassAttributes skip="interface,version,role">
  -      <attribute key="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +      <XDtAvalon:forAllClassAttributes tag="avalon.component" skip="interface,version,role">
  +      <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getClassAttributeValue/>"/>
         </XDtAvalon:forAllClassAttributes>
       </attributes>
     </component>
   
     <!-- Context in which this Component operates -->
     <XDtAvalon:forContextDef>
  -  <context<XDtMethod:ifHasMethodTag tagName="avalon.context" paramName="type"><XDtAvalon:setCurrentMethodTag
name="avalon.context"/><XDtAvalon:setCurrentAttribute name="type"/> type="<XDtAvalon:attributeValueAsType/>"<XDtAvalon:unsetCurrentAttribute/><XDtAvalon:unsetCurrentMethodTag/></XDtMethod:ifHasMethodTag>>
  +  <context<XDtMethod:ifHasMethodTag tagName="avalon.context" paramName="type">
type="<XDtAvalon:getMethodAttributeValueAsType tag="avalon.context" name="type"/>"</XDtMethod:ifHasMethodTag>>
         <XDtMethod:forAllMethodTags tagName="avalon.entry">
  -    <entry key="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="key"/>"
<XDtAvalon:setCurrentAttribute name="type"/>type="<XDtAvalon:attributeValueAsType/>"<XDtMethod:ifHasMethodTag
tagName="avalon.entry" paramName="isOptional"> optional="<XDtMethod:methodTagValue tagName="avalon.entry"
paramName="isOptional"/>"</XDtMethod:ifHasMethodTag>/>
  +    <entry key="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="key"/>"
type="<XDtAvalon:getMethodAttributeValueAsType name="type"/>"<XDtMethod:ifHasMethodTag
tagName="avalon.entry" paramName="isOptional"> optional="<XDtMethod:methodTagValue tagName="avalon.entry"
paramName="isOptional"/>"</XDtMethod:ifHasMethodTag>/>
         </XDtMethod:forAllMethodTags>
       <XDtMethod:ifHasMethodTag tagName="avalon.context">
  -      <XDtAvalon:setCurrentMethodTag name="avalon.context"/>
       <attributes>
  -        <XDtAvalon:forAllMethodAttributes skip="type">
  -      <attribute key="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +        <XDtAvalon:forAllMethodAttributes tag="avalon.context" skip="type">
  +      <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getMethodAttributeValue/>"/>
           </XDtAvalon:forAllMethodAttributes>
       </attributes>
       </XDtMethod:ifHasMethodTag>
  @@ -43,7 +41,7 @@
         <service-ref type="<XDtAvalon:getClassAttributeValueAsType name="interface"/>"<XDtClass:ifHasClassTag
tagName="avalon.service" paramName="version"> version="<XDtClass:classTagValue tagName="avalon.service"
paramName="version"/>"</XDtClass:ifHasClassTag>/>
         <attributes>
         <XDtAvalon:forAllClassAttributes skip="interface,version,role">
  -        <attribute key="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +        <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getClassAttributeValue/>"/>
         </XDtAvalon:forAllClassAttributes>
         </attributes>
       </service>
  @@ -58,7 +56,7 @@
         <service-ref type="<XDtAvalon:getMethodAttributeValueAsType name="interface"/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="version"> version="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="version"/>"</XDtMethod:ifHasMethodTag>/>
         <attributes>
         <XDtAvalon:forAllMethodAttributes skip="interface,version,role,optional">
  -        <attribute key="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +        <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getMethodAttributeValue/>"/>
         </XDtAvalon:forAllMethodAttributes>
         </attributes>
       </dependency>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message