org.apache.tools.ant
public class ProjectHelper extends Object
| Field Summary | |
|---|---|
| static String | ANTLIB_URI The URI for defined types/tasks - the format is antlib: |
| static String | ANT_CORE_URI The URI for ant name space |
| static String | ANT_CURRENT_URI The URI for antlib current definitions |
| static String | ANT_TYPE Polymorphic attribute |
| static String | HELPER_PROPERTY
Name of JVM system property which provides the name of the
ProjectHelper class to use. |
| static String | PROJECTHELPER_REFERENCE
name of project helper reference that we add to a project |
| static String | SERVICE_ID
The service identifier in jars which provide Project Helper
implementations. |
| Constructor Summary | |
|---|---|
| ProjectHelper() Default constructor | |
| Method Summary | |
|---|---|
| static BuildException | addLocationToBuildException(BuildException ex, Location newLocation)
Add location to build exception. |
| static void | addText(Project project, Object target, char[] buf, int start, int count)
Adds the content of #PCDATA sections to an element.
|
| static void | addText(Project project, Object target, String text)
Adds the content of #PCDATA sections to an element.
|
| static void | configure(Object target, AttributeList attrs, Project project)
Configures an object using an introspection handler.
|
| static void | configureProject(Project project, File buildFile)
Configures the project with the contents of the specified XML file.
|
| static String | extractNameFromComponentName(String componentName)
extract the element name from a component name
|
| static String | extractUriFromComponentName(String componentName)
extract a uri from a component name
|
| static String | genComponentName(String uri, String name)
Map a namespaced {uri,name} to an internal string format.
|
| static ClassLoader | getContextClassLoader()
JDK1.1 compatible access to the context class loader. |
| Vector | getImportStack() EXPERIMENTAL WILL_CHANGE
Import stack.
|
| static ProjectHelper | getProjectHelper()
Discovers a project helper instance. |
| void | parse(Project project, Object source)
Parses the project file, configuring the project as it goes.
|
| static void | parsePropertyString(String value, Vector fragments, Vector propertyRefs)
Parses a string containing ${xxx} style property
references into two lists. |
| static String | replaceProperties(Project project, String value)
Replaces ${xxx} style constructions in the given value with
the string value of the corresponding properties.
|
| static String | replaceProperties(Project project, String value, Hashtable keys)
Replaces ${xxx} style constructions in the given value
with the string value of the corresponding data types.
|
| static void | storeChild(Project project, Object parent, Object child, String tag)
Stores a configured child element within its parent object.
|
Parameters: ex the build exception, if the build exception does not include newLocation the location of the calling task (may be null)
Returns: a new build exception based in the build exception with location set to newLocation. If the original exception did not have a location, just return the build exception
Parameters: project The project containing the target.
Must not be null. target The target object to be configured.
Must not be null. buf A character array of the text within the element.
Will not be null. start The start element in the array. count The number of characters to read from the array.
Throws: BuildException if the target object doesn't accept text
Parameters: project The project containing the target.
Must not be null. target The target object to be configured.
Must not be null. text Text to add to the target.
May be null, in which case this
method call is a no-op.
Throws: BuildException if the target object doesn't accept text
Deprecated: since 1.6.x. Use IntrospectionHelper for each property.
Configures an object using an introspection handler.Parameters: target The target object to be configured.
Must not be null. attrs A list of attributes to configure within the target.
Must not be null. project The project containing the target.
Must not be null.
Throws: BuildException if any of the attributes can't be handled by the target
Parameters: project The project to configure. Must not be null. buildFile An XML file giving the project's configuration.
Must not be null.
Throws: BuildException if the configuration is invalid or cannot be read
Parameters: componentName The stringified form for {uri, name}
Returns: The element name of the component
Parameters: componentName The stringified form for {uri, name}
Returns: The uri or "" if not present
Parameters: uri The namepace URI name The localname
Returns: The stringified form of the ns name
Deprecated: since 1.6.x. Use LoaderUtils.getContextClassLoader()
JDK1.1 compatible access to the context class loader. Cut & paste from JAXP.Returns: the current context class loader, or null
if the context class loader is unavailable.
Returns: the stack of import source objects.
Returns: a ProjectHelper, either a custom implementation if one is available and configured, or the default implementation otherwise.
Throws: BuildException if a specified helper class cannot be loaded/instantiated.
Parameters: project The project for the resulting ProjectHelper to configure.
Must not be null. source The source for XML configuration. A helper must support
at least File, for backward compatibility. Helpers may
support URL, InputStream, etc or specialized types.
Throws: BuildException if the configuration is invalid or cannot be read
Since: Ant1.5
Deprecated: since 1.6.x. Use PropertyHelper.
Parses a string containing${xxx} style property
references into two lists. The first list is a collection
of text fragments, while the other is a set of string property names.
null entries in the first list indicate a property
reference from the second list.
Parameters: value Text to parse. Must not be null. fragments List to add text fragments to.
Must not be null. propertyRefs List to add property names to.
Must not be null.
Throws: BuildException if the string contains an opening
${ without a closing }
Deprecated: since 1.6.x. Use project.replaceProperties().
Replaces${xxx} style constructions in the given value with
the string value of the corresponding properties.
Parameters: project The project containing the properties to replace.
Must not be null.
value The string to be scanned for property references.
May be null.
Returns: the original string with the properties replaced, or
null if the original string is null.
Throws: BuildException if the string contains an opening
${ without a closing
}
Since: 1.5
Deprecated: since 1.6.x. Use PropertyHelper.
Replaces${xxx} style constructions in the given value
with the string value of the corresponding data types.
Parameters: project The container project. This is used solely for
logging purposes. Must not be null. value The string to be scanned for property references.
May be null, in which case this
method returns immediately with no effect. keys Mapping (String to String) of property names to their
values. Must not be null.
Returns: the original string with the properties replaced, or
null if the original string is null.
Throws: BuildException if the string contains an opening
${ without a closing
}
Parameters: project Project containing the objects.
May be null. parent Parent object to add child to.
Must not be null. child Child object to store in parent.
Should not be null. tag Name of element which generated the child.
May be null, in which case
the child is not stored.