org.writersforge.catalan.transform.rule
Class QueryRule

java.lang.Object
  |
  +--org.writersforge.catalan.transform.rule.QueryRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
ConvertRule, CopyRule, CreateRule, RenameRule

public abstract class QueryRule
extends java.lang.Object
implements Rule

Starting point for all Rule implementations which rely on a Bellows query to select which Datum objects to operate on. All QueryRule implementations must expect to operate on zero, one, or many targets, depending on the query results on the particular Datum tree passed into the process() method.

Author:
jsheets

Constructor Summary
QueryRule(java.lang.String query, java.lang.String propertyName)
          Creates a new instance of QueryRule for Datum or Datum property operations.
 
Method Summary
 java.lang.String getPropertyName()
          Getter for property propertyName, the optional Datum property name inside the content.
 java.lang.String getQuery()
          Getter for property query, the Bellows query for selecting target content.
 boolean isPropertyRule()
          Determines if this Rule affects Datum objects or Datum properties.
protected  void postProcessTargets(org.writersforge.bellows.Datum[] targets)
          Performs any cleanup or deletion on the source Datum objects after all normal processing is finished.
 org.writersforge.bellows.Datum process(org.writersforge.bellows.Datum content)
          Applies changes to the supplied content.
protected abstract  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 abstract  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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryRule

public QueryRule(java.lang.String query,
                 java.lang.String propertyName)
Creates a new instance of QueryRule for Datum or Datum property operations. Uses the query to gather the data to transform. If propertyName is null, the Rule should act upon the Datum itself, not the property.

Parameters:
query - the Bellows query to select target content
propertyName - the name of the Datum property to transform, or null for Datum transforms
Method Detail

getQuery

public java.lang.String getQuery()
Getter for property query, the Bellows query for selecting target content.

Returns:
Value of property query.

getPropertyName

public java.lang.String getPropertyName()
Getter for property propertyName, the optional Datum property name inside the content. If the property name is null, the Rule should act upon the Datum itself, not the Datum property.

Returns:
Value of property propertyName.

isPropertyRule

public boolean isPropertyRule()
Determines if this Rule affects Datum objects or Datum properties.

Returns:
true if this Rule affects Datum properties, or false if it affects Datum objects

process

public org.writersforge.bellows.Datum process(org.writersforge.bellows.Datum content)
Applies changes to the supplied content. If the Rule decides not to make any changes, it can return the original content, untouched.

Specified by:
process in interface Rule
Parameters:
content - a Datum object to apply the Rule to
Returns:
the transformed content

processDatum

protected abstract 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.

Parameters:
content - the root of the processing tree
target - a Datum object to apply the Rule to
Returns:
the transformed content

processProperty

protected abstract 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.

Parameters:
content - the root of the processing tree
target - a Datum object to apply the Rule to
Returns:
the transformed content

postProcessTargets

protected void postProcessTargets(org.writersforge.bellows.Datum[] targets)
Performs any cleanup or deletion on the source Datum objects after all normal processing is finished.

Parameters:
targets - an array of individual Datum objects to post-process