Package org.jibx.binding.model
Class FormatElement
- java.lang.Object
-
- org.jibx.binding.model.ElementBase
-
- org.jibx.binding.model.FormatElement
-
public class FormatElement extends ElementBase
Model component for format element. This element defines conversion to and from simple unstructured text representations.- Version:
- 1.0
- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
m_isDefault
Default format for type flag.private java.lang.String
m_label
Format label.private QName
m_qname
Format qualified name.private StringAttributes
m_stringAttrs
String attributes information for value.private IClass
m_type
Value type information.private java.lang.String
m_typeName
Name of value type.static StringArray
s_allowedAttributes
Enumeration of allowed attribute names-
Fields inherited from class org.jibx.binding.model.ElementBase
BINDING_ELEMENT, COLLECTION_ELEMENT, ELEMENT_NAMES, FORMAT_ELEMENT, INCLUDE_ELEMENT, INPUT_ELEMENT, MAPPING_ELEMENT, NAMESPACE_ELEMENT, OUTPUT_ELEMENT, SPLIT_ELEMENT, STRUCTURE_ELEMENT, TEMPLATE_ELEMENT, VALUE_ELEMENT
-
-
Constructor Summary
Constructors Constructor Description FormatElement()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FormatElement
getBaseFormat()
Get base format information.java.lang.Object
getDefault()
Get default value.java.lang.String
getDefaultText()
Get default value text.IClassItem
getDeserializer()
Get deserializer method information.java.lang.String
getDeserializerName()
Get deserializer name.IClassItem
getEnumValue()
Get enum value method information.java.lang.String
getEnumValueName()
Get enum value method name.java.lang.String
getLabel()
Get format label.QName
getQName()
Get format qualified name.private java.lang.String
getQualifiedLabel(IMarshallingContext ictx)
JiBX access method to get format label as qualified name.IClassItem
getSerializer()
Get serializer method information.java.lang.String
getSerializerName()
Get serializer name.IClass
getType()
Get value type.java.lang.String
getTypeName()
Get value type name.boolean
isDefaultFormat()
Check if default format for type.private void
postSet()
Set default flag based on whether name supplied or not.private void
preSet(IUnmarshallingContext uctx)
Make sure all attributes are defined.void
prevalidate(ValidationContext vctx)
Prevalidate attributes of element in isolation.void
setDefaultFormat(boolean dflt)
Set default format for type.void
setDefaultText(java.lang.String value)
Set default value text.void
setDeserializerName(java.lang.String name)
Set deserializer method name.void
setEnumValueName(java.lang.String name)
Set enum value method name.void
setLabel(java.lang.String label)
Set format label.void
setQName(QName qname)
Set format qualified name.private void
setQualifiedLabel(java.lang.String label, IUnmarshallingContext ictx)
JiBX access method to set format label as qualified name.void
setSerializerName(java.lang.String name)
Set serializer method name.void
setTypeName(java.lang.String value)
Set value type name.void
validate(ValidationContext vctx)
Validate element information.-
Methods inherited from class org.jibx.binding.model.ElementBase
getComment, name, setComment, toString, type, validateAttributes
-
-
-
-
Field Detail
-
s_allowedAttributes
public static final StringArray s_allowedAttributes
Enumeration of allowed attribute names
-
m_label
private java.lang.String m_label
Format label.
-
m_qname
private QName m_qname
Format qualified name.
-
m_isDefault
private boolean m_isDefault
Default format for type flag.
-
m_typeName
private java.lang.String m_typeName
Name of value type.
-
m_type
private IClass m_type
Value type information.
-
m_stringAttrs
private StringAttributes m_stringAttrs
String attributes information for value.
-
-
Method Detail
-
getLabel
public java.lang.String getLabel()
Get format label.- Returns:
- format label (
null
if none)
-
setLabel
public void setLabel(java.lang.String label)
Set format label. This method changes the qualified name to match the label.- Parameters:
label
- format label (null
if none)
-
getQName
public QName getQName()
Get format qualified name.- Returns:
- format qualified name (
null
if none)
-
setQName
public void setQName(QName qname)
Set format qualified name. This method changes the label value to match the qualified name.- Parameters:
qname
- format qualified name (null
if none)
-
isDefaultFormat
public boolean isDefaultFormat()
Check if default format for type.- Returns:
true
if default for type,false
if not
-
setDefaultFormat
public void setDefaultFormat(boolean dflt)
Set default format for type.- Parameters:
dflt
-true
if default for type,false
if not
-
getType
public IClass getType()
Get value type. This method is only usable after a call tovalidate(org.jibx.binding.model.ValidationContext)
.- Returns:
- default value object
-
getTypeName
public java.lang.String getTypeName()
Get value type name.- Returns:
- value type name
-
setTypeName
public void setTypeName(java.lang.String value)
Set value type name.- Parameters:
value
- type name
-
getDefaultText
public java.lang.String getDefaultText()
Get default value text.- Returns:
- default value text
-
getDefault
public java.lang.Object getDefault()
Get default value. This call is only meaningful after validation.- Returns:
- default value object
-
setDefaultText
public void setDefaultText(java.lang.String value)
Set default value text.- Parameters:
value
- default value text
-
getEnumValue
public IClassItem getEnumValue()
Get enum value method information. This method is only usable after a call tovalidate(ValidationContext)
.- Returns:
- enum value method information (or
null
if none)
-
getEnumValueName
public java.lang.String getEnumValueName()
Get enum value method name.- Returns:
- enum value method name (or
null
if none)
-
setEnumValueName
public void setEnumValueName(java.lang.String name)
Set enum value method name.- Parameters:
name
- enum value method name (null
if none)
-
getSerializerName
public java.lang.String getSerializerName()
Get serializer name.- Returns:
- fully qualified class and method name for serializer (or
null
if none)
-
getSerializer
public IClassItem getSerializer()
Get serializer method information. This call is only meaningful after validation.- Returns:
- serializer information (or
null
if none)
-
setSerializerName
public void setSerializerName(java.lang.String name)
Set serializer method name.- Parameters:
name
- fully qualified class and method name for serializer
-
getDeserializerName
public java.lang.String getDeserializerName()
Get deserializer name.- Returns:
- fully qualified class and method name for deserializer (or
null
if none)
-
getDeserializer
public IClassItem getDeserializer()
Get deserializer method information. This call is only meaningful after validation.- Returns:
- deserializer information (or
null
if none)
-
setDeserializerName
public void setDeserializerName(java.lang.String name)
Set deserializer method name.- Parameters:
name
- fully qualified class and method name for deserializer
-
getBaseFormat
public FormatElement getBaseFormat()
Get base format information. This method is only usable after a call tovalidate(org.jibx.binding.model.ValidationContext)
.- Returns:
- base format element (or
null
if none)
-
setQualifiedLabel
private void setQualifiedLabel(java.lang.String label, IUnmarshallingContext ictx) throws JiBXException
JiBX access method to set format label as qualified name.- Parameters:
label
- format label text (null
if none)ictx
- unmarshalling context- Throws:
JiBXException
- on deserialization error
-
getQualifiedLabel
private java.lang.String getQualifiedLabel(IMarshallingContext ictx) throws JiBXException
JiBX access method to get format label as qualified name.- Parameters:
ictx
- marshalling context- Returns:
- format label text (
null
if none) - Throws:
JiBXException
- on deserialization error
-
preSet
private void preSet(IUnmarshallingContext uctx) throws JiBXException
Make sure all attributes are defined.- Parameters:
uctx
- unmarshalling context- Throws:
JiBXException
- on unmarshalling error
-
postSet
private void postSet()
Set default flag based on whether name supplied or not. TODO: use explicit flag for 2.0
-
prevalidate
public void prevalidate(ValidationContext vctx)
Prevalidate attributes of element in isolation. Note that this adds the format information to the context, which is necessary because the string attributes for values need to have access to the format information for their own prevalidation. This is the only type of registration which is done during the prevalidation pass.- Overrides:
prevalidate
in classElementBase
- Parameters:
vctx
- validation context
-
validate
public void validate(ValidationContext vctx)
Description copied from class:ElementBase
Validate element information. The validation step is used for checking the interactions between elements, such as name references to other elements. TheElementBase.prevalidate(org.jibx.binding.model.ValidationContext)
method will always be called for every element in the binding definition before this method is called for any element. This empty base class implementation should be overridden by each subclass that requires validation handling.- Overrides:
validate
in classElementBase
- Parameters:
vctx
- validation context
-
-