|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objectwave.utility.ObjectFormatter
This class converts data from one type to another. Used extensively for persistence manipulation.
Nested Class Summary | |
static class |
ObjectFormatter.Test
Unit tests. |
Field Summary | |
static java.lang.String |
Native_Array_Delimiter
|
protected static java.lang.ThreadLocal |
outputStreams
|
static int |
zipBufferSize
|
Constructor Summary | |
ObjectFormatter()
|
Method Summary | |
protected void |
bytesToString(byte[] data,
java.lang.StringBuffer buffer)
Convert the byte array into a string buffer representing the hexidecimal equivalent of the data. |
java.lang.String |
convertArray(java.lang.Object dataArray)
Convert a native array into a string value. |
protected java.lang.Object |
convertPrimitive(java.lang.Class c,
java.lang.String str)
Convert the string value to the correct primitive type. |
java.lang.Object |
convertString(java.lang.Class c,
java.lang.String str)
When converting to an array, we need every element to be inserted into the array to be of the correct object type. |
java.lang.Object |
convertType(java.lang.Class c,
java.lang.Object obj)
Convert the object from its database representation to its actual value in the business object. |
protected java.lang.Object |
createArray(java.lang.Class clazz,
java.lang.String vals)
Convert a string value into a Native Array. |
java.lang.Number |
createNumber(java.lang.Class c,
java.lang.Number value)
If the SQL type was "NUMERIC", then we need to check to see if the Double that NUMBERIC values are converted to should really be an Integer or a Long. |
protected java.lang.Object |
createScalarType(java.lang.Class c,
java.lang.String value)
To support custom 'scalar' types (types that will be stored in the database as a string, but will in fact be an object in the object model) a ScalarFactory was introduced. |
protected void |
formatDate(java.util.Date value,
java.lang.StringBuffer buf)
To facilitate overriding of this method, the formatting is broken out. |
void |
formatSerializable(java.io.Serializable value,
java.lang.StringBuffer buf)
To facilitate overriding of this method, the formatting is broken out. |
java.lang.String |
formatValue(java.lang.Object value)
Convert the Object to a string. |
void |
formatValue(java.lang.Object value,
java.lang.StringBuffer buf)
Common formatting routine used by most of the sqlAssembler objects. |
java.lang.Object |
readSerializable(byte[] bytes)
Create an object from the bytes read from the database. |
static java.lang.String |
replace1QuoteWith2(java.lang.String fromString)
|
byte[] |
serializeObject(java.io.Serializable value)
Serialize the object into a byte [] |
byte[] |
stringToBytes(java.lang.String string)
Take a string of bytes in Hex format and create a byte array from the string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int zipBufferSize
public static final java.lang.String Native_Array_Delimiter
protected static java.lang.ThreadLocal outputStreams
Constructor Detail |
public ObjectFormatter()
Method Detail |
public static java.lang.String replace1QuoteWith2(java.lang.String fromString)
fromString
-
public java.lang.Object convertString(java.lang.Class c, java.lang.String str)
c
- Class to which the string is going to be converted.str
- A String representation of the class.
public java.lang.Object convertType(java.lang.Class c, java.lang.Object obj)
c
- Class to which the object is going to be converted.obj
- An unkown object type that may need to be converted to be a type
of the class 'c'.
public java.lang.Object readSerializable(byte[] bytes)
bytes
- byte[] Zipped byte array that contains a serialized object
serializeObject(java.io.Serializable)
public java.lang.String convertArray(java.lang.Object dataArray)
dataArray
- an object representing an array. The value is assumed to
be non-null.
public java.lang.String formatValue(java.lang.Object value) throws java.io.IOException
value
-
java.io.IOException
public void formatValue(java.lang.Object value, java.lang.StringBuffer buf) throws java.io.IOException
value
- buf
-
java.io.IOException
public byte[] serializeObject(java.io.Serializable value) throws java.io.IOException
value
-
java.io.IOException
public byte[] stringToBytes(java.lang.String string)
string
-
public java.lang.Number createNumber(java.lang.Class c, java.lang.Number value)
c
- value
-
public void formatSerializable(java.io.Serializable value, java.lang.StringBuffer buf) throws java.io.IOException
buf
- StringBuffer upon which to write the data.value
- Serializable object to convert to a string value.
java.io.IOException
protected void bytesToString(byte[] data, java.lang.StringBuffer buffer)
data
- buffer
- protected java.lang.Object convertPrimitive(java.lang.Class c, java.lang.String str)
c
- Class to which the string is going to be converted.str
- A String representation of the class.
protected java.lang.Object createArray(java.lang.Class clazz, java.lang.String vals)
clazz
- java.lang.Class The class of the native array being built.vals
-
protected java.lang.Object createScalarType(java.lang.Class c, java.lang.String value)
c
- value
-
protected void formatDate(java.util.Date value, java.lang.StringBuffer buf)
value
- Date object to format.buf
- StringBuffer upon which to write the data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |