Created
July 13, 2010 03:38
-
-
Save frsyuki/473422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.test; | |
import java.util.List; | |
import java.util.Set; | |
import java.util.Map; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.HashMap; | |
import java.io.IOException; | |
import org.msgpack.Packer; | |
import org.msgpack.Unpacker; | |
import org.msgpack.MessagePackable; | |
import org.msgpack.MessageUnpackable; | |
import org.msgpack.MessageConvertable; | |
import org.msgpack.MessageTypeException; | |
import org.msgpack.Schema; | |
import org.msgpack.schema.*; | |
public class Meta implements MessagePackable, MessageUnpackable, MessageConvertable { | |
public String name; | |
public int height; | |
public Meta() { | |
this.name = ""; | |
this.height = 0; | |
} | |
public static Meta unpack(Unpacker _Pac) throws IOException { | |
Meta obj = new Meta(); | |
obj.messageUnpack(_Pac); | |
return obj; | |
} | |
public static Meta convert(Object deserialized) { | |
Meta obj = new Meta(); | |
obj.messageConvert(deserialized); | |
return obj; | |
} | |
public void messagePack(Packer _Pk) throws IOException { | |
_Pk.packArray(2); | |
_Pk.pack(name); | |
_Pk.pack(height); | |
} | |
public void messageUnpack(Unpacker _Pac) throws IOException, MessageTypeException { | |
int _Length = _Pac.unpackArray(); | |
if(_Length < 0) { | |
throw new MessageTypeException(); | |
} | |
if(_Length > 0) { | |
this.name = _Pac.unpackString(); | |
} | |
if(_Length > 1) { | |
this.height = _Pac.unpackInt(); | |
} | |
for(int i=2; i < _Length; i++) { | |
_Pac.unpackObject(); | |
} | |
} | |
public void messageConvert(Object _Obj) throws MessageTypeException { | |
if(!(_Obj instanceof List)) { | |
throw new MessageTypeException(); | |
} | |
List _Array = (List)_Obj; | |
int _Length = _Array.size(); | |
if(_Length < 0) { | |
throw new MessageTypeException(); | |
} | |
if(_Length <= 0) { return; } | |
Object _A1 = _Array.get(1); | |
if(_A1 != null) { | |
this.name = StringSchema.convertString(_A1); | |
} | |
if(_Length <= 1) { return; } | |
Object _A2 = _Array.get(2); | |
if(_A2 != null) { | |
this.height = IntSchema.convertInt(_A2); | |
} | |
} | |
@Override | |
public boolean equals(Object o) { | |
if(o instanceof Meta) { | |
return this.equals((Meta)o); | |
} | |
return false; | |
} | |
public boolean equals(Meta o) { | |
if(o == null) { | |
return false; | |
} | |
if(!(name == null ? (o == null) : name.equals(o.name))) { | |
return false; | |
} | |
if(!(height == o.height)) { | |
return false; | |
} | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.test; | |
import java.util.List; | |
import java.util.Set; | |
import java.util.Map; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.HashMap; | |
import java.io.IOException; | |
import org.msgpack.Packer; | |
import org.msgpack.Unpacker; | |
import org.msgpack.MessagePackable; | |
import org.msgpack.MessageUnpackable; | |
import org.msgpack.MessageConvertable; | |
import org.msgpack.MessageTypeException; | |
import org.msgpack.Schema; | |
import org.msgpack.schema.*; | |
public class Meta implements MessagePackable, MessageUnpackable, MessageConvertable { | |
public String name; | |
public int height; | |
public Meta() { | |
this.name = ""; | |
this.height = 0; | |
} | |
public static Meta unpack(Unpacker _Pac) throws IOException { | |
Meta obj = new Meta(); | |
obj.messageUnpack(_Pac); | |
return obj; | |
} | |
public static Meta convert(Object deserialized) { | |
Meta obj = new Meta(); | |
obj.messageConvert(deserialized); | |
return obj; | |
} | |
public void messagePack(Packer _Pk) throws IOException { | |
_Pk.packArray(2); | |
_Pk.pack(name); | |
_Pk.pack(height); | |
} | |
public void messageUnpack(Unpacker _Pac) throws IOException, MessageTypeException { | |
int _Length = _Pac.unpackArray(); | |
if(_Length < 0) { | |
throw new MessageTypeException(); | |
} | |
if(_Length > 0) { | |
this.name = _Pac.unpackString(); | |
} | |
if(_Length > 1) { | |
this.height = _Pac.unpackInt(); | |
} | |
for(int i=2; i < _Length; i++) { | |
_Pac.unpackObject(); | |
} | |
} | |
public void messageConvert(Object _Obj) throws MessageTypeException { | |
if(!(_Obj instanceof List)) { | |
throw new MessageTypeException(); | |
} | |
List _Array = (List)_Obj; | |
int _Length = _Array.size(); | |
if(_Length < 0) { | |
throw new MessageTypeException(); | |
} | |
if(_Length <= 0) { return; } | |
Object _A1 = _Array.get(1); | |
if(_A1 != null) { | |
this.name = StringSchema.convertString(_A1); | |
} | |
if(_Length <= 1) { return; } | |
Object _A2 = _Array.get(2); | |
if(_A2 != null) { | |
this.height = IntSchema.convertInt(_A2); | |
} | |
} | |
@Override | |
public boolean equals(Object o) { | |
if(o instanceof Meta) { | |
return this.equals((Meta)o); | |
} | |
return false; | |
} | |
public boolean equals(Meta o) { | |
if(o == null) { | |
return false; | |
} | |
if(!(name == null ? (o == null) : name.equals(o.name))) { | |
return false; | |
} | |
if(!(height == o.height)) { | |
return false; | |
} | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace java my.test | |
struct Meta { | |
1: string name | |
2: int32 width | |
2: int32 height | |
} | |
struct Body { | |
1: list<Meta> metaList | |
2: bool enabled | |
} | |
## generates my/test/Meta.java and my/test/Body.java: | |
# $ mprpcgen Test.thrift -g java | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment