com.plumtree.portalpages.rest.utils
Class JSONParser

java.lang.Object
  extended by com.plumtree.uiinfrastructure.utils.JavascriptParser
      extended by com.plumtree.portalpages.rest.utils.JSONParser
All Implemented Interfaces:
IJSONParser

public class JSONParser
extends JavascriptParser
implements IJSONParser


Field Summary
protected  java.lang.String m_strObjectName
           
protected  XPHashtable m_xpMembers
           
 
Fields inherited from class com.plumtree.uiinfrastructure.utils.JavascriptParser
CLOSE_BRACKET, CLOSE_CURLY_BRACKET, COLON, COMMA, ESCAPE, m_rootList, m_rootObj, OPEN_BRACKET, OPEN_CURLY_BRACKET, QUOTE, SINGLE_QUOTE
 
Constructor Summary
JSONParser()
          Private constructor so it can only be accessed by the GetInstance method.
 
Method Summary
static IJSONParser GetInstance()
           
 java.lang.String GetMember(java.lang.String _strName)
           
 java.lang.Boolean GetMemberAsBool(java.lang.String name)
          For boolean member values
 java.lang.Integer GetMemberAsInt(java.lang.String name)
          For integer member values
 IXPList GetMemberAsList(java.lang.String name)
          For array object members
 XPHashtable GetMemberAsMap(java.lang.String name)
          For members with nested object values
 java.lang.String GetMemberAsString(java.lang.String name)
          For string or
 java.lang.String GetObjectName()
           
protected  java.lang.String ParseJSOMemberLabel(XPStringTokenizer tokz)
          Gets the name of a javascript object member Expects the next token of the string tokenizer to be the double quote around the label.
 void ParseJSONObject(java.lang.String _strJSON)
          Parses the supplied JSON object.
 
Methods inherited from class com.plumtree.uiinfrastructure.utils.JavascriptParser
GetEscapedTokenAndEndQuote, GetNextToken, GetRootArray, GetRootObject, GetToken, IsJSComment, IsNewArray, IsNewJSObject, IsRootArray, IsRootObject, IsWhiteSpace, ParseJSArray, ParseJSObject, ParseJSOMemberValue, ParseJSSimpleValue, ParseJSString, SkipToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_strObjectName

protected java.lang.String m_strObjectName

m_xpMembers

protected XPHashtable m_xpMembers
Constructor Detail

JSONParser

public JSONParser()
Private constructor so it can only be accessed by the GetInstance method. rob: changed to public for now since the ijsoninterface is only meant for a narrow use-case when this parser has been extended to a generic json parser

Method Detail

GetInstance

public static IJSONParser GetInstance()
Returns:
an instance of a IJSONParser.

ParseJSOMemberLabel

protected java.lang.String ParseJSOMemberLabel(XPStringTokenizer tokz)
Gets the name of a javascript object member Expects the next token of the string tokenizer to be the double quote around the label. This method will also consume the ending double quote and following colon.

Overrides:
ParseJSOMemberLabel in class JavascriptParser
Parameters:
tokz -
Returns:

ParseJSONObject

public void ParseJSONObject(java.lang.String _strJSON)
Description copied from interface: IJSONParser
Parses the supplied JSON object.

Specified by:
ParseJSONObject in interface IJSONParser
Parameters:
_strJSON - the JSON string to be parsed.

GetObjectName

public java.lang.String GetObjectName()
Specified by:
GetObjectName in interface IJSONParser
Returns:
the top-level JSON object name.

GetMember

public java.lang.String GetMember(java.lang.String _strName)
Specified by:
GetMember in interface IJSONParser
Parameters:
_strName - The key for the JSON member to be returned.
Returns:
the requested JSON member value.

GetMemberAsString

public java.lang.String GetMemberAsString(java.lang.String name)
For string or

Parameters:
strName -
Returns:

GetMemberAsBool

public java.lang.Boolean GetMemberAsBool(java.lang.String name)
For boolean member values

Parameters:
name -
Returns:

GetMemberAsInt

public java.lang.Integer GetMemberAsInt(java.lang.String name)
For integer member values

Parameters:
name -
Returns:

GetMemberAsList

public IXPList GetMemberAsList(java.lang.String name)
For array object members

Parameters:
name -
Returns:

GetMemberAsMap

public XPHashtable GetMemberAsMap(java.lang.String name)
For members with nested object values

Returns:



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.