Abstract Codec class.
@author Denis Neuling (denisneuling@gmail.com) @since 0.1.1This interface provides pluggability for different ways of encoding XML infoset, such as plain XML (plus MIME attachments), XOP, and FastInfoset.
Transport usually needs a MIME content type of the encoding, so the {@link Codec}interface is designed to return this information. However, for some encoding (such as XOP), the encoding may actually change based on the actual content of {@link Message}, therefore the codec returns the content type as a result of encoding.
{@link Codec} does not produce transport-specific information, such as HTTP headers.
{@link Codec} is a non-reentrant object, meaning no two threadscan concurrently invoke the decode method. This allows the implementation to easily reuse parser objects (as instance variables), which are costly otherwise.
{@link BindingID} determines the {@link Codec}. See {@link BindingID#createEncoder(WSBinding)}. @author Kohsuke Kawaguchi @see EndpointAwareCodec
This interface provides pluggability for different ways of encoding XML infoset, such as plain XML (plus MIME attachments), XOP, and FastInfoset.
Transport usually needs a MIME content type of the encoding, so the {@link Codec}interface is designed to return this information. However, for some encoding (such as XOP), the encoding may actually change based on the actual content of {@link Message}, therefore the codec returns the content type as a result of encoding.
{@link Codec} does not produce transport-specific information, such as HTTP headers.
{@link Codec} is a non-reentrant object, meaning no two threadscan concurrently invoke the decode method. This allows the implementation to easily reuse parser objects (as instance variables), which are costly otherwise.
{@link BindingID} determines the {@link Codec}. See {@link BindingID#createEncoder(WSBinding)}. @author Kohsuke Kawaguchi @see EndpointAwareCodec
Generally the input side will provide a charset name which drives the char/byte codec behaviour of WBSAX. If the input side provides all strings, then it may leave the charset name as null, in which case the output side may nominate the charset it wishes the strings to be converted to.
public class LongToString implements Codec<Long,String> { {@literal @}Override public Class sourceType() { return Long.class; } {@literal @}Override public Class targetType() { return String.class; } {@literal @}Override public String encode(Long fromJava) throws AchillesTranscodingException { return fromJava.toString(); } {@literal @}Override public Long decode(String fromCassandra) throws AchillesTranscodingException { return Long.parseLong(fromCassandra); } }
@param < FROM> sourceType
@param < TO> targetType compatible with Cassandra
This is a backport of the Codec from HBase 0.96, but ignoring support for a Cell interface and sticking with the good, old {@link KeyValue}.
n
is multiplied by H^n
. So the number 1234 may be represented as the sequence 4 3 2 1 with a radix (H) of 10. Note that other permutations are also possible; 43 2 1 will also encode 1234. The co-parameter L is defined as 256-H. This is important because only the last value in a sequence may be < L; all prior values must be > L.1 1 1 1 1
will represent the sequence 1 2 3 4 5
. For this reason, the codec supports two variants of decode; one {@link #decode(InputStream,long) with} and one{@link #decode(InputStream) without} a last
parameter. If thecodec is a non-delta encoding, then the value is ignored if passed. If the codec is a delta encoding, it is a run-time error to call the value without the extra parameter, and the previous value should be returned. (It was designed this way to support multi-threaded access without requiring a new instance of the Codec to be cloned for each use.) Note, when extending this class, the name ( {@link #getName}) is written into the index. In order for the segment to be read, the name must resolve to your implementation via {@link #forName(String)}. This method uses Java's {@link ServiceLoader Service Provider Interface} (SPI) to resolve codec names.
If you implement your own codec, make sure that it has a no-arg constructor so SPI can load it. @see ServiceLoader
|
|
|
|