matsudakazumi / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

XmlHttpParser constructor (ns, contentType) should be public #286

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client: 1.5.0-beta

Java environment: App Engine

The following constructor is protected, but I think it should be public:

com.google.api.client.http.xml.XmlHttpParser.XmlHttpParser(XmlNamespaceDictionar
y namespaceDictionary, String contentType)

The reason being that I use the API to access an external web service that 
requires the contentType to be "text/xml; charset=utf-8".

As a workaround, I can extend XmlHttpParser, but it would be better for the 
maintenance of my own code if I didn't have to do this.

/**
 * Need this, because we must set contentType and Google Client API
 * 1.5.0-beta protects the contructor.
 */
protected static class XmlHttpParserExtended extends XmlHttpParser
{
  public XmlHttpParserExtended(
    final XmlNamespaceDictionary namespaceDictionary, 
    final String contentType)
  {
    super(namespaceDictionary, contentType);
  }
}

Original issue reported on code.google.com by tra...@circutus.com on 31 Aug 2011 at 4:25

GoogleCodeExporter commented 9 years ago
We intentionally designed it that way because we want users to use the builder 
pattern, e.g.:

XmlHttpParser.builder(namespaceDictionary).setContent(contentType).build()

If that is a burden, you can always wrap it in a utility method, or extend it 
as you've done.

The builder pattern seems less necessary in this case, but we want the library 
to have a consistent design of using the builder pattern for classes that are 
thread safe.

Original comment by yan...@google.com on 2 Sep 2011 at 1:50

GoogleCodeExporter commented 9 years ago
Yes, that makes sense. I was mostly concerned that because this is a protected 
constructor, that it might someday be deprecated. Thanks!

Original comment by tra...@circutus.com on 2 Sep 2011 at 4:48

GoogleCodeExporter commented 9 years ago
No problem, and thanks for the feedback.  By the way, we treat protected the 
same as public in terms of level of support.  In other words, it is considered 
part of the official surface of the library and we don't intend to deprecate it 
(though we reserve the right to do so while we're still in Beta).  Our policy 
is documented here:

http://code.google.com/p/google-api-java-client/wiki/Support#Beta

Original comment by yan...@google.com on 2 Sep 2011 at 5:20