|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jibx.binding.def.StringConversion
org.jibx.binding.def.ObjectStringConversion
Object string conversion handling. Defines serialization handling for
converting objects to and from a String
value. The default is
to just use the object toString()
method for serialization and
a constructor from a String
value for deserialization.
java.lang.String
itself is a special case, with no added code
used by default for either serializing or deserializing.
java.lang.Object
is also a special case, with no added code
used by default for deserializing (the String
value is used
directly). Other classes must either implement toString()
and
a constructor from String
, or use custom serializers and/or
deserializers.
Field Summary | |
private static java.lang.String |
FROMSTRING_SIGNATURE
|
private ClassItem |
m_initFromString
Initializer used for creating instance from String
(only used if no conversion needed and no deserializer supplied;
may be null ) |
private ClassItem |
m_instToString
toString() method for converting instance to
String (only used if conversion needed and no serializer
supplied; may be null ) |
private boolean |
m_needDeserialize
Flag for conversion from String needed (type is anything
other than String or Object ) |
private boolean |
m_needSerialize
Flag for conversion to String needed (type is anything
other than String ) |
private static java.lang.String |
TOSTRING_METHOD
|
private static java.lang.String |
TOSTRING_SIGNATURE
|
Constructor Summary | |
(package private) |
ObjectStringConversion(java.lang.Object dflt,
java.lang.String ser,
java.lang.String deser,
java.lang.String type)
Constructor. |
(package private) |
ObjectStringConversion(java.lang.String type,
ObjectStringConversion inherit)
Constructor. |
Method Summary | |
protected java.lang.Object |
convertDefault(java.lang.String text)
Convert text representation into default value object. |
StringConversion |
derive(java.lang.String type,
java.lang.String ser,
java.lang.String dser,
java.lang.String dflt)
Derive from existing formatting information. |
void |
genFromText(ContextMethodBuilder mb)
Generate code to convert String representation. |
void |
genParseOptional(boolean attr,
ContextMethodBuilder mb)
Generate code to parse and convert optional attribute or element. |
void |
genParseRequired(boolean attr,
ContextMethodBuilder mb)
Generate code to parse and convert required attribute or element. |
protected BranchWrapper |
genToOptionalText(java.lang.String type,
ContextMethodBuilder mb,
int extra)
Generate code to check if an optional value is not equal to the default. |
void |
genToText(java.lang.String type,
ContextMethodBuilder mb)
Shared code generation for converting instance of type to String . |
private void |
initMethods()
Initialize methods used for conversion of types without serializer or deserializer. |
boolean |
isPrimitive()
Check if the type handled by this conversion is of a primitive type. |
Methods inherited from class org.jibx.binding.def.StringConversion |
genPopValues, genWriteOptional, genWriteRequired, genWriteText, getTypeName, setDeserializer, setSerializer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String TOSTRING_METHOD
private static final java.lang.String TOSTRING_SIGNATURE
private static final java.lang.String FROMSTRING_SIGNATURE
private boolean m_needDeserialize
String
needed (type is anything
other than String
or Object
)
private ClassItem m_initFromString
String
(only used if no conversion needed and no deserializer supplied;
may be null
)
private boolean m_needSerialize
String
needed (type is anything
other than String
)
private ClassItem m_instToString
toString()
method for converting instance to
String
(only used if conversion needed and no serializer
supplied; may be null
)
Constructor Detail |
ObjectStringConversion(java.lang.String type, ObjectStringConversion inherit) throws JiBXException
type
- fully qualified name of class handled by conversioninherit
- conversion information inherited by this conversion
JiBXException
- if error in configurationObjectStringConversion(java.lang.Object dflt, java.lang.String ser, java.lang.String deser, java.lang.String type)
dflt
- default value object (wrapped value for primitive types,
otherwise String
)ser
- fully qualified name of serialization methoddeser
- fully qualified name of deserialization methodtype
- fully qualified name of class handled by conversionMethod Detail |
private void initMethods() throws JiBXException
JiBXException
public void genFromText(ContextMethodBuilder mb) throws JiBXException
String
representation. The
code generated by this method assumes that the String
value has already been pushed on the stack. It consumes this and
leaves the converted value on the stack.
genFromText
in class StringConversion
mb
- method builder
JiBXException
- if error in configurationpublic void genParseOptional(boolean attr, ContextMethodBuilder mb) throws JiBXException
genParseOptional
in class StringConversion
attr
- item is an attribute (vs element) flagmb
- method builder
JiBXException
- if error in configurationpublic void genParseRequired(boolean attr, ContextMethodBuilder mb) throws JiBXException
genParseRequired
in class StringConversion
attr
- item is an attribute (vs element) flagmb
- method builder
JiBXException
- if error in configurationpublic void genToText(java.lang.String type, ContextMethodBuilder mb) throws JiBXException
String
. This override of the base class method checks for
serialization using the toString
method and implements that
case directly, while calling the base class method for normal handling.
The code generated by this method assumes that the reference to the
instance to be converted is on the stack. It consumes the reference,
replacing it with the corresponding String
value.
genToText
in class StringConversion
type
- fully qualified class name for value on stackmb
- marshal method builder
JiBXException
- if error in configurationprotected BranchWrapper genToOptionalText(java.lang.String type, ContextMethodBuilder mb, int extra) throws JiBXException
genToOptionalText
in class StringConversion
type
- fully qualified class name for value on stackmb
- method builderextra
- count of extra values to be popped from stack if missing
JiBXException
- if error in configurationpublic boolean isPrimitive()
isPrimitive
in class StringConversion
false
to indicate object typeprotected java.lang.Object convertDefault(java.lang.String text) throws JiBXException
convertDefault
in class StringConversion
text
- value representation to be converted
JiBXException
- on conversion errorpublic StringConversion derive(java.lang.String type, java.lang.String ser, java.lang.String dser, java.lang.String dflt) throws JiBXException
derive
in class StringConversion
type
- fully qualified name of class handled by conversionser
- fully qualified name of serialization method
(null
if inherited)dser
- fully qualified name of deserialization method
(null
if inherited)dflt
- default value text (null
if inherited)
JiBXException
- if error in configuration information
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |