public static class

AltFormat.Builder

extends Object
java.lang.Object
   ↳ com.google.gdata.wireformats.AltFormat.Builder

Class Overview

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

Summary

Fields
private Set<ContentType> acceptableTypes
private AltFormat base
private ContentType contentType
private final Builder<AltFormat> extraInputFormats
private boolean isSelectableByType
private String name
private WireFormat wireFormat
Public Methods
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(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.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private Set<ContentType> acceptableTypes

private AltFormat base

private ContentType contentType

private final Builder<AltFormat> extraInputFormats

private boolean isSelectableByType

private String name

private WireFormat wireFormat

Public Methods

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.

Parameters
formats

public AltFormat build ()

Builds the AltFormat. This can be called only once.

Throws
IllegalStateException unless both name and content type are set

public AltFormat.Builder setAcceptableTextTypes ()

Declares text/plain to be an acceptable match for the purpose of content negotiation.

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(ContentType) is acceptable.

Parameters
types

public AltFormat.Builder setAcceptableXmlTypes ()

Declares text/xml and text/plain to be acceptable matches for the purpose of content negotiation.

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.

Parameters
base

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.

Parameters
contentType

public AltFormat.Builder setName (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.

Parameters
name

public AltFormat.Builder setSelectableByType (boolean isSelectableByType)

Indicates whether the MIME content type can be used as an alias to select the representation.

Parameters
isSelectableByType

public AltFormat.Builder setWireFormat (WireFormat wireFormat)

Sets the content wire format.

Parameters
wireFormat