| java.lang.Object org.jibx.binding.def.StringConversion
All known Subclasses: org.jibx.binding.def.PrimitiveStringConversion, org.jibx.binding.def.ObjectStringConversion,
StringConversion | abstract public class StringConversion (Code) | | String conversion handling. Defines serialization handling for converting
to and from a String value. This uses an inheritance approach,
where each serialization definition is initialized based on the handling
set for the containing definition of the same (or parent class) type.
author: Dennis M. Sosnoski version: 1.0 |
Method Summary | |
abstract protected Object | convertDefault(String text) Convert text representation into default value object. | abstract public StringConversion | derive(String type, String ser, String dser, String dflt) Derive from existing formatting information. | abstract public void | genFromText(ContextMethodBuilder mb) Generate code to convert String representation. | abstract public void | genParseOptional(boolean attr, ContextMethodBuilder mb) Generate code to parse and convert optional attribute or element. | abstract public void | genParseRequired(boolean attr, ContextMethodBuilder mb) Generate code to parse and convert required attribute or element. | public void | genPopValues(int count, ContextMethodBuilder mb) Generate code to pop values from stack. | abstract protected BranchWrapper | genToOptionalText(String type, ContextMethodBuilder mb, int extra) Generate code to check if an optional value is not equal to the default.
This abstract base class method must be implemented by every subclass.
The code generated by this method assumes that the actual value to be
converted has already been pushed on the stack. | public void | genToText(String type, ContextMethodBuilder mb) Generate code to convert value to a String . | public void | genWriteOptional(boolean attr, String type, ContextMethodBuilder mb) Generate code to convert and write optional value to generated document.
The generated code first tests if the value is the same as the supplied
default, and if so skips writing. | public void | genWriteRequired(boolean attr, String type, ContextMethodBuilder mb) Generate code to convert and write required value to generated document.
The code generated by this method assumes that the marshalling context,
the name information, and the actual value to be converted have already
been pushed on the stack. | public void | genWriteText(boolean attr, ContextMethodBuilder mb) Generate code to write String value to generated document.
The code generated by this method assumes that the marshalling context,
the name information, and the actual value to be converted have already
been pushed on the stack. | public String | getTypeName() Get name of type handled by this conversion. | abstract public boolean | isPrimitive() Check if the type handled by this conversion is of a primitive type. | protected void | setDeserializer(String deser) Set deserializer for conversion. | protected void | setSerializer(String ser) Set serializer for conversion. |
COMPARE_OBJECTS_METHOD | final protected static String COMPARE_OBJECTS_METHOD(Code) | | |
COMPARE_OBJECTS_SIGNATURE | final protected static String COMPARE_OBJECTS_SIGNATURE(Code) | | |
DESERIALIZER_SIGNATURES | final protected static String[] DESERIALIZER_SIGNATURES(Code) | | |
MARSHAL_ATTRIBUTE | final protected static String MARSHAL_ATTRIBUTE(Code) | | |
MARSHAL_ELEMENT | final protected static String MARSHAL_ELEMENT(Code) | | |
MARSHAL_NAME_VALUES | final public static int MARSHAL_NAME_VALUES(Code) | | |
MARSHAL_SIGNATURE | final protected static String MARSHAL_SIGNATURE(Code) | | |
UNMARSHAL_OPT_ATTRIBUTE | final protected static String UNMARSHAL_OPT_ATTRIBUTE(Code) | | |
UNMARSHAL_OPT_ELEMENT | final protected static String UNMARSHAL_OPT_ELEMENT(Code) | | |
UNMARSHAL_OPT_SIGNATURE | final protected static String UNMARSHAL_OPT_SIGNATURE(Code) | | |
UNMARSHAL_REQ_ATTRIBUTE | final protected static String UNMARSHAL_REQ_ATTRIBUTE(Code) | | |
UNMARSHAL_REQ_ELEMENT | final protected static String UNMARSHAL_REQ_ELEMENT(Code) | | |
UNMARSHAL_REQ_SIGNATURE | final protected static String UNMARSHAL_REQ_SIGNATURE(Code) | | |
m_default | protected Object m_default(Code) | | Default value used for this type (wrapper for primitives, otherwise
String or null ).
|
m_deserializer | protected ClassItem m_deserializer(Code) | | Deserializer method information.
|
m_serializer | protected ClassItem m_serializer(Code) | | Serializer method information.
|
m_typeName | protected String m_typeName(Code) | | Fully qualified name of class handled by conversion.
|
m_typeSignature | protected String m_typeSignature(Code) | | Signature of class handled by conversion.
|
StringConversion | protected StringConversion(String type, StringConversion inherit)(Code) | | Constructor. Initializes conversion handling based on the supplied
inherited handling.
Parameters: type - fully qualified name of class handled by conversion Parameters: inherit - conversion information inherited by this conversion |
StringConversion | StringConversion(Object dflt, String ser, String deser, String type)(Code) | | Constructor. Initializes conversion handling based on argument values.
This form is only used for constructing the default set of conversions.
Because of this, it throws an unchecked exception on error.
Parameters: dflt - default value object (wrapped value for primitive types,otherwise String ) Parameters: ser - fully qualified name of serialization method Parameters: deser - fully qualified name of deserialization method Parameters: type - fully qualified name of class handled by conversion |
convertDefault | abstract protected Object convertDefault(String text) throws JiBXException(Code) | | Convert text representation into default value object. Each subclass
must implement this with the appropriate conversion handling.
Parameters: text - value representation to be converted converted default value object throws: JiBXException - on conversion error |
derive | abstract public StringConversion derive(String type, String ser, String dser, String dflt) throws JiBXException(Code) | | Derive from existing formatting information. This abstract base class
method must be implemented by every subclass. It allows constructing
a new instance from an existing format of the same or an ancestor
type, with the properties of the existing format copied to the new
instance except where overridden by the supplied values.
Parameters: type - fully qualified name of class handled by conversion Parameters: ser - fully qualified name of serialization method(null if inherited) Parameters: dser - fully qualified name of deserialization method(null if inherited) Parameters: dflt - default value text (null if inherited) new instance initialized from existing one throws: JiBXException - if error in configuration information |
genFromText | abstract public void genFromText(ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to convert 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.
Parameters: mb - method builder throws: JiBXException - if error in configuration |
genParseOptional | abstract public void genParseOptional(boolean attr, ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to parse and convert optional attribute or element. This
abstract base class method must be implemented by every subclass. The
code generated by this method assumes that the unmarshalling context
and name information for the attribute or element have already
been pushed on the stack. It consumes these and leaves the converted
value (or converted default value, if the item itself is missing) on
the stack.
Parameters: attr - item is an attribute (vs element) flag Parameters: mb - method builder throws: JiBXException - if error in configuration |
genParseRequired | abstract public void genParseRequired(boolean attr, ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to parse and convert required attribute or element. This
abstract base class method must be implemented by every subclass. The
code generated by this method assumes that the unmarshalling context and
name information for the attribute or element have already been pushed
on the stack. It consumes these and leaves the converted value on the
stack.
Parameters: attr - item is an attribute (vs element) flag Parameters: mb - method builder throws: JiBXException - if error in configuration |
genPopValues | public void genPopValues(int count, ContextMethodBuilder mb)(Code) | | Generate code to pop values from stack.
Parameters: count - number of values to be popped Parameters: mb - method builder |
genToOptionalText | abstract protected BranchWrapper genToOptionalText(String type, ContextMethodBuilder mb, int extra) throws JiBXException(Code) | | Generate code to check if an optional value is not equal to the default.
This abstract base class method must be implemented by every subclass.
The code generated by this method assumes that the actual value to be
converted has already been pushed on the stack. It consumes this,
leaving the converted text reference on the stack if it's not equal to
the default value.
Parameters: type - fully qualified class name for value on stack Parameters: mb - method builder Parameters: extra - count of extra words to be popped from stack if missing handle for branch taken when value is equal to the default(target must be set by caller) throws: JiBXException - if error in configuration |
genToText | public void genToText(String type, ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to convert value to a String . The code
generated by this method assumes that the actual value to be converted
has already been pushed on the stack. It consumes this, leaving the
converted text reference on the stack.
Parameters: type - fully qualified class name for value on stack Parameters: mb - method builder throws: JiBXException - if error in configuration |
genWriteOptional | public void genWriteOptional(boolean attr, String type, ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to convert and write optional value to generated document.
The generated code first tests if the value is the same as the supplied
default, and if so skips writing. The code assumes that the marshalling
context, the name information, and the actual value to be converted have
already been pushed on the stack. It consumes these, leaving only the
marshalling context on the stack.
Parameters: attr - item is an attribute (vs element) flag Parameters: type - fully qualified class name for value on stack Parameters: mb - method builder throws: JiBXException - if error in configuration |
genWriteRequired | public void genWriteRequired(boolean attr, String type, ContextMethodBuilder mb) throws JiBXException(Code) | | Generate code to convert and write required value to generated document.
The code generated by this method assumes that the marshalling context,
the name information, and the actual value to be converted have already
been pushed on the stack. It consumes these, leaving the returned
marshalling context on the stack.
Parameters: attr - item is an attribute (vs element) flag Parameters: type - fully qualified class name for value on stack Parameters: mb - method builder throws: JiBXException - if error in configuration |
genWriteText | public void genWriteText(boolean attr, ContextMethodBuilder mb)(Code) | | Generate code to write String value to generated document.
The code generated by this method assumes that the marshalling context,
the name information, and the actual value to be converted have already
been pushed on the stack. It consumes these, leaving the marshalling
context on the stack.
Parameters: attr - item is an attribute (vs element) flag Parameters: mb - method builder |
getTypeName | public String getTypeName()(Code) | | Get name of type handled by this conversion.
fully qualified class name of type handled by conversion |
isPrimitive | abstract public boolean isPrimitive()(Code) | | Check if the type handled by this conversion is of a primitive type.
true if a primitive type, false if anobject type |
setDeserializer | protected void setDeserializer(String deser) throws JiBXException(Code) | | Set deserializer for conversion. This finds the named static method and
sets it as the deserializer to be used for this conversion. The
deserializer method is expected to take a single argument of type
String , and to return a value of the handled type or a
subtype of that type.
Parameters: deser - fully qualified class and method name of deserializer throws: JiBXException - if deserializer not found or not usable |
setSerializer | protected void setSerializer(String ser) throws JiBXException(Code) | | Set serializer for conversion. This finds the named static method and
sets it as the serializer to be used for this conversion. The serializer
method is expected to take a single argument of either the handled
type or a superclass or interface of the handled type, and to return a
String result.
Parameters: ser - fully qualified class and method name of serializer throws: JiBXException - if serializer not found or not usable |
|
|