Selectors
Selectors
The IzPack selector for the FileSet concept has been adapted from the Apache Ant Selector core type. The functionality has been reduced to the satisfy the needs of IzPack.
Selectors are a mechanism whereby the files that make up a fileset can be selected using more criteria than the file name provided by the <include> and <exclude> tags.
How to use a Selector
A selector is an element of FileSet, and appears within it. It can also be defined outside of any target by using the <selector> tag and then used as a reference.
Different selectors have different attributes. Some selectors can contain other selectors, and these are called Selector Containers.
Core Selectors
Core selectors can be used within a fileset and can be contained within Selector Containers.
The core selectors are:
<contains> - Select files that contain a particular text string
<date> - Select files that have been modified either before or after a particular date and time
<depend> - Select files that have been modified more recently than equivalent files elsewhere
<depth> - Select files that appear so many directories down in a directory tree
<different> - Select files that are different from those elsewhere
<filename> - Select files whose name matches a particular pattern. Equivalent to the include and exclude elements of a patternset.
<present> - Select files that either do or do not exist in some other location
<containsregexp> - Select files that match a regular expression
<size> - Select files that are larger or smaller than a particular number of bytes.
<type> - Select files that are either regular files or directories.
<modified> - Select files if the return value of the configured algorithm is different from that stored in a cache.
Contains Selector
The <contains> tag in a FileSet limits the files defined by that fileset to only those which contain the string specified by the text attribute.
Attribute | Description | Required |
text | Specifies the text that every file must contain | Yes |
casesensitive | Whether to pay attention to case when looking for the string in the text attribute. Default is true. | No |
ignorewhitespace | Whether to eliminate whitespace before checking for the string in the text attribute. Default is false. | No |
Here is an example of how to use the Contains Selector:
<fileset dir="${doc.path}" includes="**/*.html">
<contains text="script" casesensitive="no"/>
</fileset>Selects all the HTML files that contain the string script.
Date Selector
The <date> tag in a FileSet will put a limit on the files specified by the include tag, so that tags whose last modified date does not meet the date limits specified by the selector will not end up being selected.
Attribute | Description | Required |
|---|---|---|
datetime | Specifies the date and time to test for. Should be in the format MM/DD/YYYY HH:MM AM_or_PM, or an alternative pattern specified via the pattern attribute. | At least one of the two. |
millis | The number of milliseconds since 1970 that should be tested for. It is usually much easier to use the datetime attribute. | |
when | Indicates how to interpret the date, whether the files to be selected are those whose last modified times should be before, after, or equal to the specified value. Acceptable values for this attribute are:
| No |
granularity | The number of milliseconds leeway to use when comparing file modification times. This is needed because not every file system supports tracking the last modified time to the millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems. | No |
pattern | The SimpleDateFormat-compatible pattern to use when interpreting the datetime attribute. | No |
checkdirs | Indicates whether or not to check dates on directories. | No, defaults to false |
Here is an example of how to use the Date Selector:
<fileset dir="${jar.path}" includes="**/*.jar">
<date datetime="01/01/2001 12:00 AM" when="before"/>
</fileset>Selects all JAR files which were last modified before midnight January 1, 2001.
Depend Selector
The <depend> tag selects files whose last modified date is later than another, equivalent file in another location.
The <depend> tag supports the use of a contained <mapper> element to define the location of the file to be compared against. If no <mapper> element is specified, the identity type mapper is used.
The <depend> selector is case-sensitive.
Attribute | Description | Required |
|---|---|---|
targetdir | The base directory to look for the files to compare against. The precise location depends on a combination of this attribute and the <mapper> element, if any. | Yes |
granularity | The number of milliseconds leeway to give before deciding a file is out of date. This is needed because not every file system supports tracking the last modified time to the millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems. | No |