mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
import MessagePack for Java implementation plan 2
This commit is contained in:
parent
93a95725fc
commit
e39e1d4f60
48 changed files with 3676 additions and 0 deletions
46
java-plan2/src/org/msgpack/schema/ShortSchema.java
Normal file
46
java-plan2/src/org/msgpack/schema/ShortSchema.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package org.msgpack.schema;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.msgpack.*;
|
||||
|
||||
public class ShortSchema extends Schema {
|
||||
public ShortSchema()
|
||||
{
|
||||
super("Short");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpression()
|
||||
{
|
||||
return "short";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(Packer pk, Object obj) throws IOException
|
||||
{
|
||||
if(obj == null) {
|
||||
pk.packNil();
|
||||
return;
|
||||
}
|
||||
pk.packShort((Short)obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(GenericObject obj)
|
||||
{
|
||||
return obj.asShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createByte(byte v)
|
||||
{
|
||||
return (int)v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createShort(short v)
|
||||
{
|
||||
return (int)v;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue