com.prosysopc.ua
Class ModelParserBase

java.lang.Object
  extended by com.prosysopc.ua.ModelParserBase
Direct Known Subclasses:
ModelParser, ModelParser

public abstract class ModelParserBase
extends Object

An XML parser for UA Information Model files defined according to the respective schema, http://opcfoundation.org/UA/2011/03/UANodeSet.xsd.


Field Summary
static String UTF8_BOM
           
 
Constructor Summary
ModelParserBase(UaApplication application)
          Creates a new ModelParser.
 
Method Summary
protected  void addNamespaceUri(String uri)
           
protected  void addNodes(List<org.opcfoundation.ua.core.AddNodesItem> nodes, String type)
           
protected  void addReferences(List<org.opcfoundation.ua.core.AddReferencesItem> references)
           
protected  void afterCreate(org.opcfoundation.ua.core.AddNodesItem item)
          This method is called once for each Variable and Object node created.
protected  void characters(char[] ch, int start, int length)
           
 void createModel(boolean failOnFirstError)
          Creates the previously parsed model into the AddressSpaceHandler specified at initialization
protected  org.opcfoundation.ua.builtintypes.NodeId doAddNode(org.opcfoundation.ua.core.AddNodesItem item)
          Add a new node to the address space
protected  void doAddReference(org.opcfoundation.ua.core.AddReferencesItem item)
          Add a new reference to the address space
protected  void endElement(String uri, String localName, String name)
           
 org.opcfoundation.ua.encoding.EncoderContext getEncoderContext()
           
 List<String> getErrorList()
           
 Collection<org.opcfoundation.ua.builtintypes.ExpandedNodeId> getIgnoredNodes()
           
protected abstract  org.opcfoundation.ua.common.NamespaceTable getNamespaceTable()
           
protected abstract  UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Get an existing node in the address space.
 List<org.opcfoundation.ua.core.AddNodesItem> getNodes()
           
 List<org.opcfoundation.ua.core.AddReferencesItem> getReferences()
           
protected abstract  org.opcfoundation.ua.common.ServerTable getServerTable()
           
 boolean isFailOnFirstError()
           
protected  boolean isIgnoredReference(org.opcfoundation.ua.core.AddReferencesItem item)
           
 boolean isReadingExtensions()
           
protected  boolean isReadingNamespaces()
           
static boolean isSkipValuesOnAndroid()
           
 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<org.opcfoundation.ua.builtintypes.ExpandedNodeId> ignoredNodes)
           
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)
           
protected  org.opcfoundation.ua.builtintypes.ExpandedNodeId toGlobalExpandedNodeId(org.opcfoundation.ua.builtintypes.NodeId nodeId)
           
protected  org.opcfoundation.ua.builtintypes.NodeId toGlobalNodeId(org.opcfoundation.ua.builtintypes.ExpandedNodeId nodeId)
           
protected  org.opcfoundation.ua.builtintypes.NodeId toGlobalNodeId(org.opcfoundation.ua.builtintypes.NodeId nodeId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8_BOM

public static final String UTF8_BOM
See Also:
Constant Field Values
Constructor Detail

ModelParserBase

public ModelParserBase(UaApplication application)
Creates a new ModelParser.

Parameters:
nodeManagerTable - the NodeManagerTable in which the nodes should be created.
Method Detail

isSkipValuesOnAndroid

public static boolean isSkipValuesOnAndroid()
Returns:
the flag value
See Also:
setSkipValuesOnAndroid(boolean)

setSkipValuesOnAndroid

public static void setSkipValuesOnAndroid(boolean skipValuesOnAndroid)
If set to true, skip finalizing value tags from the NodeSet2 xml. This is by default true, because android does not have a StAX parser available. Set this to true if you make a StAX parser implementation available.

Parameters:
skipValuesOnAndroid -

createModel

public void createModel(boolean failOnFirstError)
                 throws ModelException,
                        ServiceException
Creates the previously parsed model into the AddressSpaceHandler specified at initialization

Parameters:
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.
Throws:
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)

getEncoderContext

public org.opcfoundation.ua.encoding.EncoderContext getEncoderContext()

getErrorList

public List<String> getErrorList()
Returns:
the errorList

getIgnoredNodes

public Collection<org.opcfoundation.ua.builtintypes.ExpandedNodeId> getIgnoredNodes()
Returns:
the ignoredNodes

getNodes

public List<org.opcfoundation.ua.core.AddNodesItem> getNodes()
Returns:
the addNodeItems

getReferences

public List<org.opcfoundation.ua.core.AddReferencesItem> getReferences()
Returns:
the references

isFailOnFirstError

public boolean isFailOnFirstError()
Returns:
the failOnFirstError

isReadingExtensions

public boolean isReadingExtensions()

parseFile

public void parseFile(InputStream inputStream)
               throws IOException,
                      SAXException,
                      ModelException
Reads a XML NodeSet file and loads its information into an internal buffer. Use #createModel() to create the nodes from the buffer.

Parameters:
inputStream - the model file to parse (from stream)
Throws:
SAXException - if the required XMLReaded cannot be created.
IOException - if the model file cannot be read.
ModelException - if the file contains model errors

parseFile

public void parseFile(InputStream inputStream,
                      Charset charset)
               throws IOException,
                      SAXException,
                      ModelException
Reads a XML NodeSet file and loads its information into an internal buffer. Use #createModel() to create the nodes from the buffer.

Parameters:
inputStream - the model file to parse (from stream)
charset - the character set of the model file (stream) default is UTF-8
Throws:
SAXException - if the required XMLReaded cannot be created.
IOException - if the model file cannot be read.
ModelException - if the file contains model errors

parseFile

public void parseFile(URI uri)
               throws SAXException,
                      IOException,
                      ModelException
Reads a XML NodeSet file and loads its information into an internal buffer. Use #createModel() to create the nodes from the buffer.

Parameters:
uri - the model file to parse
Throws:
SAXException - if the required XMLReaded cannot be created.
IOException - if the model file cannot be read.
ModelException - if the file contains model errors

setFailOnFirstError

public void setFailOnFirstError(boolean failOnFirstError)
Define whether #createModel() should fail on the first error found in the model.

Parameters:
failOnFirstError - the failOnFirstError to set

setIgnoredNodes

public void setIgnoredNodes(Collection<org.opcfoundation.ua.builtintypes.ExpandedNodeId> ignoredNodes)
Parameters:
ignoredNodes -

addNamespaceUri

protected void addNamespaceUri(String uri)
Parameters:
uri -

addNodes

protected void addNodes(List<org.opcfoundation.ua.core.AddNodesItem> nodes,
                        String type)
                 throws ModelException,
                        ServiceException
Parameters:
nodes -
type -
Throws:
ModelException
ServiceException

addReferences

protected void addReferences(List<org.opcfoundation.ua.core.AddReferencesItem> references)
                      throws ModelException
Throws:
ModelException

afterCreate

protected void afterCreate(org.opcfoundation.ua.core.AddNodesItem item)
This method is called once for each Variable and Object node created. First call is after they all have been added to the address space. The default implementation does nothing.


characters

protected void characters(char[] ch,
                          int start,
                          int length)
Parameters:
ch -
start -
length -

doAddNode

protected org.opcfoundation.ua.builtintypes.NodeId doAddNode(org.opcfoundation.ua.core.AddNodesItem item)
                                                      throws StatusException,
                                                             ServiceException
Add a new node to the address space

Parameters:
item -
Returns:
the ID of the added node
Throws:
StatusException
ServiceException

doAddReference

protected void doAddReference(org.opcfoundation.ua.core.AddReferencesItem item)
                       throws StatusException,
                              ServiceException
Add a new reference to the address space

Parameters:
item -
Throws:
StatusException
ServiceException

endElement

protected void endElement(String uri,
                          String localName,
                          String name)
                   throws SAXException
Throws:
SAXException

getNamespaceTable

protected abstract org.opcfoundation.ua.common.NamespaceTable getNamespaceTable()
Returns:
the NamespaceTable

getNode

protected abstract UaNode getNode(org.opcfoundation.ua.builtintypes.NodeId nodeId)
                           throws StatusException
Get an existing node in the address space.

Parameters:
nodeId -
Throws:
StatusException

getServerTable

protected abstract org.opcfoundation.ua.common.ServerTable getServerTable()
Returns:

isIgnoredReference

protected boolean isIgnoredReference(org.opcfoundation.ua.core.AddReferencesItem item)
Parameters:
item -
Returns:

isReadingNamespaces

protected boolean isReadingNamespaces()
Returns:
the readingNamespaces

startElement

protected void startElement(String uri,
                            String localName,
                            String name,
                            Attributes attributes)
                     throws SAXException
Throws:
SAXException

toGlobalExpandedNodeId

protected org.opcfoundation.ua.builtintypes.ExpandedNodeId toGlobalExpandedNodeId(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Parameters:
nodeId -
Returns:

toGlobalNodeId

protected org.opcfoundation.ua.builtintypes.NodeId toGlobalNodeId(org.opcfoundation.ua.builtintypes.ExpandedNodeId nodeId)
Parameters:
nodeId -
Returns:

toGlobalNodeId

protected org.opcfoundation.ua.builtintypes.NodeId toGlobalNodeId(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Parameters:
nodeId -
Returns:


Copyright © 2018. All rights reserved.