public class XDMModel extends Object
Modifier and Type | Class and Description |
---|---|
static class |
XDMModel.Status
This represents the status of the XDM Model.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_INDENT |
static String |
PROP_ADDED
Indicates node added
|
static String |
PROP_DELETED
Indicates node deleted
|
static String |
PROP_MODIFIED
Indicates node modified
|
Constructor and Description |
---|
XDMModel(ModelSource ms) |
Modifier and Type | Method and Description |
---|---|
List<Node> |
add(Node parent,
Node node,
int offset)
This api adds given node to given parent at given index.
|
void |
addPropertyChangeListener(PropertyChangeListener pcl)
This api adds a property change listener.
|
void |
addUndoableEditListener(UndoableEditListener l)
This api adds an undoable edit listener.
|
List<Node> |
append(Node parent,
Node node)
This api adds given node to given parent at the end.
|
List<Node> |
delete(Node n)
This api deletes given node from a tree.
|
void |
flush()
This api flushes the changes made to the model to the underlying document.
|
Document |
getCurrentDocument()
This api returns the current document in the model, regardless of the state.
|
String |
getCurrentDocumentText() |
Document |
getDocument()
This api returns the latest stable document in the model.
|
ElementIdentity |
getElementIdentity() |
String |
getIndentation() |
int |
getNextNodeId()
This api keeps track of the nodes created in this model.
|
Map<QName,List<QName>> |
getQNameValuedAttributes() |
XDMModel.Status |
getStatus()
This returns the statuc of the model.
|
List<Node> |
insertBefore(Node parent,
Node node,
Node refChild)
This api adds given node to given parent before given ref node.
|
void |
mergeDiff(List<Difference> diffs) |
List<Node> |
modify(Node oldValue,
Node newValue)
This api replaces given old node with given new node.
|
void |
prepareSync() |
List<Node> |
remove(Node parent,
Node child)
This api deletes given node from a given parent node.
|
List<Node> |
removeAttribute(Element element,
String name)
This api removes an attribute given name and value of a given element node.
|
List<Node> |
removeChildNodes(Node parent,
Collection<Node> toRemove)
This api deletes given node from a given parent node.
|
void |
removePropertyChangeListener(PropertyChangeListener pcl)
This api removes a property change listener.
|
void |
removeUndoableEditListener(UndoableEditListener l)
This api removes an undoable edit listener.
|
List<Node> |
reorder(Node parent,
Node n,
int index)
This api changes index of the given node.
|
List<Node> |
reorderChildren(Node parent,
int[] permutation)
This api changes indexes of the given node children.
|
List<Node> |
replaceChild(Node parent,
Node child,
Node newChild) |
List<Node> |
setAttribute(Element element,
String name,
String value)
This api sets an attribute given name and value of a given element node.
|
void |
setDocument(Document newDoc) |
void |
setElementIdentity(ElementIdentity eID) |
void |
setIndentation(String indent) |
void |
setPretty(boolean print) |
void |
setQNameValuedAttributes(Map<QName,List<QName>> attrsByElement)
Set/get mapping of QName-valued attributes by element.
|
List<Node> |
setTextValue(Node node,
String value) |
List<Node> |
setXmlFragmentText(Element node,
String value) |
void |
sync()
This api syncs the model with the underlying swing document.
|
public static final String PROP_MODIFIED
public static final String PROP_DELETED
public static final String PROP_ADDED
public static final String DEFAULT_INDENT
public XDMModel(ModelSource ms)
ms
- requires an instance of org.netbeans.editor.BaseDocument to be
available in the lookup;public String getIndentation()
public void setIndentation(String indent)
public void flush()
public void sync() throws IOException
IOException
public void prepareSync()
public void mergeDiff(List<Difference> diffs)
public List<Node> modify(Node oldValue, Node newValue)
oldValue
- The old node to be replaced.newValue
- The new node.public List<Node> add(Node parent, Node node, int offset)
parent
- The parent node to which the node is to be added.node
- The node which is to be added.offset
- The index at which the node is to be added.public List<Node> insertBefore(Node parent, Node node, Node refChild)
parent
- The parent node to which the node is to be added.node
- The node which is to be added.refChild
- The ref node (child) of parent node,
before which the node is to be added.public List<Node> append(Node parent, Node node)
parent
- The parent node to which the node is to be appended.node
- The node which is to be appended.public List<Node> delete(Node n)
n
- The node to be deleted.public List<Node> reorder(Node parent, Node n, int index)
n
- The nodes to be moved.index
- the new indexe of the node.public List<Node> reorderChildren(Node parent, int[] permutation)
parent
- The parent node from which the nodes is to be reordered.permutation
- integer array with index represents current index and
value is final index after reorderedpublic List<Node> remove(Node parent, Node child)
parent
- The parent node from which the node is to be deleted.child
- The node to be deleted.public List<Node> removeChildNodes(Node parent, Collection<Node> toRemove)
parent
- The parent node from which the node is to be deleted.toRemove
- collection of node to be deleted.public List<Node> setAttribute(Element element, String name, String value)
element
- The element of which the attribute to be set.name
- The name of the attribute to be set.value
- The value of the attribute to be set.public List<Node> removeAttribute(Element element, String name)
element
- The element of which the attribute to be removed.name
- The name of the attribute to be removed.public List<Node> setXmlFragmentText(Element node, String value) throws IOException
IOException
public Document getDocument()
public Document getCurrentDocument()
public String getCurrentDocumentText()
public void setDocument(Document newDoc)
public XDMModel.Status getStatus()
XDMModel.Status
public void addUndoableEditListener(UndoableEditListener l)
l
- The undoable edit listener to be added.public void removeUndoableEditListener(UndoableEditListener l)
l
- The undoable edit listener to be removed.public void addPropertyChangeListener(PropertyChangeListener pcl)
pcl
- The property change listener to be added.public void removePropertyChangeListener(PropertyChangeListener pcl)
pcl
- The property change listener to be removed.public int getNextNodeId()
public void setPretty(boolean print)
public ElementIdentity getElementIdentity()
public void setElementIdentity(ElementIdentity eID)
public void setQNameValuedAttributes(Map<QName,List<QName>> attrsByElement)