Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.merlotxml.merlot
Class IDManager  view IDManager download IDManager.java

java.lang.Object
  extended byorg.merlotxml.merlot.IDManager
All Implemented Interfaces:
org.merlotxml.util.xml.DTDConstants, MerlotNodeListener

public class IDManager
extends java.lang.Object
implements org.merlotxml.util.xml.DTDConstants, MerlotNodeListener

Manages ID and IDRef attributes for one XML file. Generic implementation.


Field Summary
protected  java.util.Hashtable _attrLastId
          contains the last index value used for each named node.
private  int _idType
           
private  boolean _isLogOnSet
           
protected  long _lastTimeAssigned
          Used to check that the same millisecond is not assigned twice.
private  java.lang.String _logAttribute
           
private  boolean _logOn
           
protected  MerlotDOMNode _rootNode
           
static int NODE_HIGHEST
           
static int NODE_SMALLEST
           
static int NODE_TIMESTAMP
           
static int NONE
           
static int TIMESTAMP
           
static int USERID_TIMESTAMP
           
 
Fields inherited from interface org.merlotxml.util.xml.DTDConstants
ANY, CDATA, COMMENT, COMMENT_KEY, CONTENT_CONCAT, CONTENT_GROUP, CONTENT_LEAF, CONTENT_ONEMAX, CONTENT_OR, CONTENT_PLUS, CONTENT_SINGLE, CONTENT_STAR, EMPTY, GROUP, ID, IDREF, IDREFS, IMPLIED, NMTOKEN, NMTOKENS, PCDATA, PCDATA_KEY, PROCESSING_INSTRUCTION, PROCESSING_INSTRUCTION_KEY, REQUIRED, TOKEN_GROUP
 
Constructor Summary
IDManager(MerlotDOMNode rootNode)
           
 
Method Summary
 java.util.HashMap collectAttributesOfType(MerlotDOMElement start, int dtdConstant)
           
 java.lang.String getDefaultIdValue(MerlotDOMNode node, java.lang.String attrName)
          Returns a default string ID attribute value for a node.
protected  java.lang.String getDefaultIdValueForIndex(MerlotDOMNode node, java.lang.String attrName, int index)
          Returns a default string ID attribute value for a node according to an integer index.
protected  java.util.Hashtable getIDAttrs(MerlotDOMNode node, MerlotDOMNode targetNode, java.lang.String targetAttrName)
          Returns all the ID attributes in the document which belongs to a node and its children.
 java.util.Hashtable getIDAttrs(MerlotDOMNode targetNode, java.lang.String targetAttrName)
          Returns all the ID attributes in the document.
 int getIdTypeSetting()
           
protected  java.util.Vector getIdValues(MerlotDOMNode targetNode, java.lang.String targetAttrName)
          Returns all the ID attributes in the document.
 java.lang.String getLogAttribute()
           
 boolean getLogLastModifiedSetting()
           
 boolean isDuplicate(org.w3c.dom.Attr idAttr, java.util.Vector idValues)
           
 void logChange(MerlotDOMNode node)
           
 void nodeChanged(MerlotDOMNode parent, int[] indices, MerlotDOMNode[] children)
           
 void nodeDeleted(MerlotDOMNode node)
           
 void nodeInserted(MerlotDOMNode parent, int[] indices, MerlotDOMNode[] children)
          notifies the listener that one or more nodes were inserted under the given parent.
 void nodeRemoved(MerlotDOMNode parent, int[] indices, MerlotDOMNode[] children)
          notifies the listener that one or more nodes under the given parent were deleted.
 java.util.HashMap preventDuplicateId(MerlotDOMElement suspect, java.util.Vector idValues)
           
 void updateIdRefs(MerlotDOMElement root, java.util.HashMap changes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rootNode

protected MerlotDOMNode _rootNode

_attrLastId

protected java.util.Hashtable _attrLastId
contains the last index value used for each named node.


_lastTimeAssigned

protected long _lastTimeAssigned
Used to check that the same millisecond is not assigned twice.


NONE

public static final int NONE
See Also:
Constant Field Values

NODE_SMALLEST

public static final int NODE_SMALLEST
See Also:
Constant Field Values

NODE_HIGHEST

public static final int NODE_HIGHEST
See Also:
Constant Field Values

TIMESTAMP

public static final int TIMESTAMP
See Also:
Constant Field Values

NODE_TIMESTAMP

public static final int NODE_TIMESTAMP
See Also:
Constant Field Values

USERID_TIMESTAMP

public static final int USERID_TIMESTAMP
See Also:
Constant Field Values

_idType

private int _idType

_isLogOnSet

private boolean _isLogOnSet

_logOn

private boolean _logOn

_logAttribute

private java.lang.String _logAttribute
Constructor Detail

IDManager

public IDManager(MerlotDOMNode rootNode)
Method Detail

getIDAttrs

public java.util.Hashtable getIDAttrs(MerlotDOMNode targetNode,
                                      java.lang.String targetAttrName)
Returns all the ID attributes in the document. They are returned in a hashtable with Attr instancies as keys and the parent node as values.


getIDAttrs

protected java.util.Hashtable getIDAttrs(MerlotDOMNode node,
                                         MerlotDOMNode targetNode,
                                         java.lang.String targetAttrName)
Returns all the ID attributes in the document which belongs to a node and its children. Unsaved Ids are not taken into account. They are returned in a hashtable with Attr instancies as keys and the parent node as values.


getIdValues

protected java.util.Vector getIdValues(MerlotDOMNode targetNode,
                                       java.lang.String targetAttrName)
Returns all the ID attributes in the document.


getDefaultIdValue

public java.lang.String getDefaultIdValue(MerlotDOMNode node,
                                          java.lang.String attrName)
Returns a default string ID attribute value for a node. This methods checks if there is no interference with another ID in the document.


getIdTypeSetting

public int getIdTypeSetting()

getDefaultIdValueForIndex

protected java.lang.String getDefaultIdValueForIndex(MerlotDOMNode node,
                                                     java.lang.String attrName,
                                                     int index)
Returns a default string ID attribute value for a node according to an integer index.


nodeInserted

public void nodeInserted(MerlotDOMNode parent,
                         int[] indices,
                         MerlotDOMNode[] children)
notifies the listener that one or more nodes were inserted under the given parent. IDManager is added as a listener in DOMTreeTableAdapter.

Specified by:
nodeInserted in interface MerlotNodeListener

nodeRemoved

public void nodeRemoved(MerlotDOMNode parent,
                        int[] indices,
                        MerlotDOMNode[] children)
notifies the listener that one or more nodes under the given parent were deleted. Their previous indices are given.

Specified by:
nodeRemoved in interface MerlotNodeListener

nodeDeleted

public void nodeDeleted(MerlotDOMNode node)
Specified by:
nodeDeleted in interface MerlotNodeListener

nodeChanged

public void nodeChanged(MerlotDOMNode parent,
                        int[] indices,
                        MerlotDOMNode[] children)
Specified by:
nodeChanged in interface MerlotNodeListener

preventDuplicateId

public java.util.HashMap preventDuplicateId(MerlotDOMElement suspect,
                                            java.util.Vector idValues)

isDuplicate

public boolean isDuplicate(org.w3c.dom.Attr idAttr,
                           java.util.Vector idValues)

updateIdRefs

public void updateIdRefs(MerlotDOMElement root,
                         java.util.HashMap changes)

collectAttributesOfType

public java.util.HashMap collectAttributesOfType(MerlotDOMElement start,
                                                 int dtdConstant)

getLogLastModifiedSetting

public boolean getLogLastModifiedSetting()

getLogAttribute

public java.lang.String getLogAttribute()

logChange

public void logChange(MerlotDOMNode node)