git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270737 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -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 <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| 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(); | |||
| @@ -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(); | |||
| } | |||
| @@ -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; | |||
| @@ -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(); | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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 <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| 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(); | |||
| @@ -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(); | |||
| } | |||
| @@ -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; | |||
| @@ -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(); | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||