public class EncoderContext extends Object
UaDataTypeSpecification
related to the types. You can also obtain these via getDataTypeSpecification(UaNodeId),
or e.g. specifically for Structure by getStructureSpecification(UaNodeId), which
can then be used to make instances of the given Structure or process then in a general
manner (note that for non-null Structures you can obtain it also via
Structure.specification(). Normally you should use the EncoderContext from the
UaClient/UaServer object.| Constructor and Description |
|---|
EncoderContext(NamespaceTable namespaceTable,
ServerTable serverTable)
Constructor for EncoderContext.
|
EncoderContext(NamespaceTable namespaceTable,
ServerTable serverTable,
int maxMessageSize)
Constructor for EncoderContext.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataTypeSpecification(UaDataTypeSpecification specification)
Adds the given
UaDataTypeSpecification to be part of this context. |
void |
addEnumerationSpecification(EnumerationSpecification specification)
Deprecated.
use
addDataTypeSpecification(UaDataTypeSpecification) instead. |
void |
addStructureSpecification(StructureSpecification specification)
Deprecated.
use
addDataTypeSpecification(UaDataTypeSpecification) instead. |
static EncoderContext |
coreNamespaceOnly()
Returns an unmodifiable
EncoderContext instance that only handles the core namespace
(NamespaceTable.OPCUA_NAMESPACE). |
Object |
decode(ExtensionObject[] values)
Decodes the given
ExtensionObject array, returns an array of the least common subtype
of the decoded Structures. |
Object |
decode(ExtensionObject[] values,
NamespaceTable namespaceTable)
Decodes the given
ExtensionObject array, returns an array of the least common subtype
of the decoded Structures. |
UaDataTypeSpecification |
getDataTypeSpecification(UaNodeId id)
Returns
UaDataTypeSpecification that matches the given id or null if not found. |
Map<UaNodeId,UaDataTypeSpecification> |
getDataTypeSpecifications()
Returns all
UaDataTypeSpecification. |
static EncoderContext |
getDefaultInstance()
Deprecated.
This method should not be called, instead use the EncoderContext from UaClient or
UaServer. This context can only handle the
NamespaceTable.OPCUA_NAMESPACE. |
EnumerationSpecification |
getEnumerationSpecification(UaNodeId id)
Returns
EnumerationSpecification that matches the given id. |
int |
getMaxArrayLength()
Getter for the field
maxArrayLength. |
int |
getMaxByteStringLength()
Getter for the field
maxByteStringLength. |
int |
getMaxMessageSize()
Getter for the field
maxMessageSize. |
int |
getMaxStringLength()
Getter for the field
maxStringLength. |
NamespaceTable |
getNamespaceTable()
Getter for the field
namespaceTable. |
OptionSetSpecification |
getOptionSetSpecification(UaNodeId id)
Returns
OptionSetSpecification that matches the given id. |
ServerTable |
getServerTable()
Getter for the field
serverTable. |
SimpleTypeSpecification |
getSimpleTypeSpecification(UaNodeId id)
Returns
SimpleTypeSpecification for the given id (can be any encoding id or type id). |
StructureSpecification |
getStructureSpecification(UaNodeId id)
Returns
StructureSpecification for the given id (can be any encoding id or type id). |
void |
registerModel(CommonCodegenModel model)
Register an information model to use in this
EncoderContext. |
void |
removeDataTypeSpecification(UaNodeId typeId)
Removes a previously added
UaDataTypeSpecification based on the
UaDataTypeSpecification.getTypeId(). |
void |
removeDataTypeSpecifications(UaNamespace namespace)
Removes previously added
UaDataTypeSpecification based on the UaNamespace. |
void |
setDynamicDataTypeSpecificationProvider(Function<UaNodeId,UaDataTypeSpecification> provider)
Sets a provider that is called if given
UaDataTypeSpecification is not already added to
this EncoderContext. |
void |
setMaxArrayLength(int maxArrayLength)
Setter for the field
maxArrayLength. |
void |
setMaxByteStringLength(int maxByteStringLength)
Setter for the field
maxByteStringLength. |
void |
setMaxMessageSize(int encodeMessageMaxSize)
Setter for the field
maxMessageSize. |
void |
setMaxStringLength(int maxStringLength)
Setter for the field
maxStringLength. |
void |
setNamespaceTable(NamespaceTable namespaceTable)
Setter for the field
namespaceTable. |
void |
setServerTable(ServerTable serverTable)
Setter for the field
serverTable. |
EncoderContext |
shallowCopy()
Returns a new EncoderContext with same values.
|
String |
toString() |
public EncoderContext(NamespaceTable namespaceTable, ServerTable serverTable)
Constructor for EncoderContext.
namespaceTable - a NamespaceTable object.serverTable - a ServerTable object.public EncoderContext(NamespaceTable namespaceTable, ServerTable serverTable, int maxMessageSize)
Constructor for EncoderContext.
namespaceTable - a NamespaceTable object.serverTable - a ServerTable object.encodeableSerializer - a
com.prosysopc.ua.stack.encoding.binary.IEncodeableSerializer object.maxMessageSize - a int.public static EncoderContext coreNamespaceOnly()
EncoderContext instance that only handles the core namespace
(NamespaceTable.OPCUA_NAMESPACE). This should only be used in places where custom types
are not used. Any setters and mutating operations call on this instance shall throw
UnsupportedOperationException.@Deprecated public static EncoderContext getDefaultInstance()
NamespaceTable.OPCUA_NAMESPACE.public void addDataTypeSpecification(UaDataTypeSpecification specification)
UaDataTypeSpecification to be part of this context.@Deprecated public void addEnumerationSpecification(EnumerationSpecification specification)
addDataTypeSpecification(UaDataTypeSpecification) instead.EnumerationSpecification to this context. Overrides existing mappings if
any.@Deprecated public void addStructureSpecification(StructureSpecification specification)
addDataTypeSpecification(UaDataTypeSpecification) instead.StructureSpecification to this context. Maps the specification such that
it will be returned by getStructureSpecification(UaNodeId) for any of it's encoding or
type ids. Overrides existing mappings if any.public Object decode(ExtensionObject[] values) throws DecodingException
ExtensionObject array, returns an array of the least common subtype
of the decoded Structures. Throws DecodingException if decoding fails.DecodingExceptionpublic Object decode(ExtensionObject[] values, NamespaceTable namespaceTable) throws DecodingException
ExtensionObject array, returns an array of the least common subtype
of the decoded Structures. Throws DecodingException if decoding fails. The
given NamespaceTable is given to
ExtensionObject.decode(EncoderContext, NamespaceTable).DecodingExceptionpublic UaDataTypeSpecification getDataTypeSpecification(UaNodeId id)
UaDataTypeSpecification that matches the given id or null if not found.public Map<UaNodeId,UaDataTypeSpecification> getDataTypeSpecifications()
UaDataTypeSpecification. The returned Map is unmodifiable.public EnumerationSpecification getEnumerationSpecification(UaNodeId id)
EnumerationSpecification that matches the given id. Returns null if not found.public int getMaxArrayLength()
Getter for the field maxArrayLength.
public int getMaxByteStringLength()
Getter for the field maxByteStringLength.
public int getMaxMessageSize()
Getter for the field maxMessageSize.
public int getMaxStringLength()
Getter for the field maxStringLength.
public NamespaceTable getNamespaceTable()
Getter for the field namespaceTable.
NamespaceTable object.public OptionSetSpecification getOptionSetSpecification(UaNodeId id)
OptionSetSpecification that matches the given id. Returns null if not found.
Note that this will also return specifications for OptionSetStructures.public ServerTable getServerTable()
Getter for the field serverTable.
ServerTable object.public SimpleTypeSpecification getSimpleTypeSpecification(UaNodeId id)
SimpleTypeSpecification for the given id (can be any encoding id or type id).
Returns null if not found.public StructureSpecification getStructureSpecification(UaNodeId id)
StructureSpecification for the given id (can be any encoding id or type id).
Returns null if not found. Note that this will also return specifications for
OptionSetStructures.public void registerModel(CommonCodegenModel model)
EncoderContext. This is equivalent of
calling addDataTypeSpecification(UaDataTypeSpecification) for all
CodegenModel.getSpecifications().public void removeDataTypeSpecification(UaNodeId typeId)
UaDataTypeSpecification based on the
UaDataTypeSpecification.getTypeId(). In the case of StructureSpecification the
parameter can be also any of the encoding ids. This method shall not be called while another
thread is calling any of the addXXX methods, doing so may produce undefined results. If you
remove UaDataTypeSpecifications that were added via
registerModel(CommonCodegenModel), i.e. Codegen, you must do so again before they work
again.public void removeDataTypeSpecifications(UaNamespace namespace)
UaDataTypeSpecification based on the UaNamespace.
Note! This method shall not be called while another thread is calling any of the addXXX
methods, doing so may produce undefined results. If you remove a namespace whose
UaDataTypeSpecification were added via registerModel(CommonCodegenModel), i.e.
Codegen, you must do so again before they work again.public void setDynamicDataTypeSpecificationProvider(Function<UaNodeId,UaDataTypeSpecification> provider)
UaDataTypeSpecification is not already added to
this EncoderContext.public void setMaxArrayLength(int maxArrayLength)
Setter for the field maxArrayLength.
maxArrayLength - a int.public void setMaxByteStringLength(int maxByteStringLength)
Setter for the field maxByteStringLength.
maxByteStringLength - a int.public void setMaxMessageSize(int encodeMessageMaxSize)
Setter for the field maxMessageSize.
encodeMessageMaxSize - a int.public void setMaxStringLength(int maxStringLength)
Setter for the field maxStringLength.
maxStringLength - a int.public void setNamespaceTable(NamespaceTable namespaceTable)
Setter for the field namespaceTable.
namespaceTable - a NamespaceTable object.public void setServerTable(ServerTable serverTable)
Setter for the field serverTable.
serverTable - a ServerTable object.public EncoderContext shallowCopy()
Copyright © 2026. All rights reserved.