TrueUpdate Core 0.1.4

net.java.trueupdate.core.codec
Interface Codec

All Known Implementing Classes:
JaxbCodec

public interface Codec

Defines an object graph encoding/decoding (alias serialization).

Author:
Christian Schlichtherle (copied and edited from TrueLicense Core 2.3.1)

Method Summary
 String contentTransferEncoding()
          Returns an identifier for the content transfer encoding used by this codec.
 String contentType()
          Returns an identifier for the content type used by this codec.
<T> T
decode(Source source, Type expected)
          Decodes a nullable object graph from the given source.
 void encode(Sink sink, Object obj)
          Encodes a nullable object graph to the given sink.
 

Method Detail

contentTransferEncoding

String contentTransferEncoding()
Returns an identifier for the content transfer encoding used by this codec. The returned string must conform to the syntax specified in RFC2045 "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", Section 6.1 "Content-Transfer-Encoding Syntax", except that it must not start with "Content-Transfer-Encoding:" and optional spaces, i.e. the field name must be stripped.

If the Content-Transfer-Encoding equals (ignoring case) "8bit" and the Content-Type does not specify a charset parameter, then UTF-8 is assumed as the charset.


contentType

String contentType()
Returns an identifier for the content type used by this codec. The returned string must conform to the syntax specified in RFC2045 "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", Section 5.1 "Syntax of the Content-Type Header Field", except that it must not start with "Content-Type:" and optional spaces, i.e. the field name is stripped.


decode

@Nullable
<T> T decode(Source source,
                      Type expected)
         throws Exception
Decodes a nullable object graph from the given source.

Type Parameters:
T - the expected generic type of the decoded object.
Parameters:
source - the source from where to read the encoded object graph from.
expected - the expected generic type of the decoded object graph, e.g. String.class. This is just a hint and the implementation may ignore it.
Returns:
A duplicate of the original object graph. Its actual type may differ from the expected generic type. It may be null if and only if the original object graph was null.
Throws:
Exception

encode

void encode(Sink sink,
            @Nullable
            Object obj)
            throws Exception
Encodes a nullable object graph to the given sink.

Parameters:
sink - the sink to write the encoded object graph to.
obj - the nullable object graph. Implementations should support encoding null. If they do not support this, then this should be documented in the Javadoc.
Throws:
Exception

TrueUpdate Core 0.1.4

Copyright © 2013 Stimulus Software. All rights reserved.