From 8036fdf46a6c2f2526b4c58186d05c9b53316e84 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 13 Jan 2002 05:38:01 +0000 Subject: [PATCH] Made NameEntry a top level class rather than an inner class of PatternSet git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270737 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/taskdefs/MatchingTask.java | 13 +-- .../ant/taskdefs/optional/ide/VAJExport.java | 5 +- .../apache/tools/ant/taskdefs/unix/Chmod.java | 5 +- .../org/apache/tools/ant/types/FileSet.java | 8 +- .../org/apache/tools/ant/types/NameEntry.java | 89 +++++++++++++++++++ .../apache/tools/ant/types/PatternSet.java | 76 +--------------- .../tools/ant/taskdefs/MatchingTask.java | 13 +-- .../ant/taskdefs/optional/ide/VAJExport.java | 5 +- .../apache/tools/ant/taskdefs/unix/Chmod.java | 5 +- .../org/apache/tools/ant/types/FileSet.java | 8 +- .../org/apache/tools/ant/types/NameEntry.java | 89 +++++++++++++++++++ .../apache/tools/ant/types/PatternSet.java | 76 +--------------- 12 files changed, 214 insertions(+), 178 deletions(-) create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/types/NameEntry.java create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/types/NameEntry.java diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java index 8b82d8c41..ff714176b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -13,6 +13,7 @@ import org.apache.tools.ant.types.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * This is an abstract task that should be used by all those tasks that require @@ -26,9 +27,9 @@ import org.apache.tools.ant.types.PatternSet; * @author Stefan Bodewig */ -public abstract class MatchingTask extends Task +public abstract class MatchingTask + extends Task { - protected boolean useDefaultExcludes = true; protected FileSet fileset = new FileSet(); @@ -96,7 +97,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() throws TaskException { return fileset.createExclude(); @@ -107,7 +108,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExcludesFile() + public NameEntry createExcludesFile() throws TaskException { return fileset.createExcludesFile(); @@ -118,7 +119,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() throws TaskException { return fileset.createInclude(); @@ -129,7 +130,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createIncludesFile() + public NameEntry createIncludesFile() throws TaskException { return fileset.createIncludesFile(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java index a9e6d9bec..2e12151b2 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java @@ -10,6 +10,7 @@ package org.apache.tools.ant.taskdefs.optional.ide; import java.io.File; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * Export packages from the Visual Age for Java workspace. The packages are @@ -143,7 +144,7 @@ public class VAJExport extends VAJTask * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() { return patternSet.createExclude(); } @@ -153,7 +154,7 @@ public class VAJExport extends VAJTask * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() { return patternSet.createInclude(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java index 2741b3e14..098bb1b8e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java @@ -15,6 +15,7 @@ import org.apache.tools.ant.taskdefs.exec.ExecuteOn; import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * Chmod equivalent for unix-like environments. @@ -118,7 +119,7 @@ public class Chmod extends ExecuteOn * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() throws TaskException { defaultSetDefined = true; @@ -130,7 +131,7 @@ public class Chmod extends ExecuteOn * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() throws TaskException { defaultSetDefined = true; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java index 1c5d1cc73..5960b20b0 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java @@ -167,7 +167,7 @@ public class FileSet /** * add a name entry on the exclude list */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() { return m_defaultPatterns.createExclude(); } @@ -175,7 +175,7 @@ public class FileSet /** * add a name entry on the include files list */ - public PatternSet.NameEntry createExcludesFile() + public NameEntry createExcludesFile() { return m_defaultPatterns.createExcludesFile(); } @@ -183,7 +183,7 @@ public class FileSet /** * add a name entry on the include list */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() { return m_defaultPatterns.createInclude(); } @@ -191,7 +191,7 @@ public class FileSet /** * add a name entry on the include files list */ - public PatternSet.NameEntry createIncludesFile() + public NameEntry createIncludesFile() { return m_defaultPatterns.createIncludesFile(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/NameEntry.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/NameEntry.java new file mode 100644 index 000000000..889150acf --- /dev/null +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/NameEntry.java @@ -0,0 +1,89 @@ +/* + * 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; + +import org.apache.tools.ant.Project; + +/** + * inner class to hold a name on list. "If" and "Unless" attributes may be + * used to invalidate the entry based on the existence of a property + * (typically set thru the use of the Available task). + */ +public class NameEntry +{ + private String m_if; + private String m_name; + private String m_unless; + private PatternSet m_set; + + public NameEntry( final PatternSet set ) + { + m_set = set; + } + + public void setIf( final String ifCondition ) + { + m_if = ifCondition; + } + + public void setName( final String name ) + { + m_name = name; + } + + public void setUnless( final String unlessCondition ) + { + m_unless = unlessCondition; + } + + public String evalName( Project p ) + { + return valid( p ) ? m_name : null; + } + + public String toString() + { + StringBuffer buf = new StringBuffer( m_name ); + if( ( m_if != null ) || ( m_unless != null ) ) + { + buf.append( ":" ); + String connector = ""; + + if( m_if != null ) + { + buf.append( "if->" ); + buf.append( m_if ); + connector = ";"; + } + if( m_unless != null ) + { + buf.append( connector ); + buf.append( "unless->" ); + buf.append( m_unless ); + } + } + + return buf.toString(); + } + + private boolean valid( Project p ) + { + if( m_if != null && p.getProperty( m_if ) == null ) + { + return false; + } + else if( m_unless != null && p.getProperty( m_unless ) != null ) + { + return false; + } + else + { + return true; + } + } +} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java index fd8b40652..10d532879 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java @@ -206,7 +206,7 @@ public class PatternSet */ private NameEntry addPatternToList( final ArrayList list ) { - final NameEntry result = new NameEntry(); + final NameEntry result = new NameEntry( this ); list.add( result ); return result; } @@ -338,78 +338,4 @@ public class PatternSet } } - /** - * inner class to hold a name on list. "If" and "Unless" attributes may be - * used to invalidate the entry based on the existence of a property - * (typically set thru the use of the Available task). - */ - public class NameEntry - { - private String ifCond; - private String name; - private String unlessCond; - - public void setIf( String cond ) - { - ifCond = cond; - } - - public void setName( String name ) - { - this.name = name; - } - - public void setUnless( String cond ) - { - unlessCond = cond; - } - - public String getName() - { - return name; - } - - public String evalName( Project p ) - { - return valid( p ) ? name : null; - } - - public String toString() - { - StringBuffer buf = new StringBuffer( name ); - if( ( ifCond != null ) || ( unlessCond != null ) ) - { - buf.append( ":" ); - String connector = ""; - - if( ifCond != null ) - { - buf.append( "if->" ); - buf.append( ifCond ); - connector = ";"; - } - if( unlessCond != null ) - { - buf.append( connector ); - buf.append( "unless->" ); - buf.append( unlessCond ); - } - } - - return buf.toString(); - } - - private boolean valid( Project p ) - { - if( ifCond != null && p.getProperty( ifCond ) == null ) - { - return false; - } - else if( unlessCond != null && p.getProperty( unlessCond ) != null ) - { - return false; - } - return true; - } - } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java index 8b82d8c41..ff714176b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -13,6 +13,7 @@ import org.apache.tools.ant.types.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * This is an abstract task that should be used by all those tasks that require @@ -26,9 +27,9 @@ import org.apache.tools.ant.types.PatternSet; * @author Stefan Bodewig */ -public abstract class MatchingTask extends Task +public abstract class MatchingTask + extends Task { - protected boolean useDefaultExcludes = true; protected FileSet fileset = new FileSet(); @@ -96,7 +97,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() throws TaskException { return fileset.createExclude(); @@ -107,7 +108,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExcludesFile() + public NameEntry createExcludesFile() throws TaskException { return fileset.createExcludesFile(); @@ -118,7 +119,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() throws TaskException { return fileset.createInclude(); @@ -129,7 +130,7 @@ public abstract class MatchingTask extends Task * * @return Description of the Returned Value */ - public PatternSet.NameEntry createIncludesFile() + public NameEntry createIncludesFile() throws TaskException { return fileset.createIncludesFile(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java index a9e6d9bec..2e12151b2 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java @@ -10,6 +10,7 @@ package org.apache.tools.ant.taskdefs.optional.ide; import java.io.File; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * Export packages from the Visual Age for Java workspace. The packages are @@ -143,7 +144,7 @@ public class VAJExport extends VAJTask * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() { return patternSet.createExclude(); } @@ -153,7 +154,7 @@ public class VAJExport extends VAJTask * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() { return patternSet.createInclude(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java index 2741b3e14..098bb1b8e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java @@ -15,6 +15,7 @@ import org.apache.tools.ant.taskdefs.exec.ExecuteOn; import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.NameEntry; /** * Chmod equivalent for unix-like environments. @@ -118,7 +119,7 @@ public class Chmod extends ExecuteOn * * @return Description of the Returned Value */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() throws TaskException { defaultSetDefined = true; @@ -130,7 +131,7 @@ public class Chmod extends ExecuteOn * * @return Description of the Returned Value */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() throws TaskException { defaultSetDefined = true; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java index 1c5d1cc73..5960b20b0 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java @@ -167,7 +167,7 @@ public class FileSet /** * add a name entry on the exclude list */ - public PatternSet.NameEntry createExclude() + public NameEntry createExclude() { return m_defaultPatterns.createExclude(); } @@ -175,7 +175,7 @@ public class FileSet /** * add a name entry on the include files list */ - public PatternSet.NameEntry createExcludesFile() + public NameEntry createExcludesFile() { return m_defaultPatterns.createExcludesFile(); } @@ -183,7 +183,7 @@ public class FileSet /** * add a name entry on the include list */ - public PatternSet.NameEntry createInclude() + public NameEntry createInclude() { return m_defaultPatterns.createInclude(); } @@ -191,7 +191,7 @@ public class FileSet /** * add a name entry on the include files list */ - public PatternSet.NameEntry createIncludesFile() + public NameEntry createIncludesFile() { return m_defaultPatterns.createIncludesFile(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/NameEntry.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/NameEntry.java new file mode 100644 index 000000000..889150acf --- /dev/null +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/NameEntry.java @@ -0,0 +1,89 @@ +/* + * 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; + +import org.apache.tools.ant.Project; + +/** + * inner class to hold a name on list. "If" and "Unless" attributes may be + * used to invalidate the entry based on the existence of a property + * (typically set thru the use of the Available task). + */ +public class NameEntry +{ + private String m_if; + private String m_name; + private String m_unless; + private PatternSet m_set; + + public NameEntry( final PatternSet set ) + { + m_set = set; + } + + public void setIf( final String ifCondition ) + { + m_if = ifCondition; + } + + public void setName( final String name ) + { + m_name = name; + } + + public void setUnless( final String unlessCondition ) + { + m_unless = unlessCondition; + } + + public String evalName( Project p ) + { + return valid( p ) ? m_name : null; + } + + public String toString() + { + StringBuffer buf = new StringBuffer( m_name ); + if( ( m_if != null ) || ( m_unless != null ) ) + { + buf.append( ":" ); + String connector = ""; + + if( m_if != null ) + { + buf.append( "if->" ); + buf.append( m_if ); + connector = ";"; + } + if( m_unless != null ) + { + buf.append( connector ); + buf.append( "unless->" ); + buf.append( m_unless ); + } + } + + return buf.toString(); + } + + private boolean valid( Project p ) + { + if( m_if != null && p.getProperty( m_if ) == null ) + { + return false; + } + else if( m_unless != null && p.getProperty( m_unless ) != null ) + { + return false; + } + else + { + return true; + } + } +} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java index fd8b40652..10d532879 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java @@ -206,7 +206,7 @@ public class PatternSet */ private NameEntry addPatternToList( final ArrayList list ) { - final NameEntry result = new NameEntry(); + final NameEntry result = new NameEntry( this ); list.add( result ); return result; } @@ -338,78 +338,4 @@ public class PatternSet } } - /** - * inner class to hold a name on list. "If" and "Unless" attributes may be - * used to invalidate the entry based on the existence of a property - * (typically set thru the use of the Available task). - */ - public class NameEntry - { - private String ifCond; - private String name; - private String unlessCond; - - public void setIf( String cond ) - { - ifCond = cond; - } - - public void setName( String name ) - { - this.name = name; - } - - public void setUnless( String cond ) - { - unlessCond = cond; - } - - public String getName() - { - return name; - } - - public String evalName( Project p ) - { - return valid( p ) ? name : null; - } - - public String toString() - { - StringBuffer buf = new StringBuffer( name ); - if( ( ifCond != null ) || ( unlessCond != null ) ) - { - buf.append( ":" ); - String connector = ""; - - if( ifCond != null ) - { - buf.append( "if->" ); - buf.append( ifCond ); - connector = ";"; - } - if( unlessCond != null ) - { - buf.append( connector ); - buf.append( "unless->" ); - buf.append( unlessCond ); - } - } - - return buf.toString(); - } - - private boolean valid( Project p ) - { - if( ifCond != null && p.getProperty( ifCond ) == null ) - { - return false; - } - else if( unlessCond != null && p.getProperty( unlessCond ) != null ) - { - return false; - } - return true; - } - } }