Package org.apache.tools.ant.property
Class ParseProperties
java.lang.Object
org.apache.tools.ant.property.ParseProperties
- All Implemented Interfaces:
ParseNextProperty
public class ParseProperties extends java.lang.Object implements ParseNextProperty
Parse properties using a collection of expanders.
- Since:
- Ant 1.8.0
-
Constructor Summary
Constructors Constructor Description ParseProperties(Project project, java.util.Collection<PropertyExpander> expanders, GetProperty getProperty)Constructor with a getProperty. -
Method Summary
Modifier and Type Method Description booleancontainsProperties(java.lang.String value)Learn whether a String contains replaceable properties.ProjectgetProject()Get the project.java.lang.ObjectparseNextProperty(java.lang.String value, java.text.ParsePosition pos)Return any property that can be parsed from the specified position in the specified String.java.lang.ObjectparseProperties(java.lang.String value)Decode properties from a String representation.
-
Constructor Details
-
ParseProperties
public ParseProperties(Project project, java.util.Collection<PropertyExpander> expanders, GetProperty getProperty)Constructor with a getProperty.- Parameters:
project- the current Ant project.expanders- a sequence of expandersgetProperty- property resolver.
-
-
Method Details
-
getProject
Get the project.- Specified by:
getProjectin interfaceParseNextProperty- Returns:
- the current Ant project.
-
parseProperties
public java.lang.Object parseProperties(java.lang.String value)Decode properties from a String representation.- This implementation starts parsing the
valueparameter (unsurprisingly) at the beginning and asks eachPropertyExpanderwhether there is a property reference at that point. PropertyExpanders return the name of a property they may find and may advance the parse position. - If the PropertyExpander returns
nullthe method continues with the next PropertyExpander, otherwise it tries to look up the property's value using the configuredGetPropertyinstance. - Once all PropertyExpanders have been consulted, the parse
position is advanced by one character and the process repeated
until
valueis exhausted.
If the entire contents of
valueresolves to a single property, the looked up property value is returned. Otherwise a String is returned that concatenates the non-property parts ofvalueand the expanded values of the properties that have been found.- Parameters:
value- The string to be scanned for property references. May benull, in which case this method returns immediately with no effect.- Returns:
- the original string with the properties replaced, or
nullif the original string isnull.
- This implementation starts parsing the
-
containsProperties
public boolean containsProperties(java.lang.String value)Learn whether a String contains replaceable properties.Uses the configured
PropertyExpandersand scans through the string. Returns true as soon as any expander finds a property.- Parameters:
value- the String to check.- Returns:
trueifvaluecontains property notation.
-
parseNextProperty
public java.lang.Object parseNextProperty(java.lang.String value, java.text.ParsePosition pos)Return any property that can be parsed from the specified position in the specified String.Uses the configured
PropertyExpandersandGetPropertyinstance .- Specified by:
parseNextPropertyin interfaceParseNextProperty- Parameters:
value- String to parsepos- ParsePosition- Returns:
- Object or null if no property is at the current location. If a property reference has been found but the property doesn't expand to a value, the property's name is returned.
-