com.ricebridge.data.sc
Class TypeArrayStringConverter

java.lang.Object
  extended bycom.ricebridge.data.sc.StringConverterSupport
      extended bycom.ricebridge.data.sc.TypeStringConverter
          extended bycom.ricebridge.data.sc.TypeArrayStringConverter
All Implemented Interfaces:
StringConverter
Direct Known Subclasses:
BooleanArrayStringConverter, ByteArrayStringConverter, CharacterArrayStringConverter, DoubleArrayStringConverter, FloatArrayStringConverter, IntegerArrayStringConverter, LongArrayStringConverter, ShortArrayStringConverter, StringArrayStringConverter

public abstract class TypeArrayStringConverter
extends TypeStringConverter

Utility class for handling conversion of native Java types in arrays.


Field Summary
protected  char iEscChar
          Escape character for textual values in list.
protected  char iSepChar
          Separation character for text list of object values.
protected  boolean iUseNative
          Indicate that native arrays should be used.
 
Fields inherited from class com.ricebridge.data.sc.TypeStringConverter
iDefault
 
Constructor Summary
TypeArrayStringConverter()
           
 
Method Summary
protected abstract  Object makeArray(List pValues)
          Create an array object from the list of values.
protected  Object makeDefaultObjectImpl()
          Return an empty array.
protected  String makeDefaultStringImpl()
          Return an empty String.
protected abstract  ArrayList makeList(Object pValues)
          Convert an object into a List, if possible.
protected  Object makeObjectImpl(String pValue, boolean pUseDefault)
          Pass actual object creation to makeTypeObjectImpl method.
protected  String makeStringImpl(Object pValues, boolean pUseDefault)
          Pass actual text creation to makeTypeStringImpl method.
 void setDelimiters(char pSepChar, char pEscChar)
          Set the delimiters for textual lists.
 void setUseNative(boolean pUseNative)
          Indicate that native arrays should be used.
 
Methods inherited from class com.ricebridge.data.sc.TypeStringConverter
makeTypeObjectImpl, makeTypeStringImpl, setDefault
 
Methods inherited from class com.ricebridge.data.sc.StringConverterSupport
makeDefaultObject, makeDefaultString, makeObject, makeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iUseNative

protected boolean iUseNative
Indicate that native arrays should be used.


iSepChar

protected char iSepChar
Separation character for text list of object values.


iEscChar

protected char iEscChar
Escape character for textual values in list.

Constructor Detail

TypeArrayStringConverter

public TypeArrayStringConverter()
Method Detail

setUseNative

public void setUseNative(boolean pUseNative)
Indicate that native arrays should be used.

When true, assume that the object represented as a String is a native array type, for example int[].

When false, assume that the object represented as a String is a wrapper object array type, for example Integer[].

Parameters:
pUseNative - flag to use native arrays

setDelimiters

public void setDelimiters(char pSepChar,
                          char pEscChar)
Set the delimiters for textual lists.

Parameters:
pSepChar - the separation character
pEscChar - the escape character

makeObjectImpl

protected Object makeObjectImpl(String pValue,
                                boolean pUseDefault)
                         throws Exception
Pass actual object creation to makeTypeObjectImpl method.

Create the array from the returned objects.

Overrides:
makeObjectImpl in class TypeStringConverter
Throws:
Exception

makeDefaultObjectImpl

protected Object makeDefaultObjectImpl()
Return an empty array.

Overrides:
makeDefaultObjectImpl in class TypeStringConverter

makeStringImpl

protected String makeStringImpl(Object pValues,
                                boolean pUseDefault)
                         throws Exception
Pass actual text creation to makeTypeStringImpl method.

Create a textual list using the String values.

Overrides:
makeStringImpl in class TypeStringConverter
Throws:
Exception

makeDefaultStringImpl

protected String makeDefaultStringImpl()
Return an empty String.

Overrides:
makeDefaultStringImpl in class TypeStringConverter

makeArray

protected abstract Object makeArray(List pValues)
Create an array object from the list of values.

If iUseNative is true, then create a native array, else a wrapper object array.

Parameters:
pValues - list of values

makeList

protected abstract ArrayList makeList(Object pValues)
Convert an object into a List, if possible.

If iUseNative is true, then assume pValues is a native array, else a wrapper object array.

Parameters:
pValues - object that should be a list


Copyright © 2004-2005 Ricebridge