本文整理匯總了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 );
}