jp.ossc.tools.ant.taskdefs
クラス ExtendsXmlProperty

java.lang.Object
  上位を拡張 org.apache.tools.ant.ProjectComponent
      上位を拡張 org.apache.tools.ant.Task
          上位を拡張 jp.ossc.tools.ant.taskdefs.ExtendsXmlProperty
すべての実装されたインタフェース:
java.lang.Cloneable

public class ExtendsXmlProperty
extends org.apache.tools.ant.Task

Loads property values from a valid XML file, generating the property names from the file's element and attribute names.

Example:

   <root-tag myattr="true">
     <inner-tag someattr="val">Text</inner-tag>
     <a2><a3><a4>false</a4></a3></a2>
     <x>x1</x>
     <x>x2</x>
   </root-tag>

this generates the following properties:

  root-tag(myattr)=true
  root-tag.inner-tag=Text
  root-tag.inner-tag(someattr)=val
  root-tag.a2.a3.a4=false
  root-tag.x=x1,x2
 

The collapseAttributes property of this task can be set to true (the default is false) which will instead result in the following properties (note the difference in names of properties corresponding to XML attributes):

  root-tag.myattr=true
  root-tag.inner-tag=Text
  root-tag.inner-tag.someattr=val
  root-tag.a2.a3.a4=false
  root-tag.x=x1,x2
 

Optionally, to more closely mirror the abilities of the Property task, a selected set of attributes can be treated specially. To enable this behavior, the "semanticAttributes" property of this task must be set to true (it defaults to false). If this attribute is specified, the following attributes take on special meaning (setting this to true implicitly sets collapseAttributes to true as well):

For example, with keepRoot = false, the following properties file:

 <root-tag>
   <build>
   <build folder="build">
     <classes id="build.classes" location="${build.folder}/classes"/>
     <reference refid="build.classes"/>
   </build>
   <compile>
     <classpath pathid="compile.classpath">
       <pathelement location="${build.classes}"/>
     </classpath>
   </compile>
   <run-time>
     <jars>*.jar</jars>
     <classpath pathid="run-time.classpath">
       <path refid="compile.classpath"/>
       <pathelement path="${run-time.jars}"/>
     </classpath>
   </run-time>
 </root-tag>
 

is equivalent to the following entries in a build file:

 <property name="build" location="build"/>
 <property name="build.classes" location="${build.location}/classes"/>
 <property name="build.reference" refid="build.classes"/>

 <property name="run-time.jars" value="*.jar/>

 <classpath id="compile.classpath">
   <pathelement location="${build.classes}"/>
 </classpath>

 <classpath id="run-time.classpath">
   <path refid="compile.classpath"/>
   <pathelement path="${run-time.jars}"/>
 </classpath>
 

This task requires the following attributes:

This task supports the following attributes:

関連項目:
org.apache.tools.ant.taskdefs.XmlProperty

フィールドの概要
 
クラス org.apache.tools.ant.Task から継承されたフィールド
target, taskName, taskType, wrapper
 
クラス org.apache.tools.ant.ProjectComponent から継承されたフィールド
description, location, project
 
コンストラクタの概要
ExtendsXmlProperty()
          Constructor.
 
メソッドの概要
 void addConfigured(org.apache.tools.ant.types.ResourceCollection a)
          Set the source resource.
 void addConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog catalog)
          add an XMLCatalog as a nested element; optional.
 void execute()
          Run the task.
protected  boolean getCollapseAttributes()
           
protected  org.xml.sax.EntityResolver getEntityResolver()
           
protected  java.io.File getFile()
           
protected  boolean getIncludeSementicAttribute()
           
protected  boolean getKeeproot()
           
 java.lang.String getMoreTypes()
          複数形となるプロパティ名(カンマ区切り)を取得
protected  java.lang.String getPrefix()
           
protected  org.apache.tools.ant.types.Resource getResource()
           
protected  java.io.File getRootDirectory()
           
protected  boolean getSemanticAttributes()
           
protected  boolean getValidate()
           
 void init()
          Initializes the task.
 java.lang.Object processNode(org.w3c.dom.Node node, java.lang.String prefix, java.lang.Object container)
          Process the given node, adding any required attributes from this child node alone -- but not processing any children.
 void setCollapseAttributes(boolean collapseAttributes)
          flag to treat attributes as nested elements; optional, default false
 void setFile(java.io.File src)
          The XML file to parse; required.
 void setIncludeSemanticAttribute(boolean includeSemanticAttribute)
          Include the semantic attribute name as part of the property name.
 void setKeeproot(boolean keepRoot)
          flag to include the xml root tag as a first value in the property name; optional, default is true
 void setMoreTypes(java.lang.String lMoreTypes)
          複数形となるプロパティ名(カンマ区切り)を設定
 void setPrefix(java.lang.String prefix)
          the prefix to prepend to each property
 void setRootDirectory(java.io.File rootDirectory)
          The directory to use for resolving file references.
 void setSemanticAttributes(boolean semanticAttributes)
          Attribute to enable special handling of attributes - see ant manual.
 void setSrcResource(org.apache.tools.ant.types.Resource src)
          The resource to pack; required.
 void setValidate(boolean validate)
          flag to validate the XML file; optional, default false
protected  boolean supportsNonFileResources()
          Whether this task can deal with non-file resources.
 
クラス org.apache.tools.ant.Task から継承されたメソッド
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
クラス org.apache.tools.ant.ProjectComponent から継承されたメソッド
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
クラス java.lang.Object から継承されたメソッド
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

ExtendsXmlProperty

public ExtendsXmlProperty()
Constructor.

メソッドの詳細

init

public void init()
Initializes the task.

オーバーライド:
クラス org.apache.tools.ant.Task 内の init

getEntityResolver

protected org.xml.sax.EntityResolver getEntityResolver()
戻り値:
the xmlCatalog as the entityresolver.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Run the task.

オーバーライド:
クラス org.apache.tools.ant.Task 内の execute
例外:
org.apache.tools.ant.BuildException - The exception raised during task execution.

processNode

public java.lang.Object processNode(org.w3c.dom.Node node,
                                    java.lang.String prefix,
                                    java.lang.Object container)
Process the given node, adding any required attributes from this child node alone -- but not processing any children.

パラメータ:
node - the XML Node to parse
prefix - A string to prepend to any properties that get added by this node.
container - Optionally, an object that a parent node generated that this node might belong to. For example, this node could be within a node that generated a Path.
戻り値:
the Object created by this node. Generally, this is either a String if this node resulted in setting an attribute, or a Path.

setFile

public void setFile(java.io.File src)
The XML file to parse; required.

パラメータ:
src - the file to parse

setSrcResource

public void setSrcResource(org.apache.tools.ant.types.Resource src)
The resource to pack; required.

パラメータ:
src - resource to expand

addConfigured

public void addConfigured(org.apache.tools.ant.types.ResourceCollection a)
Set the source resource.

パラメータ:
a - the resource to pack as a single element Resource collection.

setPrefix

public void setPrefix(java.lang.String prefix)
the prefix to prepend to each property

パラメータ:
prefix - the prefix to prepend to each property

setKeeproot

public void setKeeproot(boolean keepRoot)
flag to include the xml root tag as a first value in the property name; optional, default is true

パラメータ:
keepRoot - if true (default), include the xml root tag

setValidate

public void setValidate(boolean validate)
flag to validate the XML file; optional, default false

パラメータ:
validate - if true validate the XML file, default false

setCollapseAttributes

public void setCollapseAttributes(boolean collapseAttributes)
flag to treat attributes as nested elements; optional, default false

パラメータ:
collapseAttributes - if true treat attributes as nested elements

setSemanticAttributes

public void setSemanticAttributes(boolean semanticAttributes)
Attribute to enable special handling of attributes - see ant manual.

パラメータ:
semanticAttributes - if true enable the special handling.

setRootDirectory

public void setRootDirectory(java.io.File rootDirectory)
The directory to use for resolving file references. Ignored if semanticAttributes is not set to true.

パラメータ:
rootDirectory - the directory.

setIncludeSemanticAttribute

public void setIncludeSemanticAttribute(boolean includeSemanticAttribute)
Include the semantic attribute name as part of the property name. Ignored if semanticAttributes is not set to true.

パラメータ:
includeSemanticAttribute - if true include the sematic attribute name.

addConfiguredXMLCatalog

public void addConfiguredXMLCatalog(org.apache.tools.ant.types.XMLCatalog catalog)
add an XMLCatalog as a nested element; optional.

パラメータ:
catalog - the XMLCatalog to use

getFile

protected java.io.File getFile()
戻り値:
the file attribute.

getResource

protected org.apache.tools.ant.types.Resource getResource()
戻り値:
the resource.

getPrefix

protected java.lang.String getPrefix()
戻り値:
the prefix attribute.

getKeeproot

protected boolean getKeeproot()
戻り値:
the keeproot attribute.

getValidate

protected boolean getValidate()
戻り値:
the validate attribute.

getCollapseAttributes

protected boolean getCollapseAttributes()
戻り値:
the collapse attributes attribute.

getSemanticAttributes

protected boolean getSemanticAttributes()
戻り値:
the semantic attributes attribute.

getRootDirectory

protected java.io.File getRootDirectory()
戻り値:
the root directory attribute.

getIncludeSementicAttribute

protected boolean getIncludeSementicAttribute()
戻り値:
the include semantic attribute.

getMoreTypes

public java.lang.String getMoreTypes()
複数形となるプロパティ名(カンマ区切り)を取得

戻り値:
複数形となるプロパティ名

setMoreTypes

public void setMoreTypes(java.lang.String lMoreTypes)
複数形となるプロパティ名(カンマ区切り)を設定

パラメータ:
lMoreTypes - 複数形となるプロパティ名

supportsNonFileResources

protected boolean supportsNonFileResources()
Whether this task can deal with non-file resources.

This implementation returns true only if this task is <xmlproperty>. Any subclass of this class that also wants to support non-file resources needs to override this method. We need to do so for backwards compatibility reasons since we can't expect subclasses to support resources.

戻り値:
true for this task.
導入されたバージョン:
Ant 1.7