| java.lang.Object org.apache.tools.ant.ProjectHelper
All known Subclasses: org.apache.tools.ant.helper.ProjectHelper2, org.apache.tools.ant.helper.ProjectHelperImpl,
ProjectHelper | public class ProjectHelper (Code) | | Configures a Project (complete with Targets and Tasks) based on
a XML build file. It'll rely on a plugin to do the actual processing
of the xml file.
This class also provide static wrappers for common introspection.
All helper plugins must provide backward compatibility with the
original ant patterns, unless a different behavior is explicitly
specified. For example, if namespace is used on the <project> tag
the helper can expect the entire build file to be namespace-enabled.
Namespaces or helper-specific tags can provide meta-information to
the helper, allowing it to use new ( or different policies ).
However, if no namespace is used the behavior should be exactly
identical with the default helper.
|
Method Summary | |
public static BuildException | addLocationToBuildException(BuildException ex, Location newLocation) Add location to build exception.
Parameters: ex - the build exception, if the build exceptiondoes not include Parameters: newLocation - the location of the calling task (may be null) a new build exception based in the build exception withlocation set to newLocation. | public static void | addText(Project project, Object target, char[] buf, int start, int count) Adds the content of #PCDATA sections to an element. | public static void | addText(Project project, Object target, String text) Adds the content of #PCDATA sections to an element. | public static void | configure(Object target, AttributeList attrs, Project project) Configures an object using an introspection handler. | public static void | configureProject(Project project, File buildFile) Configures the project with the contents of the specified XML file.
Parameters: project - The project to configure. | public static String | extractNameFromComponentName(String componentName) | public static String | extractUriFromComponentName(String componentName) | public static String | genComponentName(String uri, String name) Map a namespaced {uri,name} to an internal string format. | public static ClassLoader | getContextClassLoader() JDK1.1 compatible access to the context class loader. | public Vector | getImportStack() EXPERIMENTAL WILL_CHANGE
Import stack.
Used to keep track of imported files. | public static ProjectHelper | getProjectHelper() Discovers a project helper instance. | public void | parse(Project project, Object source) Parses the project file, configuring the project as it goes.
Parameters: project - The project for the resulting ProjectHelper to configure.Must not be null . Parameters: source - The source for XML configuration. | public static void | parsePropertyString(String value, Vector fragments, Vector propertyRefs) Parses a string containing ${xxx} style property
references into two lists. | public static String | replaceProperties(Project project, String value) Replaces ${xxx} style constructions in the given value with
the string value of the corresponding properties. | public 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.
Parameters: project - The container project. | public static void | storeChild(Project project, Object parent, Object child, String tag) Stores a configured child element within its parent object. |
ANTLIB_URI | final public static String ANTLIB_URI(Code) | | The URI for defined types/tasks - the format is antlib:
|
ANT_CORE_URI | final public static String ANT_CORE_URI(Code) | | The URI for ant name space
|
ANT_CURRENT_URI | final public static String ANT_CURRENT_URI(Code) | | The URI for antlib current definitions
|
ANT_TYPE | final public static String ANT_TYPE(Code) | | Polymorphic attribute
|
HELPER_PROPERTY | final public static String HELPER_PROPERTY(Code) | | Name of JVM system property which provides the name of the
ProjectHelper class to use.
|
PROJECTHELPER_REFERENCE | final public static String PROJECTHELPER_REFERENCE(Code) | | name of project helper reference that we add to a project
|
SERVICE_ID | final public static String SERVICE_ID(Code) | | The service identifier in jars which provide Project Helper
implementations.
|
ProjectHelper | public ProjectHelper()(Code) | | Default constructor
|
addLocationToBuildException | public static BuildException addLocationToBuildException(BuildException ex, Location newLocation)(Code) | | Add location to build exception.
Parameters: ex - the build exception, if the build exceptiondoes not include Parameters: newLocation - the location of the calling task (may be null) a new build exception based in the build exception withlocation set to newLocation. If the original exceptiondid not have a location, just return the build exception |
addText | public static void addText(Project project, Object target, char[] buf, int start, int count) throws BuildException(Code) | | Adds the content of #PCDATA sections to an element.
Parameters: project - The project containing the target.Must not be null . Parameters: target - The target object to be configured.Must not be null . Parameters: buf - A character array of the text within the element.Will not be null . Parameters: start - The start element in the array. Parameters: count - The number of characters to read from the array. exception: BuildException - if the target object doesn't accept text |
addText | public static void addText(Project project, Object target, String text) throws BuildException(Code) | | Adds the content of #PCDATA sections to an element.
Parameters: project - The project containing the target.Must not be null . Parameters: target - The target object to be configured.Must not be null . Parameters: text - Text to add to the target.May be null , in which case thismethod call is a no-op. exception: BuildException - if the target object doesn't accept text |
configure | public static void configure(Object target, AttributeList attrs, Project project) throws BuildException(Code) | | Configures an object using an introspection handler.
Parameters: target - The target object to be configured.Must not be null . Parameters: attrs - A list of attributes to configure within the target.Must not be null . Parameters: project - The project containing the target.Must not be null . exception: BuildException - if any of the attributes can't be handled bythe target |
configureProject | public static void configureProject(Project project, File buildFile) throws BuildException(Code) | | Configures the project with the contents of the specified XML file.
Parameters: project - The project to configure. Must not be null . Parameters: buildFile - An XML file giving the project's configuration.Must not be null . exception: BuildException - if the configuration is invalid or cannotbe read |
extractNameFromComponentName | public static String extractNameFromComponentName(String componentName)(Code) | | extract the element name from a component name
Parameters: componentName - The stringified form for {uri, name} The element name of the component |
extractUriFromComponentName | public static String extractUriFromComponentName(String componentName)(Code) | | extract a uri from a component name
Parameters: componentName - The stringified form for {uri, name} The uri or "" if not present |
genComponentName | public static String genComponentName(String uri, String name)(Code) | | Map a namespaced {uri,name} to an internal string format.
For BC purposes the names from the ant core uri will be
mapped to "name", other names will be mapped to
uri + ":" + name.
Parameters: uri - The namepace URI Parameters: name - The localname The stringified form of the ns name |
getContextClassLoader | public static ClassLoader getContextClassLoader()(Code) | | JDK1.1 compatible access to the context class loader.
Cut&paste from JAXP.
the current context class loader, or null if the context class loader is unavailable. |
getImportStack | public Vector getImportStack()(Code) | | EXPERIMENTAL WILL_CHANGE
Import stack.
Used to keep track of imported files. Error reporting should
display the import path.
the stack of import source objects. |
getProjectHelper | public static ProjectHelper getProjectHelper() throws BuildException(Code) | | Discovers a project helper instance. Uses the same patterns
as JAXP, commons-logging, etc: a system property, a JDK1.3
service discovery, default.
a ProjectHelper, either a custom implementationif one is available and configured, or the default implementationotherwise. exception: BuildException - if a specified helper class cannotbe loaded/instantiated. |
parse | public void parse(Project project, Object source) throws BuildException(Code) | | Parses the project file, configuring the project as it goes.
Parameters: project - The project for the resulting ProjectHelper to configure.Must not be null . Parameters: source - The source for XML configuration. A helper must supportat least File, for backward compatibility. Helpers maysupport URL, InputStream, etc or specialized types. since: Ant1.5 exception: BuildException - if the configuration is invalid or cannotbe read |
parsePropertyString | public static void parsePropertyString(String value, Vector fragments, Vector propertyRefs) throws BuildException(Code) | | 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 . Parameters: fragments - List to add text fragments to.Must not be null . Parameters: propertyRefs - List to add property names to.Must not be null . exception: BuildException - if the string contains an opening${ without a closing} |
replaceProperties | public static String replaceProperties(Project project, String value) throws BuildException(Code) | | 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 . Parameters: value - The string to be scanned for property references.May be null . exception: BuildException - if the string contains an opening${ without a closing} the original string with the properties replaced, ornull if the original string is null . since: 1.5 |
replaceProperties | public static String replaceProperties(Project project, String value, Hashtable keys) throws BuildException(Code) | | 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 forlogging purposes. Must not be null . Parameters: value - The string to be scanned for property references.May be null , in which case thismethod returns immediately with no effect. Parameters: keys - Mapping (String to String) of property names to theirvalues. Must not be null . exception: BuildException - if the string contains an opening${ without a closing} the original string with the properties replaced, ornull if the original string is null . |
storeChild | public static void storeChild(Project project, Object parent, Object child, String tag)(Code) | | Stores a configured child element within its parent object.
Parameters: project - Project containing the objects.May be null . Parameters: parent - Parent object to add child to.Must not be null . Parameters: child - Child object to store in parent.Should not be null . Parameters: tag - Name of element which generated the child.May be null , in which casethe child is not stored. |
|
|