Adds byte serializing
This commit is contained in:
parent
81fdc0a8c5
commit
eec82aa293
2 changed files with 28 additions and 1 deletions
|
@ -115,6 +115,10 @@ public class XmlRpcStreamReader {
|
|||
return deserializeStruct ( );
|
||||
case "nil":
|
||||
return null;
|
||||
case "i4":
|
||||
return deserializeByte ( );
|
||||
case "i8":
|
||||
return deserializeLong ( );
|
||||
default:
|
||||
throw new IllegalArgumentException ( "Unsupported element: " + localName );
|
||||
}
|
||||
|
@ -132,6 +136,14 @@ public class XmlRpcStreamReader {
|
|||
return Integer.parseInt ( getElementText ( ) );
|
||||
}
|
||||
|
||||
private byte deserializeByte ( ) throws XMLStreamException {
|
||||
return Byte.parseByte ( getElementText ( ) );
|
||||
}
|
||||
|
||||
private long deserializeLong ( ) throws XMLStreamException {
|
||||
return Long.parseLong ( getElementText ( ) );
|
||||
}
|
||||
|
||||
private double deserializeDouble ( ) throws XMLStreamException {
|
||||
return Double.parseDouble ( getElementText ( ) );
|
||||
}
|
||||
|
|
|
@ -83,12 +83,19 @@ public class XmlRpcStreamWriter {
|
|||
writer.write ( "</string>" );
|
||||
writer.write ( VALUE_END_TAG );
|
||||
}
|
||||
else if ( value instanceof Integer || value instanceof Long ) {
|
||||
else if ( value instanceof Integer ) {
|
||||
writer.write ( VALUE_START_TAG );
|
||||
writer.write ( "<int>" );
|
||||
writer.write ( value.toString ( ) );
|
||||
writer.write ( "</int>" );
|
||||
writer.write ( VALUE_END_TAG );
|
||||
} else if(value instanceof Long)
|
||||
{
|
||||
writer.write ( VALUE_START_TAG );
|
||||
writer.write ( "<int>" );
|
||||
writer.write ( value.toString () ); // Save it as a int for now due to unclear handling
|
||||
writer.write ( "</int>" );
|
||||
writer.write ( VALUE_END_TAG );
|
||||
}
|
||||
else if ( value instanceof Double ) {
|
||||
writer.write ( VALUE_START_TAG );
|
||||
|
@ -135,6 +142,14 @@ public class XmlRpcStreamWriter {
|
|||
writer.write ( STRUCT_END_TAG );
|
||||
writer.write ( VALUE_END_TAG );
|
||||
}
|
||||
else if(value instanceof Byte)
|
||||
{
|
||||
writer.write ( VALUE_START_TAG );
|
||||
writer.write ( "<int>" );
|
||||
writer.write ( value.toString () ); // Treat as a integer for now
|
||||
writer.write ( "</int>" );
|
||||
writer.write ( VALUE_END_TAG );
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException ( "Unsupported data type: " + value.getClass ( ).getName ( ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue