|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.overview.Node
public class Node
A node in an overview. There are two types of nodes: folder nodes
and item nodes. The only difference is that an item node has a link
to a BasicItem
(see getItem()
but a folder node does not.
Both node types can have child nodes.
Each node has a unique ID (getId()
) which is based on the system
hashcode. Each node also has a name which should be unique among the
child nodes. If the name isn't unique the getChild(String)
returns the
first matching node.
Nested Class Summary | |
---|---|
static class |
Node.Type
The type of node. |
Field Summary | |
---|---|
private int |
childErrors
|
private List<Node> |
children
|
private boolean |
childrenLoaded
|
private int |
childWarnings
|
private ChildNodeDirection |
direction
|
private BasicItem |
item
|
private String |
name
|
private String |
nodeId
|
private int |
numErrors
|
private int |
numWarnings
|
private Node |
parent
|
private String |
title
|
private Node.Type |
type
|
Constructor Summary | |
---|---|
private |
Node(Node copyFrom,
Node parent)
Make a copy of a node |
|
Node(String name,
String title,
BasicItem item)
Create an item-type root node. |
|
Node(String name,
String title,
Node parent)
Create a folder-type child node. |
|
Node(String name,
String title,
Node parent,
BasicItem item)
Create an item-type child node |
|
Node(String name,
String title,
Node parent,
BasicItem item,
ChildNodeDirection direction)
Create an item-type child node |
private |
Node(String name,
String title,
Node parent,
BasicItem item,
Node.Type type,
ChildNodeDirection direction)
|
|
Node(String name,
String title,
Node parent,
ChildNodeDirection direction)
Create a folder-type child node. |
Method Summary | |
---|---|
protected void |
addChild(Node child)
Add a child node to this one. |
protected void |
addChildErrors(int numErrors)
Add child errors to this node. |
protected void |
addChildWarnings(int numWarnings)
Add child warnings to this node. |
void |
addErrors(int numErrors)
Add more errors to this node. |
void |
addWarnings(int numWarnings)
Add more warnings to this node. |
void |
clearFailures()
Clear all warnings, errors on this node and on all child nodes. |
int |
compareTo(Node o)
|
Node |
deepCopy(Node parentOfCopy)
Create a deep copy of this node and all it's children. |
private Node |
deepCopyInternal(Node parentOfCopy)
|
Node |
getChild(String name)
Get the child node with a specific name. |
int |
getChildErrors()
Get the number of errors to children of this node. |
ChildNodeDirection |
getChildNodeDirection()
Get the direction to use when loading children of this node. |
List<Node> |
getChildren()
Get all child nodes of this node. |
int |
getChildWarnings()
Get the number of warnings to children of this node. |
Node |
getFirstParent(Filter<? super Node> filter)
Find the first parent node that matches a filter. |
String |
getId()
Get a unique ID for this node. |
BasicItem |
getItem()
Get the item that is related to this node. |
BasicItem |
getItem(DbControl dc)
Get the item that is related to this node and make sure that it is loaded with the current DbControl. |
Item |
getItemType()
Get the item type of the item that this node related to this node. |
String |
getName()
Get the name of this node. |
Node.Type |
getNodeType()
Get the node type of this node. |
int |
getNumErrors()
Get the number of errors on this node. |
int |
getNumWarnings()
Get the number of warnings on this node. |
Node |
getParent()
Get the parent of this node. |
String |
getTitle()
Get the display title of this node. |
boolean |
isChildrenLoaded()
|
int |
numChildren()
Get the number of child nodes in this node. |
void |
setChildrenLoaded()
Sets a flag to indicate that all children has been loaded. |
void |
setErrors(int numErrors)
Set the number of errors that was found while validating this node. |
void |
setWarnings(int numWarnings)
Set the number of warnings that was found while validating this node. |
void |
sortChildren(Comparator<? super Node> comparator)
Sorts the list of child nodes. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final String name
private final String title
private final BasicItem item
private final Node parent
private final Node.Type type
private final String nodeId
private final ChildNodeDirection direction
private List<Node> children
private int numWarnings
private int numErrors
private int childWarnings
private int childErrors
private boolean childrenLoaded
Constructor Detail |
---|
public Node(String name, String title, BasicItem item)
name
- The name of the nodetitle
- The display title of the nodeitem
- The item the node referencesGenericOverview.getRootNode()
public Node(String name, String title, Node parent)
name
- The name of the child nodetitle
- The display title of the nodeparent
- The parent nodepublic Node(String name, String title, Node parent, ChildNodeDirection direction)
name
- The name of the child nodetitle
- The display title of the nodeparent
- The parent nodedirection
- The direction to use when continuing to
load child nodespublic Node(String name, String title, Node parent, BasicItem item)
name
- The name of the child nodetitle
- The display title of the nodeparent
- The parent nodeitem
- The item this node referencespublic Node(String name, String title, Node parent, BasicItem item, ChildNodeDirection direction)
name
- The name of the child nodetitle
- The display title of the nodeparent
- The parent nodeitem
- The item this node referencesdirection
- The direction to use when continuing to
load child nodesprivate Node(String name, String title, Node parent, BasicItem item, Node.Type type, ChildNodeDirection direction)
private Node(Node copyFrom, Node parent)
Method Detail |
---|
public String getId()
public Node.Type getNodeType()
getItem()
always return null. It it returns null for
an item-type node it usually means that access was denied to that
particular item.
public String getName()
getParent().getChild(this.getName())
should return this node.
public String getTitle()
public BasicItem getItem()
public BasicItem getItem(DbControl dc)
public Item getItemType()
getItem().getType()
.
public Node getParent()
public Node getFirstParent(Filter<? super Node> filter)
Filter.evaluate(Object)
returns true is the node that is returned.
filter
- The filter to use for matching parent
public List<Node> getChildren()
public int numChildren()
public Node getChild(String name)
name
- The name of the child node.
protected void addChild(Node child)
public void sortChildren(Comparator<? super Node> comparator)
comparator
- A comparator that determines the sort order,
if not specifed, they children are sorted according to their
titlepublic void setChildrenLoaded()
public boolean isChildrenLoaded()
public ChildNodeDirection getChildNodeDirection()
public void setWarnings(int numWarnings)
numWarnings
- The number of warningsaddWarnings(int)
public void addWarnings(int numWarnings)
numWarnings
- The numer of warnings to addsetWarnings(int)
protected void addChildWarnings(int numWarnings)
public void setErrors(int numErrors)
numErrors
- The number of errorsaddErrors(int)
public void addErrors(int numErrors)
numErrors
- The numer of errors to addsetErrors(int)
protected void addChildErrors(int numErrors)
public int getNumWarnings()
getChildWarnings()
public int getNumErrors()
getChildErrors()
public int getChildWarnings()
getNumWarnings()
public int getChildErrors()
getNumErrors()
public void clearFailures()
public Node deepCopy(Node parentOfCopy)
parentOfCopy
- The node that should be the parent of the
copy or null to make the copy a root node
PermissionDeniedException
- If the given parent node is a
descendant of this node (it would lead to an infinite loop)private Node deepCopyInternal(Node parentOfCopy)
public int compareTo(Node o)
compareTo
in interface Comparable<Node>
public String toString()
toString
in class Object
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |