Class XMLAttributeList


  • public class XMLAttributeList
    extends java.lang.Object
    Helper class to format attributes in an XML tag.
    Author:
    David Hovemeyer
    • Constructor Detail

      • XMLAttributeList

        public XMLAttributeList()
        Constructor. Creates an empty object.
    • Method Detail

      • addAttribute

        public XMLAttributeList addAttribute​(@Nonnull
                                             java.lang.String name,
                                             @Nonnull
                                             java.lang.String value)
        Add a single attribute name and value.
        Parameters:
        name - the attribute name
        value - the attribute value
        Returns:
        this object (so calls to addAttribute() can be chained)
      • addOptionalAttribute

        public XMLAttributeList addOptionalAttribute​(@Nonnull
                                                     java.lang.String name,
                                                     @CheckForNull
                                                     java.lang.String value)
        Add a single attribute name and value.
        Parameters:
        name - the attribute name
        value - the attribute value
        Returns:
        this object (so calls to addAttribute() can be chained)
      • toString

        public java.lang.String toString()
        Return the attribute list as a String which can be directly output as part of an XML tag.
        Overrides:
        toString in class java.lang.Object
      • getQuotedAttributeValue

        public static java.lang.String getQuotedAttributeValue​(@Nonnull
                                                               java.lang.String rawValue)
        Return a properly quoted form for an attribute value.
        Parameters:
        rawValue - the raw value of the attribute
        Returns:
        a properly quoted representation of the value