java.lang.Object
net.luis.utils.io.data.xml.XmlAttribute
- All Implemented Interfaces:
DefaultValueGetter
,ValueGetter
Represents an xml attribute.
An xml attribute consists of a name and a value.
The name and the value are both strings.
An xml attribute consists of a name and a value.
The name and the value are both strings.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXmlAttribute
(@NotNull String name, boolean value) Constructs a new xml attribute with the given name and boolean value.XmlAttribute
(@NotNull String name, @Nullable Number value) Constructs a new xml attribute with the given name and number value.XmlAttribute
(@NotNull String name, @Nullable String value) Constructs a new xml attribute with the given name and string value.
The value will be xml-escaped automatically. -
Method Summary
Modifier and TypeMethodDescriptionboolean
@NotNull String
Returns the value which is hold by this object as a string.@NotNull String
getName()
Returns the name of the attribute.@NotNull String
Returns the raw unescaped value of the attribute.@NotNull String
Returns the unescaped value of the attribute.int
hashCode()
toString()
@NotNull String
Returns the string representation of the attribute.
The string representation is in the form ofname="value"
.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.luis.utils.util.getter.DefaultValueGetter
getAs, getAsBoolean, getAsByte, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsNumber, getAsShort
Methods inherited from interface net.luis.utils.util.getter.ValueGetter
getAs, getAsBoolean, getAsByte, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsNumber, getAsShort
-
Field Details
-
name
The name of the attribute. -
value
The value of the attribute.
-
-
Constructor Details
-
XmlAttribute
Constructs a new xml attribute with the given name and boolean value.- Parameters:
name
- The name of the attributevalue
- The boolean value of the attribute- Throws:
IllegalArgumentException
- If the name is invalid (e.g. empty, blank, or does not match the patternXmlHelper.XML_ATTRIBUTE_NAME_PATTERN
)
-
XmlAttribute
Constructs a new xml attribute with the given name and number value.- Parameters:
name
- The name of the attributevalue
- The number value of the attribute- Throws:
IllegalArgumentException
- If the name is invalid (e.g. empty, blank, or does not match the patternXmlHelper.XML_ATTRIBUTE_NAME_PATTERN
)
-
XmlAttribute
Constructs a new xml attribute with the given name and string value.
The value will be xml-escaped automatically.- Parameters:
name
- The name of the attributevalue
- The string value of the attribute- Throws:
IllegalArgumentException
- If the name is invalid (e.g. empty, blank, or does not match the patternXmlHelper.XML_ATTRIBUTE_NAME_PATTERN
)
-
-
Method Details
-
getName
Returns the name of the attribute.- Returns:
- The name
-
getRawValue
Returns the raw unescaped value of the attribute.- Returns:
- The raw value
-
getUnescapedValue
Returns the unescaped value of the attribute.- Returns:
- The unescaped value
-
getAsString
Returns the value which is hold by this object as a string.
This method is equivalent togetUnescapedValue()
.- Specified by:
getAsString
in interfaceValueGetter
- Returns:
- The value as a string
-
equals
-
hashCode
public int hashCode() -
toString
-
toString
Returns the string representation of the attribute.
The string representation is in the form ofname="value"
.- Parameters:
config
- The xml config to use for the string representation (unused)- Returns:
- The string representation
-