Top Description Fields Constructors Methods
org.apache.tools.ant.property

public Class ParseProperties

extends Object
implements ParseNextProperty
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.property.ParseNextProperty
Imports
java.text.ParsePosition, java.util.Collection, .Objects, org.apache.tools.ant.Project

Parse properties using a collection of expanders.
Since
Ant 1.8.0

Field Summary

Modifier and TypeField and Description
private final Collection<PropertyExpander>
private final GetProperty
private final Project

Constructor Summary

AccessConstructor and Description
public
ParseProperties(Project
the current Ant project.
project
,
Collection<PropertyExpander>
a sequence of expanders
expanders
,
GetProperty
property resolver.
getProperty
)

Constructor with a getProperty.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if value contains property notation.
containsProperties
(String
the String to check.
value
)

Learn whether a String contains replaceable properties.

public Project

Returns:

the current Ant project.
getProject
()

Implements org.apache.tools.ant.property.ParseNextProperty.getProject.

Get the project.
private Object
getProperty(String propertyName)

public Object

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.
parseNextProperty
(String
String to parse
value
,
ParsePosition
ParsePosition
pos
)

Implements org.apache.tools.ant.property.ParseNextProperty.parseNextProperty.

Return any property that can be parsed from the specified position in the specified String.
public Object

Returns:

the original string with the properties replaced, or null if the original string is null.
parseProperties
(String
The string to be scanned for property references. May be null, in which case this method returns immediately with no effect.
value
)

Decode properties from a String representation.

private String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

expandersback to summary
private final Collection<PropertyExpander> expanders
getPropertyback to summary
private final GetProperty getProperty
projectback to summary
private final Project project

Constructor Detail

ParsePropertiesback to summary
public ParseProperties(Project project, Collection<PropertyExpander> expanders, GetProperty getProperty)

Constructor with a getProperty.

Parameters
project:Project

the current Ant project.

expanders:Collection<PropertyExpander>

a sequence of expanders

getProperty:GetProperty

property resolver.

Method Detail

containsPropertiesback to summary
public boolean containsProperties(String value)

Learn whether a String contains replaceable properties.

Uses the configured PropertyExpanders and scans through the string. Returns true as soon as any expander finds a property.

Parameters
value:String

the String to check.

Returns:boolean

true if value contains property notation.

getProjectback to summary
public Project getProject()

Implements org.apache.tools.ant.property.ParseNextProperty.getProject.

Get the project.

Returns:Project

the current Ant project.

Annotations
@Override
getPropertyback to summary
private Object getProperty(String propertyName)
parseNextPropertyback to summary
public Object parseNextProperty(String value, ParsePosition pos)

Implements org.apache.tools.ant.property.ParseNextProperty.parseNextProperty.

Return any property that can be parsed from the specified position in the specified String.

Uses the configured PropertyExpanders and GetProperty instance .

Parameters
value:String

String to parse

pos:ParsePosition

ParsePosition

Returns:Object

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.

Annotations
@Override
parsePropertiesback to summary
public Object parseProperties(String value)

Decode properties from a String representation.

  • This implementation starts parsing the value parameter (unsurprisingly) at the beginning and asks each PropertyExpander whether 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 null the method continues with the next PropertyExpander, otherwise it tries to look up the property's value using the configured GetProperty instance.
  • Once all PropertyExpanders have been consulted, the parse position is advanced by one character and the process repeated until value is exhausted.

If the entire contents of value resolves to a single property, the looked up property value is returned. Otherwise a String is returned that concatenates the non-property parts of value and the expanded values of the properties that have been found.

Parameters
value:String

The string to be scanned for property references. May be null, in which case this method returns immediately with no effect.

Returns:Object

the original string with the properties replaced, or null if the original string is null.

parsePropertyNameback to summary
private String parsePropertyName(String value, ParsePosition pos)