public class XmlEncoder extends AbstactEncoder implements IEncoder
An EncoderContext must be set before use.
Null valued arguments are encoded with default empty values (for UA types not having a Null encoding) when encoder mode is NonStrict, which is the default mode.
the decoder equivalent of this class.| Modifier and Type | Field and Description |
|---|---|
static String |
OPC_UA_TYPES_NAMESPACE |
ctx| Constructor and Description |
|---|
XmlEncoder(EncoderContext encoderContext)
Creates a new
XmlEncoder that will write to the given output. |
XmlEncoder(EncoderContext encoderContext,
boolean writeNamespaces)
Creates a new
XmlEncoder. |
| Modifier and Type | Method and Description |
|---|---|
String |
getDefaultNamespace() |
EncoderMode |
getEncoderType()
getEncoderType.
|
String |
getEncoding() |
int |
getIndentAmount() |
List<Locale> |
getLocales()
The current Locale preferences.
|
int |
getMaxDiagnosticInfoNestingLevel() |
boolean |
isIndent() |
boolean |
isOmitXmlDeclaration() |
void |
put(String fieldName,
Object value,
UaNodeId dataTypeId,
int dimensions)
Encodes the given field.
|
void |
putRawVariant(Variant value,
String xmlNamespace)
Encode raw Variant value, i.e.
|
void |
setDefaultNamespace(String defaultNamespace) |
void |
setEncoderMode(EncoderMode type)
Set encoding mode.
|
void |
setEncoding(String encoding) |
void |
setIndent(boolean indent) |
void |
setIndentAmount(int indentAmount) |
void |
setMaxDiagnosticInfoNestingLevel(int maxDiagnosticInfoNestingLevel) |
void |
setOmitXmlDeclaration(boolean omitXmlDeclaration) |
void |
write(Writer writer)
Writes XML to the given output.
|
getEncoderContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEncoderContext, putBoolean, putBooleanArray, putBooleanArray, putByte, putByteArray, putByteArray, putByteString, putByteStringArray, putByteStringArray, putDataValue, putDataValueArray, putDataValueArray, putDateTime, putDateTimeArray, putDateTimeArray, putDiagnosticInfo, putDiagnosticInfoArray, putDiagnosticInfoArray, putDouble, putDouble, putDoubleArray, putDoubleArray, putExpandedNodeId, putExpandedNodeIdArray, putExpandedNodeIdArray, putExtensionObject, putExtensionObjectArray, putExtensionObjectArray, putFloat, putFloat, putFloatArray, putFloatArray, putGuid, putGuidArray, putGuidArray, putInt16, putInt16, putInt16Array, putInt16Array, putInt32, putInt32, putInt32Array, putInt32Array, putInt32Array, putInt64, putInt64, putInt64Array, putInt64Array, putLocalizedText, putLocalizedTextArray, putLocalizedTextArray, putNodeId, putNodeIdArray, putNodeIdArray, putQualifiedName, putQualifiedNameArray, putQualifiedNameArray, putSByte, putSByte, putSByte, putSByteArray, putSByteArray, putStatusCode, putStatusCodeArray, putStatusCodeArray, putString, putStringArray, putStringArray, putUInt16, putUInt16Array, putUInt16Array, putUInt32, putUInt32Array, putUInt32Array, putUInt64, putUInt64Array, putUInt64Array, putVariant, putVariantArray, putXmlElement, putXmlElementArray, putXmlElementArraypublic static final String OPC_UA_TYPES_NAMESPACE
public XmlEncoder(EncoderContext encoderContext) throws EncodingException
XmlEncoder that will write to the given output.EncodingExceptionpublic XmlEncoder(EncoderContext encoderContext, boolean writeNamespaces) throws EncodingException
XmlEncoder.EncodingExceptionpublic String getDefaultNamespace()
public EncoderMode getEncoderType()
getEncoderType.
EncoderMode object.public String getEncoding()
public int getIndentAmount()
public List<Locale> getLocales()
IEncodergetLocales in interface IEncoderpublic int getMaxDiagnosticInfoNestingLevel()
public boolean isIndent()
public boolean isOmitXmlDeclaration()
public void put(String fieldName, Object value, UaNodeId dataTypeId, int dimensions) throws EncodingException
IEncoderput in interface IEncoderfieldName - the name of the field (not used in all encodings e.g. Binary encodings do not
typically use a name, but JSON does).value - the value for the field, possibly null.dataTypeId - the OPC UA DataType of the field, not null.dimensions - the dimensions of the field, 0 if scalar, 1 if 1-dim array, etc.).EncodingException - in case the value cannot be encoded. Possible errors are e.g. giving
wrong DataType for a given value, giving wrong dimensions or giving values that are too
large for limits of the IEncoder.getEncoderContext().public void putRawVariant(Variant value, String xmlNamespace) throws EncodingException
EncodingExceptionpublic void setDefaultNamespace(String defaultNamespace)
public void setEncoderMode(EncoderMode type)
type - encoder typepublic void setEncoding(String encoding)
public void setIndent(boolean indent)
public void setIndentAmount(int indentAmount)
public void setMaxDiagnosticInfoNestingLevel(int maxDiagnosticInfoNestingLevel)
public void setOmitXmlDeclaration(boolean omitXmlDeclaration)
public void write(Writer writer) throws EncodingException
EncodingExceptionCopyright © 2026. All rights reserved.