com.bea.p13n.model
Class XmlObjectModel

java.lang.Object
  extended by com.bea.p13n.model.Model
      extended by com.bea.p13n.model.XmlObjectModel
All Implemented Interfaces
Serializable, Cloneable
Direct Known Subclasses:
CampaignModel, ClauseModel, ContentQueryModel, PlaceholderModel, QueryDefinitionModel, RuleSetModel, ScenarioModel

public abstract class XmlObjectModel
extends Model

A base class for a model that holds onto an XmlObject.

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  org.apache.xmlbeans.XmlObject copyRootXmlObject
          A copy of our root xml object, initialized in preRemove().
protected  String instanceUri
          The opaque instanceUri value.
protected  boolean isComplete
          The is-complete flag for this clause.
 
Fields inherited from class com.bea.p13n.model.Model
childrenModels, docModel, parentModel, roChildrenModels
 
Constructor Summary
XmlObjectModel()
           
 
Method Summary
static void checkElement(org.apache.xmlbeans.XmlObject element, Class cl, String... names)
          Check if the specified element is an instanceof the specified class and has one of the specified local names.
protected  boolean childAdded(Model child)
          Override to determine completeness on change updates.
protected  boolean childRemoved(Model child)
          Override to determine completeness on change updates.
abstract  void clearCachedData()
          Subclasses need to override this to clear out any cached data.
protected  boolean determineIsComplete()
          Determine if this model is complete.
static org.apache.xmlbeans.XmlObject fixQName(org.apache.xmlbeans.XmlObject element, QName newName, boolean removeXsiType)
          Set the specified element's QName.
 String getApplicationInstanceUri()
          Get the application-specific location identifier associated to the model.
static org.apache.xmlbeans.XmlObject getChild(org.apache.xmlbeans.XmlObject parent, int index)
           
protected  org.apache.xmlbeans.XmlObject getCopyXmlObject()
          Get a copy of our root xml object.
static org.apache.xmlbeans.XmlObject getDocument(org.apache.xmlbeans.XmlObject o)
          Get the top-level document of the specified XmlObject.
static String getLocalName(org.apache.xmlbeans.XmlObject o)
          Get the local name of the specified XmlObject.
static org.apache.xmlbeans.XmlObject getParent(org.apache.xmlbeans.XmlObject o)
          Get the parent XmlObject of the specified XmlObject.
static QName getQName(org.apache.xmlbeans.XmlObject o)
          Get the qualified name of the specified XmlObject.
 org.apache.xmlbeans.XmlObject getRootXmlObject()
          Get the root xml object.
 boolean isComplete()
          Tell if this model is complete.
 boolean isNil(org.apache.xmlbeans.XmlObject o)
           
 void preRemove()
          Called prior to being removed.
protected  boolean propertyChanged(String name, Object oldVal, Object newVal)
          Override to determine completeness on change updates.
static int removeAllChildren(org.apache.xmlbeans.XmlObject o)
          Remove all the children elements of the specified object.
static boolean removeChild(org.apache.xmlbeans.XmlObject parent, int index)
          Remove the index'th child of the specified parent.
 void setApplicationInstanceUri(String uri)
          Set an application-specific value to associate the model with a location.
 void setIsComplete()
          Determine completeness and set it.
protected  void setIsComplete(boolean isComplete)
          Manually set the isComplete flag.
protected  void setParent(Model parent)
          Override to set our root xml object to the copyRootXmlObject initialized in preRemove() if parent is null (i.e.
protected  void setRootXmlObject(org.apache.xmlbeans.XmlObject object)
          Set the root xml object of this model.
 
Methods inherited from class com.bea.p13n.model.Model
addChangeListener, addChild, addChild, clone, copy, 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
 

Field Detail

copyRootXmlObject

protected transient org.apache.xmlbeans.XmlObject copyRootXmlObject
A copy of our root xml object, initialized in preRemove(). The root xml object will be set to this after we're removed from our parent. This is to avoid runtime errors from xml beans about being orphaned if we're used after being removed.


isComplete

protected boolean isComplete
The is-complete flag for this clause.


instanceUri

protected String instanceUri
The opaque instanceUri value.

Constructor Detail

XmlObjectModel

public XmlObjectModel()
Method Detail

getApplicationInstanceUri

public String getApplicationInstanceUri()
Get the application-specific location identifier associated to the model.

This is not used by the model apis at all. Applications using the model apis can use this field to save a location identifier on the model, which can used for retrieval or storage.

The portal admin tools framework will set value to the datasync uri of where the model came from. Other clients may not set this field.

Returns
the instance uri, or null if not set.

setApplicationInstanceUri

public void setApplicationInstanceUri(String uri)
Set an application-specific value to associate the model with a location.

Parameters
uri - the instance uri (null for none).
See Also
getApplicationInstanceUri()

setRootXmlObject

protected void setRootXmlObject(org.apache.xmlbeans.XmlObject object)
Set the root xml object of this model. Subclasses of this will publically expose a mechanism for setting the root xml object.


getRootXmlObject

public org.apache.xmlbeans.XmlObject getRootXmlObject()
Get the root xml object.


preRemove

public void preRemove()
Called prior to being removed. This will initialize our copy of the root xml object. Parent's of XmlObjectModel's need to call this method prior to unhooking any xbeans objects or removing any children.

Overrides:
preRemove in class Model

setParent

protected void setParent(Model parent)
Override to set our root xml object to the copyRootXmlObject initialized in preRemove() if parent is null (i.e. we were removed from our parent).

Overrides:
setParent in class Model

getCopyXmlObject

protected org.apache.xmlbeans.XmlObject getCopyXmlObject()
Get a copy of our root xml object. This just returns a copy() for the root xml object. Subclasses can override if they need to make a copy of the root xml object in a different way (some schema classes require copying from the document).


clearCachedData

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


isComplete

public boolean isComplete()
Tell if this model is complete.


setIsComplete

protected void setIsComplete(boolean isComplete)
Manually set the isComplete flag.

This will fire a model change event.

Subclasses can override this method to update our stores (e.g. an attribute on the root xml object) as well.


setIsComplete

public void setIsComplete()
Determine completeness and set it.

See Also
determineIsComplete()

determineIsComplete

protected boolean determineIsComplete()
Determine if this model is complete.

Currently hard-wired to return true. Subclasses need to override with appropriate behavior by inspecting their underlying data.


propertyChanged

protected boolean propertyChanged(String name,
                                  Object oldVal,
                                  Object newVal)
Override to determine completeness on change updates.

Overrides:
propertyChanged in class Model
Parameters
name - the property name.
oldVal - the previous value (null is valid).
newVal - the new value (null is valid).
Returns
true if we handled this changed, false if it was ignored.
See Also
setIsComplete(boolean)

childAdded

protected boolean childAdded(Model child)
Override to determine completeness on change updates.

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

childRemoved

protected boolean childRemoved(Model child)
Override to determine completeness on change updates.

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

getQName

public static QName getQName(org.apache.xmlbeans.XmlObject o)
Get the qualified name of the specified XmlObject.

See Also
XmlCursor.getName()

getLocalName

public static String getLocalName(org.apache.xmlbeans.XmlObject o)
Get the local name of the specified XmlObject.

See Also
getQName(org.apache.xmlbeans.XmlObject)

getParent

public static org.apache.xmlbeans.XmlObject getParent(org.apache.xmlbeans.XmlObject o)
Get the parent XmlObject of the specified XmlObject.


getDocument

public static org.apache.xmlbeans.XmlObject getDocument(org.apache.xmlbeans.XmlObject o)
Get the top-level document of the specified XmlObject.


fixQName

public static org.apache.xmlbeans.XmlObject fixQName(org.apache.xmlbeans.XmlObject element,
                                                     QName newName,
                                                     boolean removeXsiType)
Set the specified element's QName. With substitionGroups, sometimes the localPart of the QName of added children gets lost (and replaced with a typename as the element name). This will correct that.

Parameters
element - the element.
newName - the name the element should be.
removeXsiType - true to remove any xsi:type variable (which xbeans addes when it changes element names).
Returns
the updated XmlObject (might not be element).

isNil

public boolean isNil(org.apache.xmlbeans.XmlObject o)

checkElement

public static void checkElement(org.apache.xmlbeans.XmlObject element,
                                Class cl,
                                String... names)
                         throws IllegalArgumentException
Check if the specified element is an instanceof the specified class and has one of the specified local names.

Parameters
element - the element to check.
cl - the class the element must be (null for no check).
names - the array of local names the element must be (null for no check).
Throws
IllegalArgumentException - if element doesn't match.

removeAllChildren

public static int removeAllChildren(org.apache.xmlbeans.XmlObject o)
Remove all the children elements of the specified object.


removeChild

public static boolean removeChild(org.apache.xmlbeans.XmlObject parent,
                                  int index)
Remove the index'th child of the specified parent.

Returns
true if removed, false if not.

getChild

public static org.apache.xmlbeans.XmlObject getChild(org.apache.xmlbeans.XmlObject parent,
                                                     int index)


Copyright © 2011, Oracle. All rights reserved.