org.vmguys.vmtools.utils
Class AbstractOperation

java.lang.Object
  |
  +--org.vmguys.vmtools.utils.AbstractOperation
Direct Known Subclasses:
AttributeDeleteOperation, AttributeInsertOperation, AttributeModifyOperation, ContentAddOperation, ContentDeleteOperation, ContentModifyOperation, ElementDeleteOperation, ElementRenameOperation, SubtreeDeleteOperation, SubtreeInsertOperation

public abstract class AbstractOperation
extends java.lang.Object

This is the parent class of the various operations that can be put into a CostOps object.


Field Summary
protected  java.lang.String comment
          This is a comment associated with the operation.
protected  DiffElement node
          This is a reference to the Element being operated upon.
 
Constructor Summary
AbstractOperation()
           
 
Method Summary
abstract  org.jdom.Element asElement(org.jdom.Namespace namespace)
          Converts the operation to a JDOM Element, possibly with children, that represents the operation.
abstract  int cost()
          Returns a cost associated with this operation.
 int getNodeNumber()
          Returns the node number this operation is being applied to.
abstract  int getOperationNodeNumber()
          Returns the number of the node this operation is being applied to.
abstract  java.lang.String getOperationXpath()
          Returns the xpath of the node this operation is being applied to.
 java.lang.String getXpath()
          Returns the xpath of the node saved in this operation.
 java.lang.String toString()
           
protected  org.jdom.Element wrapComment(org.jdom.Comment comment)
          Returns an Element containing all the pertinent information about a Comment.
protected  org.jdom.Element wrapMetaData(org.jdom.Element node)
          Looks for any Comments or ProcessingInstruction elements in the tree and replaces them with an Element containing the same information.
protected  org.jdom.Element wrapPI(org.jdom.ProcessingInstruction procInst)
          Returns an Element containing all the pertinent information about a ProcessingInstruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

protected DiffElement node
This is a reference to the Element being operated upon. For the operations that operate upon an Element's content (AddContentOperation, DeleteContentOperation, etc.) this is the Element that contains the content.

comment

protected java.lang.String comment
This is a comment associated with the operation.
Constructor Detail

AbstractOperation

public AbstractOperation()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getNodeNumber

public int getNodeNumber()
Returns the node number this operation is being applied to.

getXpath

public java.lang.String getXpath()
                          throws org.jdom.JDOMException
Returns the xpath of the node saved in this operation.

getOperationXpath

public abstract java.lang.String getOperationXpath()
                                            throws org.jdom.JDOMException

Returns the xpath of the node this operation is being applied to. This may not be the same as the xpath of the node. In some cases the xpath needed for the operation is the node's parent.

NOTE: I think this is too specific to the upper levels. Not all difference representations are going to need the same value here. This should be removed and replaced with some other technique.


getOperationNodeNumber

public abstract int getOperationNodeNumber()

Returns the number of the node this operation is being applied to. This may not be the same as the number of the node. In some cases the number needed for the operation is the node's parent.

NOTE: I think this is too specific to the upper levels. Not all difference representations are going to need the same value here. This should be removed and replaced with some other technique.


cost

public abstract int cost()
Returns a cost associated with this operation. Generally, the more complex the tree that will be returned by asElement, the higher the cost.

asElement

public abstract org.jdom.Element asElement(org.jdom.Namespace namespace)
Converts the operation to a JDOM Element, possibly with children, that represents the operation.

wrapMetaData

protected org.jdom.Element wrapMetaData(org.jdom.Element node)
Looks for any Comments or ProcessingInstruction elements in the tree and replaces them with an Element containing the same information. This ensures they will not be confused with comments or processing instructions.

wrapComment

protected org.jdom.Element wrapComment(org.jdom.Comment comment)
Returns an Element containing all the pertinent information about a Comment.

wrapPI

protected org.jdom.Element wrapPI(org.jdom.ProcessingInstruction procInst)
Returns an Element containing all the pertinent information about a ProcessingInstruction.


Copyright © 2001 VM Systems, Inc. All Rights Reserved.