当前位置: 首页>>代码示例>>Java>>正文


Java MessagePacker类代码示例

本文整理汇总了Java中org.msgpack.core.MessagePacker的典型用法代码示例。如果您正苦于以下问题:Java MessagePacker类的具体用法?Java MessagePacker怎么用?Java MessagePacker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessagePacker类属于org.msgpack.core包,在下文中一共展示了MessagePacker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
void write(MessagePacker packer) throws IOException {
  Visitor visitor = new Visitor(packer);
  packer.packArrayHeader(3);
  packer.packString(this.type);
  if (this.data != null) {
    packer.packMapHeader(this.data.size());
    for (Map.Entry<String, Object> entry : this.data.entrySet()) {
      packer.packString(entry.getKey());
      visitor.visit(entry.getValue());
    }
  } else {
    packer.packNil();
  }
  packer.packString(this.nodeId);
  packer.close();

}
 
开发者ID:vrajat,项目名称:nomadacris,代码行数:18,代码来源:Message.java

示例2: toMarkerThrows

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
private String toMarkerThrows(Map<String, Object> attributes, boolean hasHashKey) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    MessagePacker packer = MessagePack.newDefaultPacker(out);
    packer.packArrayHeader(size(hasHashKey));
    if ( ! hasHashKey ) {
        pack(packer, attributes, _hkName);
    }
    if ( null == _otherKeyNames ) {
        packer.flush();
        return BASE64_ENCODER.encodeToString(out.toByteArray());
    }
    for ( String keyName : _otherKeyNames ) {
        pack(packer, attributes, keyName);
    }
    packer.flush();
    return BASE64_ENCODER.encodeToString(out.toByteArray());
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:18,代码来源:GenericConvertMarker.java

示例3: _writeSimpleObjectToPacker

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
private void _writeSimpleObjectToPacker(Object object, MessagePacker packer) throws IOException {
	if (object == null) {
		packer.packNil();
	} else if (object instanceof Byte) {
		packer.packByte((Byte)object);
	} else if (object instanceof Boolean) {
		packer.packBoolean((Boolean)object);
	} else if (object instanceof Double) {
		packer.packDouble((Double)object);
	} else if (object instanceof Float) {
		packer.packFloat((Float)object);
	} else if (object instanceof Integer) {
		packer.packInt((Integer)object);
	} else if (object instanceof Long) {
		packer.packLong((Long)object);
	} else if (object instanceof Short) {
		packer.packShort((Short)object);
	} else if (object instanceof String) {
		packer.packString((String)object);
	} else {
		packer.packNil();
	}
}
 
开发者ID:actionk,项目名称:JUniform,代码行数:24,代码来源:JUniformPackerMessagePack.java

示例4: flush

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
@Override
public void flush() throws IOException {
    if (rootStackItem != null) {
        if (rootStackItem instanceof StackItemForObject) {
            packObject((StackItemForObject) rootStackItem);
        }
        else if (rootStackItem instanceof StackItemForArray) {
            packArray((StackItemForArray) rootStackItem);
        }
        else {
            throw new IllegalStateException("Unexpected rootStackItem: " + rootStackItem);
        }
        MessagePacker messagePacker = getMessagePacker();
        messagePacker.flush();
    }
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:17,代码来源:MessagePackGenerator.java

示例5: writeTo

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
/**
 * Serializes the {@code message} into an {@link MessageBufferOutput} using the given {@code schema}.
 */
public static <T> void writeTo(MessageBufferOutput out, T message, Schema<T> schema, boolean numeric)
        throws IOException
{

    MessagePacker packer = MessagePack.newDefaultPacker(out);

    try
    {
        writeTo(packer, message, schema, numeric);
    }
    finally
    {
        packer.flush();
    }
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:19,代码来源:MsgpackIOUtil.java

示例6: writeListTo

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
/**
 * Serializes the {@code messages} into the stream using the given schema.
 */
public static <T> void writeListTo(OutputStream out, List<T> messages,
        Schema<T> schema, boolean numeric) throws IOException
{

    MessagePacker packer = MessagePack.newDefaultPacker(out);

    try
    {
        writeListTo(packer, messages, schema, numeric);
    }
    finally
    {
        packer.flush();
    }
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:19,代码来源:MsgpackIOUtil.java

示例7: packBigNumber

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
public MessagePacker packBigNumber(BigInteger bn) throws IOException {
    byte sign = 0;
    if (bn.compareTo(new BigInteger("0")) < 0) {
        sign = '-';
        bn = bn.abs();
    } else {
        sign = '+';
    }
    byte[] data = Arrays.prepend(bn.toByteArray(), sign);
    this.packExtensionTypeHeader((byte) 0, data.length);
    this.addPayload(data);
    return this;
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:14,代码来源:Packer.java

示例8: packEcGroup

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
/**
 * Packs id of EcGroup used.
 * Fixed at id=713
 */
public MessagePacker packEcGroup() throws IOException {
    MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
    packer.packInt(713);

    byte[] data = packer.toByteArray();
    this.packExtensionTypeHeader((byte) 1, data.length);
    this.addPayload(data);
    return this;
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:14,代码来源:Packer.java

示例9: packEcPoint

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
/**
 * Packs id of EcGroup used and EcPoint data.
 * EcGroup id fixed at 713
 */
public MessagePacker packEcPoint(ECPoint point) throws IOException {
    byte[] data = ecPointToByteArray(point);
    this.packExtensionTypeHeader((byte) 2, data.length);
    this.addPayload(data);
    return this;
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:11,代码来源:Packer.java

示例10: packNumber

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
private static void packNumber(MessagePacker pack, String num) throws IOException {
    BigDecimal dec = new BigDecimal(num);
    try {
        pack.packBigInteger(dec.toBigIntegerExact());
    } catch ( ArithmeticException ex ) {
        pack.packDouble(dec.doubleValue());
    }
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:9,代码来源:AttributeValuePacker.java

示例11: serialize

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
@Override
public void serialize( Options options, OutputStream output, @Optional Object object )
{
    try( MessagePacker packer = MessagePack.newDefaultPacker( output ) )
    {
        Value value = doSerialize( options, object, true );
        packer.packValue( value );
        packer.flush();
    }
    catch( IOException ex )
    {
        throw new SerializationException( "Unable to serialize " + object, ex );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:15,代码来源:MessagePackSerializer.java

示例12: fromUniformObject

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
@Override
public Object fromUniformObject(JUniformObject object) {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	MessagePacker packer = _msgpack.newPacker(out);
	try {
		this._writeJUniformObjectToPacker(object, packer);
		packer.close();
	} catch (IOException ex) {
		return null;
	}
	return out.toByteArray();
}
 
开发者ID:actionk,项目名称:JUniform,代码行数:13,代码来源:JUniformPackerMessagePack.java

示例13: PackedBuffer

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
/**
 * Create a new PackedBuffer.
 *
 * @param bb        The ByteBuffer to use to create the packed buffer.
 */
PackedBuffer(ByteBuffer bb) {
  this.bb = bb;
  this.out = new PackedBufferOutput();
  this.temp = new byte[SPAN_ID_BYTE_LENGTH];
  this.packer = new MessagePacker(out, MSGPACK_CONF);
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:12,代码来源:PackedBuffer.java

示例14: packObject

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
private void packObject(StackItemForObject stackItem) throws IOException {
    List<String> keys = stackItem.getKeys();
    List<Object> values = stackItem.getValues();

    MessagePacker messagePacker = getMessagePacker();
    messagePacker.packMapHeader(keys.size());

    for (int i = 0; i < keys.size(); i++) {
        messagePacker.packString(keys.get(i));
        Object v = values.get(i);
        packValue(v);
    }
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:14,代码来源:MessagePackGenerator.java

示例15: packArray

import org.msgpack.core.MessagePacker; //导入依赖的package包/类
private void packArray(StackItemForArray stackItem) throws IOException {
    List<Object> values = stackItem.getValues();

    MessagePacker messagePacker = getMessagePacker();
    messagePacker.packArrayHeader(values.size());

    for (int i = 0; i < values.size(); i++) {
        Object v = values.get(i);
        packValue(v);
    }
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:12,代码来源:MessagePackGenerator.java


注:本文中的org.msgpack.core.MessagePacker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。