org.writersforge.catalan.transform.rule
Class RenameRule

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

public class RenameRule
extends QueryRule

A query-based Rule for changing the Datum type (i.e., the XML element name) or the name of a certain Datum property (i.e., the XML attribute).

Author:
jsheets

Method Summary
 java.lang.String getNewName()
          Getter for property newName.
static RenameRule newRenameDatumRule(java.lang.String query, java.lang.String newName)
          Creates a new instance of RenameRule for changing type names in Datum objects.
static RenameRule newRenamePropertyRule(java.lang.String query, java.lang.String propertyName, java.lang.String newName)
          Creates a new instance of RenameRule for changing the name of 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

newRenameDatumRule

public static RenameRule newRenameDatumRule(java.lang.String query,
                                            java.lang.String newName)
Creates a new instance of RenameRule for changing type names in Datum objects. Uses the query to establish a list of the Datum objects to change to the new type name.

Parameters:
query - the Bellows query to select target content
newName - the new type name of the Datum(s)
Returns:
a Rule object which implements the requested operation

newRenamePropertyRule

public static RenameRule newRenamePropertyRule(java.lang.String query,
                                               java.lang.String propertyName,
                                               java.lang.String newName)
Creates a new instance of RenameRule for changing the name of Datum properties. Uses the query to establish a list of the Datum objects in which to change the property name.

Parameters:
query - the Bellows query to select target content
propertyName - the name of the target Datum property
newName - the new name for the Datum properties
Returns:
a Rule object which implements the requested operation

getNewName

public java.lang.String getNewName()
Getter for property newName.

Returns:
Value of property newName.

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