ProjectHelper (Apache Ant API)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.ProjectHelper
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 compatiblity with the original ant patterns, unless a different behavior is explicitely 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.
Field Summary | |
static java.lang.String |
HELPER_PROPERTY
Name of JVM system property which provides the name of the ProjectHelper class to use. |
static java.lang.String |
SERVICE_ID
The service identifier in jars which provide Project Helper implementations. |
Constructor Summary | |
ProjectHelper()
Default constructor |
Method Summary | |
static void |
addText(Project project,
java.lang.Object target,
char[] buf,
int start,
int count)
Adds the content of #PCDATA sections to an element. |
static void |
addText(Project project,
java.lang.Object target,
java.lang.String text)
Adds the content of #PCDATA sections to an element. |
static void |
configure(java.lang.Object target,
org.xml.sax.AttributeList attrs,
Project project)
Configures an object using an introspection handler. |
static void |
configureProject(Project project,
java.io.File buildFile)
Configures the project with the contents of the specified XML file. |
static java.lang.ClassLoader |
getContextClassLoader()
JDK1.1 compatible access to the context class loader. |
static ProjectHelper |
getProjectHelper()
Discovers a project helper instance. |
void |
parse(Project project,
java.lang.Object source)
Parses the project file, configuring the project as it goes. |
static void |
parsePropertyString(java.lang.String value,
java.util.Vector fragments,
java.util.Vector propertyRefs)
Parses a string containing ${xxx} style property
references into two lists. |
static java.lang.String |
replaceProperties(Project project,
java.lang.String value)
Replaces ${xxx} style constructions in the given value with
the string value of the corresponding properties. |
static java.lang.String |
replaceProperties(Project project,
java.lang.String value,
java.util.Hashtable keys)
Replaces ${xxx} style constructions in the given value
with the string value of the corresponding data types. |
static void |
storeChild(Project project,
java.lang.Object parent,
java.lang.Object child,
java.lang.String tag)
Stores a configured child element within its parent object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String HELPER_PROPERTY
public static final java.lang.String SERVICE_ID
Constructor Detail |
public ProjectHelper()
Method Detail |
public static void configureProject(Project project, java.io.File buildFile) throws BuildException
project
- The project to configure. Must not be null
.buildFile
- An XML file giving the project's configuration.
Must not be null
.
BuildException
- if the configuration is invalid or cannot
be readpublic void parse(Project project, java.lang.Object source) throws BuildException
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.
BuildException
- if the configuration is invalid or cannot
be readpublic static ProjectHelper getProjectHelper() throws BuildException
BuildException
- if a specified helper class cannot
be loaded/instantiated.public static java.lang.ClassLoader getContextClassLoader()
null
if the context class loader is unavailable.public static void configure(java.lang.Object target, org.xml.sax.AttributeList attrs, Project project) throws BuildException
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
.
BuildException
- if any of the attributes can't be handled by
the targetpublic static void addText(Project project, java.lang.Object target, char[] buf, int start, int count) throws BuildException
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.
BuildException
- if the target object doesn't accept textpublic static void addText(Project project, java.lang.Object target, java.lang.String text) throws BuildException
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.
BuildException
- if the target object doesn't accept textpublic static void storeChild(Project project, java.lang.Object parent, java.lang.Object child, java.lang.String tag)
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.public static java.lang.String replaceProperties(Project project, java.lang.String value) throws BuildException
${xxx}
style constructions in the given value with
the string value of the corresponding properties.
project
- The project containing the properties to replace.
Must not be null
.value
- The string to be scanned for property references.
May be null
.
null
if the original string is null
.
BuildException
- if the string contains an opening
${
without a closing
}
public static java.lang.String replaceProperties(Project project, java.lang.String value, java.util.Hashtable keys) throws BuildException
${xxx}
style constructions in the given value
with the string value of the corresponding data types.
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
.
null
if the original string is null
.
BuildException
- if the string contains an opening
${
without a closing
}
public static void parsePropertyString(java.lang.String value, java.util.Vector fragments, java.util.Vector propertyRefs) throws BuildException
${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.
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
.
BuildException
- if the string contains an opening
${
without a closing
}
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |