public class XmlCodec
extends java.lang.Object
implements com.cinnober.msgcodec.StreamCodec
XML codec support a number of annotations to the protocol dictionary that control the encoding.
| Annotation | Location | Description |
|---|---|---|
xml:ns |
ProtocolDictionary | Set the XML namespace of all elements. Default is none. |
xml:field |
FieldDef | Values:
attribute = the field is encoded as an attribute in the group element.
Default for simple field types. Not applicable to group types.
element = the field is encoded as an child element in the group element.
Default for complex field types (group, sequence).
inlineElement = the field, which is a group type, is inlined within the contained group element.
This requires that there is no potential conflict with another field.
|
The following mapping between msgcodec types and XML constructs applies:
| Msgcodec | XML |
|---|---|
| uInt8 | xs:unsignedByte |
| uInt16 | xs:unsignedShort |
| uInt32 | xs:unsignedInt |
| uInt64 | xs:unsignedLong |
| int8 | xs:byte |
| int16 | xs:short |
| int32 | xs:int |
| int64 | xs:long |
| bigInt | xs:integer |
| decimal | xs:decimal |
| bigDecimal | xs:decimal |
| boolean | xs:boolean |
| string | xs:string |
| enum | xs:string (name) |
| time | xs:string, see TimeFormat. PENDING: use xs:time and xs:date? |
| binary | xs:binary. TODO: not implemented yet |
| sequence | TODO: To be documented. |
| group | element with group name as element name. Fields are represented as nested attributes or elements. |
Note: missing fields are not checked. (TODO)
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
decode(java.io.InputStream in) |
void |
encode(java.lang.Object group,
java.io.OutputStream out) |
protected NsName |
getNsName(com.cinnober.msgcodec.FieldDef fieldDef) |
protected NsName |
getNsName(com.cinnober.msgcodec.GroupDef groupDef) |
com.cinnober.msgcodec.xml.XmlElementHandler.StaticGroupValue |
lookupGroup(java.lang.Class<?> javaClass) |
com.cinnober.msgcodec.xml.XmlElementHandler.StaticGroupValue |
lookupGroup(NsName name) |
protected NsName getNsName(com.cinnober.msgcodec.GroupDef groupDef)
protected NsName getNsName(com.cinnober.msgcodec.FieldDef fieldDef)
public void encode(java.lang.Object group,
java.io.OutputStream out)
throws java.io.IOException
encode in interface com.cinnober.msgcodec.StreamCodecjava.io.IOExceptionpublic java.lang.Object decode(java.io.InputStream in)
throws java.io.IOException
decode in interface com.cinnober.msgcodec.StreamCodecjava.io.IOExceptionpublic com.cinnober.msgcodec.xml.XmlElementHandler.StaticGroupValue lookupGroup(NsName name)
public com.cinnober.msgcodec.xml.XmlElementHandler.StaticGroupValue lookupGroup(java.lang.Class<?> javaClass)