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/extension/src/java/org/apache/avalon/excalibur/extension Extension.java
Date Thu, 04 Apr 2002 01:29:15 GMT
donaldp     02/04/03 17:29:15

  Modified:    extension/src/java/org/apache/avalon/excalibur/extension
                        Extension.java
  Log:
  Move private stuff to end of class
  
  Revision  Changes    Path
  1.16      +109 -108  jakarta-avalon-excalibur/extension/src/java/org/apache/avalon/excalibur/extension/Extension.java
  
  Index: Extension.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/extension/src/java/org/apache/avalon/excalibur/extension/Extension.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Extension.java	4 Apr 2002 01:28:19 -0000	1.15
  +++ Extension.java	4 Apr 2002 01:29:14 -0000	1.16
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:craigmcc@apache.org">Craig R. McClanahan</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.15 $ $Date: 2002/04/04 01:28:19 $
  + * @version $Revision: 1.16 $ $Date: 2002/04/04 01:29:14 $
    */
   public final class Extension
   {
  @@ -231,113 +231,6 @@
       }
   
       /**
  -     * Add required optional packages defined in the specified attributes entry, if any.
  -     *
  -     * @param attributes Attributes to be parsed
  -     * @param required list to add required optional packages to
  -     */
  -    private static void getRequired( final Attributes attributes,
  -                                     final ArrayList required )
  -    {
  -        final String names = attributes.getValue( EXTENSION_LIST );
  -        if( null == names )
  -        {
  -            return;
  -        }
  -
  -        final String[] extentions = split( names, " " );
  -        for( int i = 0; i < extentions.length; i++ )
  -        {
  -            final String prefix = extentions[ i ] + "-";
  -            final Extension extension = getExtension( prefix, attributes );
  -
  -            if( null != extension )
  -            {
  -                required.add( extension );
  -            }
  -        }
  -    }
  -
  -    /**
  -     * 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;
  -    }
  -
  -    /**
  -     * Extract an Extension from Attributes.
  -     * Prefix indicates the prefix checked for each string.
  -     * Usually the prefix is <em>"&lt;extension&gt;-"</em> if looking
for a
  -     * <b>Required</b> extension. If you are looking for an <b>Available</b>
extension
  -     * then the prefix is <em>""</em>.
  -     *
  -     * @param prefix the prefix for each attribute name
  -     * @param attributes Attributes to searched
  -     * @return the new Extension object, or null
  -     */
  -    private static Extension getExtension( final String prefix, final Attributes attributes
)
  -    {
  -        //WARNING: We trim the values of all the attributes because
  -        //Some extension declarations are badly defined (ie have spaces
  -        //after version or vendorID)
  -        final String nameKey = prefix + EXTENSION_NAME;
  -        final String name = getTrimmedString( attributes.getValue( nameKey ) );
  -        if( null == name )
  -        {
  -            return null;
  -        }
  -
  -        final String specVendorKey = prefix + SPECIFICATION_VENDOR;
  -        final String specVendor = getTrimmedString( attributes.getValue( specVendorKey
) );
  -        final String specVersionKey = prefix + SPECIFICATION_VERSION;
  -        final String specVersion = getTrimmedString( attributes.getValue( specVersionKey
) );
  -
  -        final String impVersionKey = prefix + IMPLEMENTATION_VERSION;
  -        final String impVersion = getTrimmedString( attributes.getValue( impVersionKey
) );
  -        final String impVendorKey = prefix + IMPLEMENTATION_VENDOR;
  -        final String impVendor = getTrimmedString( attributes.getValue( impVendorKey )
);
  -        final String impVendorIDKey = prefix + IMPLEMENTATION_VENDOR_ID;
  -        final String impVendorId = getTrimmedString( attributes.getValue( impVendorIDKey
) );
  -        final String impURLKey = prefix + IMPLEMENTATION_URL;
  -        final String impURL = getTrimmedString( attributes.getValue( impURLKey ) );
  -
  -        return new Extension( name, specVersion, specVendor, impVersion,
  -                              impVendor, impVendorId, impURL );
  -    }
  -
  -    /**
  -     * Trim the supplied string if the string is non-null
  -     *
  -     * @param value the string to trim or null
  -     * @return the trimmed string or null
  -     */
  -    private static String getTrimmedString( final String value )
  -    {
  -        if( null == value )
  -        {
  -            return null;
  -        }
  -        else
  -        {
  -            return value.trim();
  -        }
  -    }
  -
  -    /**
        * The constructor to create Extension object.
        * Note that every component is allowed to be specified
        * but only the extensionName is mandatory.
  @@ -613,5 +506,113 @@
       private boolean isCompatible( final DeweyDecimal first, final DeweyDecimal second )
       {
           return first.isGreaterThanOrEqual( second );
  +    }
  +
  +
  +    /**
  +     * Add required optional packages defined in the specified attributes entry, if any.
  +     *
  +     * @param attributes Attributes to be parsed
  +     * @param required list to add required optional packages to
  +     */
  +    private static void getRequired( final Attributes attributes,
  +                                     final ArrayList required )
  +    {
  +        final String names = attributes.getValue( EXTENSION_LIST );
  +        if( null == names )
  +        {
  +            return;
  +        }
  +
  +        final String[] extentions = split( names, " " );
  +        for( int i = 0; i < extentions.length; i++ )
  +        {
  +            final String prefix = extentions[ i ] + "-";
  +            final Extension extension = getExtension( prefix, attributes );
  +
  +            if( null != extension )
  +            {
  +                required.add( extension );
  +            }
  +        }
  +    }
  +
  +    /**
  +     * 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;
  +    }
  +
  +    /**
  +     * Extract an Extension from Attributes.
  +     * Prefix indicates the prefix checked for each string.
  +     * Usually the prefix is <em>"&lt;extension&gt;-"</em> if looking
for a
  +     * <b>Required</b> extension. If you are looking for an <b>Available</b>
extension
  +     * then the prefix is <em>""</em>.
  +     *
  +     * @param prefix the prefix for each attribute name
  +     * @param attributes Attributes to searched
  +     * @return the new Extension object, or null
  +     */
  +    private static Extension getExtension( final String prefix, final Attributes attributes
)
  +    {
  +        //WARNING: We trim the values of all the attributes because
  +        //Some extension declarations are badly defined (ie have spaces
  +        //after version or vendorID)
  +        final String nameKey = prefix + EXTENSION_NAME;
  +        final String name = getTrimmedString( attributes.getValue( nameKey ) );
  +        if( null == name )
  +        {
  +            return null;
  +        }
  +
  +        final String specVendorKey = prefix + SPECIFICATION_VENDOR;
  +        final String specVendor = getTrimmedString( attributes.getValue( specVendorKey
) );
  +        final String specVersionKey = prefix + SPECIFICATION_VERSION;
  +        final String specVersion = getTrimmedString( attributes.getValue( specVersionKey
) );
  +
  +        final String impVersionKey = prefix + IMPLEMENTATION_VERSION;
  +        final String impVersion = getTrimmedString( attributes.getValue( impVersionKey
) );
  +        final String impVendorKey = prefix + IMPLEMENTATION_VENDOR;
  +        final String impVendor = getTrimmedString( attributes.getValue( impVendorKey )
);
  +        final String impVendorIDKey = prefix + IMPLEMENTATION_VENDOR_ID;
  +        final String impVendorId = getTrimmedString( attributes.getValue( impVendorIDKey
) );
  +        final String impURLKey = prefix + IMPLEMENTATION_URL;
  +        final String impURL = getTrimmedString( attributes.getValue( impURLKey ) );
  +
  +        return new Extension( name, specVersion, specVendor, impVersion,
  +                              impVendor, impVendorId, impURL );
  +    }
  +
  +    /**
  +     * Trim the supplied string if the string is non-null
  +     *
  +     * @param value the string to trim or null
  +     * @return the trimmed string or null
  +     */
  +    private static String getTrimmedString( final String value )
  +    {
  +        if( null == value )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            return value.trim();
  +        }
       }
   }
  
  
  

--
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