Class Xml

java.lang.Object
com.google.api.client.xml.Xml

@Beta public class Xml extends Object
Beta
XML utilities.
Since:
1.0
  • Field Details

  • Constructor Details

    • Xml

      private Xml()
  • Method Details

    • getParserFactory

      private static org.xmlpull.v1.XmlPullParserFactory getParserFactory() throws org.xmlpull.v1.XmlPullParserException
      Throws:
      org.xmlpull.v1.XmlPullParserException
    • createSerializer

      public static org.xmlpull.v1.XmlSerializer createSerializer()
      Returns a new XML serializer.
      Throws:
      IllegalArgumentException - if encountered an XmlPullParserException
    • createParser

      public static org.xmlpull.v1.XmlPullParser createParser() throws org.xmlpull.v1.XmlPullParserException
      Returns a new XML pull parser.
      Throws:
      org.xmlpull.v1.XmlPullParserException
    • toStringOf

      public static String toStringOf(Object element)
      Shows a debug string representation of an element data object of key/value pairs.

      It will make up something for the element name and XML namespaces. If those are known, it is better to use XmlNamespaceDictionary.toStringOf(String, Object).

      Parameters:
      element - element data object of key/value pairs (GenericXml, Map, or any object with public fields)
    • parseAttributeOrTextContent

      private static void parseAttributeOrTextContent(String stringValue, Field field, Type valueType, List<Type> context, Object destination, GenericXml genericXml, Map<String,Object> destinationMap, String name)
      Parses the string value of an attribute value or text content.
      Parameters:
      stringValue - string value
      field - field to set or null if not applicable
      valueType - value type (class, parameterized type, or generic array type) or null for none
      context - context list, going from least specific to most specific type context, for example container class and its field
      destination - destination object or null for none
      genericXml - generic XML or null if not applicable
      destinationMap - destination map or null if not applicable
      name - key name
    • setValue

      private static void setValue(Object value, Field field, Object destination, GenericXml genericXml, Map<String,Object> destinationMap, String name)
      Sets the value of a given field or map entry.
      Parameters:
      value - value
      field - field to set or null if not applicable
      destination - destination object or null for none
      genericXml - generic XML or null if not applicable
      destinationMap - destination map or null if not applicable
      name - key name
    • parseElement

      public static void parseElement(org.xmlpull.v1.XmlPullParser parser, Object destination, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser) throws IOException, org.xmlpull.v1.XmlPullParserException
      Parses an XML element using the given XML pull parser into the given destination object.

      Requires the current event be XmlPullParser.START_TAG (skipping any initial XmlPullParser.START_DOCUMENT) of the element being parsed. At normal parsing completion, the current event will either be XmlPullParser.END_TAG of the element being parsed, or the XmlPullParser.START_TAG of the requested atom:entry.

      Parameters:
      parser - XML pull parser
      destination - optional destination object to parser into or null to ignore XML content
      namespaceDictionary - XML namespace dictionary to store unknown namespaces
      customizeParser - optional parser customizer or null for none
      Throws:
      IOException
      org.xmlpull.v1.XmlPullParserException
    • parseElementInternal

      private static boolean parseElementInternal(org.xmlpull.v1.XmlPullParser parser, ArrayList<Type> context, Object destination, Type valueType, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser) throws IOException, org.xmlpull.v1.XmlPullParserException
      Returns whether the customize parser has requested to stop or reached end of document. Otherwise, identical to parseElement(XmlPullParser, Object, XmlNamespaceDictionary, CustomizeParser) .
      Throws:
      IOException
      org.xmlpull.v1.XmlPullParserException
    • getFieldName

      private static String getFieldName(boolean isAttribute, String alias, String namespace, String name)
    • parseTextContentForElement

      private static Object parseTextContentForElement(org.xmlpull.v1.XmlPullParser parser, List<Type> context, boolean ignoreTextContent, Type textContentType) throws org.xmlpull.v1.XmlPullParserException, IOException
      Throws:
      org.xmlpull.v1.XmlPullParserException
      IOException
    • parseValue

      private static Object parseValue(Type valueType, List<Type> context, String value)
    • parseNamespacesForElement

      private static void parseNamespacesForElement(org.xmlpull.v1.XmlPullParser parser, XmlNamespaceDictionary namespaceDictionary) throws org.xmlpull.v1.XmlPullParserException
      Parses the namespaces declared on the current element into the namespace dictionary.
      Parameters:
      parser - XML pull parser
      namespaceDictionary - namespace dictionary
      Throws:
      org.xmlpull.v1.XmlPullParserException