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


Java StatusCodes.Bad_EncodingError方法代码示例

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


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

示例1: encodeToXmlElement

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public XmlElement encodeToXmlElement(Object object, NodeId encodingTypeId) {
    try {
        EncoderDelegate<Object> delegate = DelegateRegistry.getEncoder(encodingTypeId);

        StringWriter stringWriter = new StringWriter();

        XmlEncoder encoder = new XmlEncoder();
        encoder.setOutput(stringWriter);

        delegate.encode(object, encoder);

        return new XmlElement(stringWriter.toString());
    } catch (XMLStreamException e) {
        throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:18,代码来源:OpcUaDataTypeEncoding.java

示例2: encodeGuid

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeGuid(String field, UUID value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> {
            w.writeStartElement("String");
            w.writeCharacters(value.toString());
            w.writeEndElement();
        }));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:19,代码来源:XmlEncoder.java

示例3: encodeNodeId

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeNodeId(String field, NodeId value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> {
            w.writeStartElement("Identifier");
            w.writeCharacters(value.toParseableString());
            w.writeEndElement();
        }));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:19,代码来源:XmlEncoder.java

示例4: encodeExpandedNodeId

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeExpandedNodeId(String field, ExpandedNodeId value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> {
            w.writeStartElement("Identifier");
            w.writeCharacters(value.toParseableString());
            w.writeEndElement();
        }));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:19,代码来源:XmlEncoder.java

示例5: encodeQualifiedName

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeQualifiedName(String field, QualifiedName value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> {
            encodeUInt16("NamespaceIndex", value.getNamespaceIndex());
            encodeString("Name", value.getName());
        }));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:18,代码来源:XmlEncoder.java

示例6: encodeLocalizedText

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeLocalizedText(String field, LocalizedText value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> {
            encodeString("Locale", value.getLocale());
            encodeString("Text", value.getText());
        }));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:18,代码来源:XmlEncoder.java

示例7: getEncoder

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> EncoderDelegate<T> getEncoder(Object t) throws UaSerializationException {
    try {
        return (EncoderDelegate<T>) encodersByClass.get(t.getClass());
    } catch (NullPointerException e) {
        throw new UaSerializationException(StatusCodes.Bad_EncodingError,
                "no encoder registered for class=" + t);
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:10,代码来源:DelegateRegistry.java

示例8: encodeStatusCode

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeStatusCode(String field, StatusCode value) {
    if (value != null) {
        write(field, Unchecked.consumer(w -> encodeStatusCode("Identifier", value)));
    } else {
        if (field != null) {
            try {
                streamWriter.writeEmptyElement(field);
            } catch (XMLStreamException e) {
                throw new UaSerializationException(StatusCodes.Bad_EncodingError, e);
            }
        }
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:15,代码来源:XmlEncoder.java

示例9: write

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private void write(String field, Consumer<XMLStreamWriter> c) {
    try {
        if (field != null) {
            streamWriter.writeStartElement(field);
        }

        c.accept(streamWriter);

        if (field != null) {
            streamWriter.writeEndElement();
        }
    } catch (Throwable t) {
        throw new UaSerializationException(StatusCodes.Bad_EncodingError, t);
    }
}
 
开发者ID:digitalpetri,项目名称:opc-ua-stack,代码行数:16,代码来源:XmlEncoder.java

示例10: 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_EncodingError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。