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


Java IoBuffer.put方法代码示例

本文整理汇总了Java中org.apache.mina.core.buffer.IoBuffer.put方法的典型用法代码示例。如果您正苦于以下问题:Java IoBuffer.put方法的具体用法?Java IoBuffer.put怎么用?Java IoBuffer.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.core.buffer.IoBuffer的用法示例。


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

示例1: encodeDoubleCollection

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encodeDoubleCollection ( final IoBuffer buffer, final byte fieldNumber, final Collection<Double> data ) throws Exception
{
    buffer.put ( fieldNumber );
    if ( data != null )
    {
        buffer.put ( TYPE_DOUBLE_LIST );
        buffer.putInt ( data.size () );
        for ( final Double entry : data )
        {
            buffer.putDouble ( entry );
        }
    }
    else
    {
        buffer.put ( TYPE_NULL );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DefaultBinaryContext.java

示例2: encodeBrowseUpdate

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeBrowseUpdate ( final IoSession session, final Object message, final IoBuffer data ) throws ProtocolCodecException
{
    // length
    data.putUnsignedShort ( ( (BrowseAdded)message ).getEntries ().size () );

    final CharsetEncoder encoder = Sessions.getCharsetEncoder ( session );

    // data
    for ( final BrowseAdded.Entry entry : ( (BrowseAdded)message ).getEntries () )
    {
        data.putUnsignedShort ( entry.getRegister () );
        data.put ( entry.getDataType ().getDataType () );
        data.putEnumSet ( entry.getFlags () );

        try
        {
            data.putPrefixedString ( entry.getName (), encoder );
            data.putPrefixedString ( entry.getDescription (), encoder );
            data.putPrefixedString ( entry.getUnit (), encoder );
        }
        catch ( final CharacterCodingException e )
        {
            throw new ProtocolCodecException ( e );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:ProtocolEncoderImpl.java

示例3: encode

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encode ( final IoSession session, final Object message, final ProtocolEncoderOutput output ) throws Exception
{
    if ( ! ( message instanceof Frame ) )
    {
        throw new IllegalStateException ( String.format ( "Can only encode messages of type Frame but got %s", message.getClass () ) );
    }

    final Frame frame = (Frame)message;

    if ( logger.isTraceEnabled () )
    {
        logger.trace ( "Encode frame - type: {}, data: {}", frame.getType (), frame.getData () );
    }

    final IoBuffer buffer = IoBuffer.allocate ( 1 + 1 + 4 + frame.getData ().remaining () );
    buffer.put ( (byte)0x01 ); // version - #0
    buffer.put ( (byte)frame.getType ().ordinal () ); // frame type - #1
    buffer.putInt ( frame.getData ().remaining () ); // data size - #2
    buffer.put ( frame.getData () ); // data - #6
    buffer.flip ();

    output.write ( buffer );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:FrameEncoder.java

示例4: encodeHeader

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeHeader ( final DaveMessage message, final IoBuffer data, final byte type )
{
    // == PDU header
    data.put ( PACKET_START_MAGIC );
    data.put ( type );
    data.put ( (byte)0 );
    data.put ( (byte)0 );
    data.putShort ( (short)0 ); // req nr

    data.putShort ( (short)0 ); // parameter len
    data.putShort ( (short)0 ); // data len

    if ( type == 2 || type == 3 )
    {
        data.put ( (byte)0 );
        data.put ( (byte)0 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DaveFilter.java

示例5: performRead

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private IoBuffer performRead ( final int offset, final int length )
{
    logger.debug ( "Perform read - offset: {}, length: {}, capacity: {}", offset, length, this.buffer.capacity () );

    if ( length == 0 )
    {
        return null;
    }

    if ( offset < 0 )
    {
        return null;
    }

    if ( offset + length > this.buffer.capacity () )
    {
        return null;
    }

    final IoBuffer result = IoBuffer.allocate ( length );

    result.put ( this.buffer.getSlice ( offset, length ) );

    return result;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:MemoryBlock.java

示例6: 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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DefaultBinaryContext.java

示例7: put

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void put ( final IoBuffer data, final String value )
{
    if ( value == null )
    {
        data.put ( (byte)0x00 );
    }

    try
    {
        data.putString ( value, this.length, this.charset.newEncoder () );
    }
    catch ( final CharacterCodingException e )
    {
        throw new RuntimeException ( e );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:FixedLengthStringAccessor.java

示例8: encodeEnum

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public <E extends Enum<E>> void encodeEnum ( final IoBuffer buffer, final byte fieldNumber, final E value ) throws Exception
{
    buffer.put ( fieldNumber );
    if ( value != null )
    {
        buffer.put ( TYPE_ENUM );
        inlineEncodeEnum ( buffer, value );
    }
    else
    {
        buffer.put ( TYPE_NULL );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:DefaultBinaryContext.java

示例9: beginWriteStructureList

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void beginWriteStructureList ( final IoBuffer buffer, final byte fieldNumber, final Collection<?> values ) throws Exception
{
    buffer.put ( fieldNumber );
    if ( values != null )
    {
        buffer.put ( TYPE_STRUCTURE_LIST );
        buffer.putInt ( values.size () );
    }
    else
    {
        buffer.put ( TYPE_NULL );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:DefaultBinaryContext.java

示例10: encodeInitialGreetingPacket

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
 * Encodes the initial greeting packet.
 * 
 * @param request the socks proxy request data
 * @return the encoded buffer
 */
private IoBuffer encodeInitialGreetingPacket(final SocksProxyRequest request) {
    byte nbMethods = (byte) SocksProxyConstants.SUPPORTED_AUTH_METHODS.length;
    IoBuffer buf = IoBuffer.allocate(2 + nbMethods);

    buf.put(request.getProtocolVersion());
    buf.put(nbMethods);
    buf.put(SocksProxyConstants.SUPPORTED_AUTH_METHODS);

    return buf;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:Socks5LogicHandler.java

示例11: encodeCloseMessage

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private Frame encodeCloseMessage ( final IoSession session, final CloseMessage message ) throws CharacterCodingException
{
    final IoBuffer data = IoBuffer.allocate ( 0 );
    data.setAutoExpand ( true );
    data.putString ( message.getMessage (), getCharsetEncoder ( session ) );
    data.put ( (byte)0x00 );
    data.putInt ( message.getCode () );

    data.flip ();

    return new Frame ( FrameType.CLOSE, data );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:MessageChannelCodecFilter.java

示例12: writeRequest

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
 * Encode a SOCKS4/SOCKS4a request and writes it to the next filter
 * so it can be sent to the proxy server.
 * 
 * @param nextFilter the next filter
 * @param request the request to send.
 */
protected void writeRequest(final NextFilter nextFilter, final SocksProxyRequest request) {
    try {
        boolean isV4ARequest = Arrays.equals(request.getIpAddress(), SocksProxyConstants.FAKE_IP);
        byte[] userID = request.getUserName().getBytes("ASCII");
        byte[] host = isV4ARequest ? request.getHost().getBytes("ASCII") : null;

        int len = 9 + userID.length;

        if (isV4ARequest) {
            len += host.length + 1;
        }

        IoBuffer buf = IoBuffer.allocate(len);

        buf.put(request.getProtocolVersion());
        buf.put(request.getCommandCode());
        buf.put(request.getPort());
        buf.put(request.getIpAddress());
        buf.put(userID);
        buf.put(SocksProxyConstants.TERMINATOR);

        if (isV4ARequest) {
            buf.put(host);
            buf.put(SocksProxyConstants.TERMINATOR);
        }

        if (isV4ARequest) {
            logger.debug("  sending SOCKS4a request");
        } else {
            logger.debug("  sending SOCKS4 request");
        }

        buf.flip();
        writeData(nextFilter, buf);
    } catch (Exception ex) {
        closeSession("Unable to send Socks request: ", ex);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:Socks4LogicHandler.java

示例13: encodeReadRequests

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void encodeReadRequests ( final DaveReadRequest message, final IoBuffer data )
{
    // -- Read Command
    data.put ( DaveCommandCodes.DAVE_READ.getCommandCode () );
    data.put ( (byte)message.getRequests ().size () ); // possibly the number of read requests

    for ( final Request request : message.getRequests () )
    {
        encodeAddress ( data, request );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:DaveFilter.java

示例14: encodeInt

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
@Override
public void encodeInt ( final IoBuffer buffer, final byte fieldNumber, final Integer data ) throws Exception
{
    buffer.put ( fieldNumber );
    if ( data != null )
    {
        buffer.put ( TYPE_INT );
        buffer.putInt ( data );
    }
    else
    {
        buffer.put ( TYPE_NULL );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:DefaultBinaryContext.java

示例15: storeRemainingInSession

import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
private void storeRemainingInSession(IoBuffer buf, IoSession session) {
    final IoBuffer remainingBuf = IoBuffer.allocate(buf.capacity()).setAutoExpand(true);

    remainingBuf.order(buf.order());
    remainingBuf.put(buf);

    session.setAttribute(BUFFER, remainingBuf);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:CumulativeProtocolDecoder.java


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