donaldp 02/01/04 01:26:42 Modified: proposal/myrmidon/src/main/org/apache/tools/ant/types FileList.java FileSet.java FilterSet.java Mapper.java Path.java PatternSet.java RegularExpression.java Added: proposal/myrmidon/src/main/org/apache/tools/ant/types Filter.java Removed: proposal/myrmidon/src/main/org/apache/tools/ant/types DataType.java Log: Removed DataType and maual handling of references etc Revision Changes Path 1.8 +15 -97 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileList.java Index: FileList.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileList.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FileList.java 30 Dec 2001 00:21:52 -0000 1.7 +++ FileList.java 4 Jan 2002 09:26:42 -0000 1.8 @@ -9,10 +9,9 @@ import java.io.File; import java.util.ArrayList; -import java.util.Stack; import java.util.StringTokenizer; import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; /** * FileList represents an explicitly named list of files. FileLists are useful @@ -21,137 +20,56 @@ * a matched file if it currently exists in the file system. * * @author Craeg Strong - * @version $Revision: 1.7 $ $Date: 2001/12/30 00:21:52 $ + * @version $Revision: 1.8 $ $Date: 2002/01/04 09:26:42 $ */ -public class FileList extends DataType +public class FileList + extends ProjectComponent { - - private ArrayList filenames = new ArrayList(); - private File dir; + private final ArrayList m_filenames = new ArrayList(); + private File m_dir; public FileList() { - super(); - } - - protected FileList( FileList filelist ) - { - this.dir = filelist.dir; - this.filenames = filelist.filenames; } public void setDir( File dir ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - this.dir = dir; + m_dir = dir; } public void setFiles( String filenames ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( filenames != null && filenames.length() > 0 ) { StringTokenizer tok = new StringTokenizer( filenames, ", \t\n\r\f", false ); while( tok.hasMoreTokens() ) { - this.filenames.add( tok.nextToken() ); + m_filenames.add( tok.nextToken() ); } } } - /** - * Makes this instance in effect a reference to another FileList instance. - *

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) - throws TaskException - { - if( ( dir != null ) || ( filenames.size() != 0 ) ) - { - throw tooManyAttributes(); - } - super.setRefid( r ); - } - - public File getDir( Project p ) - throws TaskException + public File getDir() { - if( isReference() ) - { - return getRef( p ).getDir( p ); - } - return dir; + return m_dir; } /** * Returns the list of files represented by this FileList. - * - * @param p Description of Parameter - * @return The Files value */ - public String[] getFiles( Project p ) + public String[] getFiles() throws TaskException { - if( isReference() ) - { - return getRef( p ).getFiles( p ); - } - - if( dir == null ) + if( m_dir == null ) { throw new TaskException( "No directory specified for filelist." ); } - if( filenames.size() == 0 ) + if( m_filenames.size() == 0 ) { throw new TaskException( "No files specified for filelist." ); } - final String result[] = new String[ filenames.size() ]; - return (String[])filenames.toArray( result ); + return (String[])m_filenames.toArray( new String[ m_filenames.size() ] ); } - - /** - * Performs the check for circular references and returns the referenced - * FileList. - * - * @param p Description of Parameter - * @return The Ref value - */ - protected FileList getRef( Project p ) - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof FileList ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a filelist"; - throw new TaskException( msg ); - } - else - { - return (FileList)o; - } - } - -}//-- FileList.java +} 1.12 +2 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java Index: FileSet.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- FileSet.java 1 Jan 2002 09:13:46 -0000 1.11 +++ FileSet.java 4 Jan 2002 09:26:42 -0000 1.12 @@ -12,6 +12,7 @@ import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; +import org.apache.tools.ant.ProjectComponent; /** * Moved out of MatchingTask to make it a standalone object that could be @@ -26,7 +27,7 @@ * @author Magesh Umasankar */ public class FileSet - extends DataType + extends ProjectComponent implements Cloneable { private PatternSet m_defaultPatterns = new PatternSet(); 1.9 +14 -169 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java Index: FilterSet.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- FilterSet.java 30 Dec 2001 10:46:59 -0000 1.8 +++ FilterSet.java 4 Jan 2002 09:26:42 -0000 1.9 @@ -16,6 +16,7 @@ import java.util.Iterator; import java.util.Properties; import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.ProjectComponent; /** * A set of filters to be applied to something. A filter set may have begintoken @@ -25,7 +26,7 @@ * @created 14 March 2001 */ public class FilterSet - extends DataType + extends ProjectComponent implements Cloneable { @@ -39,13 +40,13 @@ */ public final static String DEFAULT_TOKEN_END = "@"; - private String startOfToken = DEFAULT_TOKEN_START; - private String endOfToken = DEFAULT_TOKEN_END; + private String m_startOfToken = DEFAULT_TOKEN_START; + private String m_endOfToken = DEFAULT_TOKEN_END; /** * List of ordered filters and filter files. */ - private ArrayList filters = new ArrayList(); + private ArrayList m_filters = new ArrayList(); public FilterSet() { @@ -60,7 +61,7 @@ throws TaskException { super(); - this.filters = (ArrayList)filterset.getFilters().clone(); + m_filters = (ArrayList)filterset.getFilters().clone(); } /** @@ -71,15 +72,11 @@ public void setBeginToken( String startOfToken ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( startOfToken == null || "".equals( startOfToken ) ) { throw new TaskException( "beginToken must not be empty" ); } - this.startOfToken = startOfToken; + m_startOfToken = startOfToken; } /** @@ -90,15 +87,11 @@ public void setEndToken( String endOfToken ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( endOfToken == null || "".equals( endOfToken ) ) { throw new TaskException( "endToken must not be empty" ); } - this.endOfToken = endOfToken; + m_endOfToken = endOfToken; } /** @@ -111,31 +104,17 @@ public void setFiltersfile( File filtersFile ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } readFiltersFromFile( filtersFile ); } public String getBeginToken() - throws TaskException { - if( isReference() ) - { - return getRef().getBeginToken(); - } - return startOfToken; + return m_startOfToken; } public String getEndToken() - throws TaskException { - if( isReference() ) - { - return getRef().getEndToken(); - } - return endOfToken; + return m_endOfToken; } /** @@ -162,13 +141,8 @@ * @param filter The feature to be added to the Filter attribute */ public void addFilter( Filter filter ) - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - filters.add( filter ); + m_filters.add( filter ); } /** @@ -178,13 +152,8 @@ * @param value The value for the new filter. */ public void addFilter( String token, String value ) - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - filters.add( new Filter( token, value ) ); + m_filters.add( new Filter( token, value ) ); } /** @@ -193,34 +162,10 @@ * @param filterSet the filterset to be added to this filterset */ public void addFilterSet( FilterSet filterSet ) - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } for( Iterator e = filterSet.getFilters().iterator(); e.hasNext(); ) { - filters.add( (Filter)e.next() ); - } - } - - public Object clone() - { - try - { - if( isReference() ) - { - return new FilterSet( getRef() ); - } - else - { - return new FilterSet( this ); - } - } - catch( final TaskException te ) - { - throw new RuntimeException( te.toString() ); + m_filters.add( (Filter)e.next() ); } } @@ -230,12 +175,7 @@ * @return The filter that was created. */ public FiltersFile createFiltersfile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } return new FiltersFile(); } @@ -260,11 +200,6 @@ public void readFiltersFromFile( File filtersFile ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - if( filtersFile.isFile() ) { getLogger().debug( "Reading filters from " + filtersFile ); @@ -371,97 +306,8 @@ } protected ArrayList getFilters() - throws TaskException - { - if( isReference() ) - { - return getRef().getFilters(); - } - return filters; - } - - protected FilterSet getRef() - throws TaskException { - return (FilterSet)getCheckedRef( FilterSet.class, "filterset" ); - } - - /** - * Individual filter component of filterset - * - * @author Michael McCallum - * @created 14 March 2001 - */ - public static class Filter - { - /** - * Token which will be replaced in the filter operation - */ - String token; - - /** - * The value which will replace the token in the filtering operation - */ - String value; - - /** - * Constructor for the Filter object - * - * @param token The token which will be replaced when filtering - * @param value The value which will replace the token when filtering - */ - public Filter( String token, String value ) - { - this.token = token; - this.value = value; - } - - /** - * No argument conmstructor - */ - public Filter() - { - } - - /** - * Sets the Token attribute of the Filter object - * - * @param token The new Token value - */ - public void setToken( String token ) - { - this.token = token; - } - - /** - * Sets the Value attribute of the Filter object - * - * @param value The new Value value - */ - public void setValue( String value ) - { - this.value = value; - } - - /** - * Gets the Token attribute of the Filter object - * - * @return The Token value - */ - public String getToken() - { - return token; - } - - /** - * Gets the Value attribute of the Filter object - * - * @return The Value value - */ - public String getValue() - { - return value; - } + return m_filters; } /** @@ -472,7 +318,6 @@ */ public class FiltersFile { - /** * Constructor for the Filter object */ 1.8 +15 -117 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java Index: Mapper.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Mapper.java 30 Dec 2001 03:33:58 -0000 1.7 +++ Mapper.java 4 Jan 2002 09:26:42 -0000 1.8 @@ -9,8 +9,8 @@ import java.net.URL; import java.net.URLClassLoader; -import java.util.Stack; import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.util.FileNameMapper; /** @@ -19,7 +19,7 @@ * @author Stefan Bodewig */ public class Mapper - extends DataType + extends ProjectComponent implements Cloneable { private MapperType m_type; @@ -33,14 +33,9 @@ * * @param classname The new Classname value */ - public void setClassname( String classname ) - throws TaskException + public void setClassname( final String classname ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - this.m_classname = classname; + m_classname = classname; } /** @@ -51,97 +46,38 @@ public void setClasspath( Path classpath ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - if( this.m_classpath == null ) + if( m_classpath == null ) { - this.m_classpath = classpath; + m_classpath = classpath; } else { - this.m_classpath.append( classpath ); + m_classpath.append( classpath ); } } /** - * Set the classpath to load the FileNameMapper through via reference - * (attribute). - * - * @param r The new ClasspathRef value - */ - public void setClasspathRef( Reference r ) - throws TaskException - { - if( isReference() ) - { - throw tooManyAttributes(); - } - createClasspath().setRefid( r ); - } - - /** * Set the argument to FileNameMapper.setFrom - * - * @param from The new From value */ - public void setFrom( String from ) - throws TaskException - { - if( isReference() ) - { - throw tooManyAttributes(); - } - this.m_from = from; - } - - /** - * Make this Mapper instance a reference to another Mapper.

- * - * You must not set any other attribute if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) - throws TaskException + public void setFrom( final String from ) { - if( m_type != null || m_from != null || m_to != null ) - { - throw tooManyAttributes(); - } - super.setRefid( r ); + m_from = from; } /** * Set the argument to FileNameMapper.setTo - * - * @param to The new To value */ - public void setTo( String to ) - throws TaskException + public void setTo( final String to ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - this.m_to = to; + m_to = to; } /** * Set the type of FileNameMapper to use. - * - * @param type The new Type value */ public void setType( MapperType type ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - this.m_type = type; + m_type = type; } /** @@ -153,11 +89,6 @@ public FileNameMapper getImplementation() throws TaskException { - if( isReference() ) - { - return getRef().getImplementation(); - } - if( m_type == null && m_classname == null ) { throw new TaskException( "one of the attributes type or classname is required" ); @@ -217,43 +148,10 @@ public Path createClasspath() throws TaskException { - if( isReference() ) + if( m_classpath == null ) { - throw noChildrenAllowed(); + m_classpath = new Path(); } - if( this.m_classpath == null ) - { - this.m_classpath = new Path(); - } - return this.m_classpath.createPath(); + return m_classpath.createPath(); } - - /** - * Performs the check for circular references and returns the referenced - * Mapper. - * - * @return The Ref value - */ - protected Mapper getRef() - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, getProject() ); - } - - Object o = ref.getReferencedObject( getProject() ); - if( !( o instanceof Mapper ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a mapper"; - throw new TaskException( msg ); - } - else - { - return (Mapper)o; - } - } - } 1.13 +51 -202 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java Index: Path.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Path.java 1 Jan 2002 09:13:46 -0000 1.12 +++ Path.java 4 Jan 2002 09:26:42 -0000 1.13 @@ -11,14 +11,12 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; -import java.util.Iterator; import java.util.Locale; -import java.util.Stack; import org.apache.avalon.excalibur.io.FileUtil; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.PathTokenizer; -import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; /** * This object represents a path as used by CLASSPATH or PATH environment @@ -51,9 +49,8 @@ * @author Thomas.Haas@softwired-inc.com * @author Stefan Bodewig */ - public class Path - extends DataType + extends ProjectComponent implements Cloneable { public final static Path systemClasspath = createSystemClasspath(); @@ -91,11 +88,8 @@ /** * Returns its argument with all file separator characters replaced so that * they match the local OS conventions. - * - * @param source Description of Parameter - * @return Description of the Returned Value */ - public static String translateFile( String source ) + private static String translateFile( final String source ) { if( source == null ) return ""; @@ -112,7 +106,7 @@ /** * Splits a PATH (with : or ; as separators) into its parts. */ - public String[] translatePath( Project project, String source ) + private String[] translatePath( final File baseDirectory, String source ) { final ArrayList result = new ArrayList(); if( source == null ) @@ -123,15 +117,18 @@ while( tok.hasMoreTokens() ) { element.setLength( 0 ); - String pathElement = tok.nextToken(); + final String pathElement = tok.nextToken(); try { - element.append( resolveFile( project, pathElement ) ); + element.append( resolveFile( baseDirectory, pathElement ) ); } catch( TaskException e ) { - getLogger().debug( "Dropping path element " + pathElement + " as it is not valid relative to the project" ); + final String message = + "Dropping path element " + pathElement + " as it is not valid relative to the project"; + getLogger().debug( message ); } + for( int i = 0; i < element.length(); i++ ) { translateFileSep( element, i ); @@ -139,8 +136,7 @@ result.add( element.toString() ); } - final String[] res = new String[ result.size() ]; - return (String[])result.toArray( res ); + return (String[])result.toArray( new String[ result.size() ] ); } /** @@ -151,7 +147,7 @@ * @param pos Description of Parameter * @return Description of the Returned Value */ - protected static boolean translateFileSep( StringBuffer buffer, int pos ) + private static boolean translateFileSep( StringBuffer buffer, int pos ) { if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) { @@ -163,15 +159,12 @@ /** * Adds a String to the ArrayList if it isn't already included. - * - * @param v The feature to be added to the UnlessPresent attribute - * @param s The feature to be added to the UnlessPresent attribute */ - private static void addUnlessPresent( ArrayList v, String s ) + private static void addUnlessPresent( final ArrayList list, final String entry ) { - if( v.indexOf( s ) == -1 ) + if( !list.contains( entry ) ) { - v.add( s ); + list.add( entry ); } } @@ -179,18 +172,14 @@ * Resolve a filename with Project's help - if we know one that is.

* * Assume the filename is absolute if project is null.

- * - * @param project Description of Parameter - * @param relativeName Description of Parameter - * @return Description of the Returned Value */ - private static String resolveFile( Project project, String relativeName ) + private static String resolveFile( final File baseDirectory, final String relativeName ) throws TaskException { - if( project != null ) + if( null != baseDirectory ) { - File f = FileUtil.resolveFile( project.getBaseDir(), relativeName ); - return f.getAbsolutePath(); + final File file = FileUtil.resolveFile( baseDirectory, relativeName ); + return file.getAbsolutePath(); } return relativeName; } @@ -200,15 +189,9 @@ * * @param location the location of the element to add (must not be null * nor empty. - * @exception TaskException Description of Exception */ - public void setLocation( File location ) - throws TaskException + public void setLocation( final File location ) { - if( isReference() ) - { - throw tooManyAttributes(); - } createPathElement().setLocation( location ); } @@ -216,63 +199,28 @@ * Parses a path definition and creates single PathElements. * * @param path the path definition. - * @exception TaskException Description of Exception */ public void setPath( String path ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } createPathElement().setPath( path ); } /** - * Makes this instance in effect a reference to another Path instance.

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) - throws TaskException - { - if( !elements.isEmpty() ) - { - throw tooManyAttributes(); - } - elements.add( r ); - super.setRefid( r ); - } - - /** * Adds the components on the given path which exist to this Path. * Components that don't exist, aren't added. * * @param source - source path whose components are examined for existence */ - public void addExisting( Path source ) + public void addExisting( final Path source ) throws TaskException { - String[] list = source.list(); + final String[] list = source.list(); for( int i = 0; i < list.length; i++ ) { - File f = null; - if( getProject() != null ) - { - f = resolveFile( list[ i ] ); - } - else - { - f = new File( list[ i ] ); - } - - if( f.exists() ) + final File file = new File( list[ i ] ); + if( file.exists() ) { - setLocation( f ); + setLocation( file ); } } } @@ -281,8 +229,6 @@ * Emulation of extdirs feature in java >= 1.2. This method adds all files * in the given directories (but not in sub-directories!) to the classpath, * so that you don't have to specify them all one by one. - * - * @param extdirs The feature to be added to the Extdirs attribute */ public void addExtdirs( Path extdirs ) throws TaskException @@ -300,16 +246,16 @@ } } - String[] dirs = extdirs.list(); + final String[] dirs = extdirs.list(); for( int i = 0; i < dirs.length; i++ ) { - File dir = resolveFile( dirs[ i ] ); + final File dir = resolveFile( dirs[ i ] ); if( dir.exists() && dir.isDirectory() ) { - FileSet fs = new FileSet(); - fs.setDir( dir ); - fs.setIncludes( "*" ); - addFileset( fs ); + final FileSet fileSet = new FileSet(); + fileSet.setDir( dir ); + fileSet.setIncludes( "*" ); + addFileset( fileSet ); } } } @@ -320,15 +266,9 @@ * @param fs The feature to be added to the Fileset attribute * @exception TaskException Description of Exception */ - public void addFileset( FileSet fs ) - throws TaskException + public void addFileset( final FileSet fileSet ) { - if( isReference() ) - { - throw noChildrenAllowed(); - } - elements.add( fs ); - checked = false; + elements.add( fileSet ); } /** @@ -382,42 +322,24 @@ /** * Append the contents of the other Path instance to this. - * - * @param other Description of Parameter */ - public void append( Path other ) + public void append( final Path other ) throws TaskException { - if( other == null ) - return; - String[] l = other.list(); - for( int i = 0; i < l.length; i++ ) + if( null == other ) { - if( elements.indexOf( l[ i ] ) == -1 ) - { - elements.add( l[ i ] ); - } + throw new NullPointerException( "other" ); } - } - /** - * Return a Path that holds the same elements as this instance. - * - * @return Description of the Returned Value - */ - public Object clone() - { - try - { - Path p = new Path(); - p.append( this ); - return p; - } - catch( TaskException e ) + final String[] list = other.list(); + for( int i = 0; i < list.length; i++ ) { - throw new IllegalStateException( e.getMessage() ); + final String file = list[ i ]; + if( elements.contains( file ) ) + { + elements.add( file ); + } } - } /** @@ -459,20 +381,17 @@ { // only: the developer knows what (s)he is doing result.addExisting( Path.systemClasspath ); - } else if( order.equals( "first" ) ) { // first: developer could use a little help result.addExisting( Path.systemClasspath ); result.addExisting( this ); - } else if( order.equals( "ignore" ) ) { // ignore: don't trust anyone result.addExisting( this ); - } else { @@ -499,50 +418,27 @@ public Path createPath() throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - Path p = new Path(); - elements.add( p ); - checked = false; - return p; + final Path other = new Path(); + elements.add( other ); + return other; } /** * Creates the nested <pathelement> element. - * - * @return Description of the Returned Value - * @exception TaskException Description of Exception */ public PathElement createPathElement() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - PathElement pe = new PathElement(); - elements.add( pe ); - return pe; + final PathElement pathElement = new PathElement(); + elements.add( pathElement ); + return pathElement; } /** * Returns all path elements defined by this and nested path objects. - * - * @return list of path elements. */ public String[] list() throws TaskException { - if( !checked ) - { - // make sure we don't have a circular reference here - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, getProject() ); - } - ArrayList result = new ArrayList( 2 * elements.size() ); for( int i = 0; i < elements.size(); i++ ) { @@ -599,14 +495,11 @@ } } } - String[] res = new String[ result.size() ]; - return (String[])result.toArray( res ); + return (String[])result.toArray( new String[ result.size() ] ); } /** * How many parts does this Path instance consist of. - * - * @return Description of the Returned Value */ public int size() throws TaskException @@ -674,51 +567,7 @@ } /** - * Overrides the version of DataType to recurse on all DataType child - * elements that may have been added. - * - * @param stk Description of Parameter - * @param p Description of Parameter - * @exception TaskException Description of Exception - */ - protected void dieOnCircularReference( Stack stk, Project p ) - throws TaskException - { - if( checked ) - { - return; - } - - Iterator enum = elements.iterator(); - while( enum.hasNext() ) - { - Object o = enum.next(); - if( o instanceof Reference ) - { - o = ( (Reference)o ).getReferencedObject( p ); - } - - if( o instanceof DataType ) - { - if( stk.contains( o ) ) - { - throw circularReference(); - } - else - { - stk.push( o ); - ( (DataType)o ).dieOnCircularReference( stk, p ); - stk.pop(); - } - } - } - checked = true; - } - - /** * Helper class, holds the nested <pathelement> values. - * - * @author RT */ public class PathElement { @@ -731,7 +580,7 @@ public void setPath( String path ) { - parts = translatePath( getProject(), path ); + parts = translatePath( getProject().getBaseDir(), path ); } public String[] getParts() 1.9 +2 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java Index: PatternSet.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- PatternSet.java 1 Jan 2002 09:13:46 -0000 1.8 +++ PatternSet.java 4 Jan 2002 09:26:42 -0000 1.9 @@ -16,6 +16,7 @@ import java.util.StringTokenizer; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; /** * Named collection of include/exclude tags.

@@ -31,7 +32,7 @@ * @author Stefan Bodewig */ public class PatternSet - extends DataType + extends ProjectComponent { private ArrayList m_includeList = new ArrayList(); private ArrayList m_excludeList = new ArrayList(); 1.5 +11 -54 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/RegularExpression.java Index: RegularExpression.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/RegularExpression.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RegularExpression.java 23 Dec 2001 06:32:48 -0000 1.4 +++ RegularExpression.java 4 Jan 2002 09:26:42 -0000 1.5 @@ -7,9 +7,8 @@ */ package org.apache.tools.ant.types; -import java.util.Stack; import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.util.regexp.Regexp; import org.apache.tools.ant.util.regexp.RegexpFactory; @@ -42,79 +41,37 @@ * @see java.util.regex.Pattern * @see org.apache.tools.ant.util.regexp.Regexp */ -public class RegularExpression extends DataType +public class RegularExpression + extends ProjectComponent { - public final static String DATA_TYPE_NAME = "regularexpression"; - // The regular expression factory private final static RegexpFactory factory = new RegexpFactory(); - private Regexp regexp; + private Regexp m_regexp; public RegularExpression() throws TaskException { - this.regexp = factory.newRegexp(); + m_regexp = factory.newRegexp(); } - public void setPattern( String pattern ) + public void setPattern( final String pattern ) throws TaskException { - this.regexp.setPattern( pattern ); + m_regexp.setPattern( pattern ); } /** * Gets the pattern string for this RegularExpression in the given project. - * - * @param p Description of Parameter - * @return The Pattern value - */ - public String getPattern( Project p ) - throws TaskException - { - if( isReference() ) - return getRef( p ).getPattern( p ); - - return regexp.getPattern(); - } - - /** - * Get the RegularExpression this reference refers to in the given project. - * Check for circular references too - * - * @param p Description of Parameter - * @return The Ref value */ - public RegularExpression getRef( Project p ) + public String getPattern() throws TaskException { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof RegularExpression ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a regularexpression"; - throw new TaskException( msg ); - } - else - { - return (RegularExpression)o; - } + return m_regexp.getPattern(); } - public Regexp getRegexp( Project p ) - throws TaskException + public Regexp getRegexp() { - if( isReference() ) - { - return getRef( p ).getRegexp( p ); - } - return this.regexp; + return m_regexp; } - } 1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Filter.java Index: Filter.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.tools.ant.types; /** * Individual filter component of filterset * * @author Michael McCallum * @created 14 March 2001 */ public class Filter { /** * Token which will be replaced in the filter operation */ private String m_token; /** * The value which will replace the token in the filtering operation */ private String m_value; /** * Constructor for the Filter object * * @param token The token which will be replaced when filtering * @param value The value which will replace the token when filtering */ public Filter( final String token, final String value ) { m_token = token; m_value = value; } /** * No argument conmstructor */ public Filter() { } /** * Sets the Token attribute of the Filter object */ public void setToken( final String token ) { m_token = token; } /** * Sets the Value attribute of the Filter object */ public void setValue( final String value ) { m_value = value; } /** * Gets the Token attribute of the Filter object */ public String getToken() { return m_token; } /** * Gets the Value attribute of the Filter object */ public String getValue() { return m_value; } } -- To unsubscribe, e-mail: For additional commands, e-mail: