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 can also be created using one of its constructors,
typically NavuContainer(NavuContext)
.
A NavuContainer
is created with a NavuContext
initialized with a Maapi
socket:
NavuContext context = new NavuContext(maapi); context.startRunningTrans(Conf.MODE_READ_WRITE); NavuContainer root = new NavuContainer(context);
As shown above, a transaction must be started before the context can be used for navigating.
A transaction can alternatively be started for operational data instead:
NavuContext context = new NavuContext(maapi); context.startOperationalTrans(Conf.MODE_READ_WRITE); NavuContainer root = new NavuContainer(context);
Either way, when a NavuContainer
is created using the above
mentioned context, the object pointed to by root
is the "root"
of the NAVU-Tree.
The root's children represent all of the loaded modules. To
choose a particular module, the method NavuContainer.container(Integer)
must be called with the hash value of the corresponding module
(ConfNamespace.hash()
).
This will return a new NavuContainer
pointing to the root of
the chosen module.
NavuContainer module = root.container(new Ncs().hash());
To continue further down to the next child, use
NavuContainer.container(Integer)
, NavuContainer.container(String)
,
NavuContainer.list(Integer)
, NavuContainer.list(String)
or NavuContainer.leaf(Integer)
,
NavuContainer.leaf(String)
as dictated by the YANG model.
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 are used for convenience. The absence of underscore (_) at the end of the static field name indicates the integer version.
Then continuing with the devices node:
NavuContainer devicesNode = module.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 reference to a subordinate
action with
the hash value key . |
NavuAction |
action(String key)
Returns a reference to a subordinate
action with
the name key . |
Collection<NavuNode> |
children()
Returns a collection containing the children of this container.
|
NavuChoice |
choice(String name)
Returns a reference to a subordinate
choice with
the name name . |
NavuContainer |
container(ConfNamespace ns,
String containerName)
Returns a reference to a subordinate
container with
the name containerName , belonging to the namespace
ns . |
NavuContainer |
container(Integer key)
Returns a reference to a subordinate
container with
the hash value key . |
NavuContainer |
container(String key)
Returns a reference to a subordinate
container with
the name key . |
NavuContainer |
container(String prefix,
String key)
Deprecated.
|
boolean |
containsNode(NavuNode node)
Checks if the given node is a direct child of this container according
to the schema.
|
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()
Encodes the sub-tree including the current
NavuNode
as the topmost NavuNode as a ConfXMLParam array. |
List<ConfXMLParam> |
encodeXML()
Encodes the sub-tree including the current
NavuNode
as the topmost NavuNode as 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)
Deprecated.
|
Map<ConfKey,NavuChange> |
findChanges(NavuContext delContext,
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 top-level node elements of
the currently selected case of the specified
choice . |
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.
|
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(ConfNamespace ns,
String leafName)
Returns a reference to a subordinate
leaf with
the name leafName , belonging to the namespace
ns . |
NavuLeaf |
leaf(Integer key)
Returns a reference to a subordinate
leaf with
the hash value key . |
NavuLeaf |
leaf(String key)
Returns a reference to a subordinate
leaf with
the name key . |
NavuLeaf |
leaf(String prefix,
String key)
Deprecated.
|
NavuLeafList |
leafList(ConfNamespace ns,
String leafListName)
Returns a reference to a subordinate
leaf-list with
the name leafListName , belonging to the namespace
ns . |
NavuLeafList |
leafList(Integer key)
Returns a reference to a subordinate
leaf-list with
the hash value key . |
NavuLeafList |
leafList(String key)
Returns a reference to a subordinate
leaf-list with
the name key . |
NavuLeafList |
leafList(String prefix,
String key)
Deprecated.
|
NavuList |
list(ConfNamespace ns,
String listName)
Returns a reference to a subordinate
list with
the name listName , belonging to the namespace
ns . |
NavuList |
list(Integer key)
Returns a reference to a subordinate
list with the
hash value key . |
NavuList |
list(String key)
Returns a reference to a subordinate
list with
the name key . |
NavuList |
list(String prefix,
String key)
Deprecated.
|
NavuContainer |
namespace(String ns)
The namespace specified here will be used when selecting a child
to this NavuContainer and returns a reference to this NavuContainer
object according to the given namespace id
ns . |
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
NavuContainer.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, getChanges, getChanges, getChanges, getConfPath, getInfo, getKeyPath, getName, getNavuNode, getParent, getValues, getValues, getXml, hashCode, prepareXMLCall, setValues, setValues, sharedSetValues, sharedSetValues, startCdbSession, stopCdbSession, xPathSelect, xPathSelectIterate
public NavuContainer()
public NavuContainer(NavuContext context)
NavuContainer
a starting point of
which further navigation is performed.context
- determines the Navigation restriction and
constraintspublic 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 module@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 namespace(String ns) throws ConfException, IOException
ns
.namespace
in class NavuNode
ns
- the namespace idConfException
IOException
public NavuContainer container(Integer key) throws NavuException
container
with
the hash value key
.
The container
hash value can be obtained as a constant
from a namespace file generated by confdc
or
ncsc
, or retrieved with one of the methods
ConfNamespace.stringToHash(String)
or
MaapiSchemas.stringToHash(String)
. It is also possible to access
a container based on its name only, using the overloaded method
NavuContainer.container(String)
.container
in class NavuNode
key
- hashed name of the container to returnNavuException
- if the corresponding subordinate node is not
a container or if there is no subordinate node
with the hash value key
public NavuContainer container(String key) throws NavuException
container
with
the name key
.container
in class NavuNode
key
- the name of the subordinate containerNavuException
- if the corresponding subordinate node is not
a container node or if there is no subordinate node
with the name key
public NavuContainer container(ConfNamespace ns, String containerName) throws NavuException
Returns a reference to a subordinate container
with
the name containerName
, belonging to the namespace
ns
.
Note that if containerName
by itself uniquely identifies a
subordinate container, that container will still have to belong to the
namespace ns
contrary to the functionality of the previous
method using prefix and containerName.
container
in class NavuNode
ns
- the namespace objectcontainerName
- the name of the subordinate containerNavuException
- if the corresponding subordinate node is not
a container node or if there is no subordinate node
with the name containerName
in the namespace
ns
@Deprecated public NavuContainer container(String prefix, String key) throws NavuException
NavuContainer.container(ConfNamespace, String)
or #namespace(String).container(String)
instead.container
in class NavuNode
NavuException
public NavuLeaf leaf(Integer key) throws NavuException
leaf
with
the hash value key
.leaf
in class NavuNode
key
- hashed name of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if there is no subordinate node
with the hash value key
public NavuLeaf leaf(String key) throws NavuException
leaf
with
the name key
.leaf
in class NavuNode
key
- the name of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if there is no subordinate node
with the name key
public NavuLeaf leaf(ConfNamespace ns, String leafName) throws NavuException
Returns a reference to a subordinate leaf
with
the name leafName
, belonging to the namespace
ns
.
Note that if leafName
by itself uniquely identifies a
subordinate leaf, that leaf will still have to belong to the
namespace ns
contrary to the functionality of the previous
method using prefix and leafName.
leaf
in class NavuNode
ns
- the namespace objectleafName
- the name of the subordinate leafNavuException
- if the corresponding subordinate node is not
a leaf node or if there is no subordinate node
with the name key
in the namespace
ns
@Deprecated public NavuLeaf leaf(String prefix, String key) throws NavuException
NavuContainer.leaf(ConfNamespace, String)
or #namespace(String).leaf(String)
instead.leaf
in class NavuNode
NavuException
public NavuLeafList leafList(Integer key) throws NavuException
leaf-list
with
the hash value key
.leafList
in class NavuNode
key
- hashed name of the subordinate leaf-listNavuException
- if the corresponding subordinate node is not
a leaf-list node or if there is no subordinate node
with the hash value key
public NavuLeafList leafList(String key) throws NavuException
leaf-list
with
the name key
.leafList
in class NavuNode
key
- the name of the subordinate leaf-listNavuException
- if the corresponding subordinate node is not
a leaf-list node or if there is no subordinate node
with the name key
public NavuLeafList leafList(ConfNamespace ns, String leafListName) throws NavuException
Returns a reference to a subordinate leaf-list
with
the name leafListName
, belonging to the namespace
ns
.
Note that if leafListName
by itself uniquely identifies a
subordinate leaf-list, that leaf-list will still have to belong to the
namespace ns
contrary to the functionality of the previous
method using prefix and leafListName.
leafList
in class NavuNode
ns
- the namespace objectleafListName
- the name of the subordinate leaf-listNavuException
- if the corresponding subordinate node is not
a leaf-list node or if there is no subordinate node
with the name leafListName
in the namespace
ns
@Deprecated public NavuLeafList leafList(String prefix, String key) throws NavuException
NavuContainer.leafList(ConfNamespace, String)
or #namespace(String).leafList(String)
instead.leafList
in class NavuNode
NavuException
public NavuList list(Integer key) throws NavuException
list
with the
hash value key
.list
in class NavuNode
key
- the hashed name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if there is no subordinate node
with the hash value key
public NavuList list(String key) throws NavuException
list
with
the name key
.list
in class NavuNode
key
- the name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if there is no subordinate node
with the name key
public NavuList list(ConfNamespace ns, String listName) throws NavuException
Returns a reference to a subordinate list
with
the name listName
, belonging to the namespace
ns
.
Note that if listName
by itself uniquely identifies a
subordinate list, that list will still have to belong to the
namespace ns
contrary to the functionality of the previous
method using prefix and listName.
list
in class NavuNode
ns
- the namespace objectlistName
- the name of the subordinate listNavuException
- if the corresponding subordinate node is not
a list node or if there is no subordinate node
with the name listName
in the namespace
ns
@Deprecated public NavuList list(String prefix, String key) throws NavuException
NavuContainer.list(ConfNamespace, String)
or #namespace(String).list(String)
instead.list
in class NavuNode
NavuException
public NavuAction action(Integer key) throws NavuException
action
with
the hash value key
.key
- the name of the subordinate actionNavuException
- if the corresponding subordinate node is not
an action node or if there is no subordinate node
with the hash value key
public NavuAction action(String key) throws NavuException
action
with
the name key
.key
- the name of the subordinate actionNavuException
- if the corresponding subordinate node is not
a action node or if there is no subordinate node
with the name key
public boolean isListInstance()
true
if this NavuContainer
represents a list-entrytrue
if this NavuContainer
is a list-entry false otherwisepublic ConfKey getKey()
public Collection<NavuNode> children() throws NavuException
children
in class NavuNode
NavuException
public NavuChoice choice(String name) throws NavuException
choice
with
the name name
.name
- the name of the choice to returnNavuException
public boolean containsNode(NavuNode node) throws NavuException
node
- node
is a child of this containerNavuException
public boolean containsNode(String nodeName) throws NavuException
nodeName
- the name of a node to look forNavuException
public NavuContainer create() throws NavuException
NavuException
public NavuContainer safeCreate() throws NavuException
NavuException
public 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 boolean exists() throws NavuException
exists
in class NavuNode
NavuException
public NavuContainer delete() throws NavuException
NavuException
public List<ConfXMLParam> encodeXML() throws NavuException
NavuNode
NavuNode
as the topmost NavuNode
as a ConfXMLParam
array.
The returned ConfXMLParam
array contains no values except
for list keys. The leaf elements are encoded as ConfXMLParamLeaf
.
Therefore, the returning array can be used as a the input parameter
to NavuNode.getValues(ConfXMLParam[])
on the current node's parent.
NavuNode node = ...; ConfXMLParam[] cxa = node.encodeXML().toArray(new ConfXMLParam[0]); // cxa contains a structure that does not contain values except for // keys in list elements NavuNode parent = node.getParent(); ConfXMLParam[] cxb = parent.getValues(cxa); // cxb contains the same sub-tree with all the values
encodeXML
in class NavuNode
ConfXMLParam
objects corresponding to the
sub-tree of this node, with no values except list keys.NavuException
ConfXMLParam
,
ConfXMLParamValue
public List<ConfXMLParam> encodeValues() throws NavuException
NavuNode
NavuNode
as the topmost NavuNode
as a ConfXMLParam
array.
As opposed to NavuNode.encodeXML()
, the returned ConfXMLParam
array does contain values in the form of ConfXMLParamValue
encodeValues
in class NavuNode
ConfXMLParam
objects corresponding to the
sub-tree of this node, including all values.NavuException
ConfXMLParam
,
ConfXMLParamValue
public Set<Map.Entry<String,NavuNode>> entrySet() throws NavuException
NavuException
public Map<ConfKey,NavuChange> findChanges(NavuContext delContext, Integer[] criteria) throws NavuException
The delContext
is a NavuContext with a read transaction
on the running database to read deletes. If null delete changes will not
be able to be retrieved.
delContext
- NavuContext to retrieve deleted values with.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
@Deprecated public Map<ConfKey,NavuChange> findChanges(Integer[] criteria) throws NavuException
NavuContainer.findChanges(NavuContext, Integer[])
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 MaapiSchemas.CSCase getSelectedCase(String choice) throws NavuException
choice
- of the choice to get selected case for.NavuException
public List<NavuNode> getSelectCaseAsNavuNode(String choice) throws NavuException
choice
.
Returns null if no case is selected for the specified
choice
or if the selected case contains no nodes.
Which of the subclasses NavuContainer, NavuList or NavuLeaf that actually constitute 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 choice
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 boolean isEmpty() throws NavuException
NavuException
public DiffIterateResultFlag iterate(ConfObject[] kp, DiffIterateOperFlag op, ConfObject oldValue, ConfObject newValue, Object state)
iterate
in interface MaapiDiffIterate
public Set<String> keySet() throws NavuException
NavuException
public int getUserSession() throws NavuException
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
public NavuNode setChange(List<ConfObject> path, DiffIterateOperFlag op, ConfValue oldValue, NavuContext delContext) throws NavuException
setChange
in class NavuNode
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
public Collection<NavuNode> select(ConfObject[] kp) throws NavuException
select
in class NavuNode
NavuException
public ConfNamespace getRootNS()
NavuNode
@Deprecated public void set(String xml) throws NavuException
NavuNode.setValues(String)
instead.xml
- -
XML structure corresponding values that will be set.NavuException
@Deprecated public NavuContainer setOperationalDataCase(String choiceStr, String caseStr) throws NavuException
NavuContainer.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 boolean equals(Object o)
NavuContainer
for equality. Returns true
if the specified object
is also a NavuContainer
and either of the following
is true:
NavuNodeInfo.isModule()
)
and they have the same namespace URI.
ConfPath
instances.