|
@@ -91,39 +91,39 @@ import org.apache.tools.ant.TaskAdapter; |
|
|
*/ |
|
|
*/ |
|
|
public class ProjectHelperImpl extends ProjectHelper { |
|
|
public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
/** |
|
|
* Parser factory to use to create parsers. |
|
|
* Parser factory to use to create parsers. |
|
|
* @see #getParserFactory |
|
|
* @see #getParserFactory |
|
|
*/ |
|
|
*/ |
|
|
private static SAXParserFactory parserFactory = null; |
|
|
private static SAXParserFactory parserFactory = null; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* SAX 1 style parser used to parse the given file. This may |
|
|
|
|
|
|
|
|
* SAX 1 style parser used to parse the given file. This may |
|
|
* in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter. |
|
|
* in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter. |
|
|
*/ |
|
|
*/ |
|
|
private org.xml.sax.Parser parser; |
|
|
private org.xml.sax.Parser parser; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The project to configure. */ |
|
|
/** The project to configure. */ |
|
|
private Project project; |
|
|
private Project project; |
|
|
/** The configuration file to parse. */ |
|
|
/** The configuration file to parse. */ |
|
|
private File buildFile; |
|
|
private File buildFile; |
|
|
/** |
|
|
|
|
|
|
|
|
/** |
|
|
* Parent directory of the build file. Used for resolving entities |
|
|
* Parent directory of the build file. Used for resolving entities |
|
|
* and setting the project's base directory. |
|
|
* and setting the project's base directory. |
|
|
*/ |
|
|
*/ |
|
|
private File buildFileParent; |
|
|
private File buildFileParent; |
|
|
/** |
|
|
|
|
|
* Locator for the configuration file parser. |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Locator for the configuration file parser. |
|
|
* Used for giving locations of errors etc. |
|
|
* Used for giving locations of errors etc. |
|
|
*/ |
|
|
*/ |
|
|
private Locator locator; |
|
|
private Locator locator; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Parses the project file, configuring the project as it goes. |
|
|
* Parses the project file, configuring the project as it goes. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param project project instance to be configured. |
|
|
* @param project project instance to be configured. |
|
|
* @param source the source from which the project is read. |
|
|
|
|
|
* @exception BuildException if the configuration is invalid or cannot |
|
|
|
|
|
|
|
|
* @param source the source from which the project is read. |
|
|
|
|
|
* @exception BuildException if the configuration is invalid or cannot |
|
|
* be read. |
|
|
* be read. |
|
|
*/ |
|
|
*/ |
|
|
public void parse(Project project, Object source) throws BuildException { |
|
|
public void parse(Project project, Object source) throws BuildException { |
|
@@ -137,7 +137,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
this.project = project; |
|
|
this.project = project; |
|
|
this.buildFile = new File(buildFile.getAbsolutePath()); |
|
|
this.buildFile = new File(buildFile.getAbsolutePath()); |
|
|
buildFileParent = new File(this.buildFile.getParent()); |
|
|
buildFileParent = new File(this.buildFile.getParent()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
SAXParser saxParser = getParserFactory().newSAXParser(); |
|
|
SAXParser saxParser = getParserFactory().newSAXParser(); |
|
|
try { |
|
|
try { |
|
@@ -146,16 +146,16 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
parser = new XMLReaderAdapter(saxParser.getXMLReader()); |
|
|
parser = new XMLReaderAdapter(saxParser.getXMLReader()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String uri = "file:" + buildFile.getAbsolutePath().replace('\\', '/'); |
|
|
String uri = "file:" + buildFile.getAbsolutePath().replace('\\', '/'); |
|
|
for (int index = uri.indexOf('#'); index != -1; index = uri.indexOf('#')) { |
|
|
for (int index = uri.indexOf('#'); index != -1; index = uri.indexOf('#')) { |
|
|
uri = uri.substring(0, index) + "%23" + uri.substring(index + 1); |
|
|
uri = uri.substring(0, index) + "%23" + uri.substring(index + 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputStream = new FileInputStream(buildFile); |
|
|
inputStream = new FileInputStream(buildFile); |
|
|
inputSource = new InputSource(inputStream); |
|
|
inputSource = new InputSource(inputStream); |
|
|
inputSource.setSystemId(uri); |
|
|
inputSource.setSystemId(uri); |
|
|
project.log("parsing buildfile " + buildFile + " with URI = " |
|
|
|
|
|
|
|
|
project.log("parsing buildfile " + buildFile + " with URI = " |
|
|
+ uri, Project.MSG_VERBOSE); |
|
|
+ uri, Project.MSG_VERBOSE); |
|
|
HandlerBase hb = new RootHandler(this); |
|
|
HandlerBase hb = new RootHandler(this); |
|
|
parser.setDocumentHandler(hb); |
|
|
parser.setDocumentHandler(hb); |
|
@@ -167,7 +167,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
throw new BuildException("Parser has not been configured correctly", exc); |
|
|
throw new BuildException("Parser has not been configured correctly", exc); |
|
|
} catch (SAXParseException exc) { |
|
|
} catch (SAXParseException exc) { |
|
|
Location location = |
|
|
Location location = |
|
|
new Location(buildFile.toString(), exc.getLineNumber(), |
|
|
|
|
|
|
|
|
new Location(buildFile.toString(), exc.getLineNumber(), |
|
|
exc.getColumnNumber()); |
|
|
exc.getColumnNumber()); |
|
|
|
|
|
|
|
|
Throwable t = exc.getException(); |
|
|
Throwable t = exc.getException(); |
|
@@ -178,7 +178,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
} |
|
|
} |
|
|
throw be; |
|
|
throw be; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new BuildException(exc.getMessage(), t, location); |
|
|
throw new BuildException(exc.getMessage(), t, location); |
|
|
} catch (SAXException exc) { |
|
|
} catch (SAXException exc) { |
|
|
Throwable t = exc.getException(); |
|
|
Throwable t = exc.getException(); |
|
@@ -189,7 +189,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
} catch (FileNotFoundException exc) { |
|
|
} catch (FileNotFoundException exc) { |
|
|
throw new BuildException(exc); |
|
|
throw new BuildException(exc); |
|
|
} catch (UnsupportedEncodingException exc) { |
|
|
} catch (UnsupportedEncodingException exc) { |
|
|
throw new BuildException("Encoding of project file is invalid.", |
|
|
|
|
|
|
|
|
throw new BuildException("Encoding of project file is invalid.", |
|
|
exc); |
|
|
exc); |
|
|
} catch (IOException exc) { |
|
|
} catch (IOException exc) { |
|
|
throw new BuildException("Error reading project file: " |
|
|
throw new BuildException("Error reading project file: " |
|
@@ -207,7 +207,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The common superclass for all SAX event handlers used to parse |
|
|
* The common superclass for all SAX event handlers used to parse |
|
|
* the configuration file. Each method just throws an exception, |
|
|
|
|
|
|
|
|
* the configuration file. Each method just throws an exception, |
|
|
* so subclasses should override what they can handle. |
|
|
* so subclasses should override what they can handle. |
|
|
* |
|
|
* |
|
|
* Each type of XML element (task, target, etc.) in Ant has |
|
|
* Each type of XML element (task, target, etc.) in Ant has |
|
@@ -218,9 +218,9 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* control back to the parent in the endElement method. |
|
|
* control back to the parent in the endElement method. |
|
|
*/ |
|
|
*/ |
|
|
static class AbstractHandler extends HandlerBase { |
|
|
static class AbstractHandler extends HandlerBase { |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Previous handler for the document. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Previous handler for the document. |
|
|
* When the next element is finished, control returns |
|
|
* When the next element is finished, control returns |
|
|
* to this handler. |
|
|
* to this handler. |
|
|
*/ |
|
|
*/ |
|
@@ -232,16 +232,16 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
explicitely it'll work with more compilers. |
|
|
explicitely it'll work with more compilers. |
|
|
*/ |
|
|
*/ |
|
|
ProjectHelperImpl helperImpl; |
|
|
ProjectHelperImpl helperImpl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Creates a handler and sets the parser to use it |
|
|
* Creates a handler and sets the parser to use it |
|
|
* for the current element. |
|
|
* for the current element. |
|
|
* |
|
|
|
|
|
* @param helperImpl the ProjectHelperImpl instance associated |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param helperImpl the ProjectHelperImpl instance associated |
|
|
* with this handler. |
|
|
* with this handler. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public AbstractHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
|
public AbstractHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
@@ -251,16 +251,16 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
// Start handling SAX events |
|
|
// Start handling SAX events |
|
|
helperImpl.parser.setDocumentHandler(this); |
|
|
helperImpl.parser.setDocumentHandler(this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Handles the start of an element. This base implementation just |
|
|
* Handles the start of an element. This base implementation just |
|
|
* throws an exception. |
|
|
* throws an exception. |
|
|
* |
|
|
|
|
|
* @param tag The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param tag The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if this method is not overridden, or in |
|
|
* @exception SAXParseException if this method is not overridden, or in |
|
|
* case of error in an overridden version |
|
|
* case of error in an overridden version |
|
|
*/ |
|
|
*/ |
|
@@ -271,12 +271,12 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles text within an element. This base implementation just |
|
|
* Handles text within an element. This base implementation just |
|
|
* throws an exception. |
|
|
* throws an exception. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param buf A character array of the text within the element. |
|
|
* @param buf A character array of the text within the element. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param start The start element in the array. |
|
|
* @param start The start element in the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if this method is not overridden, or in |
|
|
* @exception SAXParseException if this method is not overridden, or in |
|
|
* case of error in an overridden version |
|
|
* case of error in an overridden version |
|
|
*/ |
|
|
*/ |
|
@@ -298,13 +298,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* Handles the end of an element. Any required clean-up is performed |
|
|
* Handles the end of an element. Any required clean-up is performed |
|
|
* by the finished() method and then the original handler is restored to |
|
|
* by the finished() method and then the original handler is restored to |
|
|
* the parser. |
|
|
* the parser. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param name The name of the element which is ending. |
|
|
* @param name The name of the element which is ending. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXException in case of error (not thrown in |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXException in case of error (not thrown in |
|
|
* this implementation) |
|
|
* this implementation) |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @see #finished() |
|
|
* @see #finished() |
|
|
*/ |
|
|
*/ |
|
|
public void endElement(String name) throws SAXException { |
|
|
public void endElement(String name) throws SAXException { |
|
@@ -320,36 +320,36 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
*/ |
|
|
*/ |
|
|
static class RootHandler extends HandlerBase { |
|
|
static class RootHandler extends HandlerBase { |
|
|
ProjectHelperImpl helperImpl; |
|
|
ProjectHelperImpl helperImpl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public RootHandler(ProjectHelperImpl helperImpl) { |
|
|
public RootHandler(ProjectHelperImpl helperImpl) { |
|
|
this.helperImpl = helperImpl; |
|
|
this.helperImpl = helperImpl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Resolves file: URIs relative to the build file. |
|
|
* Resolves file: URIs relative to the build file. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param publicId The public identifer, or <code>null</code> |
|
|
* @param publicId The public identifer, or <code>null</code> |
|
|
* if none is available. Ignored in this |
|
|
|
|
|
|
|
|
* if none is available. Ignored in this |
|
|
* implementation. |
|
|
* implementation. |
|
|
* @param systemId The system identifier provided in the XML |
|
|
|
|
|
|
|
|
* @param systemId The system identifier provided in the XML |
|
|
* document. Will not be <code>null</code>. |
|
|
* document. Will not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public InputSource resolveEntity(String publicId, |
|
|
public InputSource resolveEntity(String publicId, |
|
|
String systemId) { |
|
|
String systemId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE); |
|
|
helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (systemId.startsWith("file:")) { |
|
|
if (systemId.startsWith("file:")) { |
|
|
String path = systemId.substring(5); |
|
|
String path = systemId.substring(5); |
|
|
int index = path.indexOf("file:"); |
|
|
int index = path.indexOf("file:"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we only have to handle these for backward compatibility |
|
|
// we only have to handle these for backward compatibility |
|
|
// since they are in the FAQ. |
|
|
// since they are in the FAQ. |
|
|
while (index != -1) { |
|
|
while (index != -1) { |
|
|
path = path.substring(0, index) + path.substring(index + 5); |
|
|
path = path.substring(0, index) + path.substring(index + 5); |
|
|
index = path.indexOf("file:"); |
|
|
index = path.indexOf("file:"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String entitySystemId = path; |
|
|
String entitySystemId = path; |
|
|
index = path.indexOf("%23"); |
|
|
index = path.indexOf("%23"); |
|
|
// convert these to # |
|
|
// convert these to # |
|
@@ -362,13 +362,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
if (!file.isAbsolute()) { |
|
|
if (!file.isAbsolute()) { |
|
|
file = new File(helperImpl.buildFileParent, path); |
|
|
file = new File(helperImpl.buildFileParent, path); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
InputSource inputSource = new InputSource(new FileInputStream(file)); |
|
|
InputSource inputSource = new InputSource(new FileInputStream(file)); |
|
|
inputSource.setSystemId("file:" + entitySystemId); |
|
|
inputSource.setSystemId("file:" + entitySystemId); |
|
|
return inputSource; |
|
|
return inputSource; |
|
|
} catch (FileNotFoundException fne) { |
|
|
} catch (FileNotFoundException fne) { |
|
|
helperImpl.project.log(file.getAbsolutePath() + " could not be found", |
|
|
|
|
|
|
|
|
helperImpl.project.log(file.getAbsolutePath() + " could not be found", |
|
|
Project.MSG_WARN); |
|
|
Project.MSG_WARN); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -379,13 +379,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles the start of a project element. A project handler is created |
|
|
* Handles the start of a project element. A project handler is created |
|
|
* and initialised with the element name and attributes. |
|
|
* and initialised with the element name and attributes. |
|
|
* |
|
|
|
|
|
* @param tag The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param tag The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if the tag given is not |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if the tag given is not |
|
|
* <code>"project"</code> |
|
|
* <code>"project"</code> |
|
|
*/ |
|
|
*/ |
|
|
public void startElement(String tag, AttributeList attrs) throws SAXParseException { |
|
|
public void startElement(String tag, AttributeList attrs) throws SAXParseException { |
|
@@ -398,7 +398,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Sets the locator in the project helper for future reference. |
|
|
* Sets the locator in the project helper for future reference. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param locator The locator used by the parser. |
|
|
* @param locator The locator used by the parser. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
@@ -411,31 +411,31 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* Handler for the top level "project" element. |
|
|
* Handler for the top level "project" element. |
|
|
*/ |
|
|
*/ |
|
|
static class ProjectHandler extends AbstractHandler { |
|
|
static class ProjectHandler extends AbstractHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor which just delegates to the superconstructor. |
|
|
* Constructor which just delegates to the superconstructor. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public ProjectHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
|
public ProjectHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
|
super(helperImpl, parentHandler); |
|
|
super(helperImpl, parentHandler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Initialisation routine called after handler creation |
|
|
* Initialisation routine called after handler creation |
|
|
* with the element name and attributes. The attributes which |
|
|
* with the element name and attributes. The attributes which |
|
|
* this handler can deal with are: <code>"default"</code>, |
|
|
* this handler can deal with are: <code>"default"</code>, |
|
|
* <code>"name"</code>, <code>"id"</code> and <code>"basedir"</code>. |
|
|
* <code>"name"</code>, <code>"id"</code> and <code>"basedir"</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param tag Name of the element which caused this handler |
|
|
* @param tag Name of the element which caused this handler |
|
|
* to be created. Should not be <code>null</code>. |
|
|
* to be created. Should not be <code>null</code>. |
|
|
* Ignored in this implementation. |
|
|
* Ignored in this implementation. |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an unexpected attribute is |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an unexpected attribute is |
|
|
* encountered or if the <code>"default"</code> attribute |
|
|
* encountered or if the <code>"default"</code> attribute |
|
|
* is missing. |
|
|
* is missing. |
|
|
*/ |
|
|
*/ |
|
@@ -464,12 +464,10 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (def == null) { |
|
|
if (def == null) { |
|
|
throw new SAXParseException("The default attribute of project is required", |
|
|
|
|
|
helperImpl.locator); |
|
|
|
|
|
|
|
|
helperImpl.project.setDefaultTarget("main"); |
|
|
|
|
|
} else { |
|
|
|
|
|
helperImpl.project.setDefaultTarget(def); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
helperImpl.project.setDefaultTarget(def); |
|
|
|
|
|
|
|
|
|
|
|
if (name != null) { |
|
|
if (name != null) { |
|
|
helperImpl.project.setName(name); |
|
|
helperImpl.project.setName(name); |
|
@@ -502,13 +500,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* Handles the start of a top-level element within the project. An |
|
|
* Handles the start of a top-level element within the project. An |
|
|
* appropriate handler is created and initialised with the details |
|
|
* appropriate handler is created and initialised with the details |
|
|
* of the element. |
|
|
* of the element. |
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if the tag given is not |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if the tag given is not |
|
|
* <code>"taskdef"</code>, <code>"typedef"</code>, |
|
|
* <code>"taskdef"</code>, <code>"typedef"</code>, |
|
|
* <code>"property"</code>, <code>"target"</code> |
|
|
* <code>"property"</code>, <code>"target"</code> |
|
|
* or a data type definition |
|
|
* or a data type definition |
|
@@ -528,19 +526,19 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
throw new SAXParseException("Unexpected element \"" + name + "\"", helperImpl.locator); |
|
|
throw new SAXParseException("Unexpected element \"" + name + "\"", helperImpl.locator); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Handles a task defintion element by creating a task handler |
|
|
* Handles a task defintion element by creating a task handler |
|
|
* and initialising is with the details of the element. |
|
|
* and initialising is with the details of the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param name The name of the element to be handled. |
|
|
* @param name The name of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* the task handler |
|
|
* the task handler |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
private void handleTaskdef(String name, AttributeList attrs) throws SAXParseException { |
|
|
private void handleTaskdef(String name, AttributeList attrs) throws SAXParseException { |
|
|
(new TaskHandler(helperImpl, this, null, null, null)).init(name, attrs); |
|
|
(new TaskHandler(helperImpl, this, null, null, null)).init(name, attrs); |
|
@@ -549,13 +547,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles a type defintion element by creating a task handler |
|
|
* Handles a type defintion element by creating a task handler |
|
|
* and initialising is with the details of the element. |
|
|
* and initialising is with the details of the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param name The name of the element to be handled. |
|
|
* @param name The name of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising the |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising the |
|
|
* handler |
|
|
* handler |
|
|
*/ |
|
|
*/ |
|
|
private void handleTypedef(String name, AttributeList attrs) throws SAXParseException { |
|
|
private void handleTypedef(String name, AttributeList attrs) throws SAXParseException { |
|
@@ -565,13 +563,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles a property defintion element by creating a task handler |
|
|
* Handles a property defintion element by creating a task handler |
|
|
* and initialising is with the details of the element. |
|
|
* and initialising is with the details of the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param name The name of the element to be handled. |
|
|
* @param name The name of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
* the handler |
|
|
* the handler |
|
|
*/ |
|
|
*/ |
|
|
private void handleProperty(String name, AttributeList attrs) throws SAXParseException { |
|
|
private void handleProperty(String name, AttributeList attrs) throws SAXParseException { |
|
@@ -581,28 +579,28 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles a target defintion element by creating a target handler |
|
|
* Handles a target defintion element by creating a target handler |
|
|
* and initialising is with the details of the element. |
|
|
* and initialising is with the details of the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param tag The name of the element to be handled. |
|
|
* @param tag The name of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
* the handler |
|
|
* the handler |
|
|
*/ |
|
|
*/ |
|
|
private void handleTarget(String tag, AttributeList attrs) throws SAXParseException { |
|
|
private void handleTarget(String tag, AttributeList attrs) throws SAXParseException { |
|
|
new TargetHandler(helperImpl, this).init(tag, attrs); |
|
|
new TargetHandler(helperImpl, this).init(tag, attrs); |
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* Handles a data type defintion element by creating a data type |
|
|
|
|
|
|
|
|
* Handles a data type defintion element by creating a data type |
|
|
* handler and initialising is with the details of the element. |
|
|
* handler and initialising is with the details of the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param name The name of the element to be handled. |
|
|
* @param name The name of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* @param attrs Attributes of the element to be handled. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException if an error occurs initialising |
|
|
* the handler |
|
|
* the handler |
|
|
*/ |
|
|
*/ |
|
|
private void handleDataType(String name, AttributeList attrs) throws SAXParseException { |
|
|
private void handleDataType(String name, AttributeList attrs) throws SAXParseException { |
|
@@ -619,9 +617,9 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor which just delegates to the superconstructor. |
|
|
* Constructor which just delegates to the superconstructor. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public TargetHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
|
public TargetHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
@@ -633,15 +631,15 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* with the element name and attributes. The attributes which |
|
|
* with the element name and attributes. The attributes which |
|
|
* this handler can deal with are: <code>"name"</code>, |
|
|
* this handler can deal with are: <code>"name"</code>, |
|
|
* <code>"depends"</code>, <code>"if"</code>, |
|
|
* <code>"depends"</code>, <code>"if"</code>, |
|
|
* <code>"unless"</code>, <code>"id"</code> and |
|
|
|
|
|
|
|
|
* <code>"unless"</code>, <code>"id"</code> and |
|
|
* <code>"description"</code>. |
|
|
* <code>"description"</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param tag Name of the element which caused this handler |
|
|
* @param tag Name of the element which caused this handler |
|
|
* to be created. Should not be <code>null</code>. |
|
|
* to be created. Should not be <code>null</code>. |
|
|
* Ignored in this implementation. |
|
|
* Ignored in this implementation. |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if an unexpected attribute is encountered |
|
|
* @exception SAXParseException if an unexpected attribute is encountered |
|
|
* or if the <code>"name"</code> attribute is missing. |
|
|
* or if the <code>"name"</code> attribute is missing. |
|
|
*/ |
|
|
*/ |
|
@@ -699,12 +697,12 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Handles the start of an element within a target. |
|
|
* Handles the start of an element within a target. |
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* the appropriate child handler |
|
|
* the appropriate child handler |
|
|
*/ |
|
|
*/ |
|
@@ -723,8 +721,8 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
static class TaskHandler extends AbstractHandler { |
|
|
static class TaskHandler extends AbstractHandler { |
|
|
/** Containing target, if any. */ |
|
|
/** Containing target, if any. */ |
|
|
private Target target; |
|
|
private Target target; |
|
|
/** |
|
|
|
|
|
* Container for the task, if any. If target is |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Container for the task, if any. If target is |
|
|
* non-<code>null</code>, this must be too. |
|
|
* non-<code>null</code>, this must be too. |
|
|
*/ |
|
|
*/ |
|
|
private TaskContainer container; |
|
|
private TaskContainer container; |
|
@@ -733,36 +731,36 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
*/ |
|
|
*/ |
|
|
private Task task; |
|
|
private Task task; |
|
|
/** |
|
|
/** |
|
|
* Wrapper for the parent element, if any. The wrapper for this |
|
|
|
|
|
|
|
|
* Wrapper for the parent element, if any. The wrapper for this |
|
|
* element will be added to this wrapper as a child. |
|
|
* element will be added to this wrapper as a child. |
|
|
*/ |
|
|
*/ |
|
|
private RuntimeConfigurable parentWrapper; |
|
|
private RuntimeConfigurable parentWrapper; |
|
|
/** |
|
|
/** |
|
|
* Wrapper for this element which takes care of actually configuring |
|
|
* Wrapper for this element which takes care of actually configuring |
|
|
* the element, if this element is contained within a target. |
|
|
|
|
|
|
|
|
* the element, if this element is contained within a target. |
|
|
* Otherwise the configuration is performed with the configure method. |
|
|
* Otherwise the configuration is performed with the configure method. |
|
|
* @see ProjectHelper#configure(Object,AttributeList,Project) |
|
|
* @see ProjectHelper#configure(Object,AttributeList,Project) |
|
|
*/ |
|
|
*/ |
|
|
private RuntimeConfigurable wrapper = null; |
|
|
private RuntimeConfigurable wrapper = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor. |
|
|
* Constructor. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @param container Container for the element. |
|
|
|
|
|
* May be <code>null</code> if the target is |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param container Container for the element. |
|
|
|
|
|
* May be <code>null</code> if the target is |
|
|
* <code>null</code> as well. If the |
|
|
* <code>null</code> as well. If the |
|
|
* target is <code>null</code>, this parameter |
|
|
* target is <code>null</code>, this parameter |
|
|
* is effectively ignored. |
|
|
* is effectively ignored. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param parentWrapper Wrapper for the parent element, if any. |
|
|
* @param parentWrapper Wrapper for the parent element, if any. |
|
|
* May be <code>null</code>. If the |
|
|
* May be <code>null</code>. If the |
|
|
* target is <code>null</code>, this parameter |
|
|
* target is <code>null</code>, this parameter |
|
|
* is effectively ignored. |
|
|
* is effectively ignored. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param target Target this element is part of. |
|
|
* @param target Target this element is part of. |
|
|
* May be <code>null</code>. |
|
|
* May be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
@@ -780,13 +778,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* the element with its attributes and sets it up with |
|
|
* the element with its attributes and sets it up with |
|
|
* its parent container (if any). Nested elements are then |
|
|
* its parent container (if any). Nested elements are then |
|
|
* added later as the parser encounters them. |
|
|
* added later as the parser encounters them. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param tag Name of the element which caused this handler |
|
|
* @param tag Name of the element which caused this handler |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException in case of error (not thrown in |
|
|
* @exception SAXParseException in case of error (not thrown in |
|
|
* this implementation) |
|
|
* this implementation) |
|
|
*/ |
|
|
*/ |
|
@@ -794,7 +792,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
try { |
|
|
try { |
|
|
task = helperImpl.project.createTask(tag); |
|
|
task = helperImpl.project.createTask(tag); |
|
|
} catch (BuildException e) { |
|
|
} catch (BuildException e) { |
|
|
// swallow here, will be thrown again in |
|
|
|
|
|
|
|
|
// swallow here, will be thrown again in |
|
|
// UnknownElement.maybeConfigure if the problem persists. |
|
|
// UnknownElement.maybeConfigure if the problem persists. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -836,16 +834,16 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds text to the task, using the wrapper if one is |
|
|
* Adds text to the task, using the wrapper if one is |
|
|
* available (in other words if the task is within a target) |
|
|
|
|
|
|
|
|
* available (in other words if the task is within a target) |
|
|
* or using addText otherwise. |
|
|
* or using addText otherwise. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param buf A character array of the text within the element. |
|
|
* @param buf A character array of the text within the element. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param start The start element in the array. |
|
|
* @param start The start element in the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
*/ |
|
|
*/ |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
@@ -859,27 +857,27 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
wrapper.addText(buf, start, count); |
|
|
wrapper.addText(buf, start, count); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Handles the start of an element within a target. Task containers |
|
|
* Handles the start of an element within a target. Task containers |
|
|
* will always use another task handler, and all other tasks |
|
|
* will always use another task handler, and all other tasks |
|
|
* will always use a nested element handler. |
|
|
* will always use a nested element handler. |
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* the appropriate child handler |
|
|
* the appropriate child handler |
|
|
*/ |
|
|
*/ |
|
|
public void startElement(String name, AttributeList attrs) throws SAXParseException { |
|
|
public void startElement(String name, AttributeList attrs) throws SAXParseException { |
|
|
if (task instanceof TaskContainer) { |
|
|
if (task instanceof TaskContainer) { |
|
|
// task can contain other tasks - no other nested elements possible |
|
|
// task can contain other tasks - no other nested elements possible |
|
|
new TaskHandler(helperImpl, this, (TaskContainer) task, |
|
|
|
|
|
|
|
|
new TaskHandler(helperImpl, this, (TaskContainer) task, |
|
|
wrapper, target).init(name, attrs); |
|
|
wrapper, target).init(name, attrs); |
|
|
} else { |
|
|
} else { |
|
|
new NestedElementHandler(helperImpl, this, task, |
|
|
|
|
|
|
|
|
new NestedElementHandler(helperImpl, this, task, |
|
|
wrapper, target).init(name, attrs); |
|
|
wrapper, target).init(name, attrs); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -894,7 +892,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** The nested element itself. */ |
|
|
/** The nested element itself. */ |
|
|
private Object child; |
|
|
private Object child; |
|
|
/** |
|
|
/** |
|
|
* Wrapper for the parent element, if any. The wrapper for this |
|
|
|
|
|
|
|
|
* Wrapper for the parent element, if any. The wrapper for this |
|
|
* element will be added to this wrapper as a child. |
|
|
* element will be added to this wrapper as a child. |
|
|
*/ |
|
|
*/ |
|
|
private RuntimeConfigurable parentWrapper; |
|
|
private RuntimeConfigurable parentWrapper; |
|
@@ -910,22 +908,22 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor. |
|
|
* Constructor. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param parent Parent of this element (task/data type/etc). |
|
|
* @param parent Parent of this element (task/data type/etc). |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param parentWrapper Wrapper for the parent element, if any. |
|
|
* @param parentWrapper Wrapper for the parent element, if any. |
|
|
* May be <code>null</code>. |
|
|
* May be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param target Target this element is part of. |
|
|
* @param target Target this element is part of. |
|
|
* May be <code>null</code>. |
|
|
* May be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public NestedElementHandler(ProjectHelperImpl helperImpl, |
|
|
public NestedElementHandler(ProjectHelperImpl helperImpl, |
|
|
DocumentHandler parentHandler, |
|
|
|
|
|
|
|
|
DocumentHandler parentHandler, |
|
|
Object parent, |
|
|
Object parent, |
|
|
RuntimeConfigurable parentWrapper, |
|
|
RuntimeConfigurable parentWrapper, |
|
|
Target target) { |
|
|
Target target) { |
|
@@ -946,19 +944,19 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* the element with its attributes and sets it up with |
|
|
* the element with its attributes and sets it up with |
|
|
* its parent container (if any). Nested elements are then |
|
|
* its parent container (if any). Nested elements are then |
|
|
* added later as the parser encounters them. |
|
|
* added later as the parser encounters them. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param propType Name of the element which caused this handler |
|
|
* @param propType Name of the element which caused this handler |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException in case of error, such as a |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException in case of error, such as a |
|
|
* BuildException being thrown during configuration. |
|
|
* BuildException being thrown during configuration. |
|
|
*/ |
|
|
*/ |
|
|
public void init(String propType, AttributeList attrs) throws SAXParseException { |
|
|
public void init(String propType, AttributeList attrs) throws SAXParseException { |
|
|
Class parentClass = parent.getClass(); |
|
|
Class parentClass = parent.getClass(); |
|
|
IntrospectionHelper ih = |
|
|
|
|
|
|
|
|
IntrospectionHelper ih = |
|
|
IntrospectionHelper.getHelper(parentClass); |
|
|
IntrospectionHelper.getHelper(parentClass); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
@@ -990,14 +988,14 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Adds text to the element, using the wrapper if one is |
|
|
* Adds text to the element, using the wrapper if one is |
|
|
* available or using addText otherwise. |
|
|
* available or using addText otherwise. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param buf A character array of the text within the element. |
|
|
* @param buf A character array of the text within the element. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param start The start element in the array. |
|
|
* @param start The start element in the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
*/ |
|
|
*/ |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
@@ -1016,23 +1014,23 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* Handles the start of an element within this one. Task containers |
|
|
* Handles the start of an element within this one. Task containers |
|
|
* will always use a task handler, and all other elements |
|
|
* will always use a task handler, and all other elements |
|
|
* will always use another nested element handler. |
|
|
* will always use another nested element handler. |
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* the appropriate child handler |
|
|
* the appropriate child handler |
|
|
*/ |
|
|
*/ |
|
|
public void startElement(String name, AttributeList attrs) throws SAXParseException { |
|
|
public void startElement(String name, AttributeList attrs) throws SAXParseException { |
|
|
if (child instanceof TaskContainer) { |
|
|
if (child instanceof TaskContainer) { |
|
|
// taskcontainer nested element can contain other tasks - no other |
|
|
|
|
|
|
|
|
// taskcontainer nested element can contain other tasks - no other |
|
|
// nested elements possible |
|
|
// nested elements possible |
|
|
new TaskHandler(helperImpl, this, (TaskContainer) child, |
|
|
|
|
|
|
|
|
new TaskHandler(helperImpl, this, (TaskContainer) child, |
|
|
childWrapper, target).init(name, attrs); |
|
|
childWrapper, target).init(name, attrs); |
|
|
} else { |
|
|
} else { |
|
|
new NestedElementHandler(helperImpl, this, child, |
|
|
|
|
|
|
|
|
new NestedElementHandler(helperImpl, this, child, |
|
|
childWrapper, target).init(name, attrs); |
|
|
childWrapper, target).init(name, attrs); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -1048,12 +1046,12 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
private Object element; |
|
|
private Object element; |
|
|
/** Wrapper for this element, if it's part of a target. */ |
|
|
/** Wrapper for this element, if it's part of a target. */ |
|
|
private RuntimeConfigurable wrapper = null; |
|
|
private RuntimeConfigurable wrapper = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor with no target specified. |
|
|
* Constructor with no target specified. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
|
public DataTypeHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
|
public DataTypeHandler(ProjectHelperImpl helperImpl, DocumentHandler parentHandler) { |
|
@@ -1062,11 +1060,11 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Constructor with a target specified. |
|
|
* Constructor with a target specified. |
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param parentHandler The handler which should be restored to the |
|
|
|
|
|
* parser at the end of the element. |
|
|
* Must not be <code>null</code>. |
|
|
* Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param target The parent target of this element. |
|
|
* @param target The parent target of this element. |
|
|
* May be <code>null</code>. |
|
|
* May be <code>null</code>. |
|
|
*/ |
|
|
*/ |
|
@@ -1081,14 +1079,14 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
* the element with its attributes and sets it up with |
|
|
* the element with its attributes and sets it up with |
|
|
* its parent container (if any). Nested elements are then |
|
|
* its parent container (if any). Nested elements are then |
|
|
* added later as the parser encounters them. |
|
|
* added later as the parser encounters them. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param propType Name of the element which caused this handler |
|
|
* @param propType Name of the element which caused this handler |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* @param attrs Attributes of the element which caused this |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* handler to be created. Must not be <code>null</code>. |
|
|
* |
|
|
|
|
|
* @exception SAXParseException in case of error, such as a |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @exception SAXParseException in case of error, such as a |
|
|
* BuildException being thrown during configuration. |
|
|
* BuildException being thrown during configuration. |
|
|
*/ |
|
|
*/ |
|
|
public void init(String propType, AttributeList attrs) throws SAXParseException { |
|
|
public void init(String propType, AttributeList attrs) throws SAXParseException { |
|
@@ -1097,7 +1095,7 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
if (element == null) { |
|
|
if (element == null) { |
|
|
throw new BuildException("Unknown data type " + propType); |
|
|
throw new BuildException("Unknown data type " + propType); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (target != null) { |
|
|
if (target != null) { |
|
|
wrapper = new RuntimeConfigurable(element, propType); |
|
|
wrapper = new RuntimeConfigurable(element, propType); |
|
|
wrapper.setAttributes(attrs); |
|
|
wrapper.setAttributes(attrs); |
|
@@ -1115,14 +1113,14 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
// if one is available, whereas NestedElementHandler.characters does? |
|
|
// if one is available, whereas NestedElementHandler.characters does? |
|
|
/** |
|
|
/** |
|
|
* Adds text to the element. |
|
|
* Adds text to the element. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @param buf A character array of the text within the element. |
|
|
* @param buf A character array of the text within the element. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param start The start element in the array. |
|
|
* @param start The start element in the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* @param count The number of characters to read from the array. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* @exception SAXParseException if the element doesn't support text |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
* @see ProjectHelper#addText(Project,Object,char[],int,int) |
|
|
*/ |
|
|
*/ |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
|
public void characters(char[] buf, int start, int count) throws SAXParseException { |
|
@@ -1136,12 +1134,12 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
/** |
|
|
/** |
|
|
* Handles the start of an element within this one. |
|
|
* Handles the start of an element within this one. |
|
|
* This will always use a nested element handler. |
|
|
* This will always use a nested element handler. |
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @param name The name of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* @param attrs Attributes of the element being started. |
|
|
* Will not be <code>null</code>. |
|
|
* Will not be <code>null</code>. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* @exception SAXParseException if an error occurs when initialising |
|
|
* the child handler |
|
|
* the child handler |
|
|
*/ |
|
|
*/ |
|
@@ -1152,9 +1150,9 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Returns the parser factory to use. Only one parser |
|
|
* Returns the parser factory to use. Only one parser |
|
|
* factory is ever created by this method (multi-threading |
|
|
|
|
|
|
|
|
* factory is ever created by this method (multi-threading |
|
|
* issues aside) and is then cached for future use. |
|
|
* issues aside) and is then cached for future use. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @return a SAXParserFactory to use within this class |
|
|
* @return a SAXParserFactory to use within this class |
|
|
*/ |
|
|
*/ |
|
|
private static SAXParserFactory getParserFactory() { |
|
|
private static SAXParserFactory getParserFactory() { |
|
@@ -1166,13 +1164,13 @@ public class ProjectHelperImpl extends ProjectHelper { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Scans an attribute list for the <code>id</code> attribute and |
|
|
|
|
|
|
|
|
* Scans an attribute list for the <code>id</code> attribute and |
|
|
* stores a reference to the target object in the project if an |
|
|
* stores a reference to the target object in the project if an |
|
|
* id is found. |
|
|
* id is found. |
|
|
* <p> |
|
|
* <p> |
|
|
* This method was moved out of the configure method to allow |
|
|
* This method was moved out of the configure method to allow |
|
|
* it to be executed at parse time. |
|
|
* it to be executed at parse time. |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* @see #configure(Object,AttributeList,Project) |
|
|
* @see #configure(Object,AttributeList,Project) |
|
|
*/ |
|
|
*/ |
|
|
private void configureId(Object target, AttributeList attr) { |
|
|
private void configureId(Object target, AttributeList attr) { |
|
|