ProjectHelper2 (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.helper, class: ProjectHelper2

# Class ProjectHelper2

java.lang.Object
org.apache.tools.ant.ProjectHelper
org.apache.tools.ant.helper.ProjectHelper2

public class ProjectHelper2 extends ProjectHelper
Sax2 based project reader

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `ProjectHelper2.AntHandler`
  The common superclass for all SAX event handlers used to parse the configuration file.
  `static class`
  `ProjectHelper2.ElementHandler`
  Handler for all project elements (tasks, data types)
  `static class`
  `ProjectHelper2.MainHandler`
  The main handler - it handles the <project> tag.
  `static class`
  `ProjectHelper2.ProjectHandler`
  Handler for the top level "project" element.
  `static class`
  `ProjectHelper2.RootHandler`
  Handler for ant processing.
  `static class`
  `ProjectHelper2.TargetHandler`
  Handler for "target" and "extension-point" elements.

  ### Nested classes/interfaces inherited from class ProjectHelper

  `ProjectHelper.OnMissingExtensionPoint`
  Modifier and Type
  Class
  Description
  `static final class`
  `ProjectHelper.OnMissingExtensionPoint`
  Possible value for target's onMissingExtensionPoint attribute.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `REFID_TARGETS`
  Reference holding the (ordered) target Vector

  ### Fields inherited from class ProjectHelper

  `ANT_ATTRIBUTE_URI, ANT_CORE_URI, ANT_CURRENT_URI, ANT_TYPE, ANTLIB_URI, HELPER_PROPERTY, PROJECTHELPER_REFERENCE, SERVICE_ID, USE_PROJECT_NAME_AS_TARGET_PREFIX`
  Modifier and Type
  Field
  Description
  `static final String`
  `ANT_ATTRIBUTE_URI`
  The URI for ant specific attributes
  `static final String`
  `ANT_CORE_URI`
  The URI for ant name space
  `static final String`
  `ANT_CURRENT_URI`
  The URI for antlib current definitions
  `static final String`
  `ANT_TYPE`
  Polymorphic attribute
  `static final String`
  `ANTLIB_URI`
  Deprecated.
  use MagicNames.ANTLIB_PREFIX
  `static final String`
  `HELPER_PROPERTY`
  Deprecated.
  use MagicNames.PROJECT_HELPER_CLASS
  `static final String`
  `PROJECTHELPER_REFERENCE`
  Deprecated.
  use MagicNames.REFID_PROJECT_HELPER
  `static final String`
  `SERVICE_ID`
  Deprecated.
  use MagicNames.PROJECT_HELPER_SERVICE
  `static final String`
  `USE_PROJECT_NAME_AS_TARGET_PREFIX`
  constant to denote use project name as target prefix

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProjectHelper2()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canParseAntlibDescriptor(Resource resource)`
  Whether this instance of ProjectHelper can parse an Antlib descriptor given by the URL and return its content as an UnknownElement ready to be turned into an Antlib task.
  `protected static ProjectHelper2.AntHandler`
  `getElementHandler()`
  Returns element handler
  `protected static ProjectHelper2.AntHandler`
  `getMainHandler()`
  Returns main handler
  `protected static ProjectHelper2.AntHandler`
  `getProjectHandler()`
  Returns project handler
  `protected static ProjectHelper2.AntHandler`
  `getTargetHandler()`
  Returns target handler
  `void`
  `parse(Project project, Object source)`
  Parse a source xml input.
  `void`
  `parse(Project project, Object source, ProjectHelper2.RootHandler handler)`
  Parses the project file, configuring the project as it goes.
  `UnknownElement`
  `parseAntlibDescriptor(Project containingProject, Resource resource)`
  Parse the given URL as an antlib descriptor and return the content as something that can be turned into an Antlib task.
  `UnknownElement`
  `parseUnknownElement(Project project, URL source)`
  Parse an unknown element from a url
  `protected static void`
  `setElementHandler(ProjectHelper2.AntHandler handler)`
  Sets element handler
  `protected static void`
  `setMainHandler(ProjectHelper2.AntHandler handler)`
  Sets main handler
  `protected static void`
  `setProjectHandler(ProjectHelper2.AntHandler handler)`
  Sets project handler
  `protected static void`
  `setTargetHandler(ProjectHelper2.AntHandler handler)`
  Sets target handler

  ### Methods inherited from class ProjectHelper

  `addLocationToBuildException, addText, addText, canParseBuildFile, configure, configureProject, extractNameFromComponentName, extractUriFromComponentName, genComponentName, getContextClassLoader, getCurrentPrefixSeparator, getCurrentTargetPrefix, getDefaultBuildFile, getExtensionStack, getImportStack, getProjectHelper, isInIncludeMode, nsToComponentName, parsePropertyString, replaceProperties, replaceProperties, resolveExtensionOfAttributes, setCurrentPrefixSeparator, setCurrentTargetPrefix, setInIncludeMode, storeChild`
  Modifier and Type
  Method
  Description
  `static BuildException`
  `addLocationToBuildException(BuildException ex, Location newLocation)`
  Add location to build exception.
  `static void`
  `addText(Project project, Object target, char[] buf, int start, int count)`
  Adds the content of #PCDATA sections to an element.
  `static void`
  `addText(Project project, Object target, String text)`
  Adds the content of #PCDATA sections to an element.
  `boolean`
  `canParseBuildFile(Resource buildFile)`
  Check if the helper supports the kind of file.
  `static void`
  `configure(Object target, AttributeList attrs, Project project)`
  Deprecated.
  since 1.6.x.
  `static void`
  `configureProject(Project project, File buildFile)`
  Configures the project with the contents of the specified build file.
  `static String`
  `extractNameFromComponentName(String componentName)`
  extract the element name from a component name
  `static String`
  `extractUriFromComponentName(String componentName)`
  extract a uri from a component name
  `static String`
  `genComponentName(String uri, String name)`
  Map a namespaced {uri,name} to an internal string format.
  `static ClassLoader`
  `getContextClassLoader()`
  Deprecated.
  since 1.6.x.
  `static String`
  `getCurrentPrefixSeparator()`
  The separator between the prefix and the target name.
  `static String`
  `getCurrentTargetPrefix()`
  The prefix to prepend to imported target names.
  `String`
  `getDefaultBuildFile()`
  The file name of the build script to be parsed if none specified on the command line
  `List<String[]>`
  `getExtensionStack()`
  Extension stack.
  `Vector<Object>`
  `getImportStack()`
  Import stack.
  `static ProjectHelper`
  `getProjectHelper()`
  Get the first project helper found in the classpath
  `static boolean`
  `isInIncludeMode()`
  Whether the current file should be read in include as opposed to import mode.
  `static String`
  `nsToComponentName(String ns)`
  Convert an attribute namespace to a "component name".
  `static void`
  `parsePropertyString(String value, Vector<String> fragments, Vector<String> propertyRefs)`
  Deprecated.
  since 1.6.x.
  `static String`
  `replaceProperties(Project project, String value)`
  Deprecated.
  since 1.6.x.
  `static String`
  `replaceProperties(Project project, String value, Hashtable<String,Object> keys)`
  Deprecated.
  since 1.6.x.
  `void`
  `resolveExtensionOfAttributes(Project project)`
  Check extensionStack and inject all targets having extensionOf attributes into extensionPoint.
  `static void`
  `setCurrentPrefixSeparator(String sep)`
  Sets the separator between the prefix and the target name.
  `static void`
  `setCurrentTargetPrefix(String prefix)`
  Sets the prefix to prepend to imported target names.
  `static void`
  `setInIncludeMode(boolean includeMode)`
  Sets whether the current file should be read in include as opposed to import mode.
  `static void`
  `storeChild(Project project, Object parent, Object child, String tag)`
  Stores a configured child element within its parent object.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### REFID_TARGETS

    public static final String REFID_TARGETS
    Reference holding the (ordered) target Vector
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ProjectHelper2

    public ProjectHelper2()

- ## Method Details

  - ### canParseAntlibDescriptor

    public boolean canParseAntlibDescriptor(Resource resource)
    Whether this instance of ProjectHelper can parse an Antlib descriptor given by the URL and return its content as an UnknownElement ready to be turned into an Antlib task.

    This implementation returns true.

    Overrides:
      `canParseAntlibDescriptor` in class `ProjectHelper`
    Parameters:
      `resource` - Resource
    Returns:
      boolean
    Since:
      Ant 1.8.0

  - ### parseAntlibDescriptor

    public UnknownElement parseAntlibDescriptor(Project containingProject, Resource resource)
    Parse the given URL as an antlib descriptor and return the content as something that can be turned into an Antlib task.

    simply delegates to `parseUnknownElement` if the resource provides an URL and throws an exception otherwise.

    Overrides:
      `parseAntlibDescriptor` in class `ProjectHelper`
    Parameters:
      `containingProject` - Project
      `resource` - Resource
    Returns:
      UnknownElement
    Since:
      Ant 1.8.0

  - ### parseUnknownElement

    public UnknownElement parseUnknownElement(Project project, URL source) throws BuildException
    Parse an unknown element from a url
    Parameters:
      `project` - the current project
      `source` - the url containing the task
    Returns:
      a configured task
    Throws:
      `BuildException` - if an error occurs

  - ### parse

    public void parse(Project project, Object source) throws BuildException
    Parse a source xml input.
    Overrides:
      `parse` in class `ProjectHelper`
    Parameters:
      `project` - the current project
      `source` - the xml source
    Throws:
      `BuildException` - if an error occurs

  - ### parse

    public void parse(Project project, Object source, ProjectHelper2.RootHandler handler) throws BuildException
    Parses the project file, configuring the project as it goes.
    Parameters:
      `project` - the current project
      `source` - the xml source
      `handler` - the root handler to use (contains the current context)
    Throws:
      `BuildException` - if the configuration is invalid or cannot be read

  - ### getMainHandler

    protected static ProjectHelper2.AntHandler getMainHandler()
    Returns main handler
    Returns:
      main handler

  - ### setMainHandler

    protected static void setMainHandler(ProjectHelper2.AntHandler handler)
    Sets main handler
    Parameters:
      `handler` - new main handler

  - ### getProjectHandler

    protected static ProjectHelper2.AntHandler getProjectHandler()
    Returns project handler
    Returns:
      project handler

  - ### setProjectHandler

    protected static void setProjectHandler(ProjectHelper2.AntHandler handler)
    Sets project handler
    Parameters:
      `handler` - new project handler

  - ### getTargetHandler

    protected static ProjectHelper2.AntHandler getTargetHandler()
    Returns target handler
    Returns:
      target handler

  - ### setTargetHandler

    protected static void setTargetHandler(ProjectHelper2.AntHandler handler)
    Sets target handler
    Parameters:
      `handler` - new target handler

  - ### getElementHandler

    protected static ProjectHelper2.AntHandler getElementHandler()
    Returns element handler
    Returns:
      element handler

  - ### setElementHandler

    protected static void setElementHandler(ProjectHelper2.AntHandler handler)
    Sets element handler
    Parameters:
      `handler` - new element handler