com.sun.xml.ws.policy.sourcemodel
Class ModelNode

java.lang.Object
  extended by com.sun.xml.ws.policy.sourcemodel.ModelNode
All Implemented Interfaces:
Cloneable, Iterable<ModelNode>

public final class ModelNode
extends Object
implements Iterable<ModelNode>, Cloneable

The general representation of a single node within a PolicySourceModel instance. The model node is created via factory methods of the PolicySourceModel instance. It may also hold AssertionData instance in case its type is ModelNode.Type.ASSERTION.

Author:
Marek Potociar

Nested Class Summary
static class ModelNode.Type
          Policy source model node type enumeration
 
Method Summary
 int childrenSize()
          Returns the number of child policy source model nodes.
protected  ModelNode clone()
           
 ModelNode createChildAllNode()
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 ModelNode createChildAssertionNode()
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 ModelNode createChildAssertionNode(AssertionData nodeData)
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 ModelNode createChildAssertionParameterNode()
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 ModelNode createChildExactlyOneNode()
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 ModelNode createChildPolicyNode()
          Factory method that creates new policy source model node as specified by a factory method name and input parameters.
 boolean equals(Object obj)
          An Object.equals(Object obj) method override.
 AssertionData getNodeData()
          Returns the data for this policy source model node (if any).
 PolicySourceModel getParentModel()
          Returns the parent policy source model that contains this model node.
 ModelNode getParentNode()
          Returns the parent referenced by this policy source model node.
 ModelNode.Type getType()
          Returns the type of this policy source model node.
 boolean hasChildren()
          Returns true if the node has at least one child node.
 int hashCode()
          An Object.hashCode() method override.
 Iterator<ModelNode> iterator()
          Iterates through all child nodes.
 AssertionData setOrReplaceNodeData(AssertionData newData)
          The method may be used to set or replace assertion data set for this node.
 String toString()
          Returns a string representation of the object.
 StringBuffer toString(int indentLevel, StringBuffer buffer)
          A helper method that appends indented string representation of this instance to the input string buffer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createChildPolicyNode

public ModelNode createChildPolicyNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Returns:
A new Policy node.

createChildAllNode

public ModelNode createChildAllNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Returns:
A new All node.

createChildExactlyOneNode

public ModelNode createChildExactlyOneNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Returns:
A new ExactlyOne node.

createChildAssertionNode

public ModelNode createChildAssertionNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Returns:
A new policy assertion node.

createChildAssertionNode

public ModelNode createChildAssertionNode(AssertionData nodeData)
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Parameters:
nodeData - The policy assertion data.
Returns:
A new policy assertion node.

createChildAssertionParameterNode

public ModelNode createChildAssertionParameterNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters. Each node is created with respect to its enclosing policy source model.

Returns:
A new assertion parameter node.

getParentModel

public PolicySourceModel getParentModel()
Returns the parent policy source model that contains this model node.

Returns:
the parent policy source model

getType

public ModelNode.Type getType()
Returns the type of this policy source model node.

Returns:
actual type of this policy source model node

getParentNode

public ModelNode getParentNode()
Returns the parent referenced by this policy source model node.

Returns:
current parent of this policy source model node or null if the node does not have a parent currently.

getNodeData

public AssertionData getNodeData()
Returns the data for this policy source model node (if any). The model node data are expected to be not null only in case the type of this node is ASSERTION or ASSERTION_PARAMETER_NODE.

Returns:
the data of this policy source model node or null if the node does not have any data associated to it attached.

setOrReplaceNodeData

public AssertionData setOrReplaceNodeData(AssertionData newData)
The method may be used to set or replace assertion data set for this node. If there are assertion data set already, those are replaced by a new reference and eventualy returned from the method.

This method is supported only in case this model node instance's type is ASSERTION or ASSERTION_PARAMETER_NODE. If used from other node types, an exception is thrown.

Parameters:
newData - new assertion data to be set.
Returns:
old and replaced assertion data if any or null otherwise.
Throws:
UnsupportedOperationException - in case this method is called on nodes of type other than ASSERTION or ASSERTION_PARAMETER_NODE

childrenSize

public int childrenSize()
Returns the number of child policy source model nodes. If this model node contains more than Integer.MAX_VALUE children, returns Integer.MAX_VALUE.

Returns:
the number of children of this node.

hasChildren

public boolean hasChildren()
Returns true if the node has at least one child node.

Returns:
true if the node has at least one child node, false otherwise.

iterator

public Iterator<ModelNode> iterator()
Iterates through all child nodes.

Specified by:
iterator in interface Iterable<ModelNode>
Returns:
An iterator for the child nodes

equals

public boolean equals(Object obj)
An Object.equals(Object obj) method override. Method ignores the parent source model. It means that two model nodes may be the same even if they belong to different models.

If parent model comparison is desired, it must be accomplished separately. To perform that, the reference equality test is sufficient (nodeA.getParentModel() == nodeB.getParentModel()), since all model nodes are created for specific model instances.

Overrides:
equals in class Object

hashCode

public int hashCode()
An Object.hashCode() method override.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object.

Overrides:
toString in class Object
Returns:
a string representation of the object.

toString

public StringBuffer toString(int indentLevel,
                             StringBuffer buffer)
A helper method that appends indented string representation of this instance to the input string buffer.

Parameters:
indentLevel - indentation level to be used.
buffer - buffer to be used for appending string representation of this instance
Returns:
modified buffer containing new string representation of the instance

clone

protected ModelNode clone()
                   throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.