cms::Message::ValueType ActiveMQStreamMessage::getNextValueType()

in activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp [884:940]


cms::Message::ValueType ActiveMQStreamMessage::getNextValueType() const {

    initializeReading();
    try {

        if (this->impl->remainingBytes != -1) {
            throw cms::IllegalStateException(
                "Cannot read the next type during an byte array read operation, complete the read first.");
        }

        this->dataIn->mark(10);
        int type = this->dataIn->read();

        if (type == -1) {
            throw MessageEOFException("reached end of data", NULL);
        }

        this->dataIn->reset();

        switch(type) {
            case util::PrimitiveValueNode::NULL_TYPE:
                return cms::Message::NULL_TYPE;
            case util::PrimitiveValueNode::BOOLEAN_TYPE:
                return cms::Message::BOOLEAN_TYPE;
            case util::PrimitiveValueNode::BYTE_TYPE:
                return cms::Message::BYTE_TYPE;
            case util::PrimitiveValueNode::BYTE_ARRAY_TYPE:
                return cms::Message::BYTE_ARRAY_TYPE;
            case util::PrimitiveValueNode::CHAR_TYPE:
                return cms::Message::CHAR_TYPE;
            case util::PrimitiveValueNode::SHORT_TYPE:
                return cms::Message::SHORT_TYPE;
            case util::PrimitiveValueNode::INTEGER_TYPE:
                return cms::Message::INTEGER_TYPE;
            case util::PrimitiveValueNode::LONG_TYPE:
                return cms::Message::LONG_TYPE;
            case util::PrimitiveValueNode::DOUBLE_TYPE:
                return cms::Message::DOUBLE_TYPE;
            case util::PrimitiveValueNode::FLOAT_TYPE:
                return cms::Message::FLOAT_TYPE;
            case util::PrimitiveValueNode::STRING_TYPE:
            case util::PrimitiveValueNode::BIG_STRING_TYPE:
                return cms::Message::STRING_TYPE;
            default:
                throw MessageFormatException("Unknown type found in stream", NULL);
        }

        return cms::Message::UNKNOWN_TYPE;

    } catch (EOFException& e) {
        throw CMSExceptionSupport::createMessageEOFException(e);
    } catch (IOException& e) {
        throw CMSExceptionSupport::createMessageFormatException(e);
    } catch (Exception& e) {
        throw CMSExceptionSupport::create(e);
    }
}