cc.plural.jsonij.marshal.codec
Class DateJSONCodec<D extends Date>

java.lang.Object
  extended by cc.plural.jsonij.marshal.JSONCodec<D>
      extended by cc.plural.jsonij.marshal.codec.DateJSONCodec<D>

public class DateJSONCodec<D extends Date>
extends JSONCodec<D>

JSON codec implementation for java.util.Date. Encodes a java.util.Date instance into a JSON Object with two attributes,

  1. $type - The JSON String "java.util.Date"
  2. time - The value of getTime() from the java.util.Date

Author:
openecho

Constructor Summary
DateJSONCodec()
           
 
Method Summary
 DateJSONCodec<? extends Date> createInstance()
          Helper method to create the specific internalType of the DateJSONCodec.
 D decode(Value value)
          The decode method for the DateJSONCodec.
 Value encode(D d)
          The encode method for the DateJSONCodec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateJSONCodec

public DateJSONCodec()
Method Detail

createInstance

public DateJSONCodec<? extends Date> createInstance()
Helper method to create the specific internalType of the DateJSONCodec. This is required to circumvent a short coming of Java Generics. Simply return a new instance of the codec class with the generic internalType specified.

Specified by:
createInstance in class JSONCodec<D extends Date>
Returns:
DateJSONCodec instance.

encode

public Value encode(D d)
The encode method for the DateJSONCodec.

Specified by:
encode in class JSONCodec<D extends Date>
Parameters:
d - Accepts any class D that extends java.util.Date
Returns:
Value Object for the java.util.Date that is passed.

decode

public D decode(Value value)
The decode method for the DateJSONCodec.

Specified by:
decode in class JSONCodec<D extends Date>
Parameters:
value - The JSON Value to be decoded.
Returns:
D that extends java.util.Date representing the passed JSON Value


Copyright © 2012. All Rights Reserved.