JSON
Version 1.0

org.codehaus.jackson
Class JsonWriteContext

java.lang.Object
  extended by org.codehaus.jackson.JsonWriteContext

public abstract class JsonWriteContext
extends Object

Context object is used to keep track of relative logical position of the current event when generating json content.


Nested Class Summary
static class JsonWriteContext.Type
          Type of the context
 
Field Summary
protected  int mIndex
          Index of the currently processed entry.
protected  JsonWriteContext mParent
           
static int STATUS_EXPECT_NAME
           
static int STATUS_EXPECT_VALUE
           
static int STATUS_OK_AFTER_COLON
           
static int STATUS_OK_AFTER_COMMA
           
static int STATUS_OK_AFTER_SPACE
           
static int STATUS_OK_AS_IS
           
 
Constructor Summary
JsonWriteContext(JsonWriteContext parent)
           
 
Method Summary
protected abstract  void appendDesc(StringBuilder sb)
           
 JsonWriteContext createChildArrayContext()
           
 JsonWriteContext createChildObjectContext()
           
static JsonWriteContext createRootContext()
           
 int getCurrentIndex()
           
 int getEntryCount()
           
 JsonWriteContext getParent()
           
abstract  JsonWriteContext.Type getType()
           
 boolean inArray()
           
 boolean inObject()
           
 boolean isRoot()
           
 String toString()
          Overridden to provide developer writeable "JsonPath" representation of the context.
abstract  int writeFieldName(String name)
          Method that writer is to call before it writes a field name.
abstract  int writeValue()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_OK_AS_IS

public static final int STATUS_OK_AS_IS
See Also:
Constant Field Values

STATUS_OK_AFTER_COMMA

public static final int STATUS_OK_AFTER_COMMA
See Also:
Constant Field Values

STATUS_OK_AFTER_COLON

public static final int STATUS_OK_AFTER_COLON
See Also:
Constant Field Values

STATUS_OK_AFTER_SPACE

public static final int STATUS_OK_AFTER_SPACE
See Also:
Constant Field Values

STATUS_EXPECT_VALUE

public static final int STATUS_EXPECT_VALUE
See Also:
Constant Field Values

STATUS_EXPECT_NAME

public static final int STATUS_EXPECT_NAME
See Also:
Constant Field Values

mParent

protected final JsonWriteContext mParent

mIndex

protected int mIndex
Index of the currently processed entry. Starts with -1 to signal that no entries have been started, and gets advanced each time a new entry is started.

Constructor Detail

JsonWriteContext

public JsonWriteContext(JsonWriteContext parent)
Method Detail

createRootContext

public static JsonWriteContext createRootContext()

createChildArrayContext

public final JsonWriteContext createChildArrayContext()

createChildObjectContext

public final JsonWriteContext createChildObjectContext()

getParent

public final JsonWriteContext getParent()

isRoot

public final boolean isRoot()

getEntryCount

public final int getEntryCount()

getCurrentIndex

public final int getCurrentIndex()
Returns:
Index of the currently processed entry, if any

getType

public abstract JsonWriteContext.Type getType()

writeFieldName

public abstract int writeFieldName(String name)
Method that writer is to call before it writes a field name.

Returns:
Index of the field entry (0-based)

writeValue

public abstract int writeValue()

inArray

public boolean inArray()

inObject

public boolean inObject()

appendDesc

protected abstract void appendDesc(StringBuilder sb)

toString

public final String toString()
Overridden to provide developer writeable "JsonPath" representation of the context.

Overrides:
toString in class Object

JSON
Version 1.0

Apache License, Version 2.0