org.writersforge.catalan.transform.external
Class DatumAdapter

java.lang.Object
  extended byorg.writersforge.catalan.transform.external.DatumAdapter

public class DatumAdapter
extends java.lang.Object

Simple adapter for exporting both raw Datum tree and DatumQuery support for easy use in Velocity templates.

Author:
jsheets

Constructor Summary
DatumAdapter(org.writersforge.bellows.Datum root)
          Creates a new instance of DatumAdapter.
 
Method Summary
 java.lang.String getPcdata()
          Retrieves all the PCDATA content of the wrapped Datum node and its children.
 java.lang.String getPcdata(boolean collapseWhiteSpace)
          Retrieves all the PCDATA content of the wrapped Datum node and its children with the specified whitespace behavior.
 org.writersforge.bellows.util.PropertyName getProperty(java.lang.String property)
          Retrieves a Datum property value from the root node as a PropertyName object.
 org.writersforge.bellows.Datum getRoot()
          Retrieves the root of the wrapped Datum tree.
 java.lang.String getSafePcdata()
          Retrieves a Java String-safe version of the PCDATA content in the wrapped Datum node.
 org.writersforge.bellows.util.PropertyName getType()
          Retrieves element type of root node as a PropertyName object.
 DatumAdapter[] query(java.lang.String query)
          Runs the Bellows query and wraps all results in other DatumAdapter objects.
 java.lang.String[] queryPcdata(java.lang.String query)
          Runs the Bellows query, then extracts the PCDATA content from each result node.
 org.writersforge.bellows.util.PropertyName[] queryProperties(java.lang.String query, java.lang.String attribute)
          Runs the Bellows query then extracts the Datum property described in attribute from each query result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatumAdapter

public DatumAdapter(org.writersforge.bellows.Datum root)
Creates a new instance of DatumAdapter.

Parameters:
root - Datum tree to wrap
Method Detail

getRoot

public org.writersforge.bellows.Datum getRoot()
Retrieves the root of the wrapped Datum tree.

Returns:
wrapped Datum tree root

getType

public org.writersforge.bellows.util.PropertyName getType()
Retrieves element type of root node as a PropertyName object.

Returns:
root element type

getProperty

public org.writersforge.bellows.util.PropertyName getProperty(java.lang.String property)
Retrieves a Datum property value from the root node as a PropertyName object.

Parameters:
property - the key name of the Datum property
Returns:
the property value

getPcdata

public java.lang.String getPcdata()
Retrieves all the PCDATA content of the wrapped Datum node and its children. Does not collapse whitespace.

Returns:
the Datum root's PCDATA content

getPcdata

public java.lang.String getPcdata(boolean collapseWhiteSpace)
Retrieves all the PCDATA content of the wrapped Datum node and its children with the specified whitespace behavior.

Parameters:
collapseWhiteSpace - if true, collapse whitespace
Returns:
the Datum root's PCDATA content

getSafePcdata

public java.lang.String getSafePcdata()
Retrieves a Java String-safe version of the PCDATA content in the wrapped Datum node. Collapses whitespace, removes line feeds, and escapes quote (") characters with backslashes. The returned String can safely be quoted and assigned to a String reference.

Returns:
the String-safe Datum root's PCDATA content

query

public DatumAdapter[] query(java.lang.String query)
Runs the Bellows query and wraps all results in other DatumAdapter objects.

Parameters:
query - a Bellows query
Returns:
the query results

queryPcdata

public java.lang.String[] queryPcdata(java.lang.String query)
Runs the Bellows query, then extracts the PCDATA content from each result node. The returned String array will have one element for each query result.

Parameters:
query - a Bellows query
Returns:
PCDATA content for each query result

queryProperties

public org.writersforge.bellows.util.PropertyName[] queryProperties(java.lang.String query,
                                                                    java.lang.String attribute)
Runs the Bellows query then extracts the Datum property described in attribute from each query result. Wraps each attribute value in a PropertyName object.

Parameters:
query - a Bellows query
attribute - a Datum property key
Returns:
a PropertyName attribute for each query result