本文整理汇总了Java中org.msgpack.packer.Packer.writeArrayBegin方法的典型用法代码示例。如果您正苦于以下问题:Java Packer.writeArrayBegin方法的具体用法?Java Packer.writeArrayBegin怎么用?Java Packer.writeArrayBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.msgpack.packer.Packer
的用法示例。
在下文中一共展示了Packer.writeArrayBegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeCall
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
protected void writeCall(String methodName, Object[] args) throws IOException {
huc = u.openConnection();
huc.setDoOutput(true);
huc.setDoInput(true);
huc.setUseCaches(false);
huc.setRequestProperty("Content-Type", "binary/message-pack");
huc.setReadTimeout(0);
OutputStream os = huc.getOutputStream();
Packer pk = msgpack.createPacker(os);
pk.writeArrayBegin(args.length+1);
pk.write(methodName);
for (Object arg : args)
pk.write(arg);
pk.writeArrayEnd();
pk.close();
os.close();
}
示例2: marshallRequestParams
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
@Override
public byte[] marshallRequestParams(final Object[] requestParams) throws IOException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Packer packer = msgPack.createPacker(outputStream);
final Object[] params;
if (requestParams == null) {
params = new Object[0];
} else {
params = requestParams;
}
packer.writeArrayBegin(params.length);
for (final Object param : params) {
packer.write(param);
}
packer.writeArrayEnd();
return outputStream.toByteArray();
}
示例3: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, Set<E> target, boolean required)
throws IOException {
if (!(target instanceof Set)) {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
throw new MessageTypeException("Target is not a List but "
+ target.getClass());
}
pk.writeArrayBegin(target.size());
for (E e : target) {
elementTemplate.write(pk, e);
}
pk.writeArrayEnd();
}
示例4: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
@Override
public void write(Packer packer, Object v, boolean required)
throws IOException {
if (v == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
packer.writeNil();
return;
}
if (!(v instanceof Object[]) ||
!componentClass.isAssignableFrom(v.getClass().getComponentType())) {
throw new MessageTypeException();
}
Object[] array = (Object[]) v;
int length = array.length;
packer.writeArrayBegin(length);
for (int i = 0; i < length; i++) {
componentTemplate.write(packer, array[i], required);
}
packer.writeArrayEnd();
}
示例5: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, Collection<E> target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
Collection<E> col = target;
pk.writeArrayBegin(col.size());
for (E e : col) {
elementTemplate.write(pk, e);
}
pk.writeArrayEnd();
}
示例6: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, List<E> target, boolean required)
throws IOException {
if (!(target instanceof List)) {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
throw new MessageTypeException("Target is not a List but "
+ target.getClass());
}
pk.writeArrayBegin(target.size());
for (E e : target) {
elementTemplate.write(pk, e);
}
pk.writeArrayEnd();
}
示例7: writeTo
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void writeTo(Packer pk) throws IOException {
pk.writeArrayBegin(3);
pk.write(Messages.NOTIFY);
pk.write(method);
pk.writeArrayBegin(args.length);
for (Object arg : args) {
pk.write(arg);
}
pk.writeArrayEnd();
pk.writeArrayEnd();
}
示例8: packData
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
protected void packData(Packer packer) throws IOException {
packer.writeArrayBegin(2);
packer.write(event);
if(data instanceof JSONObject) {
this.parseObject(((JSONObject)data), packer);
} else if(data instanceof JSONArray) {
this.parseArray(((JSONArray)data), packer);
}
packer.writeArrayEnd(true);
}
示例9: writeTo
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void writeTo(Packer pk) throws IOException {
pk.writeArrayBegin(4);
pk.write(Messages.REQUEST);
pk.write(msgid);
pk.write(method);
pk.writeArrayBegin(args.length);
for (Object arg : args) {
pk.write(arg);
}
pk.writeArrayEnd();
pk.writeArrayEnd();
}
示例10: writeTo
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
@Override
public void writeTo(Packer packer) throws IOException {
packer.writeArrayBegin(2);
packer.writeMapBegin(3);
packer.write("type");
packer.write(this.type);
packer.write("data");
this.packData(packer);
packer.write("nsp");
packer.write(this.nsp);
packer.writeMapEnd(true);
packer.writeMapBegin(2);
packer.write("rooms");
packer.writeArrayBegin(rooms.size());
for(String room : rooms) {
packer.write(room);
}
packer.writeArrayEnd(true);
packer.write("flags");
packer.writeMapBegin(flags.size());
Iterator<Entry<String, Object>> it = flags.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> pairs = (Map.Entry<String, Object>)it.next();
packer.write(pairs.getKey());
packer.write( pairs.getValue());
it.remove(); // avoids a ConcurrentModificationException
}
packer.writeMapEnd(true);
packer.writeMapEnd(true);
packer.writeArrayEnd(true);
}
示例11: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, double[] target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(target.length);
for (double a : target) {
pk.write(a);
}
pk.writeArrayEnd();
}
示例12: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, short[] target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(target.length);
for (short a : target) {
pk.write(a);
}
pk.writeArrayEnd();
}
示例13: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, int[] target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(target.length);
for (int a : target) {
pk.write(a);
}
pk.writeArrayEnd();
}
示例14: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, long[] target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(target.length);
for (long a : target) {
pk.write(a);
}
pk.writeArrayEnd();
}
示例15: write
import org.msgpack.packer.Packer; //导入方法依赖的package包/类
public void write(Packer pk, float[] target, boolean required)
throws IOException {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(target.length);
for (float a : target) {
pk.write(a);
}
pk.writeArrayEnd();
}