Class Utils

java.lang.Object
com.itextpdf.kernel.xmp.impl.Utils
All Implemented Interfaces:
XMPConst

public final class Utils extends Object implements XMPConst
Utility functions for the XMPToolkit implementation.
Since:
06.06.2006
  • Field Details

    • UUID_SEGMENT_COUNT

      public static final int UUID_SEGMENT_COUNT
      segments of a UUID
      See Also:
    • UUID_LENGTH

      public static final int UUID_LENGTH
      length of a UUID
      See Also:
  • Method Details

    • normalizeLangValue

      public static String normalizeLangValue (String value)
      Normalize an xml:lang value so that comparisons are effectively case insensitive as required by RFC 3066 (which superceeds RFC 1766). The normalization rules:
      • The primary subtag is lower case, the suggested practice of ISO 639.
      • All 2 letter secondary subtags are upper case, the suggested practice of ISO 3166.
      • All other subtags are lower case.
      Parameters:
      value - raw value
      Returns:
      Returns the normalized value.
    • isXMLName

      public static boolean isXMLName (String name)
      Simple check for valid XMLNames. Within ASCII range
      ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6]
      are accepted, above all characters (which is not entirely correct according to the XML Spec.
      Parameters:
      name - an XML Name
      Returns:
      Return true if the name is correct.
    • isXMLNameNS

      public static boolean isXMLNameNS (String name)
      Checks if the value is a legal "unqualified" XML name, as defined in the XML Namespaces proposed recommendation. These are XML names, except that they must not contain a colon.
      Parameters:
      name - the value to check
      Returns:
      Returns true if the name is a valid "unqualified" XML name.
    • escapeXML

      public static String escapeXML (String value, boolean forAttribute, boolean escapeWhitespaces)
      Serializes the node value in XML encoding. Its used for tag bodies and attributes.
      Note: The attribute is always limited by quotes, thats why ' is never serialized.
      Note: Control chars are written unescaped, but if the user uses others than tab, LF and CR the resulting XML will become invalid.
      Parameters:
      value - a string
      forAttribute - flag if string is attribute value (need to additional escape quotes)
      escapeWhitespaces - Decides if LF, CR and TAB are escaped.
      Returns:
      Returns the value ready for XML output.