com.esri.arcgis.system
Class JSONWriter

java.lang.Object
  extended by com.esri.arcgis.system.JSONWriter
All Implemented Interfaces:
com.esri.arcgis.interop.RemoteObjRef, IJSONWriter, IJSONWriter2, ISupportErrorInfo, Serializable

public class JSONWriter
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IJSONWriter, IJSONWriter2, ISupportErrorInfo

A sequential JSON Writer.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

See Also:
Serialized Form

Constructor Summary
JSONWriter()
          Constructs a JSONWriter using ArcGIS Engine.
JSONWriter(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
JSONWriter theJSONWriter = (JSONWriter) obj;
 
Method Summary
 void endArray()
          Ends an array.
 void endObject()
          Ends writing of an object.
 boolean equals(Object o)
          Compare this object with another
static String getClsid()
          getClsid.
 IStream getStream()
          Obtains underlying stream.
 byte[] getStringBuffer()
          Obtains copy of string buffer.
 int hashCode()
          the hashcode for this object
 void interfaceSupportsErrorInfo(GUID riid)
          interfaceSupportsErrorInfo
 void reset()
          Resets IJSONWriter's internal state.
 void setFormatted(boolean value)
          Writes 'pretty' formatting on or off.
 void setIndent(int value)
          Writes indent for 'pretty' formatting.
 void startArray(String name)
          Starts an array.
 void startObject(String name)
          Starts writing an object.
 void writeBinary(String name, byte[] value)
          Writes a byte array.
 void writeBinaryVal(byte[] value)
          Writes a byte array.
 void writeBoolean(String name, boolean value)
          Writes a boolean.
 void writeBooleanVal(boolean value)
          Writes a boolean in array.
 void writeByte(String name, byte value)
          Writes a byte.
 void writeByteVal(byte value)
          Writes a byte in array.
 void writeDate(String name, Date value, boolean asString)
          Writes a date.
 void writeDateVal(Date value, boolean asString)
          Writes a date in array.
 void writeDouble(String name, double value)
          Writes a double.
 void writeDoubleEx(String name, double value, int precision)
          Writes a double with specified number of digits after decimal point.
 void writeDoubleVal(double value)
          Writes a double in array.
 void writeDoubleValEx(double value, int precision)
          Writes a double in array with specified number of digits after decimal point.
 void writeFloat(String name, float value)
          Writes a float.
 void writeFloatVal(float value)
          Writes a float in array.
 void writeInteger(String name, int value)
          Writes an integer.
 void writeIntegerVal(int value)
          Writes an integer in array.
 void writeNull(String name)
          Writes null property.
 void writeNullVal()
          Writes null value in array.
 void writeRawString(String name, String value)
          Writes a raw property without any processing.
 void writeRawStringVal(String value)
          Writes a raw value without any processing.
 void writeShort(String name, short value)
          Writes a short.
 void writeShortVal(short value)
          Writes a short int in array.
 void writeString(String name, String value)
          Writes a string property.
 void writeStringVal(String value)
          Writes a string in array.
 void writeTo(IStream outputStream)
          Specifies output JSON stream.
 void writeToString()
          Redirects writing to internal string buffer.
 void writeVariant(String name, Object value)
          Writes a variant valued property.
 void writeVariantVal(Object value)
          Writes a variant in array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

JSONWriter

public JSONWriter()
           throws IOException,
                  UnknownHostException
Constructs a JSONWriter using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

JSONWriter

public JSONWriter(Object obj)
           throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
JSONWriter theJSONWriter = (JSONWriter) obj;

Construct a JSONWriter using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to JSONWriter.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

writeTo

public void writeTo(IStream outputStream)
             throws IOException,
                    AutomationException
Specifies output JSON stream.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeTo in interface IJSONWriter
Parameters:
outputStream - A reference to a com.esri.arcgis.system.IStream (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeToString

public void writeToString()
                   throws IOException,
                          AutomationException
Redirects writing to internal string buffer.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeToString in interface IJSONWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getStringBuffer

public byte[] getStringBuffer()
                       throws IOException,
                              AutomationException
Obtains copy of string buffer. Encoding is UTF8.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getStringBuffer in interface IJSONWriter
Returns:
An unsigned byte
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getStream

public IStream getStream()
                  throws IOException,
                         AutomationException
Obtains underlying stream. If WriteTo() is not called yet, will return NULL. Also will return NULL if WriteToString() was called.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
getStream in interface IJSONWriter
Returns:
A reference to a com.esri.arcgis.system.IStream
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setFormatted

public void setFormatted(boolean value)
                  throws IOException,
                         AutomationException
Writes 'pretty' formatting on or off.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
setFormatted in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setIndent

public void setIndent(int value)
               throws IOException,
                      AutomationException
Writes indent for 'pretty' formatting. Default is 2.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
setIndent in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

startObject

public void startObject(String name)
                 throws IOException,
                        AutomationException
Starts writing an object.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
startObject in interface IJSONWriter
Parameters:
name - The name (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

endObject

public void endObject()
               throws IOException,
                      AutomationException
Ends writing of an object.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
endObject in interface IJSONWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

startArray

public void startArray(String name)
                throws IOException,
                       AutomationException
Starts an array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
startArray in interface IJSONWriter
Parameters:
name - The name (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

endArray

public void endArray()
              throws IOException,
                     AutomationException
Ends an array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
endArray in interface IJSONWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeVariant

public void writeVariant(String name,
                         Object value)
                  throws IOException,
                         AutomationException
Writes a variant valued property.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeVariant in interface IJSONWriter
Parameters:
name - The name (in)
value - A Variant (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeString

public void writeString(String name,
                        String value)
                 throws IOException,
                        AutomationException
Writes a string property.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeString in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBoolean

public void writeBoolean(String name,
                         boolean value)
                  throws IOException,
                         AutomationException
Writes a boolean.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeBoolean in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeByte

public void writeByte(String name,
                      byte value)
               throws IOException,
                      AutomationException
Writes a byte.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeByte in interface IJSONWriter
Parameters:
name - The name (in)
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeShort

public void writeShort(String name,
                       short value)
                throws IOException,
                       AutomationException
Writes a short.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeShort in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeInteger

public void writeInteger(String name,
                         int value)
                  throws IOException,
                         AutomationException
Writes an integer.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeInteger in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeFloat

public void writeFloat(String name,
                       float value)
                throws IOException,
                       AutomationException
Writes a float.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeFloat in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDouble

public void writeDouble(String name,
                        double value)
                 throws IOException,
                        AutomationException
Writes a double.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDouble in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDate

public void writeDate(String name,
                      Date value,
                      boolean asString)
               throws IOException,
                      AutomationException
Writes a date.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDate in interface IJSONWriter
Parameters:
name - The name (in)
value - The value (in)
asString - The asString (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBinary

public void writeBinary(String name,
                        byte[] value)
                 throws IOException,
                        AutomationException
Writes a byte array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeBinary in interface IJSONWriter
Parameters:
name - The name (in)
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeNull

public void writeNull(String name)
               throws IOException,
                      AutomationException
Writes null property.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeNull in interface IJSONWriter
Parameters:
name - The name (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeVariantVal

public void writeVariantVal(Object value)
                     throws IOException,
                            AutomationException
Writes a variant in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeVariantVal in interface IJSONWriter
Parameters:
value - A Variant (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeStringVal

public void writeStringVal(String value)
                    throws IOException,
                           AutomationException
Writes a string in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeStringVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBooleanVal

public void writeBooleanVal(boolean value)
                     throws IOException,
                            AutomationException
Writes a boolean in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeBooleanVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeByteVal

public void writeByteVal(byte value)
                  throws IOException,
                         AutomationException
Writes a byte in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeByteVal in interface IJSONWriter
Parameters:
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeShortVal

public void writeShortVal(short value)
                   throws IOException,
                          AutomationException
Writes a short int in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeShortVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeIntegerVal

public void writeIntegerVal(int value)
                     throws IOException,
                            AutomationException
Writes an integer in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeIntegerVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeFloatVal

public void writeFloatVal(float value)
                   throws IOException,
                          AutomationException
Writes a float in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeFloatVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDoubleVal

public void writeDoubleVal(double value)
                    throws IOException,
                           AutomationException
Writes a double in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDoubleVal in interface IJSONWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDateVal

public void writeDateVal(Date value,
                         boolean asString)
                  throws IOException,
                         AutomationException
Writes a date in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDateVal in interface IJSONWriter
Parameters:
value - The value (in)
asString - The asString (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBinaryVal

public void writeBinaryVal(byte[] value)
                    throws IOException,
                           AutomationException
Writes a byte array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeBinaryVal in interface IJSONWriter
Parameters:
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeNullVal

public void writeNullVal()
                  throws IOException,
                         AutomationException
Writes null value in array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeNullVal in interface IJSONWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

reset

public void reset()
           throws IOException,
                  AutomationException
Resets IJSONWriter's internal state.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
reset in interface IJSONWriter2
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeRawString

public void writeRawString(String name,
                           String value)
                    throws IOException,
                           AutomationException
Writes a raw property without any processing. Use to insert JSON sub-object or sub-array strings only.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeRawString in interface IJSONWriter2
Parameters:
name - The name (in)
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeRawStringVal

public void writeRawStringVal(String value)
                       throws IOException,
                              AutomationException
Writes a raw value without any processing. Use to insert JSON sub-object or sub-array strings only.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeRawStringVal in interface IJSONWriter2
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDoubleValEx

public void writeDoubleValEx(double value,
                             int precision)
                      throws IOException,
                             AutomationException
Writes a double in array with specified number of digits after decimal point.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDoubleValEx in interface IJSONWriter2
Parameters:
value - The value (in)
precision - The precision (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDoubleEx

public void writeDoubleEx(String name,
                          double value,
                          int precision)
                   throws IOException,
                          AutomationException
Writes a double with specified number of digits after decimal point.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
writeDoubleEx in interface IJSONWriter2
Parameters:
name - The name (in)
value - The value (in)
precision - The precision (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

interfaceSupportsErrorInfo

public void interfaceSupportsErrorInfo(GUID riid)
                                throws IOException,
                                       AutomationException
interfaceSupportsErrorInfo

Description

Indicates whether the interface supports IErrorInfo.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
interfaceSupportsErrorInfo in interface ISupportErrorInfo
Parameters:
riid - A Structure: com.esri.arcgis.support.ms.stdole.GUID (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.