com.google.cloud.dataflow.sdk.coders

## Class JAXBCoder<T>

- java.lang.Object
- - com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
  - - com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
    - - com.google.cloud.dataflow.sdk.coders.AtomicCoder<T>
      - - com.google.cloud.dataflow.sdk.coders.JAXBCoder<T>

Type Parameters:
  `T` - type of JAXB annotated objects that will be serialized.

All Implemented Interfaces:
  Coder<T>, Serializable

    public class JAXBCoder<T>
    extends AtomicCoder<T>

A coder for JAXB annotated objects. This coder uses JAXB marshalling/unmarshalling mechanisms to encode/decode the objects. Users must provide the `Class` of the JAXB annotated object.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder

`Coder.Context, Coder.NonDeterministicException`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`com.google.cloud.dataflow.sdk.util.CloudObject` `asCloudObject()` Returns the `CloudObject` that represents this `Coder`.
`T` `decode(InputStream inStream, Coder.Context context)` Decodes a value of type `T` from the given input stream in the given context.
`void` `encode(T value, OutputStream outStream, Coder.Context context)` Encodes the given value of type `T` onto the given output stream in the given context.
`String` `getEncodingId()` An identifier for the binary format written by `Coder.encode(T, java.io.OutputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context)`.
`Class<T>` `getJAXBClass()`
`static <T> JAXBCoder<T>` `of(Class<T> jaxbClass)` Create a coder for a given type of JAXB annotated objects.
`static <T> JAXBCoder<T>` `of(String jaxbClassName)` Constructor for JSON deserialization only.

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder

`getCoderArguments, getInstanceComponents`

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder

`verifyDeterministic`

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder

`consistentWithEquals, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, toString, verifyDeterministic, verifyDeterministic`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### getJAXBClass

    public Class<T> getJAXBClass()

#### of

    public static <T> JAXBCoder<T> of(Class<T> jaxbClass)

Create a coder for a given type of JAXB annotated objects.

Parameters:
  `jaxbClass` - the `Class` of the JAXB annotated objects.

#### encode

    public void encode(T value,
                       OutputStream outStream,
                       Coder.Context context)
                throws CoderException,
                       IOException

Description copied from interface: `Coder`
Encodes the given value of type `T` onto the given output stream in the given context.

Throws:
  `CoderException` - if the value could not be encoded for some reason
  `IOException` - if writing to the `OutputStream` fails for some reason

#### decode

    public T decode(InputStream inStream,
                    Coder.Context context)
             throws CoderException,
                    IOException

Description copied from interface: `Coder`
Decodes a value of type `T` from the given input stream in the given context. Returns the decoded value.

Throws:
  `CoderException` - if the value could not be decoded for some reason
  `IOException` - if reading from the `InputStream` fails for some reason

#### getEncodingId

    public String getEncodingId()

Description copied from interface: `Coder`
An identifier for the binary format written by `Coder.encode(T, java.io.OutputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context)`.

This value, along with the fully qualified class name, forms an identifier for the binary format of this coder. Whenever this value changes, the new encoding is considered incompatible with the prior format: It is presumed that the prior version of the coder will be unable to correctly read the new format and the new version of the coder will be unable to correctly read the old format.

If the format is changed in a backwards-compatible way (the Coder can still accept data from the prior format), such as by adding optional fields to a Protocol Buffer or Avro definition, and you want Dataflow to understand that the new coder is compatible with the prior coder, this value must remain unchanged. It is then the responsibility of `Coder.decode(java.io.InputStream, com.google.cloud.dataflow.sdk.coders.Coder.Context)` to correctly read data from the prior format.

Specified by:
  `getEncodingId` in interface `Coder<T>`
Overrides:
  `getEncodingId` in class `StandardCoder<T>`

#### of

    public static <T> JAXBCoder<T> of(String jaxbClassName)

Constructor for JSON deserialization only.

#### asCloudObject

    public com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()

Description copied from interface: `Coder`
Returns the `CloudObject` that represents this `Coder`.

Specified by:
  `asCloudObject` in interface `Coder<T>`
Overrides:
  `asCloudObject` in class `StandardCoder<T>`