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


Java StatusCodes.Bad_EncodingLimitsExceeded方法代码示例

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


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

示例1: decodeString

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public String decodeString(String field) throws UaSerializationException {
    int length = decodeInt32(null);

    if (length == -1) {
        return null;
    } else {
        if (length > maxStringLength) {
            throw new UaSerializationException(StatusCodes.Bad_EncodingLimitsExceeded,
                    String.format("max string length exceeded (length=%s, max=%s)", length, maxStringLength));
        }

        String s = buffer.toString(buffer.readerIndex(), length, Charset.forName("UTF-8"));
        buffer.skipBytes(length);
        return s;
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:18,代码来源:BinaryDecoder.java

示例2: decodeArray

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T[] decodeArray(String field, Function<String, T> decoder, Class<T> clazz) throws UaSerializationException {
    int length = decodeInt32(null);

    if (length == -1) {
        return (T[]) Array.newInstance(clazz, 0);
    } else {
        if (length > maxArrayLength) {
            throw new UaSerializationException(StatusCodes.Bad_EncodingLimitsExceeded,
                    "max array length exceeded");
        }

        Object array = Array.newInstance(clazz, length);

        for (int i = 0; i < length; i++) {
            Array.set(array, i, decoder.apply(null));
        }

        return (T[]) array;
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:23,代码来源:BinaryDecoder.java

示例3: encodeArray

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public <T> void encodeArray(String field, T[] values, BiConsumer<String, T> consumer) throws UaSerializationException {
    if (values == null) {
        buffer.writeInt(-1);
    } else {
        if (values.length > maxArrayLength) {
            throw new UaSerializationException(StatusCodes.Bad_EncodingLimitsExceeded,
                    "max array length exceeded");
        }

        encodeInt32(null, values.length);
        for (T t : values) {
            consumer.accept(null, t);
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:17,代码来源:BinaryEncoder.java

示例4: encodeString

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeString(String field, String value) throws UaSerializationException {
    if (value == null) {
        buffer.writeInt(-1);
    } else {
        if (value.length() > maxStringLength) {
            throw new UaSerializationException(StatusCodes.Bad_EncodingLimitsExceeded,
                    "max string length exceeded");
        }

        try {
            // Record the current index and write a placeholder for the length.
            int lengthIndex = buffer.writerIndex();
            buffer.writeInt(0x42424242);

            // Write the string bytes.
            int indexBefore = buffer.writerIndex();
            buffer.writeBytes(value.getBytes("UTF-8"));
            int indexAfter = buffer.writerIndex();
            int bytesWritten = indexAfter - indexBefore;

            // Go back and update the length.
            buffer.writerIndex(lengthIndex);
            buffer.writeInt(bytesWritten);

            // Return to where we were after writing the string.
            buffer.writerIndex(indexAfter);
        } catch (UnsupportedEncodingException e) {
            throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:33,代码来源:BinaryEncoder.java


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