Class ExtensionObject
java.lang.Object
org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject
- Direct Known Subclasses:
ExtensionObject.Binary,ExtensionObject.Json,ExtensionObject.Xml
@NullMarked
public abstract sealed class ExtensionObject
extends Object
permits ExtensionObject.Binary, ExtensionObject.Json, ExtensionObject.Xml
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn ExtensionObject that contains aByteStringbody, used with Binary encoding.static final classAn ExtensionObject that contains aStringbody, used with JSON encoding.static final classAn ExtensionObject that contains anXmlElementbody, used with XML encoding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal UaStructuredTypedecode(EncodingContext context) Decode theUaStructuredTypevalue contained in this ExtensionObject using the datatype encoding that matches its body type.final UaStructuredTypedecode(EncodingContext context, DataTypeEncoding encoding) Decode theUaStructuredTypevalue contained in this ExtensionObject using the specified encoding, if it hasn't already been decoded.static ExtensionObjectencode(EncodingContext context, UaStructuredType value) Encode aUaStructuredTypevalue in the default binary encoding.static ExtensionObjectencode(EncodingContext context, UaStructuredType struct, DataTypeEncoding encoding) Encode aUaStructuredTypevalue in the specified datatype encoding.static ExtensionObject[]encodeArray(EncodingContext context, UaStructuredType[] values) Encode an array ofUaStructuredTypevalues in the default binary encoding.abstract ObjectgetBody()Get the body of this ExtensionObject.abstract NodeIdGet theNodeIdof the datatype encoding or datatype of the encoded value contained by this ExtensionObject.abstract booleanisNull()Check if this ExtensionObject is null.static ExtensionObjectCreate a new ExtensionObject with the specified String body and type id.static ExtensionObjectof(ByteString body, NodeId encodingId) Create a new ExtensionObject with the specified ByteString body and encoding id.static ExtensionObjectof(XmlElement body, NodeId encodingId) Create a new ExtensionObject with the specified XmlElement body and encoding id.final ExtensionObjecttranscode(EncodingContext context, NodeId newEncodingId, DataTypeEncoding newEncoding) Transcode this ExtensionObject to a new encoding.
-
Constructor Details
-
ExtensionObject
public ExtensionObject()
-
-
Method Details
-
getBody
Get the body of this ExtensionObject.The body is the encoded value of the ExtensionObject. The type of the body depends on the encoding that was used to encode the ExtensionObject. The body is one of:
ByteStringfor Binary encodingXmlElementfor XML encodingStringfor JSON encoding
- Returns:
- the body of this ExtensionObject.
-
getEncodingOrTypeId
Get theNodeIdof the datatype encoding or datatype of the encoded value contained by this ExtensionObject.The NodeId returned is the encoding id if the encoding is Binary or XML, or the datatype id if the encoding is JSON.
- Returns:
- the
NodeIdof the datatype encoding or datatype.
-
isNull
public abstract boolean isNull()Check if this ExtensionObject is null.- Returns:
- true if this ExtensionObject is null, false otherwise.
-
decode
Decode theUaStructuredTypevalue contained in this ExtensionObject using the datatype encoding that matches its body type.- Parameters:
context- anEncodingContext.- Returns:
- the decoded
UaStructuredTypevalue. - Throws:
UaSerializationException- if the decoding fails.
-
decode
public final UaStructuredType decode(EncodingContext context, DataTypeEncoding encoding) throws UaSerializationException Decode theUaStructuredTypevalue contained in this ExtensionObject using the specified encoding, if it hasn't already been decoded.- Parameters:
context- anEncodingContext.encoding- theDataTypeEncodingto use.- Returns:
- the decoded
UaStructuredTypevalue. - Throws:
UaSerializationException- if the decoding fails.
-
transcode
public final ExtensionObject transcode(EncodingContext context, NodeId newEncodingId, DataTypeEncoding newEncoding) throws UaSerializationException Transcode this ExtensionObject to a new encoding.- Parameters:
context- anEncodingContext.newEncodingId- theNodeIdof the new encoding.newEncoding- theDataTypeEncodingto use.- Returns:
- a new ExtensionObject with a value encoded in the specified encoding.
- Throws:
UaSerializationException- if the transcoding fails.
-
of
Create a new ExtensionObject with the specified ByteString body and encoding id.- Parameters:
body- the ByteString body of the ExtensionObjectencodingId- the NodeId of the datatype encoding.- Returns:
- a new ExtensionObject with the specified body and encoding id.
-
of
Create a new ExtensionObject with the specified XmlElement body and encoding id.- Parameters:
body- the XmlElement body of the ExtensionObjectencodingId- the NodeId of the datatype encoding.- Returns:
- a new ExtensionObject with the specified body and encoding id.
-
of
Create a new ExtensionObject with the specified String body and type id.- Parameters:
body- the String body of the ExtensionObjecttypeId- the NodeId of the datatype.- Returns:
- a new ExtensionObject with the specified body and type id.
-
encodeArray
public static ExtensionObject[] encodeArray(EncodingContext context, UaStructuredType[] values) throws UaSerializationException Encode an array ofUaStructuredTypevalues in the default binary encoding.- Parameters:
context- anEncodingContext.values- theUaStructuredTypevalues to encode.- Returns:
- an array of
ExtensionObjectcontaining the encoded values. - Throws:
UaSerializationException- if the encoding fails.
-
encode
public static ExtensionObject encode(EncodingContext context, UaStructuredType value) throws UaSerializationException Encode aUaStructuredTypevalue in the default binary encoding.- Parameters:
context- anEncodingContext.value- theUaStructuredTypevalue to encode.- Returns:
- an
ExtensionObjectcontaining the encoded value. - Throws:
UaSerializationException- if the encoding fails.
-
encode
public static ExtensionObject encode(EncodingContext context, UaStructuredType struct, DataTypeEncoding encoding) throws UaSerializationException Encode aUaStructuredTypevalue in the specified datatype encoding.- Parameters:
context- anEncodingContext.struct- theUaStructuredTypevalue to encode.encoding- theDataTypeEncodingto use.- Returns:
- an
ExtensionObjectcontaining the encoded value. - Throws:
UaSerializationException- if the encoding fails.
-