com.google.api.client.http.xml
Class XmlHttpParser

java.lang.Object
  extended by com.google.api.client.http.xml.XmlHttpParser
All Implemented Interfaces:
HttpParser
Direct Known Subclasses:
AtomParser

public class XmlHttpParser
extends Object
implements HttpParser

XML HTTP parser into an data class of key/value pairs.

Implementation is thread-safe as long as the fields are not set directly (which is deprecated usage).

Sample usage:

 
  static void setParser(HttpRequest request, XmlNamespaceDictionary namespaceDictionary) {
    request.addParser(new XmlHttpParser(namespaceDictionary));
  }
 
 

Since:
1.0
Author:
Yaniv Inbar

Nested Class Summary
static class XmlHttpParser.Builder
          Builder for XmlHttpParser.
 
Field Summary
static String CONTENT_TYPE
          "application/xml" content type.
 String contentType
          Deprecated. (scheduled to be made private final in 1.6) Use getContentType() or XmlHttpParser.Builder.setContentType(java.lang.String)
 XmlNamespaceDictionary namespaceDictionary
          Deprecated. (scheduled to be made private final in 1.6) Use getNamespaceDictionary()
 
Constructor Summary
  XmlHttpParser()
          Deprecated. (scheduled to be removed in 1.6) Use XmlHttpParser(XmlNamespaceDictionary)
  XmlHttpParser(XmlNamespaceDictionary namespaceDictionary)
           
protected XmlHttpParser(XmlNamespaceDictionary namespaceDictionary, String contentType)
           
 
Method Summary
static XmlHttpParser.Builder builder(XmlNamespaceDictionary namespaceDictionary)
          Returns an instance of a new builder.
 String getContentType()
          Returns the content type.
 XmlNamespaceDictionary getNamespaceDictionary()
          Returns the XML namespace dictionary.
<T> T
parse(HttpResponse response, Class<T> dataClass)
          Default implementation parses the content of the response into the data class of key/value pairs, but subclasses may override.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final String CONTENT_TYPE
"application/xml" content type.

See Also:
Constant Field Values

contentType

@Deprecated
public String contentType
Deprecated. (scheduled to be made private final in 1.6) Use getContentType() or XmlHttpParser.Builder.setContentType(java.lang.String)
Content type. Default value is CONTENT_TYPE.


namespaceDictionary

@Deprecated
public XmlNamespaceDictionary namespaceDictionary
Deprecated. (scheduled to be made private final in 1.6) Use getNamespaceDictionary()
XML namespace dictionary.

Since:
1.3
Constructor Detail

XmlHttpParser

@Deprecated
public XmlHttpParser()
Deprecated. (scheduled to be removed in 1.6) Use XmlHttpParser(XmlNamespaceDictionary)


XmlHttpParser

public XmlHttpParser(XmlNamespaceDictionary namespaceDictionary)
Parameters:
namespaceDictionary - XML namespace dictionary
Since:
1.5

XmlHttpParser

protected XmlHttpParser(XmlNamespaceDictionary namespaceDictionary,
                        String contentType)
Parameters:
namespaceDictionary - XML namespace dictionary
contentType - content type or null for none
Since:
1.5
Method Detail

getContentType

public final String getContentType()
Description copied from interface: HttpParser
Returns the content type.

Specified by:
getContentType in interface HttpParser

parse

public <T> T parse(HttpResponse response,
                   Class<T> dataClass)
        throws IOException
Default implementation parses the content of the response into the data class of key/value pairs, but subclasses may override.

Specified by:
parse in interface HttpParser
Throws:
IOException

getNamespaceDictionary

public final XmlNamespaceDictionary getNamespaceDictionary()
Returns the XML namespace dictionary.

Since:
1.5

builder

public static XmlHttpParser.Builder builder(XmlNamespaceDictionary namespaceDictionary)
Returns an instance of a new builder.

Parameters:
namespaceDictionary - XML namespace dictionary
Since:
1.5


Copyright © 2011 Google. All Rights Reserved.