org.writersforge.catalan.process.properties
Class XmlProperties

java.lang.Object
  extended byorg.writersforge.catalan.process.properties.BaseWorkProperties
      extended byorg.writersforge.catalan.process.properties.XmlProperties
All Implemented Interfaces:
IWorkProperties

public class XmlProperties
extends BaseWorkProperties

IWorkProperties which exports XML attributes as properties.

Author:
jsheets

Constructor Summary
XmlProperties(org.writersforge.bellows.Datum xml)
          Creates a new instance of XmlProperties.
 
Method Summary
 java.lang.Object getProperty(java.lang.String name)
          Retrieves the value of a named config property.
 java.lang.String[] getPropertyNames()
          Retrieves the names of all properties currently set on this holder.
 
Methods inherited from class org.writersforge.catalan.process.properties.BaseWorkProperties
asMap, asMap, getPropertyAsBoolean, getPropertyAsDatum, getPropertyAsMap, getPropertyAsNumber, getPropertyAsString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlProperties

public XmlProperties(org.writersforge.bellows.Datum xml)
Creates a new instance of XmlProperties.

Parameters:
xml - XML document to wrap
Method Detail

getPropertyNames

public java.lang.String[] getPropertyNames()
Retrieves the names of all properties currently set on this holder.

Returns:
array of all property names

getProperty

public java.lang.Object getProperty(java.lang.String name)
Retrieves the value of a named config property. The XmlProperties supports a few different property retrieval techniques, all of which work against the root config Datum wrapped by this XmlProperties instance:
  1. Property name - Looks up the property name as an XML attribute on the root Datum, or as an XML element which is the direct child of the root; in the latter case, the property value is the PCDATA content of the child element, or a Datum[] object if the child has embedded XML content. A child property element will override an attribute property; if more than one child element exists with the same name, the last one will be used.
  2. Special null property - Returns the immediate child contents of the root Datum object which are not <property> elements. This property will always be a non-null Datum[] object. If no such content is found, the Datum[] array will simply be empty.
  3. Special "=" property - Returns the root config Datum directly.
  4. Bellows Query path property - Runs a Bellows query against the root config Datum. Pass in a property as the Bellows query prefixed by the '=' character. For example, the property name "=*/child" will return all <child> elements directly inside the root config element. If no matches exist for the given path, this method will return a null, not an empty Datum[] array; this makes it possible for chained lookups to continue searching other configs for the same path.
  5. Parameters:
    name - property name, or null for non-property child content
    Returns:
    the value of the property, or null if not set