Class XmlValue

java.lang.Object
net.luis.utils.io.data.xml.XmlElement
net.luis.utils.io.data.xml.XmlValue
All Implemented Interfaces:
DefaultValueGetter, ValueGetter

public final class XmlValue extends XmlElement implements DefaultValueGetter
Represents a xml value element.
  • Field Details

    • value

      private final String value
      The value of the xml element.
  • Constructor Details

    • XmlValue

      public XmlValue(@NotNull @NotNull String name, boolean value)
      Constructs a new xml value with the given name and boolean value.
      Parameters:
      name - The name of the xml element
      value - The value of the xml element
      Throws:
      NullPointerException - If the name is null
    • XmlValue

      public XmlValue(@NotNull @NotNull String name, @Nullable @Nullable Number value)
      Constructs a new xml value with the given name and number value.
      Parameters:
      name - The name of the xml element
      value - The value of the xml element
      Throws:
      NullPointerException - If the name is null
    • XmlValue

      public XmlValue(@NotNull @NotNull String name, @Nullable @Nullable String value)
      Constructs a new xml value with the given name and string value.
      The value will be escaped automatically.
      Parameters:
      name - The name of the xml element
      value - The value of the xml element
      Throws:
      NullPointerException - If the name is null
    • XmlValue

      public XmlValue(@NotNull @NotNull String name, @NotNull @NotNull XmlAttributes attributes, boolean value)
      Constructs a new xml value with the given name, attributes and boolean value.
      Parameters:
      name - The name of the xml element
      attributes - The attributes of the xml element
      value - The value of the xml element
      Throws:
      NullPointerException - If the name or attributes are null
    • XmlValue

      public XmlValue(@NotNull @NotNull String name, @NotNull @NotNull XmlAttributes attributes, @Nullable @Nullable Number value)
      Constructs a new xml value with the given name, attributes and number value.
      Parameters:
      name - The name of the xml element
      attributes - The attributes of the xml element
      value - The value of the xml element
    • XmlValue

      public XmlValue(@NotNull @NotNull String name, @NotNull @NotNull XmlAttributes attributes, @Nullable @Nullable String value)
      Constructs a new xml value with the given name, attributes and string value.
      The value will be escaped automatically.
      Parameters:
      name - The name of the xml element
      attributes - The attributes of the xml element
      value - The value of the xml element
      Throws:
      NullPointerException - If the name or attributes are null
  • Method Details

    • getElementType

      @NotNull protected @NotNull String getElementType()
      Description copied from class: XmlElement
      Returns the type of the xml element.
      This is used internally for error messages.
      Overrides:
      getElementType in class XmlElement
      Returns:
      The type of the xml element
    • isSelfClosing

      public boolean isSelfClosing()
      Description copied from class: XmlElement
      Checks if the xml element is self-closing.
      Overrides:
      isSelfClosing in class XmlElement
      Returns:
      Always false
    • getRawValue

      @NotNull public @NotNull String getRawValue()
      Returns the raw unescaped value of the element.
      Returns:
      The raw value
    • getUnescapedValue

      @NotNull public @NotNull String getUnescapedValue()
      Returns the unescaped value of the element.
      Returns:
      The unescaped value
    • getAsString

      @NotNull public @NotNull String getAsString()
      Returns the value which is hold by this object as a string.
      This method is equivalent to getUnescapedValue().
      Specified by:
      getAsString in interface ValueGetter
      Returns:
      The value as a string
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class XmlElement
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class XmlElement
    • toString

      @NotNull public @NotNull String toString(@NotNull @NotNull XmlConfig config)
      Returns a string representation of this value.
      Overrides:
      toString in class XmlElement
      Parameters:
      config - The xml config to use for the string representation
      Returns:
      The string representation
      Throws:
      NullPointerException - If the config is null