Class XmlNode
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.artifactModel.FragmentArtifact
-
- net.ssehub.easy.instantiation.core.model.artifactModel.CompositeFragmentArtifact
-
- net.ssehub.easy.instantiation.core.model.artifactModel.xml.XmlNode
-
- All Implemented Interfaces:
IArtifact,IArtifactChangedListener,IStringValueProvider,IVilType
- Direct Known Subclasses:
XmlComment,XmlElement
public abstract class XmlNode extends CompositeFragmentArtifact implements IStringValueProvider, IArtifactChangedListener
An abstract fragment representing a XML node.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedXmlNode(XmlElement parent, org.w3c.dom.Node node)Creates a new XML comment fragment artifact.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(IArtifactVisitor visitor)Visits this artifact (and dependent on the visitor also contained artifacts and fragments) using the given visitor.voidartifactChanged(java.lang.Object cause)Is called when the artifact was changed, e.g., to trigger a reanalysis of substructures.protected voidcheckRoot()Checks if this object represents the Root element.protected voidcheckValidity()Checks the validity of this object.voiddelete()Deletes this artifact.(package private) abstract voiddeleteChild(XmlNode child)Removes a child from this Element.BinarygetBinary()Returns the binary representation of the contents of this artifact for manipulation.TextgetCdata()Returns the cdata of the element.protected TextgetCdataDirect()Returns the text object for cdata regardless whether it is null.(package private) XmlNodegetChild(int index)Returns the child at the givenindex.(package private) intgetChildCount()Returns the number of children.(package private) XmlFileArtifactgetFile()Returns the parent XML file artifact.(package private) java.lang.StringgetNameSafe()Returns the name of this attribute without potential exception.protected org.w3c.dom.NodegetNode()Returns the represented XML node.XmlElementgetParent()Returns the parent of this fragment.TextgetText()Returns the textual representation of the contents of this artifact for manipulation.protected TextgetTextDirect()Returns the text object even if it is null.protected voidnotifyChange()Notifies the containing file about a change through this object.(package private) voidnotifyChange(java.lang.Object cause)Notifies the containing file about a change.voidsetCdata(java.lang.String cdata)Sets the cdata of the element.protected voidsetNode(org.w3c.dom.Node node)Changes the representing XML node.(package private) voidsortAttributes(org.xml.sax.Attributes att)Sorts the attribute sequence of this element according to the given SAX attribute set.(package private) voidsynchronizeAttributeSequence()Synchronizes the attribute sequence.voidupdate()Called if the underlying real artifact may have been updated, e.g., by overriding it by another file.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.artifactModel.CompositeFragmentArtifact
selectAll
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.artifactModel.FragmentArtifact
exists, lastModification, store
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact
getName, rename
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
getStringValue
-
-
-
-
Field Detail
-
parent
private XmlElement parent
-
cdata
private Text cdata
-
text
private Text text
-
node
private org.w3c.dom.Node node
-
-
Constructor Detail
-
XmlNode
protected XmlNode(XmlElement parent, org.w3c.dom.Node node)
Creates a new XML comment fragment artifact.- Parameters:
parent- the parent artifactnode- the node that is represented by this XmlElement
-
-
Method Detail
-
getParent
public XmlElement getParent()
Returns the parent of this fragment.- Returns:
- the parent of this fragment
-
getNode
protected org.w3c.dom.Node getNode()
Returns the represented XML node.- Returns:
- the node (may be null)
-
setNode
protected void setNode(org.w3c.dom.Node node)
Changes the representing XML node.- Parameters:
node- the new representing XML node
-
checkValidity
protected void checkValidity() throws VilExceptionChecks the validity of this object.- Throws:
VilException- in case that this object is invalid
-
checkRoot
protected void checkRoot() throws VilExceptionChecks if this object represents the Root element. Root elements can not be changed.- Throws:
VilException- in case that this object is the root element.
-
deleteChild
abstract void deleteChild(XmlNode child)
Removes a child from this Element.- Parameters:
child- the child that is to be removed.
-
delete
public void delete() throws VilExceptionDescription copied from interface:IArtifactDeletes this artifact.- Specified by:
deletein interfaceIArtifact- Throws:
VilException- in case of serious problems so that this operation cannot continue
-
setCdata
public void setCdata(java.lang.String cdata) throws VilExceptionSets the cdata of the element.- Parameters:
cdata- String of the cdata to store- Throws:
VilException- in case that reading fails for some reason
-
getBinary
public Binary getBinary() throws VilException
Description copied from interface:IArtifactReturns the binary representation of the contents of this artifact for manipulation.- Specified by:
getBinaryin interfaceIArtifact- Returns:
- the binary representation of the contents
- Throws:
VilException- in case of obtaining the representation causes serious problems
-
getText
public Text getText() throws VilException
Description copied from interface:IArtifactReturns the textual representation of the contents of this artifact for manipulation. In case of binary artifacts, the returned object may be empty.- Specified by:
getTextin interfaceIArtifact- Returns:
- the textual representation of the contents
- Throws:
VilException- in case of obtaining the representation causes serious problems
-
getTextDirect
protected Text getTextDirect()
Returns the text object even if it is null.- Returns:
- the text object
-
getCdata
public Text getCdata() throws VilException
Returns the cdata of the element.- Returns:
- the cdata information of this element. Null if there is no cdata
- Throws:
VilException- if element is invalid.
-
getCdataDirect
protected Text getCdataDirect()
Returns the text object for cdata regardless whether it is null.- Returns:
- the text object for cdata, may be null
-
getFile
XmlFileArtifact getFile()
Returns the parent XML file artifact.- Returns:
- the parent file artifact, may be null
-
notifyChange
protected void notifyChange()
Notifies the containing file about a change through this object.
-
notifyChange
void notifyChange(java.lang.Object cause)
Notifies the containing file about a change.- Parameters:
cause- the causing object
-
artifactChanged
public void artifactChanged(java.lang.Object cause) throws VilExceptionDescription copied from interface:IArtifactChangedListenerIs called when the artifact was changed, e.g., to trigger a reanalysis of substructures.- Specified by:
artifactChangedin interfaceIArtifactChangedListener- Parameters:
cause- the cause for the change, e.g., an artifact representation- Throws:
VilException- in case that the required operations fail for some reason
-
accept
public void accept(IArtifactVisitor visitor)
Description copied from interface:IArtifactVisits this artifact (and dependent on the visitor also contained artifacts and fragments) using the given visitor.
-
update
public void update() throws VilExceptionDescription copied from interface:IArtifactCalled if the underlying real artifact may have been updated, e.g., by overriding it by another file.- Specified by:
updatein interfaceIArtifact- Throws:
VilException- in case that updating fails
-
getChildCount
int getChildCount()
Returns the number of children.- Returns:
- the number of children
-
getChild
XmlNode getChild(int index)
Returns the child at the givenindex.- Parameters:
index- the 0-based index of the child to return- Returns:
- the child
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getChildCount()
-
getNameSafe
java.lang.String getNameSafe()
Returns the name of this attribute without potential exception.- Returns:
- the name
-
synchronizeAttributeSequence
void synchronizeAttributeSequence()
Synchronizes the attribute sequence.
-
sortAttributes
void sortAttributes(org.xml.sax.Attributes att)
Sorts the attribute sequence of this element according to the given SAX attribute set.- Parameters:
att- the SAX attributes
-
-