public class XmlAttribute
extends java.lang.Object
Represents an XML attribute.
Constructor and Description |
---|
XmlAttribute() |
Modifier and Type | Method and Description |
---|---|
XmlAttribute |
andValue(java.lang.String value)
Convenience function for modifying the value of an attribute.
|
java.lang.String |
getLocalName()
Return local element name, without namespace prefix, e.g.
|
java.lang.String |
getName()
Return attribute name, possibly qualified by namespace prefix, e.g.
|
java.lang.String |
getNamespaceURI()
Return (nullable) Namespace URI, if known.
|
java.lang.String |
getPrefix()
Return (nullable) Optional namespace prefix, e.g.
|
java.lang.String |
getValue()
Return attribute value.
|
boolean |
hasPrefix()
Return is
XmlAttribute.prefix non-null? |
void |
setLocalName(java.lang.String value)
Set local element name, without namespace prefix, e.g.
|
void |
setName(java.lang.String value)
Set attribute name, possibly qualified by namespace prefix, e.g.
|
void |
setNamespaceURI(java.lang.String value)
Set namespace URI, if known.
|
void |
setPrefix(java.lang.String value)
Set optional namespace prefix, e.g.
|
void |
setValue(java.lang.String value)
Set attribute value.
|
java.lang.String |
toString() |
static XmlAttribute |
withName(java.lang.String name)
Convenience function for constructing an attribute with a specified name.
|
static XmlAttribute |
withQName(XmlName name)
Convenience function for constructing an attribute node with specified name.
|
public XmlAttribute andValue(java.lang.String value)
Convenience function for modifying the value of an attribute.
let a = XmlAttribute.withName("a").andValue("v");
value
- Attribute value.public java.lang.String getLocalName()
Return local element name, without namespace prefix, e.g. "MyAttribute".
public java.lang.String getName()
Return attribute name, possibly qualified by namespace prefix, e.g. "MyAttribute" or "myns:MyAttribute".
public java.lang.String getNamespaceURI()
Return (nullable) Namespace URI, if known. Will not be valid unless XmlElement.resolveNamespaces
has been called for the element hierarchy containing this attribute.
XmlElement.resolveNamespaces
has been called for the element hierarchy containing this attribute.public java.lang.String getPrefix()
Return (nullable) Optional namespace prefix, e.g. "myns" or null
.
null
.public java.lang.String getValue()
Return attribute value.
public boolean hasPrefix()
Return is XmlAttribute.prefix
non-null?
XmlAttribute.prefix
non-null?public void setLocalName(java.lang.String value)
Set local element name, without namespace prefix, e.g. "MyAttribute".
value
- Local element name, without namespace prefix, e.g. "MyAttribute".public void setName(java.lang.String value)
Set attribute name, possibly qualified by namespace prefix, e.g. "MyAttribute" or "myns:MyAttribute".
value
- Attribute name, possibly qualified by namespace prefix, e.g. "MyAttribute" or "myns:MyAttribute".public void setNamespaceURI(java.lang.String value)
Set namespace URI, if known. Will not be valid unless XmlElement.resolveNamespaces
has been called for the element hierarchy containing this attribute.
value
- Namespace URI, if known. Will not be valid unless XmlElement.resolveNamespaces
has been called for the element hierarchy containing this attribute.public void setPrefix(java.lang.String value)
Set optional namespace prefix, e.g. "myns" or null
.
value
- Optional namespace prefix, e.g. "myns" or null
.public void setValue(java.lang.String value)
Set attribute value.
value
- Attribute value.public java.lang.String toString()
toString
in class java.lang.Object
public static XmlAttribute withName(java.lang.String name)
Convenience function for constructing an attribute with a specified name.
let a = XmlAttribute.withName("a");
name
- Attribute name.public static XmlAttribute withQName(XmlName name)
Convenience function for constructing an attribute node with specified name.
name
- The attribute name.