de.hpi.fgis.dude.util.data.json
Class JsonNull

java.lang.Object
  extended by de.hpi.fgis.dude.util.data.json.JsonNull
All Implemented Interfaces:
AutoJsonable, JsonAtomic, JsonValue, Jsonable, Comparable<JsonValue>

public class JsonNull
extends Object
implements JsonAtomic

JsonNull represents the Json null value. Parts of the code are reused and were taken from the JSON.org implementation.

Author:
Matthias Pohl

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.hpi.fgis.dude.util.data.json.JsonValue
JsonValue.JsonType
 
Field Summary
static JsonNull NULL
          The Json null value.
 
Method Summary
protected  Object clone()
          There is only intended to be a single instance of the NULL object, so the clone method returns itself.
 int compareTo(JsonValue other)
          Compares the current instance with the passed JsonValue.
 boolean equals(Object object)
          A JsonRecord.JsonNull object is equal to the null value and to itself.
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
 String getStringValue()
          Returns the actual value converted into a String.
 JsonValue.JsonType getType()
          Returns JsonType.Null.
 int hashCode()
           
 int size()
          Returns 0 since JsonRecord.JsonNull does not have any value.
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 String toString()
          Returns the "null" String value.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final JsonNull NULL
The Json null value.

Method Detail

clone

protected final Object clone()
There is only intended to be a single instance of the NULL object, so the clone method returns itself.

Overrides:
clone in class Object
Returns:
NULL.

equals

public boolean equals(Object object)
A JsonRecord.JsonNull object is equal to the null value and to itself.

Overrides:
equals in class Object
Parameters:
object - An object to test for being null.
Returns:
true if the object parameter is the JsonRecord.JsonNull object or null; otherwise false.

toString

public String toString()
Returns the "null" String value.

Overrides:
toString in class Object
Returns:
The String "null".

getType

public JsonValue.JsonType getType()
Returns JsonType.Null.

Specified by:
getType in interface JsonValue
Returns:
The type of the current instance.
See Also:
JsonValue.getType()

size

public int size()
Returns 0 since JsonRecord.JsonNull does not have any value.

Specified by:
size in interface JsonValue
Returns:
The number of concrete Java objects that are collected by the current instance.
See Also:
JsonValue.size()

compareTo

public int compareTo(JsonValue other)
Description copied from interface: JsonValue
Compares the current instance with the passed JsonValue. Instances of different JsonValue.JsonTypes are ordered lexicographically except for JsonValue.JsonType.Null. The above mentioned requirements define the following order: null == JsonValue.JsonType.Null < JsonValue.JsonType.Array < JsonValue.JsonType.Boolean < JsonValue.JsonType.Number < JsonValue.JsonType.Record < JsonValue.JsonType.String.

Specified by:
compareTo in interface JsonValue
Specified by:
compareTo in interface Comparable<JsonValue>
See Also:
Comparable.compareTo(Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.

getStringValue

public String getStringValue()
Description copied from interface: JsonAtomic
Returns the actual value converted into a String. This method should be preferred in contrast to #toString().

Specified by:
getStringValue in interface JsonAtomic
Returns:
The actual value converted into a String.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.