public abstract class AbstractDocumentComponent<C extends DocumentComponent<C>> extends AbstractComponent<C> implements DocumentComponent2<C>, DocumentModelAccess.NodeUpdater
Modifier and Type | Class and Description |
---|---|
static class |
AbstractDocumentComponent.PrefixAttribute |
TEXT_CONTENT_PROPERTY
Constructor and Description |
---|
AbstractDocumentComponent(AbstractDocumentModel model,
Element e) |
Modifier and Type | Method and Description |
---|---|
void |
addPrefix(String prefix,
String namespace)
Declare prefix for given namespace (without any refactoring action).
|
protected void |
appendChildQuietly(C component,
List<C> children) |
DocumentComponent |
copy(C parent)
Returns a copy of this component for adding into the given parent component.
|
protected Attribute |
createPrefixAttribute(String prefix) |
protected String |
ensureUnique(String prefix,
String namespace)
Returns a unique prefix for the given namespace by appending number from 1 to 100.
|
protected void |
ensureValueNamespaceDeclared(String newNamespace,
String oldNamespace,
String preferredPrefix) |
int |
findAttributePosition(String attributeName)
Returns position of the attribute by the given name, or -1 if not found.
|
C |
findChildComponent(Element e)
Returns child component backed by given element node.
|
C |
findChildComponentByIdentity(Element e) |
protected int |
findDomainIndex(Element e) |
int |
findEndPosition() |
int |
findPosition()
Returns the position of this component in the schema document,
expressed as an offset from the start of the document.
|
protected void |
fireChildAdded() |
protected void |
fireChildRemoved() |
protected void |
firePropertyChange(String propName,
Object oldValue,
Object newValue) |
protected void |
fireValueChanged() |
protected DocumentModelAccess |
getAccess() |
String |
getAnyAttribute(QName attr)
Returns string value of the attribute from different namespace
or null if the attribute is currently undefined.
|
String |
getAttribute(Attribute attr) |
Map<QName,String> |
getAttributeMap() |
protected abstract Object |
getAttributeValueOf(Attribute attr,
String stringValue) |
protected Element |
getChildElement(QName qname) |
protected String |
getChildElementText(QName qname)
Returns value of all text nodes from the child element with given QName.
|
protected AbstractDocumentComponent |
getEffectiveParent() |
protected String |
getLeadingText(C child)
Returns leading text for the child component of the given index.
|
AbstractDocumentModel |
getModel() |
protected String |
getNamespaceURI() |
protected int |
getNodeIndexOf(Node parent,
Node child) |
Element |
getPeer()
Returns the DOM element corresponding to this component.
|
protected String |
getPrefixedName(QName q,
boolean declarePrefix) |
protected String |
getPrefixedName(String namespace,
String localName) |
protected String |
getPrefixedName(String namespace,
String name,
String prefix,
boolean declarePrefix) |
Map<String,String> |
getPrefixes() |
QName |
getQName()
Returns QName of the component.
|
static QName |
getQName(Node n) |
protected String |
getText()
Return text value of this component.
|
protected String |
getText(C child,
boolean leading,
boolean includeComments) |
static String |
getText(Element e) |
protected String |
getTrailingText(C child)
Returns trailing text for the child component of the given index.
|
protected String |
getXmlFragment()
Get the XML fragment text that make up the children the component peer node.
|
String |
getXmlFragmentInclusive()
Get the XML fragment text that make up the peer node.
|
protected void |
insertAtIndexQuietly(C newComponent,
List<C> children,
int index) |
boolean |
isInDocumentModel()
Returns true if the component is part of the document model.
|
String |
lookupNamespaceURI(String prefix) |
String |
lookupNamespaceURI(String prefix,
boolean optimized)
Returns namespace for the given prefix.
|
String |
lookupPrefix(String namespace) |
protected abstract void |
populateChildren(List<C> children) |
boolean |
referencesSameNode(Node n)
Returns true if the node referenced by this component is n.
|
protected void |
removeAttributeQuietly(Element element,
String name) |
protected void |
removeChildQuietly(C component,
List<C> children) |
void |
removePrefix(String prefix)
Remove declared prefix (without refactoring).
|
protected ModelSource |
resolveModel(String hint)
Resolves reference to external models using location hint.
|
void |
setAnyAttribute(QName attr,
String value)
Set string value of the attribute identified by given QName.
|
void |
setAttribute(String eventPropertyName,
Attribute attr,
Object value)
Sets the component attribute String value and fire property change event
with the given property name.
|
protected void |
setAttributeQuietly(Attribute type,
Object newVal) |
protected void |
setChildElementText(String propertyName,
String text,
QName qname)
Set the value of the text node from the child element with given QName.
|
protected void |
setLeadingText(String propName,
String text,
C child)
Set leading text for the child component which position is the given index.
|
protected void |
setQNameAttribute(String propertyName,
QName attr,
String value) |
protected void |
setText(String propertyName,
String text)
Set text value of the component.
|
protected void |
setText(String propName,
String value,
C child,
boolean leading,
boolean includeComments) |
protected void |
setTrailingText(String propName,
String text,
C child)
Set trailing text for the child component which position is the given index.
|
protected void |
setXmlFragment(String propertyName,
String text)
Set text as XML fragment children the component peer node.
|
protected void |
updatePeer(String propertyName,
Element newPeer)
Shared utility for implementation to replace the current peer and
ensure the document tree also get update properly.
|
void |
updateReference(Element element) |
protected <N extends Node> |
updateReference(Element peer,
List<N> updatingPath)
Updates peer node with given peer and the path for context of the update.
|
<N extends Node> |
updateReference(List<N> pathToRoot)
Update all parents with fresh nodes.
|
protected void |
verifyWrite()
This method ensures that a transaction is currently in progress and
that the current thread is able to write the model.
|
addAfter, addBefore, addPropertyChangeListener, appendChild, canPaste, checkChildrenPopulated, checkNullOrDuplicateChild, getChild, getChildren, getChildren, getChildren, getChildrenCount, getParent, insertAtIndex, insertAtIndex, isChildrenInitialized, removeChild, removeComponentListener, removePropertyChangeListener, setChild, setChild, setChildAfter, setChildBefore, setModel, setParent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canPaste, getChildren, getChildren, getChildren, getParent
public AbstractDocumentComponent(AbstractDocumentModel model, Element e)
protected abstract void populateChildren(List<C> children)
populateChildren
in class AbstractComponent<C extends DocumentComponent<C>>
public Element getPeer()
DocumentComponent
getPeer
in interface DocumentComponent<C extends DocumentComponent>
public String getAttribute(Attribute attr)
getAttribute
in interface DocumentComponent<C extends DocumentComponent>
public void setAttribute(String eventPropertyName, Attribute attr, Object value)
setAttribute
in interface DocumentComponent<C extends DocumentComponent>
eventPropertyName
- property name to be used in firing property change event.attr
- attribute namevalue
- for the attribute.protected abstract Object getAttributeValueOf(Attribute attr, String stringValue)
public String getAnyAttribute(QName attr)
attr
- non-null QName represents the attribute name.public void setAnyAttribute(QName attr, String value)
attr
- non-null QName represents the attribute name.value
- string value for the attribute.protected String getPrefixedName(String namespace, String name, String prefix, boolean declarePrefix)
protected String ensureUnique(String prefix, String namespace)
protected void appendChildQuietly(C component, List<C> children)
appendChildQuietly
in class AbstractComponent<C extends DocumentComponent<C>>
protected void insertAtIndexQuietly(C newComponent, List<C> children, int index)
insertAtIndexQuietly
in class AbstractComponent<C extends DocumentComponent<C>>
protected void removeChildQuietly(C component, List<C> children)
removeChildQuietly
in class AbstractComponent<C extends DocumentComponent<C>>
protected String getNamespaceURI()
public String lookupNamespaceURI(String prefix, boolean optimized)
protected String getXmlFragment()
public String getXmlFragmentInclusive()
protected void setXmlFragment(String propertyName, String text) throws IOException
propertyName
- name of property event to firetext
- text value to set to.IOException
- if text is not well-formed.protected void setText(String propertyName, String text)
propertyName
- name of property event to firetext
- text value to set to.protected String getText()
public AbstractDocumentModel getModel()
getModel
in interface Component<C extends DocumentComponent<C>>
getModel
in class AbstractComponent<C extends DocumentComponent<C>>
public boolean referencesSameNode(Node n)
DocumentComponent
referencesSameNode
in interface DocumentComponent<C extends DocumentComponent>
public void updateReference(Element element)
updateReference
in interface DocumentModelAccess.NodeUpdater
public <N extends Node> void updateReference(List<N> pathToRoot)
updateReference
in interface DocumentModelAccess.NodeUpdater
protected <N extends Node> void updateReference(Element peer, List<N> updatingPath)
peer
- the peer node to update withupdatingPath
- full path for context of the updateprotected DocumentModelAccess getAccess()
public int findPosition()
DocumentComponent
findPosition
in interface DocumentComponent<C extends DocumentComponent>
public int findEndPosition()
findEndPosition
in interface DocumentComponent2<C extends DocumentComponent<C>>
protected void updatePeer(String propertyName, Element newPeer)
public void addPrefix(String prefix, String namespace)
public void removePrefix(String prefix)
protected void ensureValueNamespaceDeclared(String newNamespace, String oldNamespace, String preferredPrefix)
public C findChildComponent(Element e)
DocumentComponent
findChildComponent
in interface DocumentComponent<C extends DocumentComponent>
public DocumentComponent copy(C parent)
Component
copy
in interface Component<C extends DocumentComponent<C>>
protected void verifyWrite()
AbstractComponent
verifyWrite
in class AbstractComponent<C extends DocumentComponent<C>>
protected void firePropertyChange(String propName, Object oldValue, Object newValue)
firePropertyChange
in class AbstractComponent<C extends DocumentComponent<C>>
protected void fireValueChanged()
fireValueChanged
in class AbstractComponent<C extends DocumentComponent<C>>
protected void fireChildRemoved()
fireChildRemoved
in class AbstractComponent<C extends DocumentComponent<C>>
protected void fireChildAdded()
fireChildAdded
in class AbstractComponent<C extends DocumentComponent<C>>
public boolean isInDocumentModel()
isInDocumentModel
in interface DocumentComponent<C extends DocumentComponent>
public int findAttributePosition(String attributeName)
DocumentComponent
findAttributePosition
in interface DocumentComponent<C extends DocumentComponent>
public QName getQName()
protected ModelSource resolveModel(String hint) throws CatalogModelException
hint
- on location of where external model reference could reside.CatalogModelException
- if the model cannot be located or the
hint is not well-formed URIprotected int findDomainIndex(Element e)
protected AbstractDocumentComponent getEffectiveParent()
protected String getChildElementText(QName qname)
qname
- QName of the child element to get text from.protected void setChildElementText(String propertyName, String text, QName qname)
propertyName
- property change event nametext
- the string to set value of the child element text node.qname
- QName of the child element to get text from.protected String getLeadingText(C child)
child
- the child to get associated text fromprotected void setLeadingText(String propName, String text, C child)
child
- the child to set associated texttext
- value of the leading text node, or null to remove the leading text node.protected String getTrailingText(C child)
child
- the child to get associated text fromprotected void setTrailingText(String propName, String text, C child)
child
- the child to get associated text fromtext
- value of the trailing text node, or null to remove the trailing text node.protected void setText(String propName, String value, C child, boolean leading, boolean includeComments)