IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.base
Class AjaxJSONFormat

java.lang.Object
  extended by com.ibm.btt.base.FormatElement
      extended by com.ibm.btt.base.KeyedCollectionFormat
          extended by com.ibm.btt.base.RecordFormat
              extended by com.ibm.btt.base.AjaxJSONFormat
All Implemented Interfaces:
Cacheable, java.io.Externalizable, java.io.Serializable

public class AjaxJSONFormat
extends RecordFormat

See Also:
Serialized Form

Field Summary
protected  java.lang.String escape
           
protected  java.lang.String unNamed
          unNamed tag attribute
 
Fields inherited from class com.ibm.btt.base.KeyedCollectionFormat
dataElementEmpty, elements
 
Fields inherited from class com.ibm.btt.base.FormatElement
dataElementName, externalizer, name
 
Constructor Summary
AjaxJSONFormat()
          This constructor creates an AjaxJSONFormat object.
AjaxJSONFormat(java.lang.String aName)
          This constructor creates an AjaxJSONFormat object with a specified name.
 
Method Summary
protected  java.lang.String escape(java.lang.String msg)
          " => \" , \ => \\
 java.lang.String[] extract(java.lang.String aString)
          Extracts a String taking the substring in which the format is interested.
protected static java.lang.String[] extractElement(java.lang.String aString)
          Extracts from aString the element named elementName.
 java.lang.String format(Context aContext)
          Formats data elements getting them from the context.
 java.lang.String format(KeyedCollection aKeyedCollection)
          Formats data elements, getting them from the collection passes as a parameter.
 java.lang.String formatAsJSON(DataElement aDataElement, FormatElement aFormatElement)
          Formats aDataElement to an JSON-compliant format.
 java.lang.String formatContext(Context aContext)
          This method performs the format seeking the elements to format around the context tree of the context passed as parameter.
 java.lang.String formatKeyedCollection(KeyedCollection aKeyedCollection)
          This method performs the format seeking the elements to format around the keyedCollection passed as parameter.
protected static int getArrayTagEndIndex(java.lang.String str)
          Get the end index of the array
 java.lang.String getEscape()
           
protected static int getFirstColon(java.lang.String str)
           
protected static int getFirstComma(java.lang.String str)
           
protected static java.lang.String getNameFromJSONStr(java.lang.String str)
           
protected static int getObjectTagEndIndex(java.lang.String str)
          Get the end index of the object tag
 java.lang.String getUnNamed()
          Returns the value of the unNamed property.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes an JSONFormat with the aTag attributes.
 boolean isEscape()
          Check whether the format are required to escape the format result or unescape the input string before unformat.
 boolean isUnNamed()
          Returns the boolean value of the unNamed property.
protected static java.lang.String removeFirstComma(java.lang.String str)
          remove the first comma
protected static java.lang.String removeSurround(java.lang.String str, java.lang.String preStr, java.lang.String postStr)
          remove the surround string using the prefix and suffix
 void setEscape(java.lang.String newEscape)
          Sets the value of the escape property.
 void setUnNamed(java.lang.String newUnNamed)
          Sets the value of the unNamed property.
 Vector toStrings()
          Returns a visual representation of this format element.
protected  java.lang.String unescape(java.lang.String msg)
          Do the unescape operation
 int unformat(int ndxFrom, int ndxTo, java.lang.String aString, Context aContext)
          The method is not implemented for the JSON Format.
 int unformat(int ndxFrom, int ndxTo, java.lang.String str, DataElement de)
          The method is not implemented for the JSON Format.
 DataElement unformatContext(java.lang.String aString, Context aContext)
          Unformats an JSONFormat updating data elements in the context.
 void unformatJSON(java.lang.String aString, DataElement aDataElement, FormatElement aFormatElement)
          This method unformats a String JSON compliant format in aDataElement.
 KeyedCollection unformatKeyedCollection(java.lang.String aString, KeyedCollection aKeyedCollection)
          Unformats an JSONFormat updating data elements in the collection passed as a parameter.
 
Methods inherited from class com.ibm.btt.base.RecordFormat
obtainDataElement, obtainDataElement, toString
 
Methods inherited from class com.ibm.btt.base.KeyedCollectionFormat
add, addElementAt, addFirst, at, checkIndexes, format, getDataElementEmpty, getElements, getEnumeration, reinitialize, removeAll, removeAt, setElements, size, unformat, unformat
 
Methods inherited from class com.ibm.btt.base.FormatElement
exceptionInfo, externalizer, getDataElementName, getExternalizer, getName, getTagName, isCacheable, isConstant, isItConstant, isNull, readExternal, readExternal, readObject, removeExternal, rootDecorated, setDataElementName, setExternalizer, setName, setSize, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

unNamed

protected java.lang.String unNamed
unNamed tag attribute. *


escape

protected java.lang.String escape
Constructor Detail

AjaxJSONFormat

public AjaxJSONFormat()
This constructor creates an AjaxJSONFormat object.


AjaxJSONFormat

public AjaxJSONFormat(java.lang.String aName)
               throws java.io.IOException
This constructor creates an AjaxJSONFormat object with a specified name.

Parameters:
aName - java.lang.String
Throws:
java.io.IOException
Method Detail

extract

public java.lang.String[] extract(java.lang.String aString)
                           throws DSEInvalidArgumentException
Extracts a String taking the substring in which the format is interested.

Overrides:
extract in class RecordFormat
Parameters:
aString - java.lang.String - A string which contains formated strings
Returns:
String[] - The first element is the part of the provided string that is able to unformat and the second is the rest of the provided string
Throws:
DSEInvalidArgumentException

removeSurround

protected static java.lang.String removeSurround(java.lang.String str,
                                                 java.lang.String preStr,
                                                 java.lang.String postStr)
remove the surround string using the prefix and suffix

Parameters:
str - the string content
preStr - the prefix
postStr - the suffix
Returns:
the content

getFirstComma

protected static int getFirstComma(java.lang.String str)
Parameters:
str - the string content
Returns:
the index of the first comma

getFirstColon

protected static int getFirstColon(java.lang.String str)
Parameters:
str - the string content
Returns:
the index of the first colon

removeFirstComma

protected static java.lang.String removeFirstComma(java.lang.String str)
remove the first comma

Parameters:
str - the string content
Returns:
the result

escape

protected java.lang.String escape(java.lang.String msg)
" => \" , \ => \\

Parameters:
str -
Returns:
Throws:
java.io.UnsupportedEncodingException

unescape

protected java.lang.String unescape(java.lang.String msg)
Do the unescape operation

Parameters:
msg - the message
Returns:
the unescaped string

getNameFromJSONStr

protected static java.lang.String getNameFromJSONStr(java.lang.String str)
Parameters:
str - the string content
Returns:
the name

getArrayTagEndIndex

protected static int getArrayTagEndIndex(java.lang.String str)
Get the end index of the array

Parameters:
str - the string content
Returns:
the index

getObjectTagEndIndex

protected static int getObjectTagEndIndex(java.lang.String str)
Get the end index of the object tag

Parameters:
str - the string content
Returns:
the end index

extractElement

protected static java.lang.String[] extractElement(java.lang.String aString)
                                            throws DSEInvalidArgumentException
Extracts from aString the element named elementName.

Parameters:
elementName - java.lang.String
aString - java.lang.String
Returns:
String[]
Throws:
DSEInvalidArgumentException

format

public java.lang.String format(Context aContext)
                        throws DSEInvalidClassException,
                               DSEInvalidRequestException,
                               DSEInvalidArgumentException
Formats data elements getting them from the context.

Overrides:
format in class KeyedCollectionFormat
Parameters:
aContext - com.ibm.btt.base.Context
Returns:
java.lang.String
Throws:
com.ibm.btt.base.DSEInvalidClassException.
DSEInvalidRequestException - ,
DSEInvalidArgumentException
DSEInvalidClassException

format

public java.lang.String format(KeyedCollection aKeyedCollection)
                        throws DSEInvalidClassException,
                               DSEInvalidRequestException,
                               DSEInvalidArgumentException
Formats data elements, getting them from the collection passes as a parameter.

Parameters:
aKeyedCollection - com.ibm.btt.base.KeyedCollection
Returns:
java.lang.String
Throws:
com.ibm.btt.base.DSEInvalidClassException.
DSEInvalidRequestException - ,
DSEInvalidArgumentException
DSEInvalidClassException

formatAsJSON

public java.lang.String formatAsJSON(DataElement aDataElement,
                                     FormatElement aFormatElement)
Formats aDataElement to an JSON-compliant format.

Parameters:
aDataElement - com.ibm.btt.base.DataElement
aFormatElement - com.ibm.btt.base.FormatElement
Returns:
java.lang.String

formatContext

public java.lang.String formatContext(Context aContext)
                               throws DSEInvalidClassException,
                                      DSEInvalidRequestException,
                                      DSEInvalidArgumentException
This method performs the format seeking the elements to format around the context tree of the context passed as parameter.

Overrides:
formatContext in class RecordFormat
Parameters:
aContext - com.ibm.btt.base.Context
Returns:
java.lang.String
Throws:
DSEInvalidClassException
DSEInvalidRequestException
DSEInvalidArgumentException

formatKeyedCollection

public java.lang.String formatKeyedCollection(KeyedCollection aKeyedCollection)
                                       throws DSEInvalidClassException,
                                              DSEInvalidRequestException,
                                              DSEInvalidArgumentException
This method performs the format seeking the elements to format around the keyedCollection passed as parameter.

Overrides:
formatKeyedCollection in class RecordFormat
Parameters:
aKeyedCollection - com.ibm.btt.base.KeyedCollection
Returns:
java.lang.String
Throws:
DSEInvalidClassException
DSEInvalidRequestException
DSEInvalidArgumentException

getUnNamed

public java.lang.String getUnNamed()
Returns the value of the unNamed property.

Returns:
java.lang.String - The current value of unNamed

getEscape

public java.lang.String getEscape()

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes an JSONFormat with the aTag attributes.

Overrides:
initializeFrom in class RecordFormat
Parameters:
aTag - com.ibm.btt.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException

isUnNamed

public boolean isUnNamed()
Returns the boolean value of the unNamed property.

Returns:
boolean.

isEscape

public boolean isEscape()
Check whether the format are required to escape the format result or unescape the input string before unformat.

Returns:
boolean

setUnNamed

public void setUnNamed(java.lang.String newUnNamed)
Sets the value of the unNamed property.

Parameters:
newUnNamed - java.lang.String - The new value of the property

setEscape

public void setEscape(java.lang.String newEscape)
Sets the value of the escape property.

Parameters:
newEscape - java.lang.String

toStrings

public Vector toStrings()
Description copied from class: FormatElement
Returns a visual representation of this format element.

Overrides:
toStrings in class RecordFormat
Returns:
Tag[]

unformatContext

public DataElement unformatContext(java.lang.String aString,
                                   Context aContext)
                            throws DSEInvalidRequestException,
                                   DSEInvalidArgumentException
Unformats an JSONFormat updating data elements in the context.

Overrides:
unformatContext in class RecordFormat
Parameters:
aString - java.lang.String
aContext - com.ibm.btt.base.Context
Returns:
com.ibm.btt.base.DataElement
Throws:
com.ibm.btt.base.DSEInvalidRequestException.
com.ibm.btt.base.DSEInvalidArgumentException.
DSEInvalidRequestException
DSEInvalidArgumentException

unformatKeyedCollection

public KeyedCollection unformatKeyedCollection(java.lang.String aString,
                                               KeyedCollection aKeyedCollection)
                                        throws DSEInvalidRequestException,
                                               DSEInvalidArgumentException
Unformats an JSONFormat updating data elements in the collection passed as a parameter.

Overrides:
unformatKeyedCollection in class RecordFormat
Parameters:
aString - java.lang.String
aKeyedCollection - com.ibm.btt.base.KeyedCollection
Returns:
com.ibm.btt.base.KeyedCollection
Throws:
DSEInvalidRequestException - ,
DSEInvalidArgumentException

unformatJSON

public void unformatJSON(java.lang.String aString,
                         DataElement aDataElement,
                         FormatElement aFormatElement)
                  throws DSEInvalidRequestException,
                         DSEInvalidArgumentException,
                         DSEObjectNotFoundException
This method unformats a String JSON compliant format in aDataElement.

Parameters:
aString - java.lang.String
aDataElement - com.ibm.btt.base.DataElement
aFormatElement - com.ibm.btt.base.FormatElement
Throws:
DSEInvalidRequestException - ,
DSEInvalidArgumentException
DSEObjectNotFoundException

unformat

public int unformat(int ndxFrom,
                    int ndxTo,
                    java.lang.String str,
                    DataElement de)
             throws DSEInvalidRequestException,
                    DSEInvalidArgumentException
The method is not implemented for the JSON Format. Because the unformatted JSON String may contain data which is not ordered as the same as the formatter elements.

Overrides:
unformat in class RecordFormat
Parameters:
ndxFrom - - the initial index
ndxTo - - the final index
str - java.lang.String
de - com.ibm.btt.base.KeyedCollection
Returns:
int
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException
See Also:
RecordFormat.unformat(int, int, java.lang.String, com.ibm.btt.base.DataElement)

unformat

public int unformat(int ndxFrom,
                    int ndxTo,
                    java.lang.String aString,
                    Context aContext)
             throws DSEInvalidRequestException,
                    DSEInvalidArgumentException
The method is not implemented for the JSON Format. Because the unformatted JSON String may contain data which is not ordered as the same as the formatter elements.

Overrides:
unformat in class RecordFormat
Parameters:
ndxFrom - - the initial index
ndxTo - - the final index
aString - java.lang.String
aContext - com.ibm.btt.base.Context
Returns:
int
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException
See Also:
RecordFormat.unformat(int, int, java.lang.String, com.ibm.btt.base.Context)

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011