org.writersforge.catalan.transform.rule
Class CreateRule

java.lang.Object
  |
  +--org.writersforge.catalan.transform.rule.QueryRule
        |
        +--org.writersforge.catalan.transform.rule.CreateRule
All Implemented Interfaces:
Rule

public class CreateRule
extends QueryRule

A query-based Rule to create new Datum content or a Datum property at the target location(s).

Author:
jsheets

Method Summary
 org.writersforge.bellows.Datum getDatum()
          Getter for property datumName, the name of the new Datum.
 java.lang.Object getPropertyValue()
          Getter for property propertyValue, the value of the new property.
static CreateRule newCreateDatumRule(java.lang.String query, org.writersforge.bellows.Datum datum)
          Creates a new instance of CreateRule for creating new Datum objects.
static CreateRule newCreatePropertyRule(java.lang.String query, java.lang.String propertyName, java.lang.Object propertyValue)
          Creates a new instance of CreateRule for creating new Datum properties.
protected  org.writersforge.bellows.Datum processDatum(org.writersforge.bellows.Datum content, org.writersforge.bellows.Datum target)
          Applies changes to Datum objects in the supplied content.
protected  org.writersforge.bellows.Datum processProperty(org.writersforge.bellows.Datum content, org.writersforge.bellows.Datum target)
          Applies changes to Datum properties in the supplied content.
 
Methods inherited from class org.writersforge.catalan.transform.rule.QueryRule
getPropertyName, getQuery, isPropertyRule, postProcessTargets, process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newCreateDatumRule

public static CreateRule newCreateDatumRule(java.lang.String query,
                                            org.writersforge.bellows.Datum datum)
Creates a new instance of CreateRule for creating new Datum objects. Uses the query to establish the parent nodes to place the new Datum objects in. All new Datum objects will be empty, with no properties defined.

Parameters:
query - the Bellows query to select target content
datum - the source Datum
Returns:
a Rule which will perform the specified task

newCreatePropertyRule

public static CreateRule newCreatePropertyRule(java.lang.String query,
                                               java.lang.String propertyName,
                                               java.lang.Object propertyValue)
Creates a new instance of CreateRule for creating new Datum properties. Uses the query to establish the Datum objects to set the new Datum property in. All new Datum properties are initially set to null, and must be populated by a subsequent Rule.

Parameters:
query - the Bellows query to select target content
propertyName - the name of the new Datum property
propertyValue - the value of the new Datum property
Returns:
a Rule which will perform the specified task

getDatum

public org.writersforge.bellows.Datum getDatum()
Getter for property datumName, the name of the new Datum.

Returns:
Value of property datumName.

getPropertyValue

public java.lang.Object getPropertyValue()
Getter for property propertyValue, the value of the new property.

Returns:
Value of property propertyValue.

processDatum

protected org.writersforge.bellows.Datum processDatum(org.writersforge.bellows.Datum content,
                                                      org.writersforge.bellows.Datum target)
Applies changes to Datum objects in the supplied content. If the Rule decides not to make any changes, it can return the original content, untouched.

Specified by:
processDatum in class QueryRule
Parameters:
content - the root of the processing tree
target - a Datum object to apply the Rule to
Returns:
the transformed content

processProperty

protected org.writersforge.bellows.Datum processProperty(org.writersforge.bellows.Datum content,
                                                         org.writersforge.bellows.Datum target)
Applies changes to Datum properties in the supplied content. If the Rule decides not to make any changes, it can return the original content, untouched.

Specified by:
processProperty in class QueryRule
Parameters:
content - the root of the processing tree
target - a Datum object to apply the Rule to
Returns:
the transformed content