public class NavuLeafList extends NavuLeaf implements Iterable<ConfValue>
NavuLeafList
is a representation of the YANG leaf-list.
When accessing individual elements trough containsNode
,
NavuLeafList
will only make one single exists
call (over MAAPI or CDB depending on the context) to check the
existence of the key, thus making the operation cheap.
The set of leaf-list entries can be retrieved through NavuLeafList.elements()
or by retrieving an iterator NavuLeafList.iterator()
. The difference between the
two is that NavuLeafList.elements()
will make a single call to retrieve all
the leaf-list elements, while NavuLeafList.iterator()
will try to fetch
leaf-list elements one by one using getNext() calls whenever possible.
NavuNode parent = ...; NavuLeafList someLeafList = parent.leafList(someNamespace._someLeafList); for (ConfValue value : someLeafList) { // Here the elements will be fetched one by one } for (ConfValue value : someLeafList.elements()) { // Here the elements will be fetched using a single call // and stored in memory for the duration of the iteration }
Modifier and Type | Class and Description |
---|---|
static class |
NavuLeafList.WhereTo |
Modifier and Type | Method and Description |
---|---|
boolean |
containsNode(ConfValue elem)
Returns true if and only if this
NavuLeafList
contains this element. |
boolean |
containsNode(String elemStr)
Returns true if and only if this
NavuLeafList
contains this element. |
void |
create(ConfValue elem)
Creates leaf-list entry.
|
void |
create(String elemStr)
Creates leaf-list entry.
|
void |
delete(ConfValue elem)
Deletes an entry from the leaf-list.
|
void |
delete(String elemStr)
Deletes an entry from the leaf-list.
|
Collection<ConfValue> |
elements()
Returns a copy of elements contained by the leaf-list node.
|
boolean |
isEmpty()
Checks if there are any elements in the leaf-list.
|
Iterator<ConfValue> |
iterator()
Retrieve a iterator over the elements in this
NavuLeafList
(in proper sequence). |
void |
move(ConfValue elem,
NavuLeafList.WhereTo whereTo,
ConfValue to)
Move a leaf-list element to a new position.
|
void |
move(String elemStr,
NavuLeafList.WhereTo whereTo,
String toStr)
Move a leaf-list element to a new position.
|
void |
safeCreate(ConfValue elem)
The variant of
create that succeeds even if the
object already exists. |
void |
safeCreate(String elemStr)
The variant of
create that succeeds even if the
object already exists. |
void |
sharedCreate(ConfValue elem)
The variant of
create that succeeds even if the
object already exists, and also maintains a reference counter
on the object. |
void |
sharedCreate(String elemStr)
The variant of
create that succeeds even if the
object already exists, and also maintains a reference counter
on the object. |
int |
size()
Returns the number of leaf-list elements contained by the leaf-list.
|
create, delete, deref, encodeValues, encodeXML, equals, exists, getCdbSession, getChangeFlag, getOldValue, getParent, getRootNS, getValues, idrefDerivedOrSelf, isKey, reset, safeCreate, select, select, select, set, set, setChange, setValues, sharedCreate, sharedSet, sharedSet, toKey, toString, value, valueAsString, valueUpdateInd
children, container, container, container, container, context, getChange, getChanges, getChanges, getChanges, getChanges, getChanges, getChanges, getConfPath, getInfo, getKeyPath, getName, getNavuNode, getValues, getXml, hashCode, leaf, leaf, leaf, leaf, leafList, leafList, leafList, leafList, list, list, list, list, namespace, prepareXMLCall, setValues, sharedSetValues, sharedSetValues, startCdbSession, stopCdbSession, xPathSelect, xPathSelectIterate
forEach, spliterator
public boolean containsNode(ConfValue elem) throws NavuException
NavuLeafList
contains this element.elem
- whose presence in this NavuLeafList
is to be
testedNavuException
public boolean containsNode(String elemStr) throws NavuException
NavuLeafList
contains this element.elemStr
- string representation of the element whose presence
in this NavuLeafList
is to be testedNavuException
public void create(ConfValue elem) throws NavuException
We have 3 different variants of create
.
create()
This method creates the leaf-list entry.
If such entry already exists tt will fail with a NavuException
with the error code set to ErrorCode.ERR_ALREADY_EXISTS
.
safeCreate()
similar to create()
with the sole difference that is silently succeeds even if the
leaf-list entry already exists.
sharedCreate()
This method is useful when
creating element in FASTMAP code, i.e code that implements
a FASTMAP service. The sharedCreate()
method maintains a reference counter on the created object.
Furthermore, and attribute "backpointer" will be created on the created
leaf-list entry indicating which "service" created the object
elem
- the leaf-list entry to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur,
or such entry already existspublic void create(String elemStr) throws NavuException
We have 3 different variants of create
.
create()
This method creates the leaf-list entry.
If such entry already exists tt will fail with a NavuException
with the error code set to ErrorCode.ERR_ALREADY_EXISTS
.
safeCreate()
similar to create()
with the sole difference that is silently succeeds even if the
leaf-list entry already exists.
sharedCreate()
This method is useful when
creating element in FASTMAP code, i.e code that implements
a FASTMAP service. The sharedCreate()
method maintains a reference counter on the created object.
Furthermore, and attribute "backpointer" will be created on the created
leaf-list entry indicating which "service" created the object
elemStr
- the string representation of the leaf-list entry
to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur,
or such entry already exists.public void safeCreate(ConfValue elem) throws NavuException
create
that succeeds even if the
object already exists.elem
- the leaf-list entry to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur.public void safeCreate(String elemStr) throws NavuException
create
that succeeds even if the
object already exists.elemStr
- the string representation of the leaf-list entry
to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur.public void sharedCreate(ConfValue elem) throws NavuException
create
that succeeds even if the
object already exists, and also maintains a reference counter
on the object. When the FASTMAP algorithm applies to objects
created with sharedCreate
the object is not
removed, but rather the reference counter is decremented.elem
- the leaf-list entry to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur.public void sharedCreate(String elemStr) throws NavuException
create
that succeeds even if the
object already exists, and also maintains a reference counter
on the object. When The FASTMAP algorithm applies to objects
created with sharedCreate
the object is not
removed, but rather the reference counter is decremented.elemStr
- the string representation of the leaf-list entry
to be createdNavuException
- if any MAAPI operations fail during the
create or IOException if socket errors would occur.public void delete(ConfValue elem) throws NavuException
elem
- the element to delete.NavuException
- If the method fails to delete the element.public void delete(String elemStr) throws NavuException
elemStr
- string representation of the element to delete.NavuException
- If the method fails to delete the element.public Collection<ConfValue> elements() throws NavuException
NavuException
- if the elements could not be retrieved.public boolean isEmpty() throws NavuException
NavuException
public int size() throws NavuException
NavuException
public void move(String elemStr, NavuLeafList.WhereTo whereTo, String toStr) throws NavuException
The destination
can be at the beginning, the end or in a relation to another element.
Elements are referenced by their string representation.
See also: NavuLeafList.move(ConfValue key, WhereTo whereTo, ConfValue to)
elemStr
- Move elemStr according to whereTowhereTo
- How the move should be performed. Move elemStr
WhereTo.FIRST or WhereTo.LAST or move elemStr
WhereTo.BEFORE or WhereTo.AFTER the element toStr.toStr
- If the value of whereTo is WhereTo.FIRST or WhereTo.LAST
this argument ignoredNavuException
public void move(ConfValue elem, NavuLeafList.WhereTo whereTo, ConfValue to) throws NavuException
The destination can be at the beginning, the end or in a relation to another element.
elem
- Move elem according to whereTowhereTo
- How the move should be performed. Move elem
WhereTo.FIRST or WhereTo.LAST or move elem
WhereTo.BEFORE or WhereTo.AFTER the element to.to
- If the value of whereTo is WhereTo.FIRST or WhereTo.LAST
this argument ignoredNavuException