Exemplo n.º 1
0
        private int EncodeToken(Token token)
        {
            Encoding      encoding = token.encoding();
            PrimitiveType type     = encoding.primitiveType();

            tokenCodec.wrapForEncode(directBuffer, 0).tokenOffset(token.offset()).tokenSize(token.size()).schemaId(token.schemaId()).tokenVersion(token.version()).signal(mapSignal(token.signal())).primitiveType(mapPrimitiveType(type)).byteOrder(mapByteOrder(encoding.byteOrder())).presence(mapPresence(encoding.presence()));

            sbyte[] nameBytes = token.name().getBytes(TokenCodec.nameCharacterEncoding());
            tokenCodec.putName(nameBytes, 0, nameBytes.Length);

            tokenCodec.putConstVal(valArray, 0, put(valBuffer, encoding.constVal(), type));
            tokenCodec.putMinVal(valArray, 0, put(valBuffer, encoding.minVal(), type));
            tokenCodec.putMaxVal(valArray, 0, put(valBuffer, encoding.maxVal(), type));
            tokenCodec.putNullVal(valArray, 0, put(valBuffer, encoding.nullVal(), type));

            sbyte[] charEncodingBytes = getBytes(encoding.characterEncoding(), TokenCodec.characterEncodingCharacterEncoding());
            tokenCodec.putCharacterEncoding(charEncodingBytes, 0, charEncodingBytes.Length);

            sbyte[] epochBytes = getBytes(encoding.epoch(), TokenCodec.epochCharacterEncoding());
            tokenCodec.putEpoch(epochBytes, 0, epochBytes.Length);

            sbyte[] timeUnitBytes = getBytes(encoding.timeUnit(), TokenCodec.timeUnitCharacterEncoding());
            tokenCodec.putTimeUnit(timeUnitBytes, 0, timeUnitBytes.Length);

            sbyte[] semanticTypeBytes = getBytes(encoding.semanticType(), TokenCodec.semanticTypeCharacterEncoding());
            tokenCodec.putSemanticType(semanticTypeBytes, 0, semanticTypeBytes.Length);

            return(tokenCodec.size());
        }
Exemplo n.º 2
0
    private int EncodeToken(Token token)
    {
        Encoding encoding = token.encoding();
        PrimitiveType type = encoding.primitiveType();

        tokenCodec.wrapForEncode(directBuffer, 0).tokenOffset(token.offset()).tokenSize(token.size()).schemaId(token.schemaId()).tokenVersion(token.version()).signal(mapSignal(token.signal())).primitiveType(mapPrimitiveType(type)).byteOrder(mapByteOrder(encoding.byteOrder())).presence(mapPresence(encoding.presence()));

        sbyte[] nameBytes = token.name().getBytes(TokenCodec.nameCharacterEncoding());
        tokenCodec.putName(nameBytes, 0, nameBytes.Length);

        tokenCodec.putConstVal(valArray, 0, put(valBuffer, encoding.constVal(), type));
        tokenCodec.putMinVal(valArray, 0, put(valBuffer, encoding.minVal(), type));
        tokenCodec.putMaxVal(valArray, 0, put(valBuffer, encoding.maxVal(), type));
        tokenCodec.putNullVal(valArray, 0, put(valBuffer, encoding.nullVal(), type));

        sbyte[] charEncodingBytes = getBytes(encoding.characterEncoding(), TokenCodec.characterEncodingCharacterEncoding());
        tokenCodec.putCharacterEncoding(charEncodingBytes, 0, charEncodingBytes.Length);

        sbyte[] epochBytes = getBytes(encoding.epoch(), TokenCodec.epochCharacterEncoding());
        tokenCodec.putEpoch(epochBytes, 0, epochBytes.Length);

        sbyte[] timeUnitBytes = getBytes(encoding.timeUnit(), TokenCodec.timeUnitCharacterEncoding());
        tokenCodec.putTimeUnit(timeUnitBytes, 0, timeUnitBytes.Length);

        sbyte[] semanticTypeBytes = getBytes(encoding.semanticType(), TokenCodec.semanticTypeCharacterEncoding());
        tokenCodec.putSemanticType(semanticTypeBytes, 0, semanticTypeBytes.Length);

        return tokenCodec.size();
    }