IBM Bank Transformation Toolkit Javadoc

com.ibm.btt.format.impl
Class JSONDecorator

java.lang.Object
  extended by com.ibm.btt.format.AbstractFormatElement
      extended by com.ibm.btt.format.BaseDecorator
          extended by com.ibm.btt.format.impl.JSONDecorator
All Implemented Interfaces:
FormatDecorator, FormatElement

public class JSONDecorator
extends BaseDecorator


Field Summary
 
Fields inherited from class com.ibm.btt.format.AbstractFormatElement
dataName, tagName, TOSTRINGS_MARGIN
 
Constructor Summary
JSONDecorator()
           
 
Method Summary
protected  Message addDecoration(Message message)
           
static Message escape(Message msg, java.lang.String encoding)
          " => \" , \ => \\
 Message[] extract(Message message)
          Extracts (strips) the subMessage corresponding to the FormatElement from the input Message and returns it and the remaining Message as the elements of an array.
 Message format(IndexedFormat format, ReadAdapter dataAdapter)
           
 Message format(ReadAdapter dataWrapper)
          This method is attended to be called by client code of FormatElement
protected static byte[] getBytes(java.lang.String str, java.lang.String encoding)
           
protected static Message getPostTag(boolean hasDataName, boolean isContainer, boolean isArray)
          Returns the tag that follows each DataElement.
protected static int getPostTagEndIndex(Message message, boolean hasDataName, boolean isContainer, boolean isArray)
           
protected static Message getPreTag(boolean hasDataName, boolean isContainer, boolean isArray, java.lang.String dataName)
          Returns the tag that preceeds each DataElement.
protected static int getPreTagEndIndex(Message message, boolean hasDataName, boolean isContainer, boolean isArray, java.lang.String dataName)
          Returns the tag that preceeds each DataElement.
protected static java.lang.String getStr(byte[] bytes, java.lang.String encoding)
           
protected  Message removeDecoration(Message message)
           
static Message unescape(Message msg, java.lang.String encoding)
           
 void unformat(IndexedFormat fmt, Message bytes, WriteAdapter dataAdapter)
           
 void unformat(Message message, WriteAdapter dataAdapter)
          This method is attended to be called by client code of FormatElement
 
Methods inherited from class com.ibm.btt.format.BaseDecorator
attributes, getDataName, getDecorated, isContainer, rootDecorated, setDecorated, toStrings
 
Methods inherited from class com.ibm.btt.format.AbstractFormatElement
setDataName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSONDecorator

public JSONDecorator()
Method Detail

extract

public Message[] extract(Message message)
                  throws ExtractException
Description copied from interface: FormatElement
Extracts (strips) the subMessage corresponding to the FormatElement from the input Message and returns it and the remaining Message as the elements of an array.
The returned array of Message should always contain two elements.

Take Message 1FCD2639FE for example. The returned array of Message may be {1FCD, 2639FE}, the first element 1FCD is the Message required by this FormatElement, while the second element 2639FE is the remaining Message.

This method is not attended to be called by client code of FormatElement
This method is called by the unformat() method of the composite formats such as com.ibm.btt.format.impl.RecordFormat and com.ibm.btt.format.impl.IndexedFormat.

Specified by:
extract in interface FormatElement
Overrides:
extract in class BaseDecorator
Returns:
Throws:
ExtractException

addDecoration

protected Message addDecoration(Message message)
                         throws FormatException
Specified by:
addDecoration in class BaseDecorator
Throws:
FormatException

format

public Message format(ReadAdapter dataWrapper)
               throws FormatException
Description copied from interface: FormatElement
This method is attended to be called by client code of FormatElement

Specified by:
format in interface FormatElement
Overrides:
format in class BaseDecorator
Returns:
Throws:
FormatException

unformat

public void unformat(Message message,
                     WriteAdapter dataAdapter)
              throws UnformatException
Description copied from interface: FormatElement
This method is attended to be called by client code of FormatElement

Specified by:
unformat in interface FormatElement
Overrides:
unformat in class BaseDecorator
Throws:
UnformatException

removeDecoration

protected Message removeDecoration(Message message)
                            throws UnformatException
Specified by:
removeDecoration in class BaseDecorator
Throws:
UnformatException

format

public Message format(IndexedFormat format,
                      ReadAdapter dataAdapter)
               throws FormatException
Throws:
FormatException

unformat

public void unformat(IndexedFormat fmt,
                     Message bytes,
                     WriteAdapter dataAdapter)
              throws UnformatException
Throws:
UnformatException

getPostTag

protected static Message getPostTag(boolean hasDataName,
                                    boolean isContainer,
                                    boolean isArray)
Returns the tag that follows each DataElement.

Parameters:
aName - java.lang.String
Returns:
java.lang.String
Throws:
java.io.UnsupportedEncodingException

getPreTag

protected static Message getPreTag(boolean hasDataName,
                                   boolean isContainer,
                                   boolean isArray,
                                   java.lang.String dataName)
Returns the tag that preceeds each DataElement.

Parameters:
aName - java.lang.String
Returns:
java.lang.String
Throws:
java.io.UnsupportedEncodingException

getPreTagEndIndex

protected static int getPreTagEndIndex(Message message,
                                       boolean hasDataName,
                                       boolean isContainer,
                                       boolean isArray,
                                       java.lang.String dataName)
Returns the tag that preceeds each DataElement.

Parameters:
aName - java.lang.String
Returns:
java.lang.String
Throws:
java.io.UnsupportedEncodingException

getPostTagEndIndex

protected static int getPostTagEndIndex(Message message,
                                        boolean hasDataName,
                                        boolean isContainer,
                                        boolean isArray)

escape

public static Message escape(Message msg,
                             java.lang.String encoding)
                      throws java.io.UnsupportedEncodingException
" => \" , \ => \\

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

unescape

public static Message unescape(Message msg,
                               java.lang.String encoding)
                        throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

getStr

protected static java.lang.String getStr(byte[] bytes,
                                         java.lang.String encoding)
                                  throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

getBytes

protected static byte[] getBytes(java.lang.String str,
                                 java.lang.String encoding)
                          throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

IBM Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2008