The following is an example of its usage:
<target name="setState">
<property
name="header"
value="##Generated file - do not modify!"/>
<propertyfile file="apropfile.properties" comment="${header}">
<entry key="product.version.major" type="int" value="5"/>
<entry key="product.version.minor" type="int" value="0"/>
<entry key="product.build.major" type="int" value="0" />
<entry key="product.build.minor" type="int" operation="+"/>
<entry key="product.build.date" type="date" value="now"/>
<entry key="intSet" type="int" operation="=" value="681"/>
<entry key="intDec" type="int" operation="-"/>
<entry key="StringEquals" type="string" value="testValue"/>
</propertyfile>
</target>
The <propertyfile> task must have:
The <entry> task must have:
If type is unspecified, it defaults to string.
Parameter values:String property types can only use the "=" operation. Int property types can only use the "=", "-" or "+" operations.
The message property is used for the property file header, with "\\" being a newline delimiter character.
| Modifier and Type | Class and Description |
|---|---|
| public static class | PropertyFile.
Instance of this class represents nested elements of a task propertyfile. |
| public static class | PropertyFile.
Borrowed from Tstamp |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private Vector | |
| private Properties | |
| private File | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| private void | |
| public PropertyFile. | |
| public void | |
| private void | |
| private void | |
| public void | |
| public void | |
| public void | setJDKProperties(boolean
boolean val)optional flag to use original Java properties (as opposed to layout preserving properties) |
| private void |
| comment | back to summary |
|---|---|
| private String comment | |
| entries | back to summary |
|---|---|
| private Vector<PropertyFile. | |
| properties | back to summary |
|---|---|
| private Properties properties | |
| propertyfile | back to summary |
|---|---|
| private File propertyfile | |
| useJDKProperties | back to summary |
|---|---|
| private boolean useJDKProperties | |
| PropertyFile | back to summary |
|---|---|
| public PropertyFile() | |
| checkParam | back to summary |
|---|---|
| private boolean checkParam(File param) | |
| checkParameters | back to summary |
|---|---|
| private void checkParameters() throws BuildException | |
| createEntry | back to summary |
|---|---|
| public PropertyFile. The entry nested element.
| |
| execute | back to summary |
|---|---|
| public void execute() throws BuildException Overrides org. Execute the task.
| |
| executeOperation | back to summary |
|---|---|
| private void executeOperation() throws BuildException | |
| readFile | back to summary |
|---|---|
| private void readFile() throws BuildException | |
| setComment | back to summary |
|---|---|
| public void setComment(String hdr) optional header comment for the file
| |
| setFile | back to summary |
|---|---|
| public void setFile(File file) Location of the property file to be edited; required.
| |
| setJDKProperties | back to summary |
|---|---|
| public void setJDKProperties(boolean val) optional flag to use original Java properties (as opposed to layout preserving properties)
| |
| writeFile | back to summary |
|---|---|
| private void writeFile() throws BuildException | |
| Modifier and Type | Class and Description |
|---|---|
| public static class | PropertyFile.
Enumerated attribute with the values "+", "-", "=" |
| public static class | PropertyFile.
Enumerated attribute with the values "int", "date" and "string". |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final int | |
| private static final String | |
| private String | |
| private int | |
| private String | |
| private String | |
| private int | |
| private String | |
| private int | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | executeDate(String
the current value read from the property file or
oldValue)null if the key was
not contained in the property file.Handle operations for type |
| private void | executeInteger(String
the current value read from the property file or
oldValue)null if the key was
not contained in the property file.Handle operations for type |
| protected void | executeOn(Properties
the properties to apply the entry on. props)Apply the nested element to the properties. |
| private void | executeString(String
the current value read from the property file or
oldValue)null if the key was
not contained in the property file.Handle operations for type |
| private String | |
| public void | setDefault(String
the default value. value)Initial value to set for a property if it is not already defined in the property file. |
| public void | |
| public void | |
| public void | |
| public void | setType(PropertyFile.
the type enumerated value. valueRegard the value as : int, date or string (default) |
| public void | setUnit(PropertyFile.
the unit enumerated value. unitThe unit of the value to be applied to date +/- operations. |
| public void |
| DEFAULT_DATE_VALUE | back to summary |
|---|---|
| private static final String DEFAULT_DATE_VALUE | |
| DEFAULT_INT_VALUE | back to summary |
|---|---|
| private static final int DEFAULT_INT_VALUE | |
| DEFAULT_STRING_VALUE | back to summary |
|---|---|
| private static final String DEFAULT_STRING_VALUE | |
| defaultValue | back to summary |
|---|---|
| private String defaultValue | |
| field | back to summary |
|---|---|
| private int field | |
| key | back to summary |
|---|---|
| private String key | |
| newValue | back to summary |
|---|---|
| private String newValue | |
| operation | back to summary |
|---|---|
| private int operation | |
| pattern | back to summary |
|---|---|
| private String pattern | |
| type | back to summary |
|---|---|
| private int type | |
| value | back to summary |
|---|---|
| private String value | |
| Entry | back to summary |
|---|---|
| public Entry() | |
| checkParameters | back to summary |
|---|---|
| private void checkParameters() throws BuildException Check if parameter combinations can be supported | |
| executeDate | back to summary |
|---|---|
| private void executeDate(String oldValue) throws BuildException Handle operations for type
| |
| executeInteger | back to summary |
|---|---|
| private void executeInteger(String oldValue) throws BuildException Handle operations for type
| |
| executeOn | back to summary |
|---|---|
| protected void executeOn(Properties props) throws BuildException Apply the nested element to the properties.
| |
| executeString | back to summary |
|---|---|
| private void executeString(String oldValue) throws BuildException Handle operations for type
| |
| getCurrentValue | back to summary |
|---|---|
| private String getCurrentValue(String oldValue) | |
| setDefault | back to summary |
|---|---|
| public void setDefault(String value) Initial value to set for a property if it is not already defined in the property file. For type date, an additional keyword is allowed: "now"
| |
| setKey | back to summary |
|---|---|
| public void setKey(String value) Name of the property name/value pair
| |
| setOperation | back to summary |
|---|---|
| public void setOperation(PropertyFile. operation to apply. "+" or "=" (default) for all datatypes; "-" for date and int only)\.
| |
| setPattern | back to summary |
|---|---|
| public void setPattern(String value) For int and date type only. If present, Values will be parsed and formatted accordingly.
| |
| setType | back to summary |
|---|---|
| public void setType(PropertyFile. Regard the value as : int, date or string (default)
| |
| setUnit | back to summary |
|---|---|
| public void setUnit(PropertyFile. The unit of the value to be applied to date +/- operations. Valid Values are:
| |
| setValue | back to summary |
|---|---|
| public void setValue(String value) Value to set (=), to add (+) or subtract (-)
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| public static final int | DELETE_OPER
del |
| public static final int | |
| public static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String[] | getValues()
Implements abstract org. |
| public static int |
| DECREMENT_OPER | back to summary |
|---|---|
| public static final int DECREMENT_OPER - | |
| DELETE_OPER | back to summary |
|---|---|
| public static final int DELETE_OPER del | |
| EQUALS_OPER | back to summary |
|---|---|
| public static final int EQUALS_OPER = | |
| INCREMENT_OPER | back to summary |
|---|---|
| public static final int INCREMENT_OPER + | |
| Operation | back to summary |
|---|---|
| public Operation() | |
| getValues | back to summary |
|---|---|
| public String[] getValues() Implements abstract org. Doc from org. This is the only method a subclass needs to implement.. | |
| toOperation | back to summary |
|---|---|
| public static int toOperation(String oper) Convert string to index.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | DATE_TYPE
date |
| public static final int | INTEGER_TYPE
int |
| public static final int | STRING_TYPE
string |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String[] | getValues()
Implements abstract org. |
| public static int |
| DATE_TYPE | back to summary |
|---|---|
| public static final int DATE_TYPE date | |
| INTEGER_TYPE | back to summary |
|---|---|
| public static final int INTEGER_TYPE int | |
| STRING_TYPE | back to summary |
|---|---|
| public static final int STRING_TYPE string | |
| Type | back to summary |
|---|---|
| public Type() | |
| getValues | back to summary |
|---|---|
| public String[] getValues() Implements abstract org. Doc from org. This is the only method a subclass needs to implement. | |
| toType | back to summary |
|---|---|
| public static int toType(String type) Convert string to index.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Map | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String[] | |
| private static final String | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public String[] | getValues()
Implements abstract org. |
| calendarFields | back to summary |
|---|---|
| private Map<String, Integer> calendarFields | |
| DAY | back to summary |
|---|---|
| private static final String DAY | |
| HOUR | back to summary |
|---|---|
| private static final String HOUR | |
| MILLISECOND | back to summary |
|---|---|
| private static final String MILLISECOND | |
| MINUTE | back to summary |
|---|---|
| private static final String MINUTE | |
| MONTH | back to summary |
|---|---|
| private static final String MONTH | |
| SECOND | back to summary |
|---|---|
| private static final String SECOND | |
| UNITS | back to summary |
|---|---|
| private static final String[] UNITS | |
| WEEK | back to summary |
|---|---|
| private static final String WEEK | |
| YEAR | back to summary |
|---|---|
| private static final String YEAR | |
| Unit | back to summary |
|---|---|
| public Unit() no arg constructor | |
| getCalendarField | back to summary |
|---|---|
| public int getCalendarField() Convert the value to a Calendar field index.
| |
| getValues | back to summary |
|---|---|
| public String[] getValues() Implements abstract org. Doc from org. This is the only method a subclass needs to implement.. | |