public class NavuContainer extends NavuNode implements MaapiDiffIterate
NavuContainer
is a representation of the yang
construct container,module and list-entry.
A NavuContainer
is usually supplied or returned from
a method call. It could also be created through
its constructor that takes a NavuContext
as its parameter.
NavuContainer(NavuContext)
.
NavuContainer
is created
with NavuContext
initialized with a Maapi
socket:
NavuContext context = new NavuContext(maapi); context.startRunningTrans(Conf.MODE_READ_WRITE); NavuContainer root = new NavuContainer(context);
From the above snippet it follows that a transaction need to be started before navigating using the context.
A Transaction can alternatively be started for operational data instead.
NavuContainer
could also be created with a
NavuContext context = new NavuContext(maapi); context.startOperationalTrans(Conf.MODE_READ_WRITE); NavuContainer root = new NavuContainer(context);
In either way when a NavuContainer
is created using
the above mentioned context it represents, the object pointed
by root
is the "root" of the NAVU-Tree.
The "root"s children represents all the loaded modules. To
choose a particular module the container(Integer)
should be called which returns a new NavuContainer
pointed
to the top of the "chosen" module. The parameter is the hash value
of the corresponding module ConfNamespace.hash()
.
NavuContainer module = root.container(new Ncs().hash());
To continue further down to the next child use
container(Integer)
, container(String)
,
list(Integer)
,container(String)
or leaf(Integer)
,
leaf(String)
depending on the type of yang construct.
The string version is the corresponding
MaapiSchemas.hashToString(long)
of the Integer parameter
which is the hash value of the tag name.
Usually the generated namespace classes static method is used for convenience. The absence of underscore (_) at the end of the static method indicates the integer version.
Then continuing with a devices node:
NavuContainer devicesNode = schema.container(Ncs._devices);
Constructor and Description |
---|
NavuContainer()
This constructor creates a root container.
|
NavuContainer(Cdb cdb,
int hash)
Deprecated.
|
NavuContainer(Maapi m,
int handle,
int rootHash)
Constructor for a single namespace.
|
NavuContainer(Maapi readWrite,
int readWriteTid,
Maapi readOnly,
int readOnlyTid,
int rootHash)
Deprecated.
|
NavuContainer(NavuContext context)
Creates an root
NavuContainer a starting point of
which further navigation is performed. |
Modifier and Type | Method and Description |
---|---|
NavuAction |
action(Integer key)
Returns a subordinate reference to action according to
the given hash value
key . |
NavuAction |
action(String key)
Returns a subordinate reference to action according to
the given string
key . |
Collection<NavuNode> |
children()
Returns a collection of child nodes
contained by the container.
|
NavuChoice |
choice(String name) |
NavuContainer |
container(Integer key)
Returns a subordinate reference to a container according to
the given hash value.
|
NavuContainer |
container(String key)
Returns a subordinate reference to container according to
the given string
key . |
NavuContainer |
container(String prefix,
String key)
Returns a subordinate reference to container according to
the given
key and prefix . |
boolean |
containsNode(NavuNode node)
Checks if the given node is contained in the schema in this container.
|
boolean |
containsNode(String nodeName)
Checks if there is a child node in the schema with given name.
|
NavuContainer |
create()
Creates an optional container.
|
NavuContainer |
delete()
Deletes an optional container.
|
List<ConfXMLParam> |
encodeValues()
Encoding the sub-tree including the current
NavuNode
as the topmost NavuNode to a ConfXMLParam array. |
List<ConfXMLParam> |
encodeXML()
Encoding the sub-tree including the current
NavuNode
as the topmost NavuNode to a ConfXMLParam array. |
Set<Map.Entry<String,NavuNode>> |
entrySet()
Returns a set of value-pairs.
|
boolean |
equals(Object o)
Compares the specified object with this
NavuContainer
for equality. |
boolean |
exists()
Verifies the existence of container.
|
Map<ConfKey,NavuChange> |
findChanges(Integer[] criteria)
Analyzes what changes has been done within this
transaction.
|
NavuNode |
get(String nodeName)
Returns a subordinate node with the name
nodeName . |
ConfKey |
getKey()
If this container is a list instance this method
can be used to get the list entry key.
|
ConfNamespace |
getRootNS()
Returns the root namespace of the topmost ancestor.
|
List<NavuChoice> |
getSelectCaseAsNavuChoice(String choice)
Returns a collection of the "toplevel" choice elements of
the a current selected case.
|
List<NavuNode> |
getSelectCaseAsNavuNode(String choice)
Returns a collection of the "toplevel" node elements of
the a current selected case.
|
MaapiSchemas.CSCase |
getSelectedCase(String choice)
Returns the selected cases of a given choice.
|
int |
getUserSession()
Get the current Maapi user session if this container context uses
Maapi.
|
int |
hashCode()
Returns the hash code value for this
NavuContainer . |
boolean |
isEmpty()
Checks if the container has any members.
|
boolean |
isListInstance()
Returns
true if this NavuContainer
represents a list-entry |
DiffIterateResultFlag |
iterate(ConfObject[] kp,
DiffIterateOperFlag op,
ConfObject oldValue,
ConfObject newValue,
Object state) |
Set<String> |
keySet()
Returns a set of nodeNames.
|
NavuLeaf |
leaf(Integer key)
Returns a subordinate reference to a leaf node according to
the given hash value
key . |
NavuLeaf |
leaf(String key)
Returns a subordinate reference to a leaf node according to
the given string
key . |
NavuLeaf |
leaf(String prefix,
String key)
Returns a subordinate reference to leaf according to
the given
key and prefix . |
NavuList |
list(Integer key)
Returns a subordinate reference to list according to
the given hash value
key . |
NavuList |
list(String key)
Returns a subordinate reference to list according to
the given string
key . |
NavuList |
list(String prefix,
String key)
Returns a subordinate reference to list according to
the given
key and prefix . |
void |
reset()
Resets the contained nodes
|
NavuContainer |
safeCreate()
Creates an optional container.
|
Collection<NavuNode> |
select(ConfObject[] kp) |
Collection<NavuNode> |
select(List<String> path) |
Collection<NavuNode> |
select(String path) |
void |
set(String xml)
Deprecated.
|
NavuNode |
setChange(List<ConfObject> path,
DiffIterateOperFlag op,
ConfValue oldValue,
NavuContext delContext) |
NavuContainer |
setOperationalDataCase(String choiceStr,
String caseStr)
Deprecated.
Use the method
setOperDataCase(String , String) |
void |
setOperDataCase(String choiceStr,
String caseStr)
Set a case with the name
caseStr for a choice
choiceStr for Cdb when writing operational data. |
NavuContainer |
sharedCreate()
Creates an optional container.
|
int |
size()
Returns the number of nodes contained by the container.
|
String |
toString() |
void |
valueUpdateInd(NavuNode child)
An indication received from a child node.
|
context, getCdbSession, getChange, getChangeFlag, getChanges, getChanges, getChanges, getConfPath, getInfo, getKeyPath, getName, getNavuNode, getParent, getValues, getValues, getXml, prepareXMLCall, setValues, setValues, sharedSetValues, sharedSetValues, startCdbSession, stopCdbSession, xPathSelect, xPathSelectIterate
public NavuContainer()
@Deprecated public NavuContainer(Cdb cdb, int hash)
NavuContainer
that will be able to
connect to the Cdb database to retrieve config and
operational data.cdb
- The CDB instance to use for read/write operationshash
- Namespace hash integer value representation of the
modulepublic NavuContainer(Maapi m, int handle, int rootHash)
m
- READ or READ_WRITE MAAPI
sockethandle
- a valid transaction handlerootHash
- the root hash of the module@Deprecated public NavuContainer(Maapi readWrite, int readWriteTid, Maapi readOnly, int readOnlyTid, int rootHash)
readWrite
- MAAPI socket to perform changes onreadWriteTid
- READ/WRITE transaction handle to use for
READ/WRITE operationsreadOnly
- MAAPI socket to the RUNNING datastorereadOnlyTid
- READ transaction handle to use when readingrootHash
- root hash of the modulepublic NavuContainer(NavuContext context)
NavuContainer
a starting point of
which further navigation is performed.context
- determines the Navigation restriction and
constraintspublic NavuAction action(Integer key) throws NavuException
key
.key
- the name of the subordinate actionNavuException
- if the corresponding subordinate node is not
a action node or if subordinate node has no matching action
with the hash value key
public NavuAction action(String key) throws NavuException
key
.key
- the name of the subordinate actionNavuException
- if the corresponding subordinate node is not
a action node or if subordinate node has no matching action
with the string key
public Collection<NavuNode> children() throws NavuException
children
in class NavuNode
NavuException
public NavuChoice choice(String name) throws NavuException
name
- - the name of the choice to return.NavuException
public NavuContainer container(Integer key) throws NavuException
container
hashvalue could be obtained through
ConfNamespace.stringToHash(String)
,
MaapiSchemas.stringToHash(String)
or use the
overloaded method container(String)
container
in class NavuNode
key
- hashed value of the container to returnNavuException
- if the corresponding subordinate node is not
a container or if subordinate node has no matching container
with the hash value key
public NavuContainer container(String key) throws NavuException
key
.container
in class NavuNode
key
- the name of the subordinate containerNavuException
- if the corresponding subordinate node is not
a container node or if subordinate node has no matching container
with the name key
public NavuContainer container(String prefix, String key) throws NavuException
key
and prefix
.container
in class NavuNode
prefix
- the prefix for the namespacekey
- the name of the subordinate containerNavuException
- if the corresponding subordinate node is not
a container node or if subordinate node has no matching container
with the name key
and prefix
public boolean containsNode(NavuNode node) throws NavuException
node
- NavuException
public boolean containsNode(String nodeName) throws NavuException
nodeName
- the name of a node to look for.NavuException
public NavuContainer create() throws NavuException
NavuException
public NavuContainer delete() throws NavuException
NavuException
public List<ConfXMLParam> encodeValues() throws NavuException
NavuNode
NavuNode
as the topmost NavuNode
to a ConfXMLParam
array.
As opposed to encodeXML, the returning ConfXMLParam
array
does contain values in form of ConfXMLParamValue
encodeValues
in class NavuNode
ConfXMLParam
of the sub-tree
including valuesNavuException
- If the operation could not be performed for some reasonsConfXMLParam
,
ConfXMLParamValue
public List<ConfXMLParam> encodeXML() throws NavuException
NavuNode
NavuNode
as the topmost NavuNode
to a ConfXMLParam
array.
The returning ConfXMLParam
array contains no values except
for list keys. The leaf elements are encoded as ConfXMLParamLeaf
therefore the returning array could be used as a input parameter
to NavuNode.getValues(ConfXMLParam[])
on the current elements parent.
NavuNode node = ...; //cxa contains structure that does not contains values except for //keys in list elements ConfXMLParam[] cxa = node.encodeXML().toArray(new ConfXMLParam[0]); NavuNode parent = node.getParent(); //contains sub-tree with all the values ConfXMLParam[] cxb = parent.getValues(cxa);
encodeXML
in class NavuNode
ConfXMLParam
of the sub-tree
(including key values) with key values.NavuException
- If the operation could not be performed for some reasonsConfXMLParam
,
ConfXMLParamValue
public Set<Map.Entry<String,NavuNode>> entrySet() throws NavuException
NavuException
public boolean equals(Object o)
NavuContainer
for equality. Returns true
if and only if the specified object
is also a NavuContainer and
returns true/false depending on the following:
-
NavuNodeInfo.isModule()
:
check the equality of getInfo().getCSSchema().equals
to
((NavuContainer)o).getInfo().getCSSchema()
-
NavuNodeInfo.isChildNode()
:
check the equality of getInfo().getCSNode().equals
to
((NavuContainer)o).getInfo().getCSNode()
public boolean exists() throws NavuException
exists
in class NavuNode
NavuException
public Map<ConfKey,NavuChange> findChanges(Integer[] criteria) throws NavuException
criteria
- a list hash values representing a search
path. The first element is the module name hash. The analysis
will be started at the end of the list. List elements are
represented by 0.IOException
ConfException
NavuException
public NavuNode get(String nodeName) throws NavuException
nodeName
.nodeName
- a name of a node contained within this container.NavuException
- if subordinate node has no matching container
with the name nodeName
public ConfKey getKey()
public ConfNamespace getRootNS()
NavuNode
public List<NavuChoice> getSelectCaseAsNavuChoice(String choice) throws NavuException
choice
- the choice name to get selected case forNavuException
- if this container does not contains the
choice with the specified name choicepublic List<NavuNode> getSelectCaseAsNavuNode(String choice) throws NavuException
Which of the subclasses NavuContainer, NavuList or NavuLeaf that actually constitutes this case is defined by the model or has to be tested.
choice
- the choice name to get selected case forNavuException
- if this container does not contains the
choice with the specified name choicepublic MaapiSchemas.CSCase getSelectedCase(String choice) throws NavuException
choice
- of the choice to get selected case for.NavuException
public int getUserSession() throws NavuException
NavuException
public int hashCode()
NavuContainer
.
This implementation uses exactly the code that is used to define the hash code for a String.
public boolean isEmpty() throws NavuException
NavuException
public boolean isListInstance()
true
if this NavuContainer
represents a list-entrytrue
if this NavuContainer
is a list-entry false otherwisepublic DiffIterateResultFlag iterate(ConfObject[] kp, DiffIterateOperFlag op, ConfObject oldValue, ConfObject newValue, Object state)
iterate
in interface MaapiDiffIterate
public Set<String> keySet() throws NavuException
NavuException
public NavuLeaf leaf(Integer key) throws NavuException
key
.leaf
in class NavuNode
key
- hashed value of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if subordinate node has no matching leaf
with the hash value key
public NavuLeaf leaf(String key) throws NavuException
key
.leaf
in class NavuNode
key
- the name of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if subordinate node has no matching leaf
with the name key
public NavuLeaf leaf(String prefix, String key) throws NavuException
key
and prefix
.leaf
in class NavuNode
prefix
- the prefix for the namespacekey
- the name of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if subordinate node has no matching leaf
with the name key
and prefix
public NavuList list(Integer key) throws NavuException
key
.list
in class NavuNode
key
- the name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if subordinate node has no matching list
with the hash value key
public NavuList list(String key) throws NavuException
key
.list
in class NavuNode
key
- the name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if subordinate node has no matching list
with the name key
public NavuList list(String prefix, String key) throws NavuException
key
and prefix
.list
in class NavuNode
prefix
- the prefix for the namespacekey
- the name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if subordinate node has no matching list
with the name key
and prefix
public NavuContainer safeCreate() throws NavuException
NavuException
public Collection<NavuNode> select(ConfObject[] kp) throws NavuException
select
in class NavuNode
NavuException
public Collection<NavuNode> select(List<String> path) throws NavuException
select
in class NavuNode
path
- a list of regular expression.NavuException
public Collection<NavuNode> select(String path) throws NavuException
select
in class NavuNode
path
- a "/" separated regular expression.NavuException
@Deprecated public void set(String xml) throws NavuException
NavuNode.setValues(String)
instead.xml
- -
XML structure corresponding values that will be set.NavuException
public NavuNode setChange(List<ConfObject> path, DiffIterateOperFlag op, ConfValue oldValue, NavuContext delContext) throws NavuException
setChange
in class NavuNode
NavuException
@Deprecated public NavuContainer setOperationalDataCase(String choiceStr, String caseStr) throws NavuException
setOperDataCase(String , String)
choiceStr
- name of the choicecaseStr
- name of the case to set as selected caseNavuException
public void setOperDataCase(String choiceStr, String caseStr) throws NavuException
caseStr
for a choice
choiceStr
for Cdb when writing operational data.
There is a difference in how cases for a choice is set in a Maapi context
and a Cdb context. In Maapi, when writing configuration data,
the cases are set implicitly as any leaf are
set below a choice in the model tree. For Cdb, when writing operational
data, this case has to be set explicitly. This is done using this method.
The method returns a NavuContainer representing the selected case which
can be used to navigate down the model tree.choiceStr
- name of the choicecaseStr
- name of the case to set as selected caseNavuException
- If the caseStr could not be setpublic NavuContainer sharedCreate() throws NavuException
Will silently ignore the error when the container is not a presence container. It will also maintain a counter (as an attribute) counting how many times the same containers has been created. This makes this method very useful for NCS fastmap users where sometimes we wish to create services where multiple service instances share the seam structure. Furthermore, and attribute "Backpointer" will be created on the created container indicating which "service" created the object
NavuException
public int size() throws NavuException
NavuException
public void valueUpdateInd(NavuNode child) throws NavuException
valueUpdateInd
in class NavuNode
child
- the child node doing the update.NavuException