FileDocCategorySizeDatePackage
AntXMLContext.javaAPI DocApache Ant 1.709826Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.helper

AntXMLContext

public class AntXMLContext extends Object
Context information for the ant processing.

Fields Summary
private org.apache.tools.ant.Project
project
The project to configure.
private File
buildFile
The configuration file to parse.
private Vector
targetVector
Vector with all the targets, in the order they are defined. Project maintains a Hashtable, which is not ordered. This will allow description to know the original order.
private File
buildFileParent
Parent directory of the build file. Used for resolving entities and setting the project's base directory.
private String
currentProjectName
Name of the current project
private Locator
locator
Locator for the configuration file parser. Used for giving locations of errors etc.
private org.apache.tools.ant.Target
implicitTarget
Target that all other targets will depend upon implicitly.

This holds all tasks and data type definitions that have been placed outside of targets.

private org.apache.tools.ant.Target
currentTarget
Current target ( no need for a stack as the processing model allows only one level of target )
private Vector
wStack
The stack of RuntimeConfigurable2 wrapping the objects.
private boolean
ignoreProjectTag
Indicates whether the project tag attributes are to be ignored when processing a particular build file.
private Map
prefixMapping
Keeps track of prefix -> uri mapping during parsing
private Map
currentTargets
Keeps track of targets in files
Constructors Summary
public AntXMLContext(org.apache.tools.ant.Project project)
constructor

param
project the project to which this antxml context belongs to


                     
       
        this.project = project;
        implicitTarget.setProject(project);
        implicitTarget.setName("");
        targetVector.addElement(implicitTarget);
    
Methods Summary
public voidaddTarget(org.apache.tools.ant.Target target)
add a new target

param
target target to add

        targetVector.addElement(target);
        currentTarget = target;
    
public voidconfigureId(java.lang.Object element, org.xml.sax.Attributes attr)
Scans an attribute list for the id attribute and stores a reference to the target object in the project if an id is found.

This method was moved out of the configure method to allow it to be executed at parse time.

param
element the current element
param
attr attributes of the current element

        String id = attr.getValue("id");
        if (id != null) {
            project.addIdReference(id, element);
        }
    
public org.apache.tools.ant.RuntimeConfigurablecurrentWrapper()
get the current runtime configurable wrapper can return null

return
runtime configurable wrapper

        if (wStack.size() < 1) {
            return null;
        }
        return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1);
    
public voidendPrefixMapping(java.lang.String prefix)
End of prefix to uri mapping.

param
prefix the namespace prefix

        List list = (List) prefixMapping.get(prefix);
        if (list == null || list.size() == 0) {
            return; // Should not happen
        }
        list.remove(list.size() - 1);
    
public java.io.FilegetBuildFile()
find out the build file

return
the build file to which the xml context belongs

        return buildFile;
    
public java.io.FilegetBuildFileParent()
find out the parent build file of this build file

return
the parent build file of this build file

        return buildFileParent;
    
public java.lang.StringgetCurrentProjectName()
find out the current project name

return
current project name

        return currentProjectName;
    
public org.apache.tools.ant.TargetgetCurrentTarget()
get the current target

return
current target

        return currentTarget;
    
public java.util.MapgetCurrentTargets()
Get the targets in the current source file.

return
the current targets.

        return currentTargets;
    
public org.apache.tools.ant.TargetgetImplicitTarget()
get the implicit target

return
implicit target

        return implicitTarget;
    
public org.xml.sax.LocatorgetLocator()
access the locator

return
locator

        return locator;
    
public java.lang.StringgetPrefixMapping(java.lang.String prefix)
prefix to namespace uri mapping

param
prefix the prefix to map
return
the uri for this prefix, null if not present

        List list = (List) prefixMapping.get(prefix);
        if (list == null || list.size() == 0) {
            return null;
        }
        return (String) list.get(list.size() - 1);
    
public org.apache.tools.ant.ProjectgetProject()
find out the project to which this antxml context belongs

return
project

        return project;
    
public java.util.VectorgetTargets()
access the vector of targets

return
vector of targets

        return targetVector;
    
public java.util.VectorgetWrapperStack()
access the stack of wrappers

return
the stack of wrappers

        return wStack;
    
public booleanisIgnoringProjectTag()
tells whether the project tag is being ignored

return
whether the project tag is being ignored

        return ignoreProjectTag;
    
public org.apache.tools.ant.RuntimeConfigurableparentWrapper()
get the runtime configurable wrapper of the parent project can return null

return
runtime configurable wrapper of the parent project

        if (wStack.size() < 2) {
            return null;
        }
        return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2);
    
public voidpopWrapper()
remove a runtime configurable wrapper from the stack

        if (wStack.size() > 0) {
            wStack.removeElementAt(wStack.size() - 1);
        }
    
public voidpushWrapper(org.apache.tools.ant.RuntimeConfigurable wrapper)
add a runtime configurable wrapper to the internal stack

param
wrapper runtime configurable wrapper

        wStack.addElement(wrapper);
    
public voidsetBuildFile(java.io.File buildFile)
sets the build file to which the XML context belongs

param
buildFile ant build file

        this.buildFile = buildFile;
        this.buildFileParent = new File(buildFile.getParent());
        implicitTarget.setLocation(new Location(buildFile.getAbsolutePath()));
    
public voidsetCurrentProjectName(java.lang.String name)
set the name of the current project

param
name name of the current project

        this.currentProjectName = name;
    
public voidsetCurrentTarget(org.apache.tools.ant.Target target)
sets the current target

param
target current target

        this.currentTarget = target;
    
public voidsetCurrentTargets(java.util.Map currentTargets)
Set the map of the targets in the current source file.

param
currentTargets a map of targets.

        this.currentTargets = currentTargets;
    
public voidsetIgnoreProjectTag(boolean flag)
sets the flag to ignore the project tag

param
flag to ignore the project tag

        this.ignoreProjectTag = flag;
    
public voidsetImplicitTarget(org.apache.tools.ant.Target target)
sets the implicit target

param
target the implicit target

        this.implicitTarget = target;
    
public voidsetLocator(org.xml.sax.Locator locator)
sets the locator

param
locator locator

        this.locator = locator;
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)
Called during parsing, stores the prefix to uri mapping.

param
prefix a namespace prefix
param
uri a namespace uri

        List list = (List) prefixMapping.get(prefix);
        if (list == null) {
            list = new ArrayList();
            prefixMapping.put(prefix, list);
        }
        list.add(uri);