本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}