com.bea.p13n.rules.model
Class ClauseModel

java.lang.Object
  extended by com.bea.p13n.model.Model
      extended by com.bea.p13n.model.XmlObjectModel
          extended by com.bea.p13n.rules.model.ClauseModel
All Implemented Interfaces
Serializable, Cloneable
Direct Known Subclasses:
AddContentQueryModel, AddDiscountModel, AddEmailModel, AddSegmentModel, AddToPlaceholderModel, BranchModel, CartContainsCategoryModel, CartContainsSKUModel, CartTotalModel, DateTimeBetweenModel, DateTimeModel, EndScenarioModel, EventTypeModel, MethodCallModel, PropertyToLiteralModel, RuleModel, RuleModel.ActionsModel, RuleModel.ConditionsModel, SegmentModel, UnrecognizedClauseModel, VariableBindingModel

public abstract class ClauseModel
extends XmlObjectModel

Base class for all models that can be clauses in xml.

This provides support for initializing the model from an XmlObject and for maintain state about clause completeness.

After constructing an instance of a ClauseModel, one of the initializing methods setXmlObject(java.lang.String, org.apache.xmlbeans.XmlObject) or initializeNew(java.lang.String) must be called before the ClauseModel will be usefull.

A single ClauseModel subclass may support multiple clause types via the clauseType parameter passed to the initializing methods setXmlObject(java.lang.String, org.apache.xmlbeans.XmlObject) and initializeNew(java.lang.String).

See Also
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bea.p13n.model.Model
Model.ChangeEvent, Model.ChangeListener, Model.ChangeSupport, Model.Debug
 
Field Summary
protected  String clauseType
          The clause type.
 
Fields inherited from class com.bea.p13n.model.XmlObjectModel
copyRootXmlObject, instanceUri, isComplete
 
Fields inherited from class com.bea.p13n.model.Model
childrenModels, docModel, parentModel, roChildrenModels
 
Constructor Summary
ClauseModel()
           
 
Method Summary
static com.bea.p13n.expression.schema.Branch addBranch(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.Branch o)
          Add a operator object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList.
static org.apache.xmlbeans.XmlObject addLiteral(com.bea.p13n.expression.schema.support.OpenAttributeType operator, org.apache.xmlbeans.XmlObject l)
          Add a literal object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList.
static com.bea.p13n.expression.schema.Method addMethod(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.Method m)
          Add a method object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList.
static com.bea.p13n.expression.schema.support.OpenAttributeType addMethodOrOperator(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.support.OpenAttributeType o)
          Add the specified operator or method to the specified operator-type object.
static com.bea.p13n.expression.schema.Operator addOperator(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.Operator o)
          Add a operator object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList.
static com.bea.p13n.expression.schema.VariableDocument.Variable addVariable(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.VariableDocument.Variable v)
          Add a variable object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList.
static com.bea.p13n.expression.schema.VariableBindingDocument.VariableBinding addVariableBinding(com.bea.p13n.expression.schema.support.OpenAttributeType operator, com.bea.p13n.expression.schema.VariableBindingDocument.VariableBinding v)
          Add a variable binding object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList.
 Model copy()
          Make a new copy of this model, initialized with a copy of our root xml object.
abstract  org.apache.xmlbeans.XmlObject createNewXmlObject(String clauseType)
          Create a new, empty root object for the specified clauseType.
 String getClauseType()
          Get the clause type of this clause.
 RuleModel getContainingRuleModel()
          Return the RuleModel which contains this clause.
protected  org.apache.xmlbeans.XmlObject getCopyXmlObject()
          Get a copy of our root xml object.
 void initializeNew(String clauseType)
          Initialize this object with a new, empty root object.
 boolean isInActions()
          Is this clause under a rule's actions.
 boolean isInConditions()
          Is this clause under a rule's conditions.
static boolean isValidTypeAlias(String str)
          Check if the specified str is a valid type-alias value.
static boolean isValidVariableName(String str)
          Check if the specified str is a valid variable name value.
static org.apache.xmlbeans.XmlObject makeSafeCopy(org.apache.xmlbeans.XmlObject root)
          Get a copy of a root xml object.
 void setXmlObject(String clauseType, org.apache.xmlbeans.XmlObject clause)
          Initialize this clause model with a type and a root object.
 String toString()
           
 
Methods inherited from class com.bea.p13n.model.XmlObjectModel
checkElement, childAdded, childRemoved, clearCachedData, determineIsComplete, fixQName, getApplicationInstanceUri, getChild, getDocument, getLocalName, getParent, getQName, getRootXmlObject, isComplete, isNil, preRemove, propertyChanged, removeAllChildren, removeChild, setApplicationInstanceUri, setIsComplete, setIsComplete, setParent, setRootXmlObject
 
Methods inherited from class com.bea.p13n.model.Model
addChangeListener, addChild, addChild, clone, doubleEquals, equals, getChildren, getDebug, getDebug, getDocument, getParent, longEquals, removeChangeListener, removeChild, removeChild, removeEmpties, setDocument
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clauseType

protected String clauseType
The clause type.

Constructor Detail

ClauseModel

public ClauseModel()
Method Detail

setXmlObject

public void setXmlObject(String clauseType,
                         org.apache.xmlbeans.XmlObject clause)
                  throws IllegalArgumentException
Initialize this clause model with a type and a root object.

This will fire ChangeEvents for clauseType and rootXmlObject.

Subclasses should override to call super.setXmlObject() and do any type checking and verification.

It is not expected that ClauseModel's are valid after an call to this method which throws an exception, although the caller could recall this method with valid data.

Parameters
clauseType - the clause type of the clause.
clause - the root xml object of the clause.
Throws
IllegalArgumentException - thrown if the clause is not valid for the ClauseModel or clauseType.

initializeNew

public void initializeNew(String clauseType)
                   throws IllegalArgumentException
Initialize this object with a new, empty root object.

This will call setXmlObject(java.lang.String, org.apache.xmlbeans.XmlObject) with the value from #createXmlObject. Subclasses generally shouldn't need to override this.

Parameters
clauseType - the clause type of the clause.
Throws
IllegalArgumentException - thrown on an unsupported clauseType.
See Also
setXmlObject(java.lang.String, org.apache.xmlbeans.XmlObject), createNewXmlObject(java.lang.String)

createNewXmlObject

public abstract org.apache.xmlbeans.XmlObject createNewXmlObject(String clauseType)
                                                          throws IllegalArgumentException
Create a new, empty root object for the specified clauseType.

Subclasses need to implement this to create an appropriately typed and filled root XmlObject which represents the ClauseModel. The return value from this needs to be accepted from setXmlObject(java.lang.String, org.apache.xmlbeans.XmlObject) for the specified clauseType.

Parameters
clauseType - the clause type of the clause.
Returns
a new, empty initialize root object.
Throws
IllegalArgumentException - thrown on an unsupproted clauseType.

copy

public Model copy()
Make a new copy of this model, initialized with a copy of our root xml object.

Specified by:
copy in class Model

getCopyXmlObject

protected org.apache.xmlbeans.XmlObject getCopyXmlObject()
Get a copy of our root xml object. This is aware of several of the expression schema classes which require special copying.

Overrides:
getCopyXmlObject in class XmlObjectModel
See Also
makeSafeCopy(XmlObject)

makeSafeCopy

public static final org.apache.xmlbeans.XmlObject makeSafeCopy(org.apache.xmlbeans.XmlObject root)
Get a copy of a root xml object. This is aware of several of the expression schema classes which require special copying.

Returns
root the root xml object.

getClauseType

public String getClauseType()
Get the clause type of this clause.


toString

public String toString()
Overrides:
toString in class Object

isInConditions

public boolean isInConditions()
Is this clause under a rule's conditions.


isInActions

public boolean isInActions()
Is this clause under a rule's actions.


getContainingRuleModel

public RuleModel getContainingRuleModel()
Return the RuleModel which contains this clause.

Returns
the rule model, or null.

isValidTypeAlias

public static boolean isValidTypeAlias(String str)
Check if the specified str is a valid type-alias value. type-aliases need to be valid java class identifiers.


isValidVariableName

public static boolean isValidVariableName(String str)
Check if the specified str is a valid variable name value. Variable names need to be a letter or underscore, followed by 0 or more letters, numbers, or underscores.


addMethod

public static com.bea.p13n.expression.schema.Method addMethod(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                              com.bea.p13n.expression.schema.Method m)
Add a method object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList. This might cause a copy of the incoming Method to actually be added instead.

Returns
the Method added to the operator, or null on failure.

addVariable

public static com.bea.p13n.expression.schema.VariableDocument.Variable addVariable(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                                                   com.bea.p13n.expression.schema.VariableDocument.Variable v)
Add a variable object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList. This might cause a copy of the incoming Variable object to be added.

Returns
the Literal that was added, or null on failure.

addVariableBinding

public static com.bea.p13n.expression.schema.VariableBindingDocument.VariableBinding addVariableBinding(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                                                                        com.bea.p13n.expression.schema.VariableBindingDocument.VariableBinding v)
Add a variable binding object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList. This might cause a copy of the incoming Variable object to be added.

Returns
the Literal that was added, or null on failure.

addOperator

public static com.bea.p13n.expression.schema.Operator addOperator(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                                  com.bea.p13n.expression.schema.Operator o)
Add a operator object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList. This might cause a copy of the incoming Operator to be added.

Returns
the Operator that was added, or null on failure.

addBranch

public static com.bea.p13n.expression.schema.Branch addBranch(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                              com.bea.p13n.expression.schema.Branch o)
Add a operator object to the Binary, Conditional, Equality, MultiArg, MultiConditional, or MethodArgumentList. This might cause a copy of the incoming Branch to be added.

Returns
the Branch that was added, or null on failure.

addLiteral

public static org.apache.xmlbeans.XmlObject addLiteral(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                       org.apache.xmlbeans.XmlObject l)
Add a literal object to the Binary, Conditional, Equality, MultiArg, MultiConditional, RelationalOperator, or MethodArgumentList. This might cause a copy of the incoming literal object to be added.

Returns
the Literal that was added, or null on failure.

addMethodOrOperator

public static com.bea.p13n.expression.schema.support.OpenAttributeType addMethodOrOperator(com.bea.p13n.expression.schema.support.OpenAttributeType operator,
                                                                                           com.bea.p13n.expression.schema.support.OpenAttributeType o)
Add the specified operator or method to the specified operator-type object. This might cause a copy of the incoming object to be added.

Returns
the Method or Operator added, or null on failure.


Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.