com.bea.p13n.rules.model
Class RuleSetModel

java.lang.Object
  extended by com.bea.p13n.model.Model
      extended by com.bea.p13n.model.XmlObjectModel
          extended by com.bea.p13n.rules.model.RuleSetModel
All Implemented Interfaces
Serializable, Cloneable

public class RuleSetModel
extends XmlObjectModel

A model representing a set of rules. This will have #RuleModel children.

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
 
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
RuleSetModel()
          Empty constructor.
RuleSetModel(com.bea.p13n.rules.schema.RuleSetDocument.RuleSet rs)
          Constructor from a RuleSet xml object, which should not be null.
 
Method Summary
 RuleModel addCopyRuleModel(RuleModel rm)
          Add a copy fo the specified rule to this rule model.
 void addRuleModel(RuleModel model)
          Add a new rule to this rule set.
protected  boolean childAdded(Model child)
          Override to start listening to changes to child rule names.
protected  boolean childRemoved(Model child)
          Override to stop listening to changes to child rule names.
 void clearCachedData()
          Subclasses need to override this to clear out any cached data.
 Model copy()
          Make a new Model of the same type as this, initialized with the same underlying data, but otherwise unassociated to this one.
 org.apache.xmlbeans.XmlObject createNewXmlObject()
          Create a new, empty rule-set xml object.
protected  boolean determineIsComplete()
          Is this rule-set complete? A rule-set is complete if: All RuleModel children are complete All RuleModel children have unique names
static String findUniqueRuleName(Model container, RuleModel model)
          Find a unique rule name amongst the container's RuleModels for the specified RuleModel (using its name as the basis).
 String getDescription()
          Get the rule set description.
 void initializeNew()
          Initialize this a new, empty ruleset on this model.
 boolean removeRuleModel(int index)
          Remove the specified rule.
 boolean removeRuleModel(RuleModel rm)
          Remove the specified rule.
 void setDescription(String newDesc)
          Set the rule set description.
 void setIsComplete(boolean isComplete)
          Override to set on our ruleset object also.
 void setXmlObject(org.apache.xmlbeans.XmlObject object)
          Set the root xml object for this, which should be a RuleSet.
 
Methods inherited from class com.bea.p13n.model.XmlObjectModel
checkElement, fixQName, getApplicationInstanceUri, getChild, getCopyXmlObject, getDocument, getLocalName, getParent, getQName, getRootXmlObject, isComplete, isNil, preRemove, propertyChanged, removeAllChildren, removeChild, setApplicationInstanceUri, 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, toString, wait, wait, wait
 

Constructor Detail

RuleSetModel

public RuleSetModel()
Empty constructor. The caller should use either setXmlObject(XmlObject) or initializeNew() to initialize the model with a RuleSet.


RuleSetModel

public RuleSetModel(com.bea.p13n.rules.schema.RuleSetDocument.RuleSet rs)
Constructor from a RuleSet xml object, which should not be null.

Method Detail

childAdded

protected boolean childAdded(Model child)
Override to start listening to changes to child rule names.

Overrides:
childAdded in class XmlObjectModel
Parameters
child - the child that was added.
Returns
true if we handled this changed, false if it was ignored.
See Also
XmlObjectModel.setIsComplete(boolean)

childRemoved

protected boolean childRemoved(Model child)
Override to stop listening to changes to child rule names.

Overrides:
childRemoved in class XmlObjectModel
Parameters
child - the child that was removed.
Returns
true if we handled this changed, false if it was ignored.
See Also
XmlObjectModel.setIsComplete(boolean)

setXmlObject

public void setXmlObject(org.apache.xmlbeans.XmlObject object)
                  throws IllegalArgumentException
Set the root xml object for this, which should be a RuleSet.

Throws
IllegalArgumentException - thrown on an invalid object.

clearCachedData

public void clearCachedData()
Description copied from class: XmlObjectModel
Subclasses need to override this to clear out any cached data. This will be automatically called when the root XmlObject or clauseType changes.

Specified by:
clearCachedData in class XmlObjectModel

copy

public Model copy()
Description copied from class: Model
Make a new Model of the same type as this, initialized with the same underlying data, but otherwise unassociated to this one. Listeners will not be propogated to copies.

Specified by:
copy in class Model

createNewXmlObject

public org.apache.xmlbeans.XmlObject createNewXmlObject()
Create a new, empty rule-set xml object.


initializeNew

public void initializeNew()
Initialize this a new, empty ruleset on this model.


getDescription

public String getDescription()
Get the rule set description.

Returns
the description, or null if not set

setDescription

public void setDescription(String newDesc)
Set the rule set description.

Parameters
newDesc - the new description, or null to unset.

addRuleModel

public void addRuleModel(RuleModel model)
Add a new rule to this rule set.


findUniqueRuleName

public static String findUniqueRuleName(Model container,
                                        RuleModel model)
Find a unique rule name amongst the container's RuleModels for the specified RuleModel (using its name as the basis).

Parameters
container - the containing model (whose children should be RuleModels).
model - the model to base the unique name upon.
Returns
the unique name

addCopyRuleModel

public RuleModel addCopyRuleModel(RuleModel rm)
Add a copy fo the specified rule to this rule model.


removeRuleModel

public boolean removeRuleModel(RuleModel rm)
Remove the specified rule.

Parameters
rm - the rule model.
Returns
true if removed, false if not (probably because not a child).

removeRuleModel

public boolean removeRuleModel(int index)
Remove the specified rule.

Parameters
index - the index of rule model in our children.
Returns
true if removed, false if not (probably because not a child).

setIsComplete

public void setIsComplete(boolean isComplete)
Override to set on our ruleset object also.

Overrides:
setIsComplete in class XmlObjectModel

determineIsComplete

protected boolean determineIsComplete()
Is this rule-set complete? A rule-set is complete if:
  1. All RuleModel children are complete
  2. All RuleModel children have unique names

      Overrides:
      determineIsComplete in class XmlObjectModel


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.