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


Java ByteBuffer.getString方法代码示例

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


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

示例1: readObject

import org.apache.mina.common.ByteBuffer; //导入方法依赖的package包/类
/**
 * Read object from StreamMessage ByteBuffer content
 *
 * @param wrapMsgContent ByteBuffer which contains data
 * @param encoding       message encoding
 * @return Object extracted from ByteBuffer
 * @throws JMSException
 * @throws CharacterCodingException
 */
private Object readObject(ByteBuffer wrapMsgContent, String encoding)
        throws JMSException, CharacterCodingException {
    int position = wrapMsgContent.position();
    checkAvailable(1, wrapMsgContent);
    byte wireType = wrapMsgContent.get();
    Object result = null;
    try {
        switch (wireType) {
        case BOOLEAN_TYPE:
            checkAvailable(1, wrapMsgContent);
            result = wrapMsgContent.get() != 0;
            break;
        case BYTE_TYPE:
            checkAvailable(1, wrapMsgContent);
            result = wrapMsgContent.get();
            break;
        case BYTEARRAY_TYPE:
            checkAvailable(4, wrapMsgContent);
            int size = wrapMsgContent.getInt();
            if (size == -1) {
                result = null;
            } else {
                byteArrayRemaining = size;
                byte[] bytesResult = new byte[size];
                readBytesImpl(wrapMsgContent, bytesResult);
                result = bytesResult;
            }
            break;
        case SHORT_TYPE:
            checkAvailable(2, wrapMsgContent);
            result = wrapMsgContent.getShort();
            break;
        case CHAR_TYPE:
            checkAvailable(2, wrapMsgContent);
            result = wrapMsgContent.getChar();
            break;
        case INT_TYPE:
            checkAvailable(4, wrapMsgContent);
            result = wrapMsgContent.getInt();
            break;
        case LONG_TYPE:
            checkAvailable(8, wrapMsgContent);
            result = wrapMsgContent.getLong();
            break;
        case FLOAT_TYPE:
            checkAvailable(4, wrapMsgContent);
            result = wrapMsgContent.getFloat();
            break;
        case DOUBLE_TYPE:
            checkAvailable(8, wrapMsgContent);
            result = wrapMsgContent.getDouble();
            break;
        case NULL_STRING_TYPE:
            result = null;
            break;
        case STRING_TYPE:
            checkAvailable(1, wrapMsgContent);
            result = wrapMsgContent.getString(Charset.forName(encoding).newDecoder());
            break;
        }
        return result;
    } catch (RuntimeException e) {
        wrapMsgContent.position(position);
        throw e;
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:76,代码来源:QueueManagementInformationMBean.java

示例2: extractTextMessageContent

import org.apache.mina.common.ByteBuffer; //导入方法依赖的package包/类
/**
 * Extract TextMessage from ByteBuffer
 *
 * @param wrapMsgContent ByteBuffer which contains data
 * @param encoding       message encoding
 * @return extracted content as text
 * @throws CharacterCodingException
 */
private String extractTextMessageContent(ByteBuffer wrapMsgContent, String encoding)
        throws CharacterCodingException {
    String wholeMsg;
    wholeMsg = wrapMsgContent.getString(Charset.forName(encoding).newDecoder());
    return wholeMsg;
}
 
开发者ID:wso2,项目名称:andes,代码行数:15,代码来源:QueueManagementInformationMBean.java


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