git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274790 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -69,21 +69,19 @@ package org.apache.tools.ant.taskdefs.optional.extension; | |||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| * @see Extension | * @see Extension | ||||
| */ | */ | ||||
| public final class Compatability | |||||
| { | |||||
| public final class Compatability { | |||||
| /** | /** | ||||
| * A string representaiton of compatability level. | * A string representaiton of compatability level. | ||||
| */ | */ | ||||
| private final String m_name; | |||||
| private final String name; | |||||
| /** | /** | ||||
| * Create a compatability enum with specified name. | * Create a compatability enum with specified name. | ||||
| * | * | ||||
| * @param name the name of compatability level | * @param name the name of compatability level | ||||
| */ | */ | ||||
| Compatability( final String name ) | |||||
| { | |||||
| m_name = name; | |||||
| Compatability(final String name) { | |||||
| this.name = name; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -91,8 +89,7 @@ public final class Compatability | |||||
| * | * | ||||
| * @return the name of compatability level | * @return the name of compatability level | ||||
| */ | */ | ||||
| public String toString() | |||||
| { | |||||
| return m_name; | |||||
| public String toString() { | |||||
| return name; | |||||
| } | } | ||||
| } | } | ||||
| @@ -69,21 +69,19 @@ package org.apache.tools.ant.taskdefs.optional.extension; | |||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| * @see Extension | * @see Extension | ||||
| */ | */ | ||||
| public final class Compatibility | |||||
| { | |||||
| public final class Compatibility { | |||||
| /** | /** | ||||
| * A string representaiton of compatibility level. | * A string representaiton of compatibility level. | ||||
| */ | */ | ||||
| private final String m_name; | |||||
| private final String name; | |||||
| /** | /** | ||||
| * Create a compatibility enum with specified name. | * Create a compatibility enum with specified name. | ||||
| * | * | ||||
| * @param name the name of compatibility level | * @param name the name of compatibility level | ||||
| */ | */ | ||||
| Compatibility( final String name ) | |||||
| { | |||||
| m_name = name; | |||||
| Compatibility(final String name) { | |||||
| this.name = name; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -91,8 +89,7 @@ public final class Compatibility | |||||
| * | * | ||||
| * @return the name of compatibility level | * @return the name of compatibility level | ||||
| */ | */ | ||||
| public String toString() | |||||
| { | |||||
| return m_name; | |||||
| public String toString() { | |||||
| return name; | |||||
| } | } | ||||
| } | } | ||||
| @@ -63,33 +63,23 @@ import java.util.StringTokenizer; | |||||
| * represent major, minor, micro, etc versions. The version number | * represent major, minor, micro, etc versions. The version number | ||||
| * must begin with a number. | * must begin with a number. | ||||
| * | * | ||||
| * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |||||
| * This file is from excalibur.extension package. Dont edit this file | |||||
| * directly as there is no unit tests to make sure it is operational | |||||
| * in ant. Edit file in excalibur and run tests there before changing | |||||
| * ants file. | |||||
| * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public final class DeweyDecimal | |||||
| { | |||||
| ///Array of components that make up DeweyDecimal | |||||
| private int[] m_components; | |||||
| public final class DeweyDecimal { | |||||
| /** Array of components that make up DeweyDecimal */ | |||||
| private int[] components; | |||||
| /** | /** | ||||
| * Construct a DeweyDecimal from an array of integer components. | * Construct a DeweyDecimal from an array of integer components. | ||||
| * | * | ||||
| * @param components an array of integer components. | * @param components an array of integer components. | ||||
| */ | */ | ||||
| public DeweyDecimal( final int[] components ) | |||||
| { | |||||
| m_components = new int[ components.length ]; | |||||
| public DeweyDecimal(final int[] components) { | |||||
| this.components = new int[components.length]; | |||||
| for( int i = 0; i < m_components.length; i++ ) | |||||
| { | |||||
| m_components[ i ] = components[ i ]; | |||||
| for (int i = 0; i < components.length; i++) { | |||||
| this.components[i] = components[i]; | |||||
| } | } | ||||
| } | } | ||||
| @@ -99,33 +89,28 @@ public final class DeweyDecimal | |||||
| * @param string the string in dewey decimal format | * @param string the string in dewey decimal format | ||||
| * @exception NumberFormatException if string is malformed | * @exception NumberFormatException if string is malformed | ||||
| */ | */ | ||||
| public DeweyDecimal( final String string ) | |||||
| throws NumberFormatException | |||||
| { | |||||
| final StringTokenizer tokenizer = new StringTokenizer( string, ".", true ); | |||||
| public DeweyDecimal(final String string) | |||||
| throws NumberFormatException { | |||||
| final StringTokenizer tokenizer = new StringTokenizer(string, ".", true); | |||||
| final int size = tokenizer.countTokens(); | final int size = tokenizer.countTokens(); | ||||
| m_components = new int[ ( size + 1 ) / 2 ]; | |||||
| components = new int[ (size + 1) / 2 ]; | |||||
| for( int i = 0; i < m_components.length; i++ ) | |||||
| { | |||||
| for (int i = 0; i < components.length; i++) { | |||||
| final String component = tokenizer.nextToken(); | final String component = tokenizer.nextToken(); | ||||
| if( component.equals( "" ) ) | |||||
| { | |||||
| throw new NumberFormatException( "Empty component in string" ); | |||||
| if (component.equals("")) { | |||||
| throw new NumberFormatException("Empty component in string"); | |||||
| } | } | ||||
| m_components[ i ] = Integer.parseInt( component ); | |||||
| components[ i ] = Integer.parseInt(component); | |||||
| //Strip '.' token | //Strip '.' token | ||||
| if( tokenizer.hasMoreTokens() ) | |||||
| { | |||||
| if (tokenizer.hasMoreTokens()) { | |||||
| tokenizer.nextToken(); | tokenizer.nextToken(); | ||||
| //If it ended in a dot, throw an exception | //If it ended in a dot, throw an exception | ||||
| if( !tokenizer.hasMoreTokens() ) | |||||
| { | |||||
| throw new NumberFormatException( "DeweyDecimal ended in a '.'" ); | |||||
| if (!tokenizer.hasMoreTokens()) { | |||||
| throw new NumberFormatException("DeweyDecimal ended in a '.'"); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -136,9 +121,8 @@ public final class DeweyDecimal | |||||
| * | * | ||||
| * @return the number of components in dewey decimal | * @return the number of components in dewey decimal | ||||
| */ | */ | ||||
| public int getSize() | |||||
| { | |||||
| return m_components.length; | |||||
| public int getSize() { | |||||
| return components.length; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -147,9 +131,8 @@ public final class DeweyDecimal | |||||
| * @param index the index of components | * @param index the index of components | ||||
| * @return the value of component at index | * @return the value of component at index | ||||
| */ | */ | ||||
| public int get( final int index ) | |||||
| { | |||||
| return m_components[ index ]; | |||||
| public int get(final int index) { | |||||
| return components[ index ]; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -159,17 +142,14 @@ public final class DeweyDecimal | |||||
| * @param other the other DeweyDecimal | * @param other the other DeweyDecimal | ||||
| * @return true if equal to other DeweyDecimal, false otherwise | * @return true if equal to other DeweyDecimal, false otherwise | ||||
| */ | */ | ||||
| public boolean isEqual( final DeweyDecimal other ) | |||||
| { | |||||
| final int max = Math.max( other.m_components.length, m_components.length ); | |||||
| public boolean isEqual(final DeweyDecimal other) { | |||||
| final int max = Math.max(other.components.length, components.length); | |||||
| for( int i = 0; i < max; i++ ) | |||||
| { | |||||
| final int component1 = ( i < m_components.length ) ? m_components[ i ] : 0; | |||||
| final int component2 = ( i < other.m_components.length ) ? other.m_components[ i ] : 0; | |||||
| for (int i = 0; i < max; i++) { | |||||
| final int component1 = (i < components.length) ? components[ i ] : 0; | |||||
| final int component2 = (i < other.components.length) ? other.components[ i ] : 0; | |||||
| if( component2 != component1 ) | |||||
| { | |||||
| if (component2 != component1) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| @@ -184,9 +164,8 @@ public final class DeweyDecimal | |||||
| * @param other the other DeweyDecimal | * @param other the other DeweyDecimal | ||||
| * @return true if less than other DeweyDecimal, false otherwise | * @return true if less than other DeweyDecimal, false otherwise | ||||
| */ | */ | ||||
| public boolean isLessThan( final DeweyDecimal other ) | |||||
| { | |||||
| return !isGreaterThanOrEqual( other ); | |||||
| public boolean isLessThan(final DeweyDecimal other) { | |||||
| return !isGreaterThanOrEqual(other); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -196,9 +175,8 @@ public final class DeweyDecimal | |||||
| * @param other the other DeweyDecimal | * @param other the other DeweyDecimal | ||||
| * @return true if less than or equal to other DeweyDecimal, false otherwise | * @return true if less than or equal to other DeweyDecimal, false otherwise | ||||
| */ | */ | ||||
| public boolean isLessThanOrEqual( final DeweyDecimal other ) | |||||
| { | |||||
| return !isGreaterThan( other ); | |||||
| public boolean isLessThanOrEqual(final DeweyDecimal other) { | |||||
| return !isGreaterThan(other); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -208,21 +186,17 @@ public final class DeweyDecimal | |||||
| * @param other the other DeweyDecimal | * @param other the other DeweyDecimal | ||||
| * @return true if greater than other DeweyDecimal, false otherwise | * @return true if greater than other DeweyDecimal, false otherwise | ||||
| */ | */ | ||||
| public boolean isGreaterThan( final DeweyDecimal other ) | |||||
| { | |||||
| final int max = Math.max( other.m_components.length, m_components.length ); | |||||
| public boolean isGreaterThan(final DeweyDecimal other) { | |||||
| final int max = Math.max(other.components.length, components.length); | |||||
| for( int i = 0; i < max; i++ ) | |||||
| { | |||||
| final int component1 = ( i < m_components.length ) ? m_components[ i ] : 0; | |||||
| final int component2 = ( i < other.m_components.length ) ? other.m_components[ i ] : 0; | |||||
| for (int i = 0; i < max; i++) { | |||||
| final int component1 = (i < components.length) ? components[ i ] : 0; | |||||
| final int component2 = (i < other.components.length) ? other.components[ i ] : 0; | |||||
| if( component2 > component1 ) | |||||
| { | |||||
| if (component2 > component1) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| if( component2 < component1 ) | |||||
| { | |||||
| if (component2 < component1) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -237,21 +211,17 @@ public final class DeweyDecimal | |||||
| * @param other the other DeweyDecimal | * @param other the other DeweyDecimal | ||||
| * @return true if greater than or equal to other DeweyDecimal, false otherwise | * @return true if greater than or equal to other DeweyDecimal, false otherwise | ||||
| */ | */ | ||||
| public boolean isGreaterThanOrEqual( final DeweyDecimal other ) | |||||
| { | |||||
| final int max = Math.max( other.m_components.length, m_components.length ); | |||||
| public boolean isGreaterThanOrEqual(final DeweyDecimal other) { | |||||
| final int max = Math.max(other.components.length, components.length); | |||||
| for( int i = 0; i < max; i++ ) | |||||
| { | |||||
| final int component1 = ( i < m_components.length ) ? m_components[ i ] : 0; | |||||
| final int component2 = ( i < other.m_components.length ) ? other.m_components[ i ] : 0; | |||||
| for (int i = 0; i < max; i++) { | |||||
| final int component1 = (i < components.length) ? components[ i ] : 0; | |||||
| final int component2 = (i < other.components.length) ? other.components[ i ] : 0; | |||||
| if( component2 > component1 ) | |||||
| { | |||||
| if (component2 > component1) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| if( component2 < component1 ) | |||||
| { | |||||
| if (component2 < component1) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -264,17 +234,14 @@ public final class DeweyDecimal | |||||
| * | * | ||||
| * @return the string representation of DeweyDecimal. | * @return the string representation of DeweyDecimal. | ||||
| */ | */ | ||||
| public String toString() | |||||
| { | |||||
| public String toString() { | |||||
| final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
| for( int i = 0; i < m_components.length; i++ ) | |||||
| { | |||||
| if( i != 0 ) | |||||
| { | |||||
| sb.append( '.' ); | |||||
| for (int i = 0; i < components.length; i++) { | |||||
| if (i != 0) { | |||||
| sb.append('.'); | |||||
| } | } | ||||
| sb.append( m_components[ i ] ); | |||||
| sb.append(components[ i ]); | |||||
| } | } | ||||
| return sb.toString(); | return sb.toString(); | ||||
| @@ -65,59 +65,56 @@ import org.apache.tools.ant.types.Reference; | |||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| * @ant.data-type name="extension" | * @ant.data-type name="extension" | ||||
| */ | */ | ||||
| public class ExtensionAdapter | |||||
| extends DataType | |||||
| { | |||||
| public class ExtensionAdapter extends DataType { | |||||
| /** | /** | ||||
| * The name of the optional package being made available, or required. | * The name of the optional package being made available, or required. | ||||
| */ | */ | ||||
| private String m_extensionName; | |||||
| private String extensionName; | |||||
| /** | /** | ||||
| * The version number (dotted decimal notation) of the specification | * The version number (dotted decimal notation) of the specification | ||||
| * to which this optional package conforms. | * to which this optional package conforms. | ||||
| */ | */ | ||||
| private DeweyDecimal m_specificationVersion; | |||||
| private DeweyDecimal specificationVersion; | |||||
| /** | /** | ||||
| * The name of the company or organization that originated the | * The name of the company or organization that originated the | ||||
| * specification to which this optional package conforms. | * specification to which this optional package conforms. | ||||
| */ | */ | ||||
| private String m_specificationVendor; | |||||
| private String specificationVendor; | |||||
| /** | /** | ||||
| * The unique identifier of the company that produced the optional | * The unique identifier of the company that produced the optional | ||||
| * package contained in this JAR file. | * package contained in this JAR file. | ||||
| */ | */ | ||||
| private String m_implementationVendorID; | |||||
| private String implementationVendorID; | |||||
| /** | /** | ||||
| * The name of the company or organization that produced this | * The name of the company or organization that produced this | ||||
| * implementation of this optional package. | * implementation of this optional package. | ||||
| */ | */ | ||||
| private String m_implementationVendor; | |||||
| private String implementationVendor; | |||||
| /** | /** | ||||
| * The version number (dotted decimal notation) for this implementation | * The version number (dotted decimal notation) for this implementation | ||||
| * of the optional package. | * of the optional package. | ||||
| */ | */ | ||||
| private DeweyDecimal m_implementationVersion; | |||||
| private DeweyDecimal implementationVersion; | |||||
| /** | /** | ||||
| * The URL from which the most recent version of this optional package | * The URL from which the most recent version of this optional package | ||||
| * can be obtained if it is not already installed. | * can be obtained if it is not already installed. | ||||
| */ | */ | ||||
| private String m_implementationURL; | |||||
| private String implementationVendor; | |||||
| /** | /** | ||||
| * Set the name of extension. | * Set the name of extension. | ||||
| * | * | ||||
| * @param extensionName the name of extension | * @param extensionName the name of extension | ||||
| */ | */ | ||||
| public void setExtensionName( final String extensionName ) | |||||
| { | |||||
| public void setExtensionName(final String extensionName) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_extensionName = extensionName; | |||||
| this.extensionName = extensionName; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -125,10 +122,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param specificationVersion the specificationVersion of extension | * @param specificationVersion the specificationVersion of extension | ||||
| */ | */ | ||||
| public void setSpecificationVersion( final String specificationVersion ) | |||||
| { | |||||
| public void setSpecificationVersion(final String specificationVersion) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_specificationVersion = new DeweyDecimal( specificationVersion ); | |||||
| this.specificationVersion = new DeweyDecimal(specificationVersion); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -136,10 +132,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param specificationVendor the specificationVendor of extension | * @param specificationVendor the specificationVendor of extension | ||||
| */ | */ | ||||
| public void setSpecificationVendor( final String specificationVendor ) | |||||
| { | |||||
| public void setSpecificationVendor(final String specificationVendor) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_specificationVendor = specificationVendor; | |||||
| this.specificationVendor = specificationVendor; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -147,10 +142,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param implementationVendorID the implementationVendorID of extension | * @param implementationVendorID the implementationVendorID of extension | ||||
| */ | */ | ||||
| public void setImplementationVendorId( final String implementationVendorID ) | |||||
| { | |||||
| public void setImplementationVendorId(final String implementationVendorID) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_implementationVendorID = implementationVendorID; | |||||
| this.implementationVendorID = implementationVendorID; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -158,10 +152,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param implementationVendor the implementationVendor of extension | * @param implementationVendor the implementationVendor of extension | ||||
| */ | */ | ||||
| public void setImplementationVendor( final String implementationVendor ) | |||||
| { | |||||
| public void setImplementationVendor(final String implementationVendor) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_implementationVendor = implementationVendor; | |||||
| this.implementationVendor = implementationVendor; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -169,10 +162,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param implementationVersion the implementationVersion of extension | * @param implementationVersion the implementationVersion of extension | ||||
| */ | */ | ||||
| public void setImplementationVersion( final String implementationVersion ) | |||||
| { | |||||
| public void setImplementationVersion(final String implementationVersion) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_implementationVersion = new DeweyDecimal( implementationVersion ); | |||||
| this.implementationVersion = new DeweyDecimal(implementationVersion); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -180,10 +172,9 @@ public class ExtensionAdapter | |||||
| * | * | ||||
| * @param implementationURL the implementationURL of extension | * @param implementationURL the implementationURL of extension | ||||
| */ | */ | ||||
| public void setImplementationUrl( final String implementationURL ) | |||||
| { | |||||
| public void setImplementationUrl(final String implementationURL) { | |||||
| verifyNotAReference(); | verifyNotAReference(); | ||||
| m_implementationURL = implementationURL; | |||||
| this.implementationVendor = implementationURL; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -196,47 +187,40 @@ public class ExtensionAdapter | |||||
| * @param reference the reference to which this instance is associated | * @param reference the reference to which this instance is associated | ||||
| * @exception BuildException if this instance already has been configured. | * @exception BuildException if this instance already has been configured. | ||||
| */ | */ | ||||
| public void setRefid( final Reference reference ) | |||||
| throws BuildException | |||||
| { | |||||
| if( null != m_extensionName || | |||||
| null != m_specificationVersion || | |||||
| null != m_specificationVendor || | |||||
| null != m_implementationVersion || | |||||
| null != m_implementationVendorID || | |||||
| null != m_implementationVendor || | |||||
| null != m_implementationURL ) | |||||
| { | |||||
| public void setRefid(final Reference reference) | |||||
| throws BuildException { | |||||
| if (null != extensionName | |||||
| || null != specificationVersion | |||||
| || null != specificationVendor | |||||
| || null != implementationVersion | |||||
| || null != implementationVendorID | |||||
| || null != implementationVendor | |||||
| || null != implementationVendor) { | |||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| // change this to get the objects from the other reference | // change this to get the objects from the other reference | ||||
| Object o = reference.getReferencedObject( getProject() ); | |||||
| if( o instanceof ExtensionAdapter ) | |||||
| { | |||||
| final ExtensionAdapter other = (ExtensionAdapter)o; | |||||
| m_extensionName = other.m_extensionName; | |||||
| m_specificationVersion = other.m_specificationVersion; | |||||
| m_specificationVendor = other.m_specificationVendor; | |||||
| m_implementationVersion = other.m_implementationVersion; | |||||
| m_implementationVendorID = other.m_implementationVendorID; | |||||
| m_implementationVendor = other.m_implementationVendor; | |||||
| m_implementationURL = other.m_implementationURL; | |||||
| } | |||||
| else | |||||
| { | |||||
| Object o = reference.getReferencedObject(getProject()); | |||||
| if (o instanceof ExtensionAdapter) { | |||||
| final ExtensionAdapter other = (ExtensionAdapter) o; | |||||
| extensionName = other.extensionName; | |||||
| specificationVersion = other.specificationVersion; | |||||
| specificationVendor = other.specificationVendor; | |||||
| implementationVersion = other.implementationVersion; | |||||
| implementationVendorID = other.implementationVendorID; | |||||
| implementationVendor = other.implementationVendor; | |||||
| implementationVendor = other.implementationVendor; | |||||
| } else { | |||||
| final String message = | final String message = | ||||
| reference.getRefId() + " doesn\'t refer to a Extension"; | reference.getRefId() + " doesn\'t refer to a Extension"; | ||||
| throw new BuildException( message ); | |||||
| throw new BuildException(message); | |||||
| } | } | ||||
| super.setRefid( reference ); | |||||
| super.setRefid(reference); | |||||
| } | } | ||||
| private void verifyNotAReference() | private void verifyNotAReference() | ||||
| throws BuildException | |||||
| { | |||||
| if( isReference() ) | |||||
| { | |||||
| throws BuildException { | |||||
| if (isReference()) { | |||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -247,35 +231,33 @@ public class ExtensionAdapter | |||||
| * @return the extension object | * @return the extension object | ||||
| */ | */ | ||||
| Extension toExtension() | Extension toExtension() | ||||
| throws BuildException | |||||
| { | |||||
| if( null == m_extensionName ) | |||||
| { | |||||
| throws BuildException { | |||||
| if (null == extensionName) { | |||||
| final String message = "Extension is missing name."; | final String message = "Extension is missing name."; | ||||
| throw new BuildException( message ); | |||||
| throw new BuildException(message); | |||||
| } | } | ||||
| String specificationVersion = null; | |||||
| if( null != m_specificationVersion ) | |||||
| { | |||||
| specificationVersion = m_specificationVersion.toString(); | |||||
| String specificationVersionString = null; | |||||
| if (null != specificationVersion) { | |||||
| specificationVersionString = specificationVersion.toString(); | |||||
| } | } | ||||
| String implementationVersion = null; | |||||
| if( null != m_implementationVersion ) | |||||
| { | |||||
| implementationVersion = m_implementationVersion.toString(); | |||||
| String implementationVersionString = null; | |||||
| if (null != implementationVersion) { | |||||
| implementationVersionString = implementationVersion.toString(); | |||||
| } | } | ||||
| return new Extension( m_extensionName, | |||||
| specificationVersion, | |||||
| m_specificationVendor, | |||||
| implementationVersion, | |||||
| m_implementationVendor, | |||||
| m_implementationVendorID, | |||||
| m_implementationURL ); | |||||
| return new Extension(extensionName, | |||||
| specificationVersionString, | |||||
| specificationVendor, | |||||
| implementationVersionString, | |||||
| implementationVendor, | |||||
| implementationVendorID, | |||||
| implementationVendor); | |||||
| } | } | ||||
| public String toString() | |||||
| { | |||||
| /** | |||||
| * @see java.lang.Object#toString() | |||||
| */ | |||||
| public String toString() { | |||||
| return "{" + toExtension().toString() + "}"; | return "{" + toExtension().toString() + "}"; | ||||
| } | } | ||||
| } | } | ||||
| @@ -64,18 +64,18 @@ import org.apache.tools.ant.Project; | |||||
| * @author <a href="mailto:jeff@socialchange.net.au">Jeff Turner</> | * @author <a href="mailto:jeff@socialchange.net.au">Jeff Turner</> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public interface ExtensionResolver | |||||
| { | |||||
| public interface ExtensionResolver { | |||||
| /** | /** | ||||
| * Attempt to locate File that satisfies | * Attempt to locate File that satisfies | ||||
| * extension via resolver. | * extension via resolver. | ||||
| * | * | ||||
| * @param extension the extension | * @param extension the extension | ||||
| * @param project the Ant project instance | |||||
| * @return the File satisfying extension, null | * @return the File satisfying extension, null | ||||
| * if can not resolve extension | * if can not resolve extension | ||||
| * @throws BuildException if error occurs attempting to | * @throws BuildException if error occurs attempting to | ||||
| * resolve extension | * resolve extension | ||||
| */ | */ | ||||
| File resolve( Extension extension, Project project ) | |||||
| File resolve(Extension extension, Project project) | |||||
| throws BuildException; | throws BuildException; | ||||
| } | } | ||||
| @@ -70,26 +70,24 @@ import org.apache.tools.ant.types.Reference; | |||||
| * @ant.data-type name="extension-set" | * @ant.data-type name="extension-set" | ||||
| */ | */ | ||||
| public class ExtensionSet | public class ExtensionSet | ||||
| extends DataType | |||||
| { | |||||
| extends DataType { | |||||
| /** | /** | ||||
| * ExtensionAdapter objects representing extensions. | * ExtensionAdapter objects representing extensions. | ||||
| */ | */ | ||||
| private final ArrayList m_extensions = new ArrayList(); | |||||
| private final ArrayList extensions = new ArrayList(); | |||||
| /** | /** | ||||
| * Filesets specifying all the extensions wanted. | * Filesets specifying all the extensions wanted. | ||||
| */ | */ | ||||
| private final ArrayList m_extensionsFilesets = new ArrayList(); | |||||
| private final ArrayList extensionsFilesets = new ArrayList(); | |||||
| /** | /** | ||||
| * Adds an extension that this library requires. | * Adds an extension that this library requires. | ||||
| * | * | ||||
| * @param extensionAdapter an extension that this library requires. | * @param extensionAdapter an extension that this library requires. | ||||
| */ | */ | ||||
| public void addExtension( final ExtensionAdapter extensionAdapter ) | |||||
| { | |||||
| m_extensions.add( extensionAdapter ); | |||||
| public void addExtension(final ExtensionAdapter extensionAdapter) { | |||||
| extensions.add(extensionAdapter); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -97,9 +95,8 @@ public class ExtensionSet | |||||
| * | * | ||||
| * @param fileSet a set of files about which extensions data will be extracted. | * @param fileSet a set of files about which extensions data will be extracted. | ||||
| */ | */ | ||||
| public void addLibfileset( final LibFileSet fileSet ) | |||||
| { | |||||
| m_extensionsFilesets.add( fileSet ); | |||||
| public void addLibfileset(final LibFileSet fileSet) { | |||||
| extensionsFilesets.add(fileSet); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -107,22 +104,22 @@ public class ExtensionSet | |||||
| * | * | ||||
| * @param fileSet a set of files about which extensions data will be extracted. | * @param fileSet a set of files about which extensions data will be extracted. | ||||
| */ | */ | ||||
| public void addFileset( final FileSet fileSet ) | |||||
| { | |||||
| m_extensionsFilesets.add( fileSet ); | |||||
| public void addFileset(final FileSet fileSet) { | |||||
| extensionsFilesets.add(fileSet); | |||||
| } | } | ||||
| /** | /** | ||||
| * Extract a set of Extension objects from the ExtensionSet. | * Extract a set of Extension objects from the ExtensionSet. | ||||
| * | * | ||||
| * @param project the project instance. | |||||
| * @return an array containing the Extensions from this set | |||||
| * @throws BuildException if an error occurs | * @throws BuildException if an error occurs | ||||
| */ | */ | ||||
| public Extension[] toExtensions( final Project project ) | |||||
| throws BuildException | |||||
| { | |||||
| final ArrayList extensions = ExtensionUtil.toExtensions( m_extensions ); | |||||
| ExtensionUtil.extractExtensions( project, extensions, m_extensionsFilesets ); | |||||
| return (Extension[])extensions.toArray( new Extension[ extensions.size() ] ); | |||||
| public Extension[] toExtensions(final Project project) | |||||
| throws BuildException { | |||||
| final ArrayList extensionsList = ExtensionUtil.toExtensions(extensions); | |||||
| ExtensionUtil.extractExtensions(project, extensionsList, extensionsFilesets); | |||||
| return (Extension[]) extensionsList.toArray(new Extension[extensionsList.size()]); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -135,35 +132,31 @@ public class ExtensionSet | |||||
| * @param reference the reference to which this instance is associated | * @param reference the reference to which this instance is associated | ||||
| * @exception BuildException if this instance already has been configured. | * @exception BuildException if this instance already has been configured. | ||||
| */ | */ | ||||
| public void setRefid( final Reference reference ) | |||||
| throws BuildException | |||||
| { | |||||
| if( !m_extensions.isEmpty() || | |||||
| !m_extensionsFilesets.isEmpty() ) | |||||
| { | |||||
| public void setRefid(final Reference reference) | |||||
| throws BuildException { | |||||
| if (!extensions.isEmpty() || !extensionsFilesets.isEmpty()) { | |||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| // change this to get the objects from the other reference | // change this to get the objects from the other reference | ||||
| final Object object = | final Object object = | ||||
| reference.getReferencedObject( getProject() ); | |||||
| if( object instanceof ExtensionSet ) | |||||
| { | |||||
| final ExtensionSet other = (ExtensionSet)object; | |||||
| m_extensions.addAll( other.m_extensions ); | |||||
| m_extensionsFilesets.addAll( other.m_extensionsFilesets ); | |||||
| } | |||||
| else | |||||
| { | |||||
| reference.getReferencedObject(getProject()); | |||||
| if (object instanceof ExtensionSet) { | |||||
| final ExtensionSet other = (ExtensionSet) object; | |||||
| extensions.addAll(other.extensions); | |||||
| extensionsFilesets.addAll(other.extensionsFilesets); | |||||
| } else { | |||||
| final String message = | final String message = | ||||
| reference.getRefId() + " doesn\'t refer to a ExtensionSet"; | reference.getRefId() + " doesn\'t refer to a ExtensionSet"; | ||||
| throw new BuildException( message ); | |||||
| throw new BuildException(message); | |||||
| } | } | ||||
| super.setRefid( reference ); | |||||
| super.setRefid(reference); | |||||
| } | } | ||||
| public String toString() | |||||
| { | |||||
| return "ExtensionSet" + Arrays.asList( toExtensions( getProject() ) ); | |||||
| /** | |||||
| * @see java.lang.Object#toString() | |||||
| */ | |||||
| public String toString() { | |||||
| return "ExtensionSet" + Arrays.asList(toExtensions(getProject())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -70,26 +70,29 @@ import org.apache.tools.ant.types.FileSet; | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public class ExtensionUtil | |||||
| { | |||||
| public class ExtensionUtil { | |||||
| /** | |||||
| * Class is not meant to be instantiated. | |||||
| */ | |||||
| private ExtensionUtil() { | |||||
| } | |||||
| /** | /** | ||||
| * Convert a list of extensionAdapter objects to extensions. | * Convert a list of extensionAdapter objects to extensions. | ||||
| * | * | ||||
| * @param adapters the list of ExtensionAdapterss to add to convert | * @param adapters the list of ExtensionAdapterss to add to convert | ||||
| * @throws BuildException if an error occurs | * @throws BuildException if an error occurs | ||||
| */ | */ | ||||
| static ArrayList toExtensions( final ArrayList adapters ) | |||||
| throws BuildException | |||||
| { | |||||
| static ArrayList toExtensions(final ArrayList adapters) | |||||
| throws BuildException { | |||||
| final ArrayList results = new ArrayList(); | final ArrayList results = new ArrayList(); | ||||
| final int size = adapters.size(); | final int size = adapters.size(); | ||||
| for( int i = 0; i < size; i++ ) | |||||
| { | |||||
| for (int i = 0; i < size; i++) { | |||||
| final ExtensionAdapter adapter = | final ExtensionAdapter adapter = | ||||
| (ExtensionAdapter)adapters.get( i ); | |||||
| (ExtensionAdapter) adapters.get(i); | |||||
| final Extension extension = adapter.toExtension(); | final Extension extension = adapter.toExtension(); | ||||
| results.add( extension ); | |||||
| results.add(extension); | |||||
| } | } | ||||
| return results; | return results; | ||||
| @@ -102,18 +105,15 @@ public class ExtensionUtil | |||||
| * @param fileset the filesets containing librarys | * @param fileset the filesets containing librarys | ||||
| * @throws BuildException if an error occurs | * @throws BuildException if an error occurs | ||||
| */ | */ | ||||
| static void extractExtensions( final Project project, | |||||
| static void extractExtensions(final Project project, | |||||
| final ArrayList librarys, | final ArrayList librarys, | ||||
| final ArrayList fileset ) | |||||
| throws BuildException | |||||
| { | |||||
| if( !fileset.isEmpty() ) | |||||
| { | |||||
| final Extension[] extensions = getExtensions( project, | |||||
| fileset ); | |||||
| for( int i = 0; i < extensions.length; i++ ) | |||||
| { | |||||
| librarys.add( extensions[ i ] ); | |||||
| final ArrayList fileset) | |||||
| throws BuildException { | |||||
| if (!fileset.isEmpty()) { | |||||
| final Extension[] extensions = getExtensions(project, | |||||
| fileset); | |||||
| for (int i = 0; i < extensions.length; i++) { | |||||
| librarys.add(extensions[ i ]); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -125,36 +125,32 @@ public class ExtensionUtil | |||||
| * @return the extensions contained in librarys | * @return the extensions contained in librarys | ||||
| * @throws BuildException if failing to scan librarys | * @throws BuildException if failing to scan librarys | ||||
| */ | */ | ||||
| private static Extension[] getExtensions( final Project project, | |||||
| final ArrayList librarys ) | |||||
| throws BuildException | |||||
| { | |||||
| private static Extension[] getExtensions(final Project project, | |||||
| final ArrayList librarys) | |||||
| throws BuildException { | |||||
| final ArrayList extensions = new ArrayList(); | final ArrayList extensions = new ArrayList(); | ||||
| final Iterator iterator = librarys.iterator(); | final Iterator iterator = librarys.iterator(); | ||||
| while( iterator.hasNext() ) | |||||
| { | |||||
| final FileSet fileSet = (FileSet)iterator.next(); | |||||
| while (iterator.hasNext()) { | |||||
| final FileSet fileSet = (FileSet) iterator.next(); | |||||
| boolean includeImpl = true; | boolean includeImpl = true; | ||||
| boolean includeURL = true; | boolean includeURL = true; | ||||
| if( fileSet instanceof LibFileSet ) | |||||
| { | |||||
| LibFileSet libFileSet = (LibFileSet)fileSet; | |||||
| if (fileSet instanceof LibFileSet) { | |||||
| LibFileSet libFileSet = (LibFileSet) fileSet; | |||||
| includeImpl = libFileSet.isIncludeImpl(); | includeImpl = libFileSet.isIncludeImpl(); | ||||
| includeURL = libFileSet.isIncludeURL(); | includeURL = libFileSet.isIncludeURL(); | ||||
| } | } | ||||
| final DirectoryScanner scanner = fileSet.getDirectoryScanner( project ); | |||||
| final DirectoryScanner scanner = fileSet.getDirectoryScanner(project); | |||||
| final File basedir = scanner.getBasedir(); | final File basedir = scanner.getBasedir(); | ||||
| final String[] files = scanner.getIncludedFiles(); | final String[] files = scanner.getIncludedFiles(); | ||||
| for( int i = 0; i < files.length; i++ ) | |||||
| { | |||||
| final File file = new File( basedir, files[ i ] ); | |||||
| loadExtensions( file, extensions, includeImpl, includeURL ); | |||||
| for (int i = 0; i < files.length; i++) { | |||||
| final File file = new File(basedir, files[ i ]); | |||||
| loadExtensions(file, extensions, includeImpl, includeURL); | |||||
| } | } | ||||
| } | } | ||||
| return (Extension[])extensions.toArray( new Extension[ extensions.size() ] ); | |||||
| return (Extension[]) extensions.toArray(new Extension[extensions.size()]); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -164,26 +160,21 @@ public class ExtensionUtil | |||||
| * @param extensionList the list to add available extensions to | * @param extensionList the list to add available extensions to | ||||
| * @throws BuildException if there is an error | * @throws BuildException if there is an error | ||||
| */ | */ | ||||
| private static void loadExtensions( final File file, | |||||
| private static void loadExtensions(final File file, | |||||
| final ArrayList extensionList, | final ArrayList extensionList, | ||||
| final boolean includeImpl, | final boolean includeImpl, | ||||
| final boolean includeURL ) | |||||
| throws BuildException | |||||
| { | |||||
| try | |||||
| { | |||||
| final JarFile jarFile = new JarFile( file ); | |||||
| final boolean includeURL) | |||||
| throws BuildException { | |||||
| try { | |||||
| final JarFile jarFile = new JarFile(file); | |||||
| final Extension[] extensions = | final Extension[] extensions = | ||||
| Extension.getAvailable( jarFile.getManifest() ); | |||||
| for( int i = 0; i < extensions.length; i++ ) | |||||
| { | |||||
| Extension.getAvailable(jarFile.getManifest()); | |||||
| for (int i = 0; i < extensions.length; i++) { | |||||
| final Extension extension = extensions[ i ]; | final Extension extension = extensions[ i ]; | ||||
| addExtension( extensionList, extension, includeImpl, includeURL ); | |||||
| addExtension(extensionList, extension, includeImpl, includeURL); | |||||
| } | } | ||||
| } | |||||
| catch( final Exception e ) | |||||
| { | |||||
| throw new BuildException( e.getMessage(), e ); | |||||
| } catch (final Exception e) { | |||||
| throw new BuildException(e.getMessage(), e); | |||||
| } | } | ||||
| } | } | ||||
| @@ -198,44 +189,41 @@ public class ExtensionUtil | |||||
| * @param includeImpl false to exclude implementation details | * @param includeImpl false to exclude implementation details | ||||
| * @param includeURL false to exclude implementation URL | * @param includeURL false to exclude implementation URL | ||||
| */ | */ | ||||
| private static void addExtension( final ArrayList extensionList, | |||||
| private static void addExtension(final ArrayList extensionList, | |||||
| final Extension originalExtension, | final Extension originalExtension, | ||||
| final boolean includeImpl, | final boolean includeImpl, | ||||
| final boolean includeURL ) | |||||
| { | |||||
| final boolean includeURL) { | |||||
| Extension extension = originalExtension; | Extension extension = originalExtension; | ||||
| if( !includeURL && | |||||
| null != extension.getImplementationURL() ) | |||||
| { | |||||
| if (!includeURL | |||||
| && null != extension.getImplementationURL()) { | |||||
| extension = | extension = | ||||
| new Extension( extension.getExtensionName(), | |||||
| new Extension(extension.getExtensionName(), | |||||
| extension.getSpecificationVersion().toString(), | extension.getSpecificationVersion().toString(), | ||||
| extension.getSpecificationVendor(), | extension.getSpecificationVendor(), | ||||
| extension.getImplementationVersion().toString(), | extension.getImplementationVersion().toString(), | ||||
| extension.getImplementationVendor(), | extension.getImplementationVendor(), | ||||
| extension.getImplementationVendorID(), | extension.getImplementationVendorID(), | ||||
| null ); | |||||
| null); | |||||
| } | } | ||||
| final boolean hasImplAttributes = | final boolean hasImplAttributes = | ||||
| null != extension.getImplementationURL() || | |||||
| null != extension.getImplementationVersion() || | |||||
| null != extension.getImplementationVendorID() || | |||||
| null != extension.getImplementationVendor(); | |||||
| null != extension.getImplementationURL() | |||||
| || null != extension.getImplementationVersion() | |||||
| || null != extension.getImplementationVendorID() | |||||
| || null != extension.getImplementationVendor(); | |||||
| if( !includeImpl && hasImplAttributes ) | |||||
| { | |||||
| if (!includeImpl && hasImplAttributes) { | |||||
| extension = | extension = | ||||
| new Extension( extension.getExtensionName(), | |||||
| new Extension(extension.getExtensionName(), | |||||
| extension.getSpecificationVersion().toString(), | extension.getSpecificationVersion().toString(), | ||||
| extension.getSpecificationVendor(), | extension.getSpecificationVendor(), | ||||
| null, | null, | ||||
| null, | null, | ||||
| null, | null, | ||||
| extension.getImplementationURL() ); | |||||
| extension.getImplementationURL()); | |||||
| } | } | ||||
| extensionList.add( extension ); | |||||
| extensionList.add(extension); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -246,17 +234,13 @@ public class ExtensionUtil | |||||
| * @throws BuildException if errror occurs (file not exist, | * @throws BuildException if errror occurs (file not exist, | ||||
| * file not a jar, manifest not exist in file) | * file not a jar, manifest not exist in file) | ||||
| */ | */ | ||||
| static Manifest getManifest( final File file ) | |||||
| throws BuildException | |||||
| { | |||||
| try | |||||
| { | |||||
| final JarFile jarFile = new JarFile( file ); | |||||
| static Manifest getManifest(final File file) | |||||
| throws BuildException { | |||||
| try { | |||||
| final JarFile jarFile = new JarFile(file); | |||||
| return jarFile.getManifest(); | return jarFile.getManifest(); | ||||
| } | |||||
| catch( final IOException ioe ) | |||||
| { | |||||
| throw new BuildException( ioe.getMessage(), ioe ); | |||||
| } catch (final IOException ioe) { | |||||
| throw new BuildException(ioe.getMessage(), ioe); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -63,19 +63,17 @@ import org.apache.tools.ant.BuildException; | |||||
| * @todo Refactor this and all the other parameter, sysproperty, | * @todo Refactor this and all the other parameter, sysproperty, | ||||
| * property etc into a single class in framework | * property etc into a single class in framework | ||||
| */ | */ | ||||
| public class ExtraAttribute | |||||
| { | |||||
| private String m_name; | |||||
| private String m_value; | |||||
| public class ExtraAttribute { | |||||
| private String name; | |||||
| private String value; | |||||
| /** | /** | ||||
| * Set the name of the parameter. | * Set the name of the parameter. | ||||
| * | * | ||||
| * @param name the name of parameter | * @param name the name of parameter | ||||
| */ | */ | ||||
| public void setName( final String name ) | |||||
| { | |||||
| m_name = name; | |||||
| public void setName(final String name) { | |||||
| this.name = name; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -83,9 +81,8 @@ public class ExtraAttribute | |||||
| * | * | ||||
| * @param value the parameter value | * @param value the parameter value | ||||
| */ | */ | ||||
| public void setValue( final String value ) | |||||
| { | |||||
| m_value = value; | |||||
| public void setValue(final String value) { | |||||
| this.value = value; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -93,9 +90,8 @@ public class ExtraAttribute | |||||
| * | * | ||||
| * @return the name of parameter. | * @return the name of parameter. | ||||
| */ | */ | ||||
| String getName() | |||||
| { | |||||
| return m_name; | |||||
| String getName() { | |||||
| return name; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -103,27 +99,23 @@ public class ExtraAttribute | |||||
| * | * | ||||
| * @return the value of parameter. | * @return the value of parameter. | ||||
| */ | */ | ||||
| String getValue() | |||||
| { | |||||
| return m_value; | |||||
| String getValue() { | |||||
| return value; | |||||
| } | } | ||||
| /** | /** | ||||
| * Make sure that neither the name or the value | * Make sure that neither the name or the value | ||||
| * is null. | * is null. | ||||
| * | |||||
| * @throws BuildException if the attribute is invalid. | |||||
| */ | */ | ||||
| public void validate() | |||||
| throws BuildException | |||||
| { | |||||
| if( null == m_name ) | |||||
| { | |||||
| public void validate() throws BuildException { | |||||
| if (null == name) { | |||||
| final String message = "Missing name from parameter."; | final String message = "Missing name from parameter."; | ||||
| throw new BuildException( message ); | |||||
| } | |||||
| else if( null == m_value ) | |||||
| { | |||||
| final String message = "Missing value from parameter " + m_name + "."; | |||||
| throw new BuildException( message ); | |||||
| throw new BuildException(message); | |||||
| } else if (null == value) { | |||||
| final String message = "Missing value from parameter " + name + "."; | |||||
| throw new BuildException(message); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -64,21 +64,20 @@ import org.apache.tools.ant.types.FileSet; | |||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public class LibFileSet | public class LibFileSet | ||||
| extends FileSet | |||||
| { | |||||
| extends FileSet { | |||||
| /** | /** | ||||
| * Flag indicating whether should include the | * Flag indicating whether should include the | ||||
| * "Implementation-URL" attribute in manifest. | * "Implementation-URL" attribute in manifest. | ||||
| * Defaults to false. | * Defaults to false. | ||||
| */ | */ | ||||
| private boolean m_includeURL; | |||||
| private boolean includeURL; | |||||
| /** | /** | ||||
| * Flag indicating whether should include the | * Flag indicating whether should include the | ||||
| * "Implementation-*" attributes in manifest. | * "Implementation-*" attributes in manifest. | ||||
| * Defaults to false. | * Defaults to false. | ||||
| */ | */ | ||||
| private boolean m_includeImpl; | |||||
| private boolean includeImpl; | |||||
| /** | /** | ||||
| * String that is the base URL for the librarys | * String that is the base URL for the librarys | ||||
| @@ -94,7 +93,7 @@ public class LibFileSet | |||||
| * | * | ||||
| * Note that this also implies includeURL=true | * Note that this also implies includeURL=true | ||||
| */ | */ | ||||
| private String m_urlBase; | |||||
| private String urlBase; | |||||
| /** | /** | ||||
| * Flag indicating whether should include the | * Flag indicating whether should include the | ||||
| @@ -102,11 +101,10 @@ public class LibFileSet | |||||
| * Defaults to false. | * Defaults to false. | ||||
| * | * | ||||
| * @param includeURL the flag | * @param includeURL the flag | ||||
| * @see #m_includeURL | |||||
| * @see #includeURL | |||||
| */ | */ | ||||
| public void setIncludeUrl( boolean includeURL ) | |||||
| { | |||||
| m_includeURL = includeURL; | |||||
| public void setIncludeUrl(boolean includeURL) { | |||||
| this.includeURL = includeURL; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -115,22 +113,20 @@ public class LibFileSet | |||||
| * Defaults to false. | * Defaults to false. | ||||
| * | * | ||||
| * @param includeImpl the flag | * @param includeImpl the flag | ||||
| * @see #m_includeImpl | |||||
| * @see #includeImpl | |||||
| */ | */ | ||||
| public void setIncludeImpl( boolean includeImpl ) | |||||
| { | |||||
| m_includeImpl = includeImpl; | |||||
| public void setIncludeImpl(boolean includeImpl) { | |||||
| this.includeImpl = includeImpl; | |||||
| } | } | ||||
| /** | /** | ||||
| * Set the url base for fileset. | * Set the url base for fileset. | ||||
| * | * | ||||
| * @param urlBase the base url | * @param urlBase the base url | ||||
| * @see #m_urlBase | |||||
| * @see #urlBase | |||||
| */ | */ | ||||
| public void setUrlBase( String urlBase ) | |||||
| { | |||||
| m_urlBase = urlBase; | |||||
| public void setUrlBase(String urlBase) { | |||||
| this.urlBase = urlBase; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -138,9 +134,8 @@ public class LibFileSet | |||||
| * | * | ||||
| * @return the includeURL flag. | * @return the includeURL flag. | ||||
| */ | */ | ||||
| boolean isIncludeURL() | |||||
| { | |||||
| return m_includeURL; | |||||
| boolean isIncludeURL() { | |||||
| return includeURL; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -148,9 +143,8 @@ public class LibFileSet | |||||
| * | * | ||||
| * @return the includeImpl flag. | * @return the includeImpl flag. | ||||
| */ | */ | ||||
| boolean isIncludeImpl() | |||||
| { | |||||
| return m_includeImpl; | |||||
| boolean isIncludeImpl() { | |||||
| return includeImpl; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -158,8 +152,7 @@ public class LibFileSet | |||||
| * | * | ||||
| * @return the urlbase. | * @return the urlbase. | ||||
| */ | */ | ||||
| String getUrlBase() | |||||
| { | |||||
| return m_urlBase; | |||||
| String getUrlBase() { | |||||
| return urlBase; | |||||
| } | } | ||||
| } | } | ||||
| @@ -66,8 +66,7 @@ import org.apache.tools.ant.BuildException; | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| class LibraryDisplayer | |||||
| { | |||||
| class LibraryDisplayer { | |||||
| /** | /** | ||||
| * Display the extensions and specifications contained | * Display the extensions and specifications contained | ||||
| * within specified file. | * within specified file. | ||||
| @@ -75,11 +74,10 @@ class LibraryDisplayer | |||||
| * @param file the file | * @param file the file | ||||
| * @throws BuildException if fail to read file | * @throws BuildException if fail to read file | ||||
| */ | */ | ||||
| void displayLibrary( final File file ) | |||||
| throws BuildException | |||||
| { | |||||
| final Manifest manifest = ExtensionUtil.getManifest( file ); | |||||
| displayLibrary( file, manifest ); | |||||
| void displayLibrary(final File file) | |||||
| throws BuildException { | |||||
| final Manifest manifest = ExtensionUtil.getManifest(file); | |||||
| displayLibrary(file, manifest); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -90,65 +88,53 @@ class LibraryDisplayer | |||||
| * @param manifest the manifest of file | * @param manifest the manifest of file | ||||
| * @throws BuildException if fail to read file | * @throws BuildException if fail to read file | ||||
| */ | */ | ||||
| void displayLibrary( final File file, | |||||
| final Manifest manifest ) | |||||
| throws BuildException | |||||
| { | |||||
| final Extension[] available = Extension.getAvailable( manifest ); | |||||
| final Extension[] required = Extension.getRequired( manifest ); | |||||
| final Extension[] options = Extension.getOptions( manifest ); | |||||
| final Specification[] specifications = getSpecifications( manifest ); | |||||
| void displayLibrary(final File file, | |||||
| final Manifest manifest) | |||||
| throws BuildException { | |||||
| final Extension[] available = Extension.getAvailable(manifest); | |||||
| final Extension[] required = Extension.getRequired(manifest); | |||||
| final Extension[] options = Extension.getOptions(manifest); | |||||
| final Specification[] specifications = getSpecifications(manifest); | |||||
| if( 0 == available.length && | |||||
| 0 == required.length && | |||||
| 0 == options.length && | |||||
| 0 == specifications.length ) | |||||
| { | |||||
| if (0 == available.length && 0 == required.length && 0 == options.length | |||||
| && 0 == specifications.length) { | |||||
| return; | return; | ||||
| } | } | ||||
| final String message = "File: " + file; | final String message = "File: " + file; | ||||
| final int size = message.length(); | final int size = message.length(); | ||||
| printLine( size ); | |||||
| System.out.println( message ); | |||||
| printLine( size ); | |||||
| if( 0 != available.length ) | |||||
| { | |||||
| System.out.println( "Extensions Supported By Library:" ); | |||||
| for( int i = 0; i < available.length; i++ ) | |||||
| { | |||||
| printLine(size); | |||||
| System.out.println(message); | |||||
| printLine(size); | |||||
| if (0 != available.length) { | |||||
| System.out.println("Extensions Supported By Library:"); | |||||
| for (int i = 0; i < available.length; i++) { | |||||
| final Extension extension = available[ i ]; | final Extension extension = available[ i ]; | ||||
| System.out.println( extension.toString() ); | |||||
| System.out.println(extension.toString()); | |||||
| } | } | ||||
| } | } | ||||
| if( 0 != required.length ) | |||||
| { | |||||
| System.out.println( "Extensions Required By Library:" ); | |||||
| for( int i = 0; i < required.length; i++ ) | |||||
| { | |||||
| if (0 != required.length) { | |||||
| System.out.println("Extensions Required By Library:"); | |||||
| for (int i = 0; i < required.length; i++) { | |||||
| final Extension extension = required[ i ]; | final Extension extension = required[ i ]; | ||||
| System.out.println( extension.toString() ); | |||||
| System.out.println(extension.toString()); | |||||
| } | } | ||||
| } | } | ||||
| if( 0 != options.length ) | |||||
| { | |||||
| System.out.println( "Extensions that will be used by Library if present:" ); | |||||
| for( int i = 0; i < options.length; i++ ) | |||||
| { | |||||
| if (0 != options.length) { | |||||
| System.out.println("Extensions that will be used by Library if present:"); | |||||
| for (int i = 0; i < options.length; i++) { | |||||
| final Extension extension = options[ i ]; | final Extension extension = options[ i ]; | ||||
| System.out.println( extension.toString() ); | |||||
| System.out.println(extension.toString()); | |||||
| } | } | ||||
| } | } | ||||
| if( 0 != specifications.length ) | |||||
| { | |||||
| System.out.println( "Specifications Supported By Library:" ); | |||||
| for( int i = 0; i < specifications.length; i++ ) | |||||
| { | |||||
| if (0 != specifications.length) { | |||||
| System.out.println("Specifications Supported By Library:"); | |||||
| for (int i = 0; i < specifications.length; i++) { | |||||
| final Specification specification = specifications[ i ]; | final Specification specification = specifications[ i ]; | ||||
| displaySpecification( specification ); | |||||
| displaySpecification(specification); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -158,11 +144,9 @@ class LibraryDisplayer | |||||
| * | * | ||||
| * @param size the number of dashes to printout | * @param size the number of dashes to printout | ||||
| */ | */ | ||||
| private void printLine( final int size ) | |||||
| { | |||||
| for( int i = 0; i < size; i++ ) | |||||
| { | |||||
| System.out.print( "-" ); | |||||
| private void printLine(final int size) { | |||||
| for (int i = 0; i < size; i++) { | |||||
| System.out.print("-"); | |||||
| } | } | ||||
| System.out.println(); | System.out.println(); | ||||
| } | } | ||||
| @@ -174,16 +158,12 @@ class LibraryDisplayer | |||||
| * @return the specifications or null if none | * @return the specifications or null if none | ||||
| * @throws BuildException if malformed specification sections | * @throws BuildException if malformed specification sections | ||||
| */ | */ | ||||
| private Specification[] getSpecifications( final Manifest manifest ) | |||||
| throws BuildException | |||||
| { | |||||
| try | |||||
| { | |||||
| return Specification.getSpecifications( manifest ); | |||||
| } | |||||
| catch( final ParseException pe ) | |||||
| { | |||||
| throw new BuildException( pe.getMessage(), pe ); | |||||
| private Specification[] getSpecifications(final Manifest manifest) | |||||
| throws BuildException { | |||||
| try { | |||||
| return Specification.getSpecifications(manifest); | |||||
| } catch (final ParseException pe) { | |||||
| throw new BuildException(pe.getMessage(), pe); | |||||
| } | } | ||||
| } | } | ||||
| @@ -192,19 +172,16 @@ class LibraryDisplayer | |||||
| * | * | ||||
| * @param specification the specification | * @param specification the specification | ||||
| */ | */ | ||||
| private void displaySpecification( final Specification specification ) | |||||
| { | |||||
| private void displaySpecification(final Specification specification) { | |||||
| final String[] sections = specification.getSections(); | final String[] sections = specification.getSections(); | ||||
| if( null != sections ) | |||||
| { | |||||
| final StringBuffer sb = new StringBuffer( "Sections: " ); | |||||
| for( int i = 0; i < sections.length; i++ ) | |||||
| { | |||||
| sb.append( " " ); | |||||
| sb.append( sections[ i ] ); | |||||
| if (null != sections) { | |||||
| final StringBuffer sb = new StringBuffer("Sections: "); | |||||
| for (int i = 0; i < sections.length; i++) { | |||||
| sb.append(" "); | |||||
| sb.append(sections[ i ]); | |||||
| } | } | ||||
| System.out.println( sb ); | |||||
| System.out.println(sb); | |||||
| } | } | ||||
| System.out.println( specification.toString() ); | |||||
| System.out.println(specification.toString()); | |||||
| } | } | ||||
| } | } | ||||