Class XmlAttribute
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.artifactModel.FragmentArtifact
-
- net.ssehub.easy.instantiation.core.model.artifactModel.xml.XmlAttribute
-
- All Implemented Interfaces:
IArtifact,IStringValueProvider,IVilType
public class XmlAttribute extends FragmentArtifact implements IStringValueProvider
Represents a parsed XML attribute.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate XmlElementparentprivate java.lang.Stringvalue
-
Constructor Summary
Constructors Constructor Description XmlAttribute(XmlElement parent, java.lang.String name, java.lang.String value)Creates a new XML attribute.
-
Method Summary
All Methods Static Methods Instance 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.private voidcheckValidity()Checks the validity of this object.static XmlAttributecreate(XmlElement parent, java.lang.String name, java.lang.String value)Creates a new Attribute for given XmlElement, with given name and value.static XmlAttributecreate(XmlElement parent, java.lang.String name, java.lang.String value, boolean forceOverwrite)Creates a new Attribute for given XmlElement, with given name and value.voiddelete()Deletes this artifact.BinarygetBinary()Returns the binary representation of the contents of this artifact for manipulation.java.lang.StringgetName()Returns the name of this artifact.(package private) java.lang.StringgetNameSafe()Returns the name of this attribute without potential exception.XmlElementgetParent()Returns the parent of this fragment.java.lang.StringgetStringValue(IStringValueProvider.StringComparator comparator)Returns the string value of this object.TextgetText()Returns the textual representation of the contents of this artifact for manipulation.java.lang.StringgetValue()Returns the value of this attribute.voidrename(java.lang.String name)Renames this artifact.(package private) voidsetName(java.lang.String name)Changes the name of this attribute.(package private) voidsetParent(XmlElement parent)Sets a new parent for this fragment.voidsetValue(java.lang.String value)Changes the value of this attribute.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.FragmentArtifact
exists, lastModification, store
-
-
-
-
Field Detail
-
parent
private XmlElement parent
-
name
private java.lang.String name
-
value
private java.lang.String value
-
-
Constructor Detail
-
XmlAttribute
XmlAttribute(XmlElement parent, java.lang.String name, java.lang.String value)
Creates a new XML attribute.- Parameters:
parent- the parent elementname- the name of the attributevalue- the name of the value
-
-
Method Detail
-
create
public static XmlAttribute create(XmlElement parent, java.lang.String name, java.lang.String value) throws VilException
Creates a new Attribute for given XmlElement, with given name and value.- Parameters:
parent- The XmlElement the attribute is for.name- The name of the new attribute.value- The value of the new attribute.- Returns:
- The created XmlAttribute.
- Throws:
VilException- if attribute could not be created.
-
create
public static XmlAttribute create(XmlElement parent, java.lang.String name, java.lang.String value, boolean forceOverwrite) throws VilException
Creates a new Attribute for given XmlElement, with given name and value. Overwrites by default.- Parameters:
parent- The XmlElement the attribute is for.name- The name of the attribute.value- The value of the new attribute.forceOverwrite- True if existing attributes with same name shall be overwritten. Default = true.- Returns:
- The created XmlAttribute. The existing attribute if forceOverwrite is false.
- Throws:
VilException- if attribute could not be created for different reason then pre-existance.
-
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
-
getName
public java.lang.String getName() throws VilExceptionDescription copied from interface:IArtifactReturns the name of this artifact.- Specified by:
getNamein interfaceIArtifact- Returns:
- the name of this artifact
- Throws:
VilException- in case of serious problems so that this operation cannot continue
-
getNameSafe
java.lang.String getNameSafe()
Returns the name of this attribute without potential exception.- Returns:
- the name
-
getValue
public java.lang.String getValue() throws VilExceptionReturns the value of this attribute.- Returns:
- the value of this attribute
- Throws:
VilException- in case that this object is invalid (was deleted)
-
setValue
public void setValue(java.lang.String value) throws VilExceptionChanges the value of this attribute.- Parameters:
value- the new value of this attribute- Throws:
VilException- in case that this object is invalid (was deleted)
-
rename
public void rename(java.lang.String name) throws VilExceptionDescription copied from interface:IArtifactRenames this artifact.- Specified by:
renamein interfaceIArtifact- Parameters:
name- the new name of this artifact- Throws:
VilException- in case of serious problems so that this operation cannot continue
-
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
-
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
-
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.
-
getParent
public XmlElement getParent()
Returns the parent of this fragment.- Returns:
- the parent of this fragment
-
setParent
void setParent(XmlElement parent)
Sets a new parent for this fragment.- Parameters:
parent- the new parent.
-
checkValidity
private void checkValidity() throws VilExceptionChecks the validity of this object.- Throws:
VilException- in case that this object is invalid
-
setName
void setName(java.lang.String name)
Changes the name of this attribute.- Parameters:
name- the new name of this attribute
-
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
-
getStringValue
public java.lang.String getStringValue(IStringValueProvider.StringComparator comparator)
Description copied from interface:IStringValueProviderReturns the string value of this object.- Specified by:
getStringValuein interfaceIStringValueProvider- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
-