org.opcfoundation.ua.builtintypes
Class ExtensionObject

java.lang.Object
  extended by org.opcfoundation.ua.builtintypes.ExtensionObject

public class ExtensionObject
extends Object

Extension object contains a Structure which is either XML or binary encoded.


Constructor Summary
ExtensionObject(ExpandedNodeId typeId)
          Constructor for ExtensionObject.
ExtensionObject(ExpandedNodeId typeId, byte[] object)
          Constructor for ExtensionObject.
ExtensionObject(ExpandedNodeId typeId, XmlElement object)
          Constructor for ExtensionObject.
ExtensionObject(Structure encodeable)
          ExtensionObject that encodes the value later when put into a Encoder.
 
Method Summary
static ExtensionObject binaryEncode(Structure encodeable, EncoderContext ctx)
          Create extension object by encoding an encodeable to a binary format using the default serializer.
static ExtensionObject binaryEncode(Structure encodeable, IEncodeableSerializer serializer, EncoderContext ctx)
          Create extension object by encoding an encodeable to a binary format
<T extends IEncodeable>
T
decode(EncoderContext ctx)
          Attempts to decode the extension object using the default serializer of the stack.
<T extends IEncodeable>
T
decode(EncoderContext ctx, NamespaceTable namespaceTable)
          decode.
<T extends IEncodeable>
T
decode(IEncodeableSerializer serializer, EncoderContext ctx, NamespaceTable namespaceTable)
          Decode the extension object
static ExtensionObject encode(Structure encodeable, QualifiedName encodingType, EncoderContext ctx)
          Create extension object by encoding an encodeable to the defined encoding using the default serializer.
static ExtensionObject encode(Structure encodeable, QualifiedName encodingType, IEncodeableSerializer serializer, EncoderContext ctx)
          Create extension object by encoding an encodeable to the defined encoding using the default serializer.
 boolean equals(Object obj)
          
 EncodeType getEncodeType()
          Getter for the field encodeType.
 Object getObject()
          Getter for the field object.
 ExpandedNodeId getTypeId()
          Getter for the field typeId.
 int hashCode()
           
 boolean isEncoded()
          Returns true, if the getObject() is encoded value.
static ExtensionObject xmlEncode(Structure encodeable)
          Create extension object by encoding an encodeable to xml format using the default serializer
static ExtensionObject xmlEncode(Structure encodeable, IEncodeableSerializer serializer)
          Create extension object by encoding an encodeable to xml format
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionObject

public ExtensionObject(ExpandedNodeId typeId)

Constructor for ExtensionObject.

Parameters:
typeId - a ExpandedNodeId object.

ExtensionObject

public ExtensionObject(ExpandedNodeId typeId,
                       byte[] object)

Constructor for ExtensionObject.

Parameters:
typeId - a ExpandedNodeId object.
object - an array of byte.

ExtensionObject

public ExtensionObject(ExpandedNodeId typeId,
                       XmlElement object)

Constructor for ExtensionObject.

Parameters:
typeId - a ExpandedNodeId object.
object - a XmlElement object.

ExtensionObject

public ExtensionObject(Structure encodeable)
ExtensionObject that encodes the value later when put into a Encoder.

Parameters:
encodeable - a Structure that should later be encoded.
Method Detail

encode

public static ExtensionObject encode(Structure encodeable,
                                     QualifiedName encodingType,
                                     IEncodeableSerializer serializer,
                                     EncoderContext ctx)
                              throws EncodingException
Create extension object by encoding an encodeable to the defined encoding using the default serializer.

Parameters:
encodeable - the objects to encode
encodingType - the requested encoding type either QualifiedName.DEFAULT_BINARY_ENCODING or QualifiedName.DEFAULT_XML_ENCODING
serializer - the serializer to use (default is StackUtils.getDefaultSerializer())
ctx - a EncoderContext object.
Returns:
the encodeable as an ExtensionObject
Throws:
EncodingException - if the encodingType is unsupported or the encoding fails

encode

public static ExtensionObject encode(Structure encodeable,
                                     QualifiedName encodingType,
                                     EncoderContext ctx)
                              throws EncodingException
Create extension object by encoding an encodeable to the defined encoding using the default serializer.

Parameters:
encodeable - the objects to encode
encodingType - the requested encoding type either QualifiedName.DEFAULT_BINARY_ENCODING or QualifiedName.DEFAULT_XML_ENCODING
ctx - a EncoderContext object.
Returns:
the encodeable as an ExtensionObject
Throws:
EncodingException - if the encodingType is unsupported or the encoding fails

binaryEncode

public static ExtensionObject binaryEncode(Structure encodeable,
                                           EncoderContext ctx)
                                    throws EncodingException
Create extension object by encoding an encodeable to a binary format using the default serializer.

Parameters:
encodeable - encodeable
ctx - a EncoderContext object.
Returns:
binary encoded encodeable
Throws:
EncodingException - on encoding problem

binaryEncode

public static ExtensionObject binaryEncode(Structure encodeable,
                                           IEncodeableSerializer serializer,
                                           EncoderContext ctx)
                                    throws EncodingException
Create extension object by encoding an encodeable to a binary format

Parameters:
encodeable - encodeable
serializer - serializer
ctx - a EncoderContext object.
Returns:
binary encoded encodeable
Throws:
EncodingException - on encoding problem

xmlEncode

public static ExtensionObject xmlEncode(Structure encodeable)
                                 throws EncodingException
Create extension object by encoding an encodeable to xml format using the default serializer

Parameters:
encodeable - encodeable
Returns:
xml encoded encodeable
Throws:
EncodingException - on encoding problem. Currently always, since the encoding is not supported.

xmlEncode

public static ExtensionObject xmlEncode(Structure encodeable,
                                        IEncodeableSerializer serializer)
                                 throws EncodingException
Create extension object by encoding an encodeable to xml format

Parameters:
encodeable - encodeable
serializer - serializer
Returns:
xml encoded encodeable
Throws:
EncodingException - on encoding problem. Currently always, since the encoding is not supported.

getEncodeType

public EncodeType getEncodeType()

Getter for the field encodeType.

Returns:
a EncodeType object.

getObject

public Object getObject()

Getter for the field object.

Returns:
a Object object.

getTypeId

public ExpandedNodeId getTypeId()

Getter for the field typeId.

Returns:
a ExpandedNodeId object.

decode

public <T extends IEncodeable> T decode(IEncodeableSerializer serializer,
                                        EncoderContext ctx,
                                        NamespaceTable namespaceTable)
                             throws DecodingException
Decode the extension object

Type Parameters:
T - type
Parameters:
serializer - serializer to use
ctx - context
namespaceTable - namespace table
Returns:
decoded object
Throws:
DecodingException - if any.

decode

public <T extends IEncodeable> T decode(EncoderContext ctx)
                             throws DecodingException
Attempts to decode the extension object using the default serializer of the stack.

Type Parameters:
T - type
Parameters:
ctx - context
Returns:
decoded object
Throws:
DecodingException - if any.

decode

public <T extends IEncodeable> T decode(EncoderContext ctx,
                                        NamespaceTable namespaceTable)
                             throws DecodingException

decode.

Type Parameters:
T - a T object.
Parameters:
ctx - context
namespaceTable - a NamespaceTable object.
Returns:
a T object.
Throws:
DecodingException - if any.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

isEncoded

public boolean isEncoded()
Returns true, if the getObject() is encoded value. Null is considered to be encoded value.

Returns:
true if value is encoded


Copyright © 2018. All rights reserved.