com.novell.sentinel.json
Class JSONSerializerBase

java.lang.Object
  extended by com.novell.sentinel.json.JSONSerializerBase
All Implemented Interfaces:
JSONHandler
Direct Known Subclasses:
JSONSerializer, JSONToString

public abstract class JSONSerializerBase
extends Object
implements JSONHandler

Base class for implementations that wish to serialize events sent to a JSONHandler.


Constructor Summary
JSONSerializerBase()
          Default constructor.
 
Method Summary
 JSONHandler booleanValue(boolean booleanValue)
          Report a JSON boolean value.
 JSONHandler endArray()
          End the current JSON array.
 JSONHandler endObject()
          End the current JSON object.
 JSONHandler name(String valueName)
          Report the name for the following value (object, array, or simple value).
 JSONHandler nullValue()
          Report a JSON null value.
 JSONHandler numberValue(String numberValue)
          Report a JSON number value.
 void setIndent(boolean indent)
          Cause the output to be indented in a more-human readable form.
 JSONHandler startArray()
          Start a new JSON array.
 JSONHandler startObject()
          Start a new JSON object.
 JSONHandler stringValue(String value)
          Report a JSON string value.
 boolean willIndent()
           
protected abstract  void write(char value)
          Output the passed char to whatever destination the derived class specifies.
protected abstract  void write(String value)
          Output the passed string to whatever destination the derived class specifies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONSerializerBase

public JSONSerializerBase()
Default constructor. The setWriter(java.io.Writer) method must be called before any JSON events are issued to the resulting instance.

Method Detail

write

protected abstract void write(String value)
                       throws IOException
Output the passed string to whatever destination the derived class specifies.

Parameters:
value - The value to write.
Throws:
IOException - If an error occurs while writing.

write

protected abstract void write(char value)
                       throws IOException
Output the passed char to whatever destination the derived class specifies.

Parameters:
value - The value to write.
Throws:
IOException - If an error occurs while writing.

setIndent

public void setIndent(boolean indent)
Cause the output to be indented in a more-human readable form.

Parameters:
indent -

willIndent

public boolean willIndent()
Returns:
true if the output will be indented.

startObject

public JSONHandler startObject()
                        throws IOException
Description copied from interface: JSONHandler
Start a new JSON object.

Specified by:
startObject in interface JSONHandler
Returns:
This handler instance.
Throws:
IOException

endObject

public JSONHandler endObject()
                      throws IOException
Description copied from interface: JSONHandler
End the current JSON object.

Specified by:
endObject in interface JSONHandler
Returns:
This handler instance.
Throws:
IOException

startArray

public JSONHandler startArray()
                       throws IOException
Description copied from interface: JSONHandler
Start a new JSON array.

Specified by:
startArray in interface JSONHandler
Returns:
This handler instance.
Throws:
IOException

endArray

public JSONHandler endArray()
                     throws IOException
Description copied from interface: JSONHandler
End the current JSON array.

Specified by:
endArray in interface JSONHandler
Returns:
This handler instance.
Throws:
IOException

name

public JSONHandler name(String valueName)
                 throws IOException
Description copied from interface: JSONHandler
Report the name for the following value (object, array, or simple value).

Specified by:
name in interface JSONHandler
Parameters:
valueName - The value name.
Returns:
This handler instance.
Throws:
IOException

stringValue

public JSONHandler stringValue(String value)
                        throws IOException
Description copied from interface: JSONHandler
Report a JSON string value.

Specified by:
stringValue in interface JSONHandler
Parameters:
value - The value.
Returns:
This handler instance.
Throws:
IOException

numberValue

public JSONHandler numberValue(String numberValue)
                        throws IOException
Description copied from interface: JSONHandler
Report a JSON number value. The implementation is responsible for converting the lexical representation into the appropriate Java type.

Specified by:
numberValue in interface JSONHandler
Parameters:
numberValue - The lexical representation of a JSON number value.
Returns:
This handler instance.
Throws:
IOException

booleanValue

public JSONHandler booleanValue(boolean booleanValue)
                         throws IOException
Description copied from interface: JSONHandler
Report a JSON boolean value.

Specified by:
booleanValue in interface JSONHandler
Parameters:
booleanValue - true or false
Returns:
This handler instance.
Throws:
IOException

nullValue

public JSONHandler nullValue()
                      throws IOException
Description copied from interface: JSONHandler
Report a JSON null value.

Specified by:
nullValue in interface JSONHandler
Returns:
This handler instance.
Throws:
IOException