Top Description Inners Fields Constructors Methods
org.apache.tools.ant.types

public Class PatternSet

extends DataType
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
org.apache.tools.ant.types.PatternSet.InvertedPatternSet
Imports
java.io.BufferedReader, .File, .FileInputStream, .FileReader, .IOException, .InputStreamReader, .Reader, java.util.ArrayList, .List, .Objects, .StringTokenizer, java.util.function.Predicate, org.apache.tools.ant.BuildException, .Project, .PropertyHelper

Named collection of include/exclude tags.

Moved out of MatchingTask to make it a standalone object that could be referenced (by scripts for example).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public class
PatternSet.NameEntry

inner class to hold a name on list.

public class
PatternSet.PatternFileNameEntry

Adds encoding support to NameEntry.

Field Summary

Modifier and TypeField and Description
private List<PatternSet.NameEntry>
private List<PatternSet.PatternFileNameEntry>
private List<PatternSet.NameEntry>
private List<PatternSet.PatternFileNameEntry>
Inherited from org.apache.tools.ant.types.DataType:
checkedref

Constructor Summary

AccessConstructor and Description
public
PatternSet()

Creates a new PatternSet instance.

Method Summary

Modifier and TypeMethod and Description
public void
addConfiguredInvert(PatternSet
the pattern to invert and add.
p
)

Add an inverted patternset.

public void
addConfiguredPatternset(PatternSet
a configured patternset nested element.
p
)

This is a patternset nested element.

private PatternSet.PatternFileNameEntry
addPatternFileToList(List<PatternSet.PatternFileNameEntry> list)

add a pattern file name entry to the given list

private PatternSet.NameEntry
addPatternToList(List<PatternSet.NameEntry> list)

add a name entry to the given list

public void
append(PatternSet
the other PatternSet instance.
other
,
Project
the current project.
p
)

Adds the patterns of the other instance to this set.

public Object

Returns:

a clone of this patternset.
clone
()

Overrides org.apache.tools.ant.types.DataType.clone.

Creates and returns a copy of this object.
public PatternSet.NameEntry

Returns:

a nested exclude element to be configured.
createExclude
()

add a name entry on the exclude list

public PatternSet.NameEntry

Returns:

a nested excludesfile element to be configured.
createExcludesFile
()

add a name entry on the exclude files list

public PatternSet.NameEntry

Returns:

a nested include element to be configured.
createInclude
()

add a name entry on the include list

public PatternSet.NameEntry

Returns:

a nested includesfile element to be configured.
createIncludesFile
()

add a name entry on the include files list

public String[]

Returns:

the filtered excluded patterns.
getExcludePatterns
(Project
the current project.
p
)

Returns the filtered include patterns.

public String[]

Returns:

the filtered included patterns.
getIncludePatterns
(Project
the current project.
p
)

Returns the filtered include patterns.

private PatternSet
getRef(Project p)

Performs the check for circular references and returns the referenced PatternSet.

public boolean

Returns:

true if there are patterns.
hasPatterns
(Project
the current project.
p
)

Helper for FileSet classes.

private String[]
makeArray(List<PatternSet.NameEntry> list, Project p)

Convert a vector of NameEntry elements into an array of Strings.

private void
readFiles(Project p)

Read includesfile ot excludesfile if not already done so.

private void
readPatterns(File patternfile, String encoding, List<PatternSet.NameEntry> patternlist, Project p)

Reads path matching patterns from a file and adds them to the includes or excludes list (as appropriate).

public void
setExcludes(String
the string containing the exclude patterns
excludes
)

Appends excludes to the current list of exclude patterns.

public void
setExcludesfile(File
The file to fetch the exclude patterns from.
excludesFile
)

Sets the name of the file containing the excludes patterns.

public void
setIncludes(String
the string containing the include patterns
includes
)

Appends includes to the current list of include patterns.

public void
setIncludesfile(File
The file to fetch the include patterns from.
includesFile
)

Sets the name of the file containing the includes patterns.

public void
setRefid(Reference
the reference to another patternset.
r
)

Overrides org.apache.tools.ant.types.DataType.setRefid.

Makes this instance in effect a reference to another PatternSet instance.
public String

Returns:

a printable form of this object.
toString
()

Overrides org.apache.tools.ant.types.DataType.toString.

Basic DataType toString().
Inherited from org.apache.tools.ant.types.DataType:
checkAttributesAllowedcheckChildrenAllowedcircularReferencedieOnCircularReferencedieOnCircularReferencedieOnCircularReferencegetCheckedRefgetCheckedRefgetCheckedRefgetCheckedRefgetCheckedRefgetDataTypeNamegetRefidinvokeCircularReferenceCheckisCheckedisReferencenoChildrenAllowedpushAndInvokeCircularReferenceChecksetCheckedtooManyAttributes

Field Detail

excludeListback to summary
private List<PatternSet.NameEntry> excludeList
excludesFileListback to summary
private List<PatternSet.PatternFileNameEntry> excludesFileList
includeListback to summary
private List<PatternSet.NameEntry> includeList
includesFileListback to summary
private List<PatternSet.PatternFileNameEntry> includesFileList

Constructor Detail

PatternSetback to summary
public PatternSet()

Creates a new PatternSet instance.

Method Detail

addConfiguredInvertback to summary
public void addConfiguredInvert(PatternSet p)

Add an inverted patternset.

Parameters
p:PatternSet

the pattern to invert and add.

addConfiguredPatternsetback to summary
public void addConfiguredPatternset(PatternSet p)

This is a patternset nested element.

Parameters
p:PatternSet

a configured patternset nested element.

addPatternFileToListback to summary
private PatternSet.PatternFileNameEntry addPatternFileToList(List<PatternSet.PatternFileNameEntry> list)

add a pattern file name entry to the given list

addPatternToListback to summary
private PatternSet.NameEntry addPatternToList(List<PatternSet.NameEntry> list)

add a name entry to the given list

appendback to summary
public void append(PatternSet other, Project p)

Adds the patterns of the other instance to this set.

Parameters
other:PatternSet

the other PatternSet instance.

p:Project

the current project.

cloneback to summary
public Object clone()

Overrides org.apache.tools.ant.types.DataType.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this patternset.

Annotations
@Override
Since
Ant 1.6
createExcludeback to summary
public PatternSet.NameEntry createExclude()

add a name entry on the exclude list

Returns:PatternSet.NameEntry

a nested exclude element to be configured.

createExcludesFileback to summary
public PatternSet.NameEntry createExcludesFile()

add a name entry on the exclude files list

Returns:PatternSet.NameEntry

a nested excludesfile element to be configured.

createIncludeback to summary
public PatternSet.NameEntry createInclude()

add a name entry on the include list

Returns:PatternSet.NameEntry

a nested include element to be configured.

createIncludesFileback to summary
public PatternSet.NameEntry createIncludesFile()

add a name entry on the include files list

Returns:PatternSet.NameEntry

a nested includesfile element to be configured.

getExcludePatternsback to summary
public String[] getExcludePatterns(Project p)

Returns the filtered include patterns.

Parameters
p:Project

the current project.

Returns:String[]

the filtered excluded patterns.

getIncludePatternsback to summary
public String[] getIncludePatterns(Project p)

Returns the filtered include patterns.

Parameters
p:Project

the current project.

Returns:String[]

the filtered included patterns.

getRefback to summary
private PatternSet getRef(Project p)

Performs the check for circular references and returns the referenced PatternSet.

hasPatternsback to summary
public boolean hasPatterns(Project p)

Helper for FileSet classes. Check if there are patterns defined.

Parameters
p:Project

the current project.

Returns:boolean

true if there are patterns.

makeArrayback to summary
private String[] makeArray(List<PatternSet.NameEntry> list, Project p)

Convert a vector of NameEntry elements into an array of Strings.

readFilesback to summary
private void readFiles(Project p)

Read includesfile ot excludesfile if not already done so.

readPatternsback to summary
private void readPatterns(File patternfile, String encoding, List<PatternSet.NameEntry> patternlist, Project p) throws BuildException

Reads path matching patterns from a file and adds them to the includes or excludes list (as appropriate).

setExcludesback to summary
public void setExcludes(String excludes)

Appends excludes to the current list of exclude patterns. Patterns may be separated by a comma or a space.

Parameters
excludes:String

the string containing the exclude patterns

setExcludesfileback to summary
public void setExcludesfile(File excludesFile) throws BuildException

Sets the name of the file containing the excludes patterns.

Parameters
excludesFile:File

The file to fetch the exclude patterns from.

Exceptions
BuildException:
on error.
setIncludesback to summary
public void setIncludes(String includes)

Appends includes to the current list of include patterns. Patterns may be separated by a comma or a space.

Parameters
includes:String

the string containing the include patterns

setIncludesfileback to summary
public void setIncludesfile(File includesFile) throws BuildException

Sets the name of the file containing the includes patterns.

Parameters
includesFile:File

The file to fetch the include patterns from.

Exceptions
BuildException:
on error.
setRefidback to summary
public void setRefid(Reference r) throws BuildException

Overrides org.apache.tools.ant.types.DataType.setRefid.

Makes this instance in effect a reference to another PatternSet instance.

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

Parameters
r:Reference

the reference to another patternset.

Annotations
@Override
Exceptions
BuildException:
on error.
toStringback to summary
public String toString()

Overrides org.apache.tools.ant.types.DataType.toString.

Doc from org.apache.tools.ant.types.DataType.toString.

Basic DataType toString().

Returns:String

a printable form of this object.

Annotations
@Override
org.apache.tools.ant.types back to summary

private final Class PatternSet.InvertedPatternSet

extends PatternSet
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String[]
getExcludePatterns(Project
the current project.
p
)

Overrides org.apache.tools.ant.types.PatternSet.getExcludePatterns.

Returns the filtered include patterns.
public String[]
getIncludePatterns(Project
the current project.
p
)

Overrides org.apache.tools.ant.types.PatternSet.getIncludePatterns.

Returns the filtered include patterns.
Inherited from org.apache.tools.ant.types.PatternSet:
addConfiguredInvertaddConfiguredPatternsetappendclonecreateExcludecreateExcludesFilecreateIncludecreateIncludesFilehasPatternssetExcludessetExcludesfilesetIncludessetIncludesfilesetRefidtoString

Constructor Detail

InvertedPatternSetback to summary
private InvertedPatternSet(PatternSet p)

Method Detail

getExcludePatternsback to summary
public String[] getExcludePatterns(Project p)

Overrides org.apache.tools.ant.types.PatternSet.getExcludePatterns.

Doc from org.apache.tools.ant.types.PatternSet.getExcludePatterns.

Returns the filtered include patterns.

Parameters
p:Project

the current project.

Returns:String[]

the filtered excluded patterns.

Annotations
@Override
getIncludePatternsback to summary
public String[] getIncludePatterns(Project p)

Overrides org.apache.tools.ant.types.PatternSet.getIncludePatterns.

Doc from org.apache.tools.ant.types.PatternSet.getIncludePatterns.

Returns the filtered include patterns.

Parameters
p:Project

the current project.

Returns:String[]

the filtered included patterns.

Annotations
@Override
org.apache.tools.ant.types back to summary

public Class PatternSet.NameEntry

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.types.PatternSet.PatternFileNameEntry

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 through the use of the Available task) or value of an expression.

Field Summary

Modifier and TypeField and Description
private Object
private String
private Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name attribute or null if the "if" or "unless" properties are not/are set.
evalName
(Project
the current project, used to check the presence or absence of a property.
p
)

This validates the name - checks the if and unless properties.

public String

Returns:

the name attribute.
getName
()

public void
setIf(Object
A property name or expression. If the expression evaluates to false or no property of its value is present, the name is invalid.
cond
)

Sets the if attribute.

public void
setIf(String
A property name or expression. If the expression evaluates to false or no property of its value is present, the name is invalid.
cond
)

Sets the if attribute.

public void
setName(String
The pattern string.
name
)

Sets the name pattern.

public void
setUnless(Object
A property name or expression. If the expression evaluates to true or a property of its value is present, the name is invalid.
cond
)

Sets the unless attribute.

public void
setUnless(String
A property name or expression. If the expression evaluates to true or a property of its value is present, the name is invalid.
cond
)

Sets the unless attribute.

public String

Returns:

a printable form of this object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ifCondback to summary
private Object ifCond
nameback to summary
private String name
unlessCondback to summary
private Object unlessCond

Constructor Detail

NameEntryback to summary
public NameEntry()

Method Detail

evalNameback to summary
public String evalName(Project p)

This validates the name - checks the if and unless properties.

Parameters
p:Project

the current project, used to check the presence or absence of a property.

Returns:String

the name attribute or null if the "if" or "unless" properties are not/are set.

getNameback to summary
public String getName()
Returns:String

the name attribute.

setIfback to summary
public void setIf(Object cond)

Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based on the existence of the property or the value of the evaluated property expression.

Parameters
cond:Object

A property name or expression. If the expression evaluates to false or no property of its value is present, the name is invalid.

Since
Ant 1.8.0
setIfback to summary
public void setIf(String cond)

Sets the if attribute. This attribute and the "unless" attribute are used to validate the name, based on the existence of the property or the value of the evaluated property expression.

Parameters
cond:String

A property name or expression. If the expression evaluates to false or no property of its value is present, the name is invalid.

setNameback to summary
public void setName(String name)

Sets the name pattern.

Parameters
name:String

The pattern string.

setUnlessback to summary
public void setUnless(Object cond)

Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based on the existence of the property or the value of the evaluated property expression.

Parameters
cond:Object

A property name or expression. If the expression evaluates to true or a property of its value is present, the name is invalid.

Since
Ant 1.8.0
setUnlessback to summary
public void setUnless(String cond)

Sets the unless attribute. This attribute and the "if" attribute are used to validate the name, based on the existence of the property or the value of the evaluated property expression.

Parameters
cond:String

A property name or expression. If the expression evaluates to true or a property of its value is present, the name is invalid.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a printable form of this object.

Annotations
@Override
validback to summary
private boolean valid(Project p)
org.apache.tools.ant.types back to summary

public Class PatternSet.PatternFileNameEntry

extends NameEntry
Class Inheritance

Adds encoding support to NameEntry.
Since
Ant 1.10.4

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final String

Returns:

the encoding name
getEncoding
()

Encoding to use when reading the file, defaults to the platform's default encoding.

public final void
setEncoding(String
String
encoding
)

Encoding to use when reading the file, defaults to the platform's default encoding.

public String
toString()

Overrides org.apache.tools.ant.types.PatternSet.NameEntry.toString.

Returns a string representation of the object.
Inherited from org.apache.tools.ant.types.PatternSet.NameEntry:
evalNamegetNamesetIfsetIfsetNamesetUnlesssetUnless

Field Detail

encodingback to summary
private String encoding

Constructor Detail

PatternFileNameEntryback to summary
public PatternFileNameEntry()

Method Detail

getEncodingback to summary
public final String getEncoding()

Encoding to use when reading the file, defaults to the platform's default encoding.

Returns:String

the encoding name

setEncodingback to summary
public final void setEncoding(String encoding)

Encoding to use when reading the file, defaults to the platform's default encoding.

For a list of possible values see https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html.

Parameters
encoding:String

String

toStringback to summary
public String toString()

Overrides org.apache.tools.ant.types.PatternSet.NameEntry.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

Doc from org.apache.tools.ant.types.PatternSet.NameEntry.toString.

a printable form of this object.

Annotations
@Override