本文整理汇总了Java中org.apache.mina.core.buffer.IoBuffer.putLong方法的典型用法代码示例。如果您正苦于以下问题:Java IoBuffer.putLong方法的具体用法?Java IoBuffer.putLong怎么用?Java IoBuffer.putLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.core.buffer.IoBuffer
的用法示例。
在下文中一共展示了IoBuffer.putLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void render ( final IoBuffer buffer, final int offset, final DataItemValue value )
{
final IoBuffer slice = buffer.getSlice ( offset, this.length );
logger.trace ( "After Slice: {}", buffer );
if ( value != null )
{
slice.put ( makeValidState ( value ) );
slice.put ( makeState ( value ) );
slice.putLong ( makeTimestamp ( value.getTimestamp () ) );
putValue ( slice, value.getValue () );
}
else
{
slice.put ( (byte)0xFF ); // invalid
slice.put ( makeState ( null ) );
slice.putLong ( makeTimestamp ( null ) );
putValue ( slice, null );
}
logger.trace ( "Buffer: {}", buffer );
}
示例2: encodeLongCollection
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encodeLongCollection ( final IoBuffer buffer, final byte fieldNumber, final Collection<Long> data ) throws Exception
{
buffer.put ( fieldNumber );
if ( data != null )
{
buffer.put ( TYPE_LONG_LIST );
buffer.putInt ( data.size () );
for ( final Long entry : data )
{
buffer.putLong ( entry );
}
}
else
{
buffer.put ( TYPE_NULL );
}
}
示例3: encodeWriteRequest
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeWriteRequest ( final IoBuffer data, final WriteRequestMessage message )
{
data.putShort ( message.getIndex () );
final Object value = message.getData ();
if ( value == null )
{
data.put ( (byte)0x00 );
}
else if ( value instanceof Boolean )
{
data.put ( (byte)0x01 );
data.put ( (byte) ( (Boolean)value ? 0xFF : 0x00 ) );
}
else if ( value instanceof Float || value instanceof Double )
{
data.put ( (byte)0x04 );
data.putFloat ( ( (Number)value ).floatValue () );
}
else if ( value instanceof Long )
{
data.put ( (byte)0x03 );
data.putLong ( ( (Number)value ).longValue () );
}
else if ( value instanceof Number )
{
data.put ( (byte)0x02 );
data.putInt ( ( (Number)value ).intValue () );
}
else if ( value instanceof String )
{
data.put ( (byte)0x02 );
data.putInt ( Integer.parseInt ( (String)value ) );
}
else
{
throw new RuntimeException ( String.format ( "Unable to write request of type %s", value.getClass () ) );
}
}
示例4: encodeEntry
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeEntry ( final IoSession session, final IoBuffer data, final Entry entry ) throws ProtocolCodecException
{
data.putUnsignedShort ( entry.getRegister () );
data.put ( entry.getMissedUpdates () );
data.putLong ( entry.getTimestamp () );
data.putEnumSetShort ( entry.getStates () );
// put payload
encodeVariant ( session, data, entry.getValue () );
}
示例5: encodeLong
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encodeLong ( final IoBuffer buffer, final byte fieldNumber, final Long data ) throws Exception
{
buffer.put ( fieldNumber );
if ( data != null )
{
buffer.put ( TYPE_LONG );
buffer.putLong ( data );
}
else
{
buffer.put ( TYPE_NULL );
}
}
示例6: encodePrimitiveLong
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encodePrimitiveLong ( final IoBuffer buffer, final byte fieldNumber, final long data ) throws Exception
{
buffer.put ( fieldNumber );
buffer.put ( TYPE_LONG );
buffer.putLong ( data );
}
示例7: inlineEncodeVariant
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void inlineEncodeVariant ( final IoBuffer buffer, final Variant variant ) throws Exception
{
final VariantType type = variant.getType ();
buffer.putEnum ( type );
switch ( type )
{
case BOOLEAN:
buffer.put ( variant.asBoolean () ? (byte)0xFF : (byte)0x00 );
break;
case DOUBLE:
buffer.putDouble ( variant.asDouble () );
break;
case INT32:
buffer.putInt ( variant.asInteger () );
break;
case INT64:
buffer.putLong ( variant.asLong () );
break;
case STRING:
buffer.putPrefixedString ( variant.asString (), STRING_PREFIX_LEN, this.encoder );
break;
case NULL:
break;
case UNKNOWN:
break;
}
}
示例8: encodeVariant
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeVariant ( final IoSession session, final IoBuffer data, final Variant value ) throws ProtocolCodecException
{
if ( value == null )
{
data.put ( DataType.DEAD.getDataType () ); // dead
}
else if ( value.isNull () )
{
data.put ( DataType.NULL.getDataType () );
}
else if ( value.isBoolean () )
{
data.put ( DataType.BOOLEAN.getDataType () );
data.put ( (byte) ( value.asBoolean () ? 0xFF : 0x00 ) );
}
else if ( value.isInteger () )
{
data.put ( DataType.INT32.getDataType () );
data.putInt ( value.asInteger ( null ) );
}
else if ( value.isLong () )
{
data.put ( DataType.INT64.getDataType () );
data.putLong ( value.asLong ( null ) );
}
else if ( value.isDouble () )
{
data.put ( DataType.DOUBLE.getDataType () );
data.putDouble ( value.asDouble ( null ) );
}
else if ( value.isString () )
{
data.put ( DataType.STRING.getDataType () );
try
{
data.putPrefixedString ( value.asString ( null ), Sessions.getCharsetEncoder ( session ) );
}
catch ( final CharacterCodingException e )
{
throw new ProtocolCodecException ( e );
}
}
}
示例9: put
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void put ( final IoBuffer data, final Long value )
{
data.putLong ( value );
}