org.netbeans.modules.xml.xam.dom
Class DocumentModelAccess

java.lang.Object
  extended by org.netbeans.modules.xml.xam.ModelAccess
      extended by org.netbeans.modules.xml.xam.dom.DocumentModelAccess
Direct Known Subclasses:
ReadOnlyAccess

public abstract class DocumentModelAccess
extends ModelAccess

Access to the underlying structure of the model.

Author:
Nam Nguyen

Nested Class Summary
static interface DocumentModelAccess.NodeUpdater
           
 
Constructor Summary
DocumentModelAccess()
           
 
Method Summary
abstract  void addMergeEventHandler(java.beans.PropertyChangeListener l)
          Add/remove merge property change listener.
 void addQNameValuedAttributes(java.util.Map<javax.xml.namespace.QName,java.util.List<javax.xml.namespace.QName>> attributesMap)
          A chance for extensible model to register attributes from extension that have QName values.
abstract  void appendChild(org.w3c.dom.Node node, org.w3c.dom.Node newChild, DocumentModelAccess.NodeUpdater updater)
           
abstract  boolean areSameNodes(org.w3c.dom.Node n1, org.w3c.dom.Node n2)
           
 long dirtyIntervalMillis()
          Returns length in milliseconds since last edit if the model source buffer is dirty, or 0 if the model source is not dirty.
abstract  org.w3c.dom.Element duplicate(org.w3c.dom.Element element)
           
abstract  org.w3c.dom.Node findNode(org.w3c.dom.Document root, java.lang.String xpath)
          Returns node from given xpath expression
abstract  java.util.List<org.w3c.dom.Node> findNodes(org.w3c.dom.Document root, java.lang.String xpath)
          Returns nodes from given xpath expression
abstract  int findPosition(org.w3c.dom.Node node)
           
abstract  java.util.Map<javax.xml.namespace.QName,java.lang.String> getAttributeMap(org.w3c.dom.Element element)
          Returns map of attribute names and string values.
abstract  org.w3c.dom.Element getContainingElement(int position)
           
 java.lang.String getCurrentDocumentText()
           
abstract  org.w3c.dom.Document getDocumentRoot()
           
abstract  ElementIdentity getElementIdentity()
          Returns element identity helper.
abstract  int getElementIndexOf(org.w3c.dom.Node parent, org.w3c.dom.Element child)
           
 AbstractDocumentModel getModel()
          Returns the associated document model.
abstract  org.w3c.dom.Node getNewEventNode(java.beans.PropertyChangeEvent evt)
           
abstract  org.w3c.dom.Node getNewEventParentNode(java.beans.PropertyChangeEvent evt)
           
abstract  org.w3c.dom.Node getOldEventNode(java.beans.PropertyChangeEvent evt)
           
abstract  org.w3c.dom.Node getOldEventParentNode(java.beans.PropertyChangeEvent evt)
           
abstract  java.util.List<org.w3c.dom.Element> getPathFromRoot(org.w3c.dom.Document root, org.w3c.dom.Element node)
          Returns path from given element to given root; or null if the node is not in tree.
abstract  java.lang.String getXmlFragment(org.w3c.dom.Element element)
           
 java.lang.String getXmlFragmentInclusive(org.w3c.dom.Element element)
           
abstract  java.lang.String getXPath(org.w3c.dom.Document root, org.w3c.dom.Element node)
          Returns xpath expression of given element.
abstract  void insertBefore(org.w3c.dom.Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild, DocumentModelAccess.NodeUpdater updater)
           
 java.lang.String lookupNamespaceURI(org.w3c.dom.Node node, java.util.List<org.w3c.dom.Node> pathToRoot)
           
 java.lang.String normalizeUndefinedAttributeValue(java.lang.String value)
          Provide a uniform return value for undefined attribute values.
abstract  void removeAttribute(org.w3c.dom.Element element, java.lang.String name, DocumentModelAccess.NodeUpdater updater)
           
abstract  void removeChild(org.w3c.dom.Node node, org.w3c.dom.Node child, DocumentModelAccess.NodeUpdater updater)
           
 void removeChildren(org.w3c.dom.Node node, java.util.Collection<org.w3c.dom.Node> children, DocumentModelAccess.NodeUpdater updater)
           
abstract  void removeMergeEventHandler(java.beans.PropertyChangeListener l)
           
 void reorderChildren(org.w3c.dom.Element element, int[] newIndexes, DocumentModelAccess.NodeUpdater updater)
          Reorder children list of an element.
abstract  void replaceChild(org.w3c.dom.Node node, org.w3c.dom.Node child, org.w3c.dom.Node newChild, DocumentModelAccess.NodeUpdater updater)
           
abstract  void setAttribute(org.w3c.dom.Element element, java.lang.String name, java.lang.String value, DocumentModelAccess.NodeUpdater updater)
           
 void setDirty()
           
abstract  void setPrefix(org.w3c.dom.Element node, java.lang.String prefix)
           
abstract  void setText(org.w3c.dom.Element element, java.lang.String val, DocumentModelAccess.NodeUpdater updater)
           
abstract  void setXmlFragment(org.w3c.dom.Element element, java.lang.String text, DocumentModelAccess.NodeUpdater updater)
          Sets the XML fragment text for given element content.
 void unsetDirty()
          Unset mark for dirty source buffer.
 
Methods inherited from class org.netbeans.modules.xml.xam.ModelAccess
addUndoableEditListener, finishUndoRedo, flush, isAutoSync, prepareForUndoRedo, prepareSync, removeUndoableEditListener, setAutoSync, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentModelAccess

public DocumentModelAccess()
Method Detail

getDocumentRoot

public abstract org.w3c.dom.Document getDocumentRoot()

getModel

public AbstractDocumentModel getModel()
Returns the associated document model. Subclass should override.


areSameNodes

public abstract boolean areSameNodes(org.w3c.dom.Node n1,
                                     org.w3c.dom.Node n2)

getElementIndexOf

public abstract int getElementIndexOf(org.w3c.dom.Node parent,
                                      org.w3c.dom.Element child)
Returns:
child element index in the children list of given parent.

setAttribute

public abstract void setAttribute(org.w3c.dom.Element element,
                                  java.lang.String name,
                                  java.lang.String value,
                                  DocumentModelAccess.NodeUpdater updater)

removeAttribute

public abstract void removeAttribute(org.w3c.dom.Element element,
                                     java.lang.String name,
                                     DocumentModelAccess.NodeUpdater updater)

appendChild

public abstract void appendChild(org.w3c.dom.Node node,
                                 org.w3c.dom.Node newChild,
                                 DocumentModelAccess.NodeUpdater updater)

insertBefore

public abstract void insertBefore(org.w3c.dom.Node node,
                                  org.w3c.dom.Node newChild,
                                  org.w3c.dom.Node refChild,
                                  DocumentModelAccess.NodeUpdater updater)

removeChild

public abstract void removeChild(org.w3c.dom.Node node,
                                 org.w3c.dom.Node child,
                                 DocumentModelAccess.NodeUpdater updater)

removeChildren

public void removeChildren(org.w3c.dom.Node node,
                           java.util.Collection<org.w3c.dom.Node> children,
                           DocumentModelAccess.NodeUpdater updater)

replaceChild

public abstract void replaceChild(org.w3c.dom.Node node,
                                  org.w3c.dom.Node child,
                                  org.w3c.dom.Node newChild,
                                  DocumentModelAccess.NodeUpdater updater)

setText

public abstract void setText(org.w3c.dom.Element element,
                             java.lang.String val,
                             DocumentModelAccess.NodeUpdater updater)

setPrefix

public abstract void setPrefix(org.w3c.dom.Element node,
                               java.lang.String prefix)

findPosition

public abstract int findPosition(org.w3c.dom.Node node)

getContainingElement

public abstract org.w3c.dom.Element getContainingElement(int position)

duplicate

public abstract org.w3c.dom.Element duplicate(org.w3c.dom.Element element)

reorderChildren

public void reorderChildren(org.w3c.dom.Element element,
                            int[] newIndexes,
                            DocumentModelAccess.NodeUpdater updater)
Reorder children list of an element.

Parameters:
element - the parent element with children to be reordered
newIndexes - array indexed by existing indexes, with values representing reordered indexes
updater - the component wrapper of the given element.

getXmlFragmentInclusive

public java.lang.String getXmlFragmentInclusive(org.w3c.dom.Element element)

getXmlFragment

public abstract java.lang.String getXmlFragment(org.w3c.dom.Element element)
Returns:
XML fragment text of the given element content.

getCurrentDocumentText

public java.lang.String getCurrentDocumentText()

setXmlFragment

public abstract void setXmlFragment(org.w3c.dom.Element element,
                                    java.lang.String text,
                                    DocumentModelAccess.NodeUpdater updater)
                             throws java.io.IOException
Sets the XML fragment text for given element content. The XML fragment will be parsed and the resulting nodes will replace the current children of this documentation element.

Parameters:
element - element to set content to.
text - XML fragment text.
Throws:
java.io.IOException - if the fragment text is not well-form.

getAttributeMap

public abstract java.util.Map<javax.xml.namespace.QName,java.lang.String> getAttributeMap(org.w3c.dom.Element element)
Returns map of attribute names and string values.


getPathFromRoot

public abstract java.util.List<org.w3c.dom.Element> getPathFromRoot(org.w3c.dom.Document root,
                                                                    org.w3c.dom.Element node)
Returns path from given element to given root; or null if the node is not in tree.


getXPath

public abstract java.lang.String getXPath(org.w3c.dom.Document root,
                                          org.w3c.dom.Element node)
Returns xpath expression of given element.


normalizeUndefinedAttributeValue

public java.lang.String normalizeUndefinedAttributeValue(java.lang.String value)
Provide a uniform return value for undefined attribute values. XDM supports full fidelty so this deviates slightly from the DOM specification in that the return value for an undefined attribute is null instead of "". This method normalizes the return value for an undefined element to null.


findNode

public abstract org.w3c.dom.Node findNode(org.w3c.dom.Document root,
                                          java.lang.String xpath)
Returns node from given xpath expression


findNodes

public abstract java.util.List<org.w3c.dom.Node> findNodes(org.w3c.dom.Document root,
                                                           java.lang.String xpath)
Returns nodes from given xpath expression


getElementIdentity

public abstract ElementIdentity getElementIdentity()
Returns element identity helper.


addMergeEventHandler

public abstract void addMergeEventHandler(java.beans.PropertyChangeListener l)
Add/remove merge property change listener.


removeMergeEventHandler

public abstract void removeMergeEventHandler(java.beans.PropertyChangeListener l)

getOldEventNode

public abstract org.w3c.dom.Node getOldEventNode(java.beans.PropertyChangeEvent evt)

getOldEventParentNode

public abstract org.w3c.dom.Node getOldEventParentNode(java.beans.PropertyChangeEvent evt)

getNewEventNode

public abstract org.w3c.dom.Node getNewEventNode(java.beans.PropertyChangeEvent evt)

getNewEventParentNode

public abstract org.w3c.dom.Node getNewEventParentNode(java.beans.PropertyChangeEvent evt)

lookupNamespaceURI

public java.lang.String lookupNamespaceURI(org.w3c.dom.Node node,
                                           java.util.List<org.w3c.dom.Node> pathToRoot)

dirtyIntervalMillis

public long dirtyIntervalMillis()
Description copied from class: ModelAccess
Returns length in milliseconds since last edit if the model source buffer is dirty, or 0 if the model source is not dirty. Class of domain model implementations should provide override.

Overrides:
dirtyIntervalMillis in class ModelAccess

setDirty

public void setDirty()

unsetDirty

public void unsetDirty()
Description copied from class: ModelAccess
Unset mark for dirty source buffer.

Overrides:
unsetDirty in class ModelAccess

addQNameValuedAttributes

public void addQNameValuedAttributes(java.util.Map<javax.xml.namespace.QName,java.util.List<javax.xml.namespace.QName>> attributesMap)
A chance for extensible model to register attributes from extension that have QName values. This will help with refactoring of namespace prefixes that happen during namespace consolidation when a new component is added to model. Note: should be overridden by implementation as necessary.