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

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

public class ReadOnlyAccess
extends DocumentModelAccess

Default document model access with limited support for read-only operations.

Author:
Nam Nguyen

Nested Class Summary
static class ReadOnlyAccess.Provider
           
 
Nested classes/interfaces inherited from class org.netbeans.modules.xml.xam.dom.DocumentModelAccess
DocumentModelAccess.NodeUpdater
 
Constructor Summary
ReadOnlyAccess(AbstractDocumentModel model)
          Creates a new instance of PlainDOMAccess
 
Method Summary
 void addMergeEventHandler(java.beans.PropertyChangeListener l)
          Add/remove merge property change listener.
 void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
           
 void appendChild(org.w3c.dom.Node node, org.w3c.dom.Node newChild, DocumentModelAccess.NodeUpdater updater)
           
 boolean areSameNodes(org.w3c.dom.Node n1, org.w3c.dom.Node n2)
           
 org.w3c.dom.Element duplicate(org.w3c.dom.Element element)
           
protected  org.w3c.dom.Element findElement(int position, java.lang.String buf, org.w3c.dom.Element base, int basePos)
           
 org.w3c.dom.Node findNode(org.w3c.dom.Document root, java.lang.String xpath)
          Returns node from given xpath expression
 java.util.List<org.w3c.dom.Node> findNodes(org.w3c.dom.Document root, java.lang.String xpath)
          Returns nodes from given xpath expression
 int findPosition(org.w3c.dom.Node node)
           
 void finishUndoRedo()
           
 void flush()
           
 java.util.Map<javax.xml.namespace.QName,java.lang.String> getAttributeMap(org.w3c.dom.Element element)
          Returns map of attribute names and string values.
 org.w3c.dom.Element getContainingElement(int position)
           
 org.w3c.dom.Document getDocumentRoot()
           
 ElementIdentity getElementIdentity()
          Returns element identity helper.
 int getElementIndexOf(org.w3c.dom.Node parent, org.w3c.dom.Element child)
           
 AbstractDocumentModel getModel()
          Returns the associated document model.
 org.w3c.dom.Node getNewEventNode(java.beans.PropertyChangeEvent evt)
           
 org.w3c.dom.Node getNewEventParentNode(java.beans.PropertyChangeEvent evt)
           
 org.w3c.dom.Node getOldEventNode(java.beans.PropertyChangeEvent evt)
           
 org.w3c.dom.Node getOldEventParentNode(java.beans.PropertyChangeEvent evt)
           
 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.
 java.lang.String getXmlFragment(org.w3c.dom.Element element)
           
 java.lang.String getXPath(org.w3c.dom.Document root, org.w3c.dom.Element node)
          Returns xpath expression of given element.
 void insertBefore(org.w3c.dom.Node node, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild, DocumentModelAccess.NodeUpdater updater)
           
static boolean isXmlnsAttribute(org.w3c.dom.Attr attr)
           
 java.lang.String normalizeUndefinedAttributeValue(java.lang.String value)
          Provide a uniform return value for undefined attribute values.
 void prepareForUndoRedo()
           
 void removeAttribute(org.w3c.dom.Element element, java.lang.String name, DocumentModelAccess.NodeUpdater updater)
           
 void removeChild(org.w3c.dom.Node node, org.w3c.dom.Node child, DocumentModelAccess.NodeUpdater updater)
           
 void removeMergeEventHandler(java.beans.PropertyChangeListener l)
           
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
           
 void replaceChild(org.w3c.dom.Node node, org.w3c.dom.Node child, org.w3c.dom.Node newChild, DocumentModelAccess.NodeUpdater updater)
           
 void setAttribute(org.w3c.dom.Element element, java.lang.String name, java.lang.String value, DocumentModelAccess.NodeUpdater updater)
           
 void setPrefix(org.w3c.dom.Element node, java.lang.String prefix)
           
 void setText(org.w3c.dom.Element element, java.lang.String val, DocumentModelAccess.NodeUpdater updater)
           
 void setXmlFragment(org.w3c.dom.Element element, java.lang.String text, DocumentModelAccess.NodeUpdater updater)
          Sets the XML fragment text for given element content.
 Model.State sync()
           
 
Methods inherited from class org.netbeans.modules.xml.xam.dom.DocumentModelAccess
addQNameValuedAttributes, dirtyIntervalMillis, getCurrentDocumentText, getXmlFragmentInclusive, lookupNamespaceURI, removeChildren, reorderChildren, setDirty, unsetDirty
 
Methods inherited from class org.netbeans.modules.xml.xam.ModelAccess
isAutoSync, prepareSync, setAutoSync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyAccess

public ReadOnlyAccess(AbstractDocumentModel model)
Creates a new instance of PlainDOMAccess

Method Detail

getModel

public AbstractDocumentModel getModel()
Description copied from class: DocumentModelAccess
Returns the associated document model. Subclass should override.

Overrides:
getModel in class DocumentModelAccess

setPrefix

public void setPrefix(org.w3c.dom.Element node,
                      java.lang.String prefix)
Specified by:
setPrefix in class DocumentModelAccess

getPathFromRoot

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

Specified by:
getPathFromRoot in class DocumentModelAccess

getXPath

public java.lang.String getXPath(org.w3c.dom.Document root,
                                 org.w3c.dom.Element node)
Description copied from class: DocumentModelAccess
Returns xpath expression of given element.

Specified by:
getXPath in class DocumentModelAccess

getAttributeMap

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

Specified by:
getAttributeMap in class DocumentModelAccess

isXmlnsAttribute

public static boolean isXmlnsAttribute(org.w3c.dom.Attr attr)

duplicate

public org.w3c.dom.Element duplicate(org.w3c.dom.Element element)
Specified by:
duplicate in class DocumentModelAccess

getXmlFragment

public java.lang.String getXmlFragment(org.w3c.dom.Element element)
Specified by:
getXmlFragment in class DocumentModelAccess
Returns:
XML fragment text of the given element content.

setXmlFragment

public void setXmlFragment(org.w3c.dom.Element element,
                           java.lang.String text,
                           DocumentModelAccess.NodeUpdater updater)
                    throws java.io.IOException
Description copied from class: DocumentModelAccess
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.

Specified by:
setXmlFragment in class DocumentModelAccess
Parameters:
element - element to set content to.
text - XML fragment text.
Throws:
java.io.IOException - if the fragment text is not well-form.

setText

public void setText(org.w3c.dom.Element element,
                    java.lang.String val,
                    DocumentModelAccess.NodeUpdater updater)
Specified by:
setText in class DocumentModelAccess

removeAttribute

public void removeAttribute(org.w3c.dom.Element element,
                            java.lang.String name,
                            DocumentModelAccess.NodeUpdater updater)
Specified by:
removeAttribute in class DocumentModelAccess

setAttribute

public void setAttribute(org.w3c.dom.Element element,
                         java.lang.String name,
                         java.lang.String value,
                         DocumentModelAccess.NodeUpdater updater)
Specified by:
setAttribute in class DocumentModelAccess

findPosition

public int findPosition(org.w3c.dom.Node node)
Specified by:
findPosition in class DocumentModelAccess

getElementIndexOf

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

findNodes

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

Specified by:
findNodes in class DocumentModelAccess

findNode

public org.w3c.dom.Node findNode(org.w3c.dom.Document root,
                                 java.lang.String xpath)
Description copied from class: DocumentModelAccess
Returns node from given xpath expression

Specified by:
findNode in class DocumentModelAccess

getContainingElement

public org.w3c.dom.Element getContainingElement(int position)
Specified by:
getContainingElement in class DocumentModelAccess

findElement

protected org.w3c.dom.Element findElement(int position,
                                          java.lang.String buf,
                                          org.w3c.dom.Element base,
                                          int basePos)

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Specified by:
addUndoableEditListener in class ModelAccess

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Specified by:
removeUndoableEditListener in class ModelAccess

appendChild

public void appendChild(org.w3c.dom.Node node,
                        org.w3c.dom.Node newChild,
                        DocumentModelAccess.NodeUpdater updater)
Specified by:
appendChild in class DocumentModelAccess

insertBefore

public void insertBefore(org.w3c.dom.Node node,
                         org.w3c.dom.Node newChild,
                         org.w3c.dom.Node refChild,
                         DocumentModelAccess.NodeUpdater updater)
Specified by:
insertBefore in class DocumentModelAccess

removeChild

public void removeChild(org.w3c.dom.Node node,
                        org.w3c.dom.Node child,
                        DocumentModelAccess.NodeUpdater updater)
Specified by:
removeChild in class DocumentModelAccess

replaceChild

public void replaceChild(org.w3c.dom.Node node,
                         org.w3c.dom.Node child,
                         org.w3c.dom.Node newChild,
                         DocumentModelAccess.NodeUpdater updater)
Specified by:
replaceChild in class DocumentModelAccess

sync

public Model.State sync()
                 throws java.io.IOException
Specified by:
sync in class ModelAccess
Throws:
java.io.IOException

getElementIdentity

public ElementIdentity getElementIdentity()
Description copied from class: DocumentModelAccess
Returns element identity helper.

Specified by:
getElementIdentity in class DocumentModelAccess

getDocumentRoot

public org.w3c.dom.Document getDocumentRoot()
Specified by:
getDocumentRoot in class DocumentModelAccess

flush

public void flush()
Specified by:
flush in class ModelAccess

finishUndoRedo

public void finishUndoRedo()
Specified by:
finishUndoRedo in class ModelAccess

areSameNodes

public boolean areSameNodes(org.w3c.dom.Node n1,
                            org.w3c.dom.Node n2)
Specified by:
areSameNodes in class DocumentModelAccess

prepareForUndoRedo

public void prepareForUndoRedo()
Specified by:
prepareForUndoRedo in class ModelAccess

addMergeEventHandler

public void addMergeEventHandler(java.beans.PropertyChangeListener l)
Description copied from class: DocumentModelAccess
Add/remove merge property change listener.

Specified by:
addMergeEventHandler in class DocumentModelAccess

removeMergeEventHandler

public void removeMergeEventHandler(java.beans.PropertyChangeListener l)
Specified by:
removeMergeEventHandler in class DocumentModelAccess

getOldEventParentNode

public org.w3c.dom.Node getOldEventParentNode(java.beans.PropertyChangeEvent evt)
Specified by:
getOldEventParentNode in class DocumentModelAccess

getOldEventNode

public org.w3c.dom.Node getOldEventNode(java.beans.PropertyChangeEvent evt)
Specified by:
getOldEventNode in class DocumentModelAccess

getNewEventParentNode

public org.w3c.dom.Node getNewEventParentNode(java.beans.PropertyChangeEvent evt)
Specified by:
getNewEventParentNode in class DocumentModelAccess

getNewEventNode

public org.w3c.dom.Node getNewEventNode(java.beans.PropertyChangeEvent evt)
Specified by:
getNewEventNode in class DocumentModelAccess

normalizeUndefinedAttributeValue

public java.lang.String normalizeUndefinedAttributeValue(java.lang.String value)
Description copied from class: DocumentModelAccess
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.

Overrides:
normalizeUndefinedAttributeValue in class DocumentModelAccess