java: supports Collection<T> to pack

This commit is contained in:
frsyuki
2010-10-20 16:32:01 +09:00
parent 65515638aa
commit 4067c56b5d
2 changed files with 11 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.Collection;
import java.math.BigInteger;
import org.msgpack.annotation.MessagePackDelegate;
@@ -480,6 +481,11 @@ public class Packer {
pack(e.getValue());
}
return this;
} else if(o instanceof Collection) {
Collection<Object> l = (Collection<Object>)o;
packArray(l.size());
for(Object i : l) { pack(i); }
return this;
//} else if(o instanceof Boolean) {
// if((Boolean)o) {
// return packTrue();

View File

@@ -30,6 +30,10 @@ public class Templates {
return new MapTemplate(keyTemplate, valueTemplate);
}
public static Template tCollection(Template elementTemplate) {
return new CollectionTemplate(elementTemplate);
}
public static Template tClass(Class target) {
return new ClassTemplate(target);
}
@@ -84,5 +88,6 @@ public class Templates {
public static Template tByteArray() {
return TByteArray;
}
}