public abstract class ModelParserBase extends Object
| Constructor and Description |
|---|
ModelParserBase(UaApplication application)
Creates a new ModelParser.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addNamespaceUri(String uri) |
protected void |
addNodes(List<AddNodesItem> nodes,
String type)
Adds the given nodes.
|
protected void |
addReferences(List<AddReferencesItem> references)
Adds the given References.
|
protected void |
afterCreate(AddNodesItem item)
This method is called once for each Variable and Object node created.
|
protected void |
characters(char[] ch,
int start,
int length)
Delegation of the SAX parsing characters method.
|
void |
createModel(boolean failOnFirstError)
Creates the previously parsed model into the AddressSpaceHandler specified at initialization.
|
protected NodeId |
doAddNode(AddNodesItem item)
Add a new node to the address space.
|
protected void |
doAddReference(AddReferencesItem item)
Add a new reference to the address space.
|
protected void |
endElement(String uri,
String localName,
String name)
Delegation of the SAX parsing endElement method.
|
EncoderContext |
getEncoderContext() |
List<String> |
getErrorList()
Returns a list of errors that happened during model loading.
|
Collection<ExpandedNodeId> |
getIgnoredNodes()
These nodes are ignored when model is loaded.
|
protected NamespaceTable |
getNamespaceTable()
Returns the Application-related
NamespaceTable, by default uses
UaApplication.getNamespaceTable() from the given constructor parameter. |
protected abstract UaNode |
getNode(NodeId nodeId)
Get an existing node in the address space.
|
List<AddNodesItem> |
getNodes()
Returns a list of loaded nodes.
|
List<AddReferencesItem> |
getReferences()
Returns a list of loaded references.
|
protected ServerTable |
getServerTable()
Returns the Application-related
ServerTable, by default uses
UaApplication.getServerTable() from the given constructor parameter. |
boolean |
isFailOnFirstError()
If true then the model loading is stopped on first error.
|
protected boolean |
isIgnoredReference(AddReferencesItem item) |
boolean |
isReadingExtensions() |
protected boolean |
isReadingNamespaces() |
static boolean |
isSkipValuesOnAndroid()
If true the Value tags are skipped when loading models on Android.
|
void |
parseFile(InputStream inputStream)
Reads a XML NodeSet file and loads its information into an internal buffer.
|
void |
parseFile(InputStream inputStream,
Charset charset)
Reads a XML NodeSet file and loads its information into an internal buffer.
|
void |
parseFile(URI uri)
Reads a XML NodeSet file and loads its information into an internal buffer.
|
void |
setFailOnFirstError(boolean failOnFirstError)
Define whether
#createModel() should fail on the first error found in the model. |
void |
setIgnoredNodes(Collection<ExpandedNodeId> ignoredNodes)
Adds the given nodes to the set of ignored nodes.
|
static void |
setSkipValuesOnAndroid(boolean skipValuesOnAndroid)
If set to true, skip finalizing value tags from the NodeSet2 xml.
|
protected void |
startElement(String uri,
String localName,
String name,
Attributes attributes)
Delegation of the SAX parsing startElement method.
|
protected ExpandedNodeId |
toGlobalExpandedNodeId(NodeId nodeId)
Transforms a model-local-NodeId to ExpandedNodeId with the namespaceuri.
|
protected NodeId |
toGlobalNodeId(ExpandedNodeId nodeId)
Transforms ExpandedNodeId with the uri to application-indexed NodeId.
|
protected NodeId |
toGlobalNodeId(NodeId nodeId)
Transforms a model-local NodeId to application-indexed NodeId.
|
public static final String UTF8_BOM
public ModelParserBase(UaApplication application)
public static boolean isSkipValuesOnAndroid()
setSkipValuesOnAndroid(boolean)public static void setSkipValuesOnAndroid(boolean skipValuesOnAndroid)
Some older android versions do not have a StAX parser, which would be needed for the value tag parsing.
public void createModel(boolean failOnFirstError)
throws ModelException,
ServiceException
failOnFirstError - make the model creation fail for the first error encountered. If false,
the model is parsed fully and possible errors are raised only at the end.ModelException - if there is a problem with the model and it cannot be fully created. The
exception is thrown for individual nodes only if isFailOnFirstError() is true.
Otherwise, it will be filled with and errorList.ServiceException - if the nodes cannot be added to the server due to a service exception
(most likely when done from the client side)public EncoderContext getEncoderContext()
public List<String> getErrorList()
public Collection<ExpandedNodeId> getIgnoredNodes()
public List<AddNodesItem> getNodes()
public List<AddReferencesItem> getReferences()
public boolean isFailOnFirstError()
public boolean isReadingExtensions()
public void parseFile(InputStream inputStream) throws IOException, SAXException, ModelException
#createModel() to create the nodes from the buffer.inputStream - the model file to parse (from stream)SAXException - if the required XMLReaded cannot be created.IOException - if the model file cannot be read.ModelException - if the file contains model errorspublic void parseFile(InputStream inputStream, Charset charset) throws IOException, SAXException, ModelException
#createModel() to create the nodes from the buffer.inputStream - the model file to parse (from stream)charset - the character set of the model file (stream) default is UTF-8SAXException - if the required XMLReaded cannot be created.IOException - if the model file cannot be read.ModelException - if the file contains model errorspublic void parseFile(URI uri) throws SAXException, IOException, ModelException
#createModel() to create the nodes from the buffer.uri - the model file to parseSAXException - if the required XMLReaded cannot be created.IOException - if the model file cannot be read.ModelException - if the file contains model errorspublic void setFailOnFirstError(boolean failOnFirstError)
#createModel() should fail on the first error found in the model.failOnFirstError - the failOnFirstError to setpublic void setIgnoredNodes(Collection<ExpandedNodeId> ignoredNodes)
protected void addNamespaceUri(String uri)
protected void addNodes(List<AddNodesItem> nodes, String type) throws ModelException, ServiceException
ModelExceptionServiceExceptionprotected void addReferences(List<AddReferencesItem> references) throws ModelException
ModelExceptionprotected void afterCreate(AddNodesItem item)
protected void characters(char[] ch,
int start,
int length)
protected NodeId doAddNode(AddNodesItem item) throws StatusException, ServiceException
item - the definition of the new node.StatusException - on failureServiceException - on failureprotected void doAddReference(AddReferencesItem item) throws StatusException, ServiceException
item - definition of the new reference.StatusException - on failure.ServiceException - on failure.protected void endElement(String uri, String localName, String name) throws SAXException
SAXExceptionprotected NamespaceTable getNamespaceTable()
NamespaceTable, by default uses
UaApplication.getNamespaceTable() from the given constructor parameter. IMPORTANT! This
is separate from the NodeSet's mappings, as it has it's own model-related-table.protected abstract UaNode getNode(NodeId nodeId) throws StatusException
StatusExceptionprotected ServerTable getServerTable()
ServerTable, by default uses
UaApplication.getServerTable() from the given constructor parameter. IMPORTANT! This is
separate from the NodeSet's mappings, as it has it's own model-related-table.protected boolean isIgnoredReference(AddReferencesItem item)
protected boolean isReadingNamespaces()
protected void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException
SAXExceptionprotected ExpandedNodeId toGlobalExpandedNodeId(NodeId nodeId)
protected NodeId toGlobalNodeId(ExpandedNodeId nodeId)
Copyright © 2026. All rights reserved.