Class DnNode<N>
java.lang.Object
org.apache.directory.api.ldap.util.tree.DnNode<N>
- Type Parameters:
N- The type of node we store
A class storing nodes in a tree designed to map DNs.
Branch nodes in this tree refers to child nodes. Leaf nodes in the tree don't have any children.
A node may contain a reference to an object whose suffix is the path through the nodes of the tree from the root.
A node may also have no attached element.
Each child node is referenced by a Rdn, and holds the full Dn corresponding to its position
Branch nodes in this tree refers to child nodes. Leaf nodes in the tree don't have any children.
A node may contain a reference to an object whose suffix is the path through the nodes of the tree from the root.
A node may also have no attached element.
Each child node is referenced by a Rdn, and holds the full Dn corresponding to its position
- Author:
- Apache Directory Project
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(org.apache.directory.api.ldap.model.name.Dn dn) Add a new node in the tree.Add a new node in the tree.booleancontains(org.apache.directory.api.ldap.model.name.Rdn rdn) Tells if the current DnBranchNode contains another node associated with an rdn.getChild(org.apache.directory.api.ldap.model.name.Rdn rdn) Get's a child using an rdn string.Get the chidren for the current nodegetDescendantElements(org.apache.directory.api.ldap.model.name.Dn dn) Get the descendant of an element at a given Dn positionorg.apache.directory.api.ldap.model.name.DngetDn()Get the DnGet the stored elementgetElement(org.apache.directory.api.ldap.model.name.Dn dn) Get the stored element associated to a DNgetNode(org.apache.directory.api.ldap.model.name.Dn dn) Get the Node for a given Dn, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned.Get the parent's nodeGet the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.getParentWithElement(org.apache.directory.api.ldap.model.name.Dn dn) Get the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.org.apache.directory.api.ldap.model.name.RdngetRdn()Get a node's RdnbooleanTells if the current DnNode has some children or notbooleanhasChildren(org.apache.directory.api.ldap.model.name.Dn dn) Tells if a node has some children or not.booleanhasDescendantElement(org.apache.directory.api.ldap.model.name.Dn dn) tells if tehre are some descendant elemnts for a given DnbooleanTells if there is an elementbooleanhasElement(org.apache.directory.api.ldap.model.name.Dn dn) tells if there is an element for a given DnbooleanTells if the current noe has a parentbooleanhasParent(org.apache.directory.api.ldap.model.name.Dn dn) Tells if there is a parent for a given Dn,.booleanhasParentElement(org.apache.directory.api.ldap.model.name.Dn dn) Get the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.booleanisLeaf()Tells if the implementation is a leaf node.booleanisLeaf(org.apache.directory.api.ldap.model.name.Dn dn) Tells if the implementation is a leaf node.voidmove(org.apache.directory.api.ldap.model.name.Dn newParent) move the DnNode's Dnvoidremove(org.apache.directory.api.ldap.model.name.Dn dn) Removes a node from the tree.voidrename(org.apache.directory.api.ldap.model.name.Rdn newRdn) rename the DnNode's DnvoidsetElement(N element) Store the given element into the nodeintsize()Returns the number of entries under this node.toString()
-
Constructor Details
-
DnNode
public DnNode()Creates a new instance of DnNode. -
DnNode
Creates a new instance of DnNode.- Parameters:
element- the element to store
-
DnNode
Creates a new instance of DnNode.- Parameters:
dn- the node's Dnelement- the element to store
-
-
Method Details
-
setElement
Store the given element into the node- Parameters:
element- The element to set
-
isLeaf
public boolean isLeaf()Tells if the implementation is a leaf node. If it's a branch node then false is returned.- Returns:
trueif the class is a leaf node, false otherwise.
-
isLeaf
public boolean isLeaf(org.apache.directory.api.ldap.model.name.Dn dn) Tells if the implementation is a leaf node. If it's a branch node then false is returned.- Parameters:
dn- The Dn we want to check- Returns:
trueif this is a leaf node, false otherwise.
-
size
public int size()Returns the number of entries under this node. It includes the node itself, plus the number of all it children and descendants.- Returns:
- The number of descendents
-
getElement
-
getElement
Get the stored element associated to a DN- Parameters:
dn- The Dn we want to get the element for- Returns:
- Return the stored element, if any
-
hasElement
public boolean hasElement()Tells if there is an element- Returns:
- True if the Node stores an element. BranchNode may not hold any element.
-
hasElement
public boolean hasElement(org.apache.directory.api.ldap.model.name.Dn dn) tells if there is an element for a given Dn- Parameters:
dn- The Dn we want to get the element for- Returns:
- True if the Node stores an element. BranchNode may not hold any element.
-
hasDescendantElement
public boolean hasDescendantElement(org.apache.directory.api.ldap.model.name.Dn dn) tells if tehre are some descendant elemnts for a given Dn- Parameters:
dn- The Dn we want to get the element for- Returns:
- True if one of the node below the current node has one element, False otherwise
-
getDescendantElements
-
hasChildren
public boolean hasChildren()Tells if the current DnNode has some children or not- Returns:
trueif the node has some children
-
hasChildren
public boolean hasChildren(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException Tells if a node has some children or not.- Parameters:
dn- the node's Dn- Returns:
trueif the node has some children- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- if the Dn is null or empty
-
getChildren
-
getParent
-
hasParent
public boolean hasParent()Tells if the current noe has a parent- Returns:
trueif the current DnNode has a parent
-
hasParent
public boolean hasParent(org.apache.directory.api.ldap.model.name.Dn dn) Tells if there is a parent for a given Dn,. This parent should be a subset of the given dn.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent
For the Dn ou=apache, dc=org, there is no parent, so false will be returned.- Parameters:
dn- the normalized distinguished name to resolve to a parent- Returns:
- true if there is a parent associated with the normalized dn
-
add
public DnNode<N> add(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException Add a new node in the tree. The added node won't have any element.- Parameters:
dn- The node's Dn- Returns:
- the corresponding node
- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- if the Dn is null or empty
-
add
public DnNode<N> add(org.apache.directory.api.ldap.model.name.Dn dn, N element) throws org.apache.directory.api.ldap.model.exception.LdapException Add a new node in the tree. We can't add a node if its Dn is empty. The added element is attached to the node, which is named by the Dn's Rdn.- Parameters:
dn- The node's Dnelement- The element to associate with this Node. Can be null.- Returns:
- the corresponding node
- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- if the Dn is null or empty
-
remove
public void remove(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException Removes a node from the tree.- Parameters:
dn- the node's Dn- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- if the Dn is null or empty
-
contains
public boolean contains(org.apache.directory.api.ldap.model.name.Rdn rdn) Tells if the current DnBranchNode contains another node associated with an rdn.- Parameters:
rdn- The name we are looking for- Returns:
trueif the tree instance contains this name
-
getChild
-
getRdn
public org.apache.directory.api.ldap.model.name.Rdn getRdn()Get a node's Rdn- Returns:
- The Node's Rdn
-
getNode
Get the Node for a given Dn, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned.
For the Dn ou=apache, dc=org, there is no parent, so null will be returned.- Parameters:
dn- the normalized distinguished name to resolve to a parent- Returns:
- the Node associated with the normalized dn
-
hasParentElement
public boolean hasParentElement(org.apache.directory.api.ldap.model.name.Dn dn) Get the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.
For the Dn ou=apache, dc=org, there is no parent, so null will be returned.- Parameters:
dn- the normalized distinguished name to resolve to a parent- Returns:
- the Node associated with the normalized dn
-
getParentWithElement
Get the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.
For the Dn ou=apache, dc=org, there is no parent, so null will be returned.- Parameters:
dn- the normalized distinguished name to resolve to a parent- Returns:
- the Node associated with the normalized dn
-
getParentWithElement
Get the closest Node for a given Dn which has an element, if present in the tree.
For instance, if we have stored dc=acme, dc=org into the tree, the Dn: ou=example, dc=acme, dc=org will have a parent, and dc=acme, dc=org will be returned if it has an associated element.
For the Dn ou=apache, dc=org, there is no parent, so null will be returned.- Returns:
- the Node associated with the normalized dn
-
rename
public void rename(org.apache.directory.api.ldap.model.name.Rdn newRdn) throws org.apache.directory.api.ldap.model.exception.LdapException rename the DnNode's Dn- Parameters:
newRdn- the new Rdn of this node- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- If the rename failed
-
move
public void move(org.apache.directory.api.ldap.model.name.Dn newParent) throws org.apache.directory.api.ldap.model.exception.LdapException move the DnNode's Dn- Parameters:
newParent- the new parent Dn- Throws:
org.apache.directory.api.ldap.model.exception.LdapException- If the move failed
-
toString
-
getDn
public org.apache.directory.api.ldap.model.name.Dn getDn()Get the Dn- Returns:
- the dn
-