FilterSet (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.types, class: FilterSet

# Class FilterSet

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.tools.ant.types.FilterSet

All Implemented Interfaces:
  `Cloneable`

public class FilterSet extends DataType implements Cloneable
A set of filters to be applied to something. A filter set may have begintoken and endtokens defined.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `FilterSet.Filter`
  Individual filter component of filterset.
  `class`
  `FilterSet.FiltersFile`
  The filtersfile nested element.
  `static class`
  `FilterSet.OnMissing`
  EnumeratedAttribute to set behavior WRT missing filtersfiles: "fail" (default), "warn", "ignore".

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_TOKEN_END`
  The default token end string
  `static final String`
  `DEFAULT_TOKEN_START`
  The default token start string

  ### Fields inherited from class DataType

  `checked, ref`
  Modifier and Type
  Field
  Description
  `protected boolean`
  `checked`
  Deprecated.
  since 1.7.
  `protected Reference`
  `ref`
  Deprecated.
  since 1.7.

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `FilterSet()`
  Default constructor.
  `protected`
  `FilterSet(FilterSet filterset)`
  Create a Filterset from another filterset.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addConfiguredFilterSet(FilterSet filterSet)`
  Add a Filterset to this filter set.
  `void`
  `addConfiguredPropertySet(PropertySet propertySet)`
  Adds the properties provided by the specified PropertySet to this filterset.
  `void`
  `addFilter(String token, String value)`
  Add a new filter made from the given token and value.
  `void`
  `addFilter(FilterSet.Filter filter)`
  Add a new filter.
  `Object`
  `clone()`
  Clone the filterset.
  `FilterSet.FiltersFile`
  `createFiltersfile()`
  Create a new FiltersFile.
  `String`
  `getBeginToken()`
  Get the begin token for this filterset.
  `String`
  `getEndToken()`
  Get the end token for this filterset.
  `Hashtable<String,String>`
  `getFilterHash()`
  Gets the filter hash of the FilterSet.
  `protected Vector<FilterSet.Filter>`
  `getFilters()`
  Get the filters in the filter set.
  `FilterSet.OnMissing`
  `getOnMissingFiltersFile()`
  Get the onMissingFiltersFile setting.
  `protected FilterSet`
  `getRef()`
  Get the referenced filter set.
  `boolean`
  `hasFilters()`
  Test to see if this filter set has filters.
  `boolean`
  `isRecurse()`
  Get whether recursive token expansion is enabled.
  `void`
  `readFiltersFromFile(File filtersFile)`
  Read the filters from the given file.
  `String`
  `replaceTokens(String line)`
  Does replacement on the given string with token matching.
  `void`
  `setBeginToken(String startOfToken)`
  Set the string used to id the beginning of a token.
  `void`
  `setEndToken(String endOfToken)`
  Set the string used to id the end of a token.
  `void`
  `setFiltersfile(File filtersFile)`
  Set the file containing the filters for this filterset.
  `void`
  `setOnMissingFiltersFile(FilterSet.OnMissing onMissingFiltersFile)`
  Set the behavior WRT missing filtersfiles.
  `void`
  `setRecurse(boolean recurse)`
  Set whether recursive token expansion is enabled.

  ### Methods inherited from class DataType

  `checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, setRefid, tooManyAttributes, toString`
  Modifier and Type
  Method
  Description
  `protected void`
  `checkAttributesAllowed()`
  check that it is ok to set attributes, i.e that no reference is defined
  `protected void`
  `checkChildrenAllowed()`
  check that it is ok to add children, i.e that no reference is defined
  `protected BuildException`
  `circularReference()`
  Creates an exception that indicates the user has generated a loop of data types referencing each other.
  `protected void`
  `dieOnCircularReference()`
  Convenience method.
  `protected void`
  `dieOnCircularReference(Stack<Object> stack, Project project)`
  Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).
  `protected void`
  `dieOnCircularReference(Project p)`
  Convenience method.
  `protected <T> T`
  `getCheckedRef()`
  Deprecated.
  use getCheckedRef(Class)
  `protected <T> T`
  `getCheckedRef(Class<T> requiredClass)`
  Performs the check for circular references and returns the referenced object.
  `protected <T> T`
  `getCheckedRef(Class<T> requiredClass, String dataTypeName)`
  Performs the check for circular references and returns the referenced object.
  `protected <T> T`
  `getCheckedRef(Class<T> requiredClass, String dataTypeName, Project project)`
  Performs the check for circular references and returns the referenced object.
  `protected <T> T`
  `getCheckedRef(Project p)`
  Deprecated.
  use getCheckedRef(Class)
  `protected String`
  `getDataTypeName()`
  Gets as descriptive as possible a name used for this datatype instance.
  `Reference`
  `getRefid()`
  get the reference set on this object
  `static void`
  `invokeCircularReferenceCheck(DataType dt, Stack<Object> stk, Project p)`
  Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.
  `protected boolean`
  `isChecked()`
  The flag that is used to indicate that circular references have been checked.
  `boolean`
  `isReference()`
  Has the refid attribute of this element been set?
  `protected BuildException`
  `noChildrenAllowed()`
  Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.
  `static void`
  `pushAndInvokeCircularReferenceCheck(DataType dt, Stack<Object> stk, Project p)`
  Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.
  `protected void`
  `setChecked(boolean checked)`
  Set the flag that is used to indicate that circular references have been checked.
  `void`
  `setRefid(Reference ref)`
  Set the value of the refid attribute.
  `protected BuildException`
  `tooManyAttributes()`
  Creates an exception that indicates that refid has to be the only attribute if it is set.
  `String`
  `toString()`
  Basic DataType toString().

  ### Methods inherited from class ProjectComponent

  `getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_TOKEN_START

    public static final String DEFAULT_TOKEN_START
    The default token start string
    See Also:
      - Constant Field Values

  - ### DEFAULT_TOKEN_END

    public static final String DEFAULT_TOKEN_END
    The default token end string
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### FilterSet

    public FilterSet()
    Default constructor.

  - ### FilterSet

    protected FilterSet(FilterSet filterset)
    Create a Filterset from another filterset.
    Parameters:
      `filterset` - the filterset upon which this filterset will be based.

- ## Method Details

  - ### getFilters

    protected Vector<FilterSet.Filter> getFilters()
    Get the filters in the filter set.
    Returns:
      a Vector of Filter instances.

  - ### getRef

    protected FilterSet getRef()
    Get the referenced filter set.
    Returns:
      the filterset from the reference.

  - ### getFilterHash

    public Hashtable<String,String> getFilterHash()
    Gets the filter hash of the FilterSet.
    Returns:
      The hash of the tokens and values for quick lookup.

  - ### setFiltersfile

    public void setFiltersfile(File filtersFile) throws BuildException
    Set the file containing the filters for this filterset.
    Parameters:
      `filtersFile` - sets the filter file from which to read filters for this filter set.
    Throws:
      `BuildException` - if there is an error.

  - ### setBeginToken

    public void setBeginToken(String startOfToken)
    Set the string used to id the beginning of a token.
    Parameters:
      `startOfToken` - The new Begintoken value.

  - ### getBeginToken

    public String getBeginToken()
    Get the begin token for this filterset.
    Returns:
      the filter set's begin token for filtering.

  - ### setEndToken

    public void setEndToken(String endOfToken)
    Set the string used to id the end of a token.
    Parameters:
      `endOfToken` - The new Endtoken value.

  - ### getEndToken

    public String getEndToken()
    Get the end token for this filterset.
    Returns:
      the filter set's end token for replacement delimiting.

  - ### setRecurse

    public void setRecurse(boolean recurse)
    Set whether recursive token expansion is enabled.
    Parameters:
      `recurse` - `boolean` whether to recurse.

  - ### isRecurse

    public boolean isRecurse()
    Get whether recursive token expansion is enabled.
    Returns:
      `boolean` whether enabled.

  - ### readFiltersFromFile

    public void readFiltersFromFile(File filtersFile) throws BuildException
    Read the filters from the given file.
    Parameters:
      `filtersFile` - the file from which filters are read.
    Throws:
      `BuildException` - when the file cannot be read.

  - ### replaceTokens

    public String replaceTokens(String line)
    Does replacement on the given string with token matching. This uses the defined begintoken and endtoken values which default to @ for both. This resets the passedTokens and calls iReplaceTokens to do the actual replacements.
    Parameters:
      `line` - The line in which to process embedded tokens.
    Returns:
      The input string after token replacement.

  - ### addFilter

    public void addFilter(FilterSet.Filter filter)
    Add a new filter.
    Parameters:
      `filter` - the filter to be added.

  - ### createFiltersfile

    public FilterSet.FiltersFile createFiltersfile()
    Create a new FiltersFile.
    Returns:
      The filtersfile that was created.

  - ### addFilter

    public void addFilter(String token, String value)
    Add a new filter made from the given token and value.
    Parameters:
      `token` - The token for the new filter.
      `value` - The value for the new filter.

  - ### addConfiguredFilterSet

    public void addConfiguredFilterSet(FilterSet filterSet)
    Add a Filterset to this filter set.
    Parameters:
      `filterSet` - the filterset to be added to this filterset

  - ### addConfiguredPropertySet

    public void addConfiguredPropertySet(PropertySet propertySet)
    Adds the properties provided by the specified PropertySet to this filterset.
    Parameters:
      `propertySet` - the propertyset to be added to this propertyset

  - ### hasFilters

    public boolean hasFilters()
    Test to see if this filter set has filters.
    Returns:
      Return true if there are filters in this set.

  - ### clone

    public Object clone() throws BuildException
    Clone the filterset.
    Overrides:
      `clone` in class `DataType`
    Returns:
      a deep clone of this filterset.
    Throws:
      `BuildException` - if the clone cannot be performed.

  - ### setOnMissingFiltersFile

    public void setOnMissingFiltersFile(FilterSet.OnMissing onMissingFiltersFile)
    Set the behavior WRT missing filtersfiles.
    Parameters:
      `onMissingFiltersFile` - the OnMissing describing the behavior.

  - ### getOnMissingFiltersFile

    public FilterSet.OnMissing getOnMissingFiltersFile()
    Get the onMissingFiltersFile setting.
    Returns:
      the OnMissing instance.