Java Doc for XmlProperty.java in  » Build » ANT » org » apache » tools » ant » taskdefs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.tools.ant.Task
   org.apache.tools.ant.taskdefs.XmlProperty

XmlProperty
public class XmlProperty extends org.apache.tools.ant.Task (Code)
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):

  • value: Identifies a text value for a property.
  • location: Identifies a file location for a property.
  • id: Sets an id for a property
  • refid: Sets a property to the value of another property based upon the provided id
  • pathid: Defines a path rather than a property with the given id.

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:

  • file: The name of the file to load.

This task supports the following attributes:

  • prefix: Optionally specify a prefix applied to all properties loaded. Defaults to an empty string.
  • keepRoot: Indicate whether the root xml element is kept as part of property name. Defaults to true.
  • validate: Indicate whether the xml file is validated. Defaults to false.
  • collapseAttributes: Indicate whether attributes are stored in property names with parens or with period delimiters. Defaults to false, meaning properties are stored with parens (i.e., foo(attr)).
  • semanticAttributes: Indicate whether attributes named "location", "value", "refid" and "path" are interpreted as ant properties. Defaults to false.
  • rootDirectory: Indicate the directory to use as the root directory for resolving location properties. Defaults to the directory of the project using the task.
  • includeSemanticAttribute: Indicate whether to include the semantic attribute ("location" or "value") as part of the property name. Defaults to false.



Constructor Summary
public  XmlProperty()
     Constructor.

Method Summary
public  voidaddConfigured(ResourceCollection a)
     Set the source resource.
public  voidaddConfiguredXMLCatalog(XMLCatalog catalog)
     add an XMLCatalog as a nested element; optional.
 voidaddNodeRecursively(org.w3c.dom.Node node, String prefix)
    
public  voidexecute()
     Run the task.
protected  booleangetCollapseAttributes()
    
protected  EntityResolvergetEntityResolver()
    
protected  FilegetFile()
    
protected  booleangetIncludeSementicAttribute()
    
protected  booleangetKeeproot()
    
protected  StringgetPrefix()
    
protected  ResourcegetResource()
    
protected  FilegetRootDirectory()
    
protected  booleangetSemanticAttributes()
    
protected  booleangetValidate()
    
public  voidinit()
     Initializes the task.
public  ObjectprocessNode(Node node, String prefix, Object container)
     Process the given node, adding any required attributes from this child node alone -- but not processing any children.
Parameters:
  node - the XML Node to parse
Parameters:
  prefix - A string to prepend to any properties that getadded by this node.
Parameters:
  container - Optionally, an object that a parent nodegenerated that this node might belong to.
public  voidsetCollapseAttributes(boolean collapseAttributes)
    
public  voidsetFile(File src)
     The XML file to parse; required.
public  voidsetIncludeSemanticAttribute(boolean includeSemanticAttribute)
     Include the semantic attribute name as part of the property name.
public  voidsetKeeproot(boolean keepRoot)
    
public  voidsetPrefix(String prefix)
    
public  voidsetRootDirectory(File rootDirectory)
     The directory to use for resolving file references.
public  voidsetSemanticAttributes(boolean semanticAttributes)
     Attribute to enable special handling of attributes - see ant manual.
public  voidsetSrcResource(Resource src)
     The resource to pack; required.
public  voidsetValidate(boolean validate)
    
protected  booleansupportsNonFileResources()
     Whether this task can deal with non-file resources.

This implementation returns true only if this task is <xmlproperty>.



Constructor Detail
XmlProperty
public XmlProperty()(Code)
Constructor.




Method Detail
addConfigured
public void addConfigured(ResourceCollection a)(Code)
Set the source resource.
Parameters:
  a - the resource to pack as a single element Resource collection.



addConfiguredXMLCatalog
public void addConfiguredXMLCatalog(XMLCatalog catalog)(Code)
add an XMLCatalog as a nested element; optional.
Parameters:
  catalog - the XMLCatalog to use



addNodeRecursively
void addNodeRecursively(org.w3c.dom.Node node, String prefix)(Code)



execute
public void execute() throws BuildException(Code)
Run the task.
throws:
  BuildException - The exception raised during task execution.



getCollapseAttributes
protected boolean getCollapseAttributes()(Code)
the collapse attributes attribute.



getEntityResolver
protected EntityResolver getEntityResolver()(Code)
the xmlCatalog as the entityresolver.



getFile
protected File getFile()(Code)
the file attribute.



getIncludeSementicAttribute
protected boolean getIncludeSementicAttribute()(Code)
the include semantic attribute.



getKeeproot
protected boolean getKeeproot()(Code)
the keeproot attribute.



getPrefix
protected String getPrefix()(Code)
the prefix attribute.



getResource
protected Resource getResource()(Code)
the resource.



getRootDirectory
protected File getRootDirectory()(Code)
the root directory attribute.



getSemanticAttributes
protected boolean getSemanticAttributes()(Code)
the semantic attributes attribute.



getValidate
protected boolean getValidate()(Code)
the validate attribute.



init
public void init()(Code)
Initializes the task.



processNode
public Object processNode(Node node, String prefix, Object container)(Code)
Process the given node, adding any required attributes from this child node alone -- but not processing any children.
Parameters:
  node - the XML Node to parse
Parameters:
  prefix - A string to prepend to any properties that getadded by this node.
Parameters:
  container - Optionally, an object that a parent nodegenerated that this node might belong to. For example, thisnode could be within a node that generated a Path. the Object created by this node. Generally, this iseither a String if this node resulted in setting an attribute,or a Path.



setCollapseAttributes
public void setCollapseAttributes(boolean collapseAttributes)(Code)
flag to treat attributes as nested elements; optional, default false
Parameters:
  collapseAttributes - if true treat attributes as nested elements



setFile
public void setFile(File src)(Code)
The XML file to parse; required.
Parameters:
  src - the file to parse



setIncludeSemanticAttribute
public void setIncludeSemanticAttribute(boolean includeSemanticAttribute)(Code)
Include the semantic attribute name as part of the property name. Ignored if semanticAttributes is not set to true.
Parameters:
  includeSemanticAttribute - if true include the sematic attributename.



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



setPrefix
public void setPrefix(String prefix)(Code)
the prefix to prepend to each property
Parameters:
  prefix - the prefix to prepend to each property



setRootDirectory
public void setRootDirectory(File rootDirectory)(Code)
The directory to use for resolving file references. Ignored if semanticAttributes is not set to true.
Parameters:
  rootDirectory - the directory.



setSemanticAttributes
public void setSemanticAttributes(boolean semanticAttributes)(Code)
Attribute to enable special handling of attributes - see ant manual.
Parameters:
  semanticAttributes - if true enable the special handling.



setSrcResource
public void setSrcResource(Resource src)(Code)
The resource to pack; required.
Parameters:
  src - resource to expand



setValidate
public void setValidate(boolean validate)(Code)
flag to validate the XML file; optional, default false
Parameters:
  validate - if true validate the XML file, default false



supportsNonFileResources
protected boolean supportsNonFileResources()(Code)
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.
since:
   Ant 1.7



Fields inherited from org.apache.tools.ant.Task
protected Target target(Code)(Java Doc)
protected String taskName(Code)(Java Doc)
protected String taskType(Code)(Java Doc)
protected RuntimeConfigurable wrapper(Code)(Java Doc)

Methods inherited from org.apache.tools.ant.Task
final public void bindToOwner(Task owner)(Code)(Java Doc)
public void execute() throws BuildException(Code)(Java Doc)
public Target getOwningTarget()(Code)(Java Doc)
public RuntimeConfigurable getRuntimeConfigurableWrapper()(Code)(Java Doc)
public String getTaskName()(Code)(Java Doc)
public String getTaskType()(Code)(Java Doc)
protected RuntimeConfigurable getWrapper()(Code)(Java Doc)
protected void handleErrorFlush(String output)(Code)(Java Doc)
protected void handleErrorOutput(String output)(Code)(Java Doc)
protected void handleFlush(String output)(Code)(Java Doc)
protected int handleInput(byte[] buffer, int offset, int length) throws IOException(Code)(Java Doc)
protected void handleOutput(String output)(Code)(Java Doc)
public void init() throws BuildException(Code)(Java Doc)
final protected boolean isInvalid()(Code)(Java Doc)
public void log(String msg)(Code)(Java Doc)
public void log(String msg, int msgLevel)(Code)(Java Doc)
public void log(Throwable t, int msgLevel)(Code)(Java Doc)
public void log(String msg, Throwable t, int msgLevel)(Code)(Java Doc)
public void maybeConfigure() throws BuildException(Code)(Java Doc)
final public void perform()(Code)(Java Doc)
public void reconfigure()(Code)(Java Doc)
public void setOwningTarget(Target target)(Code)(Java Doc)
public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)(Code)(Java Doc)
public void setTaskName(String name)(Code)(Java Doc)
public void setTaskType(String type)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.