@@ -120,38 +120,70 @@ public class AntXMLContext {
* when processing a particular build file.
* when processing a particular build file.
*/
*/
private boolean ignoreProjectTag = false;
private boolean ignoreProjectTag = false;
/**
* constructor
* @param project the project to which this antxml context belongs to
*/
public AntXMLContext(Project project) {
public AntXMLContext(Project project) {
this.project = project;
this.project = project;
implicitTarget.setName("");
implicitTarget.setName("");
targetVector.addElement(implicitTarget);
targetVector.addElement(implicitTarget);
}
}
/**
* sets the build file to which the XML context belongs
* @param buildFile ant build file
*/
public void setBuildFile(File buildFile) {
public void setBuildFile(File buildFile) {
this.buildFile = buildFile;
this.buildFile = buildFile;
this.buildFileParent = new File(buildFile.getParent());
this.buildFileParent = new File(buildFile.getParent());
}
}
/**
* find out the build file
* @return the build file to which the xml context belongs
*/
public File getBuildFile() {
public File getBuildFile() {
return buildFile;
return buildFile;
}
}
/**
* find out the parent build file of this build file
* @return the parent build file of this build file
*/
public File getBuildFileParent() {
public File getBuildFileParent() {
return buildFileParent;
return buildFileParent;
}
}
/**
* find out the project to which this antxml context belongs
* @return project
*/
public Project getProject() {
public Project getProject() {
return project;
return project;
}
}
/**
* find out the current project name
* @return current project name
*/
public String getCurrentProjectName() {
public String getCurrentProjectName() {
return currentProjectName;
return currentProjectName;
}
}
/**
* set the name of the current project
* @param name name of the current project
*/
public void setCurrentProjectName(String name) {
public void setCurrentProjectName(String name) {
this.currentProjectName = name;
this.currentProjectName = name;
}
}
/**
* get the current runtime configurable wrapper
* can return null
* @return runtime configurable wrapper
*/
public RuntimeConfigurable currentWrapper() {
public RuntimeConfigurable currentWrapper() {
if (wStack.size() < 1) {
if (wStack.size() < 1) {
return null;
return null;
@@ -159,6 +191,11 @@ public class AntXMLContext {
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1);
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1);
}
}
/**
* get the runtime configurable wrapper of the parent project
* can return null
* @return runtime configurable wrapper of the parent project
*/
public RuntimeConfigurable parentWrapper() {
public RuntimeConfigurable parentWrapper() {
if (wStack.size() < 2) {
if (wStack.size() < 2) {
return null;
return null;
@@ -166,41 +203,76 @@ public class AntXMLContext {
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2);
return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2);
}
}
/**
* add a runtime configurable wrapper to the internal stack
* @param wrapper runtime configurable wrapper
*/
public void pushWrapper(RuntimeConfigurable wrapper) {
public void pushWrapper(RuntimeConfigurable wrapper) {
wStack.addElement(wrapper);
wStack.addElement(wrapper);
}
}
/**
* remove a runtime configurable wrapper from the stack
*/
public void popWrapper() {
public void popWrapper() {
if (wStack.size() > 0) {
if (wStack.size() > 0) {
wStack.removeElementAt(wStack.size() - 1);
wStack.removeElementAt(wStack.size() - 1);
}
}
}
}
/**
* access the stack of wrappers
* @return the stack of wrappers
*/
public Vector getWrapperStack() {
public Vector getWrapperStack() {
return wStack;
return wStack;
}
}
/**
* add a new target
* @param target target to add
*/
public void addTarget(Target target) {
public void addTarget(Target target) {
targetVector.addElement(target);
targetVector.addElement(target);
currentTarget = target;
currentTarget = target;
}
}
/**
* get the current target
* @return current target
*/
public Target getCurrentTarget() {
public Target getCurrentTarget() {
return currentTarget;
return currentTarget;
}
}
/**
* get the implicit target
* @return implicit target
*/
public Target getImplicitTarget() {
public Target getImplicitTarget() {
return implicitTarget;
return implicitTarget;
}
}
/**
* sets the current target
* @param target current target
*/
public void setCurrentTarget(Target target) {
public void setCurrentTarget(Target target) {
this.currentTarget = target;
this.currentTarget = target;
}
}
/**
* sets the implicit target
* @param target
*/
public void setImplicitTarget(Target target) {
public void setImplicitTarget(Target target) {
this.implicitTarget = target;
this.implicitTarget = target;
}
}
/**
* access the vector of targets
* @return vector of targets
*/
public Vector getTargets() {
public Vector getTargets() {
return targetVector;
return targetVector;
}
}
@@ -212,8 +284,6 @@ public class AntXMLContext {
* <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(java.lang.Object,org.xml.sax.AttributeList,org.apache.tools.ant.Project)
*/
*/
public void configureId(Object element, Attributes attr) {
public void configureId(Object element, Attributes attr) {
String id = attr.getValue("id");
String id = attr.getValue("id");
@@ -222,18 +292,34 @@ public class AntXMLContext {
}
}
}
}
/**
* access the locator
* @return locator
*/
public Locator getLocator() {
public Locator getLocator() {
return locator;
return locator;
}
}
/**
* sets the locator
* @param locator locator
*/
public void setLocator(Locator locator) {
public void setLocator(Locator locator) {
this.locator = locator;
this.locator = locator;
}
}
/**
* tells whether the project tag is being ignored
* @return whether the project tag is being ignored
*/
public boolean isIgnoringProjectTag() {
public boolean isIgnoringProjectTag() {
return ignoreProjectTag;
return ignoreProjectTag;
}
}
/**
* sets the flag to ignore the project tag
* @param flag to ignore the project tag
*/
public void setIgnoreProjectTag(boolean flag) {
public void setIgnoreProjectTag(boolean flag) {
this.ignoreProjectTag = flag;
this.ignoreProjectTag = flag;
}
}