com.google.gdata.wireformats
Class AltFormat.Builder

java.lang.Object
  extended by com.google.gdata.wireformats.AltFormat.Builder
Enclosing class:
AltFormat

public static class AltFormat.Builder
extends java.lang.Object

A builder for AltFormat. Create new builders using AltFormat.builder() or AltFormat.builder(AltFormat).


Method Summary
 AltFormat.Builder addAllowedInputFormats(AltFormat... formats)
          Declares formats as being acceptable input formats when the current AltFormat is selected as output.
 AltFormat build()
          Builds the AltFormat.
 AltFormat.Builder setAcceptableTextTypes()
          Declares text/plain to be an acceptable match for the purpose of content negotiation.
 AltFormat.Builder setAcceptableTypes(ContentType... types)
          Declares MIME types to be acceptable matches for the purpose of content negotiation.
 AltFormat.Builder setAcceptableXmlTypes()
          Declares text/xml and text/plain to be acceptable matches for the purpose of content negotiation.
 AltFormat.Builder setBaseFormat(AltFormat base)
          Declares another AltFormat as the base for this one.
 AltFormat.Builder setContentType(ContentType contentType)
          Sets the primary MIME content type used for the representation.
 AltFormat.Builder setName(java.lang.String name)
          Sets the short name for this format.
 AltFormat.Builder setSelectableByType(boolean isSelectableByType)
          Indicates whether the MIME content type can be used as an alias to select the representation.
 AltFormat.Builder setWireFormat(WireFormat wireFormat)
          Sets the content wire format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setName

public AltFormat.Builder setName(java.lang.String name)
Sets the short name for this format. This value is suitable for use as the value of the alt query parameter. This is required.


setWireFormat

public AltFormat.Builder setWireFormat(WireFormat wireFormat)
Sets the content wire format.


setContentType

public AltFormat.Builder setContentType(ContentType contentType)
Sets the primary MIME content type used for the representation. This is the content type expected as input and the default content type returned as output.


setSelectableByType

public AltFormat.Builder setSelectableByType(boolean isSelectableByType)
Indicates whether the MIME content type can be used as an alias to select the representation.


setBaseFormat

public AltFormat.Builder setBaseFormat(AltFormat base)
Declares another AltFormat as the base for this one.

This is set for *-in-script variants and to allows access to the original format.


setAcceptableTextTypes

public AltFormat.Builder setAcceptableTextTypes()
Declares text/plain to be an acceptable match for the purpose of content negotiation.


setAcceptableXmlTypes

public AltFormat.Builder setAcceptableXmlTypes()
Declares text/xml and text/plain to be acceptable matches for the purpose of content negotiation.


setAcceptableTypes

public AltFormat.Builder setAcceptableTypes(ContentType... types)
Declares MIME types to be acceptable matches for the purpose of content negotiation. By default, only the content type set using setContentType(com.google.gdata.util.ContentType) is acceptable.


addAllowedInputFormats

public AltFormat.Builder addAllowedInputFormats(AltFormat... formats)
Declares formats as being acceptable input formats when the current AltFormat is selected as output.

When posting or putting data, the request content type is expected to be the same as the response content type selected with the alt query parameter. This is enforced in the server.

For example, this is acceptable:

 POST http://gdata.example.com/feeds/myfeed?alt=jsonc
 ContentType: application/json
 
and this is not:
 POST http://gdata.example.com/feeds/myfeed?alt=jsonc
 ContentType: application/atom+xml
 

Some cases violate this rule. For example, when posting a media file, the request content type is the type of the media while the response content type is either atom or json.

Such special cases should be declared using this method.


build

public AltFormat build()
Builds the AltFormat. This can be called only once.

Throws:
java.lang.IllegalStateException - unless both name and content type are set