|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<BranchNode<F>>
com.accountingenhancements.treearray.BranchNode<F>
public class BranchNode<F>
This class implements a tree branch and leaf structure.
It contains other BranchNodes and a LeafNode object.
It is implemented using ArrayList
Field Summary | |
---|---|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
attributes
|
protected int |
depth
|
protected LeafNode<F> |
leafNode
|
protected BranchNode<F> |
parent
|
protected Tree<F> |
tree
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
BranchNode(BranchNode<F> parent)
Creates a BranchNode Array of other BranchNode as well as a LeafNode array. Constructs an empty list with an initial capacity of ten and an empty LeafNode list with an initial capacity of 10. |
|
BranchNode(int initialCapacity,
int initialLeafCapacity,
BranchNode<F> parent)
Constructs an empty BranchNode with the specified initial capacity. |
Method Summary | |
---|---|
BranchNode<F> |
addLeaf(F leaf)
Appends the specified Element to the end the LeafNode list. Same as leafAdd(F leaf) |
BranchNode<F> |
addLeaf(int index,
F leaf)
Inserts the specified Element at the specified position in the LeafNode list. |
BranchNode<F> |
addLeaf(Leaf<F> leaf)
Appends the specified Leaf to the end the LeafNode list. Use this if you want to create the leaf itself. Note: if you want set attributes on the Leaf you can chain the attributes to the new Leaf<>() constructor because Leaf<>().setAttribute returns the Leaf<> again. branchNode.addLead(new Leaf Same as leafAdd(Leaf |
void |
clearLeafNode()
Removes all of the elements from the LeafNode list. |
BranchNode<F> |
createNewBranchNode()
Create as new BranchNode entry and return it.The new |
BranchNode<F> |
createNewBranchNode(java.lang.String branchName)
Create as new BranchNode entry and return it.The new |
java.lang.Object |
getAttribute(java.lang.String attribute)
Get previously set attributes |
java.util.HashMap<java.lang.String,java.lang.Object> |
getAttributeHashMap()
Get the entire attribute HashMap so that the rest of the methods are accessable. |
int |
getDepth()
|
F |
getLeaf(int index)
Returns the element at the specified position in the LeafNode list.Same as leafGet(int index) |
java.lang.Object |
getLeafAttribute(int index,
java.lang.String attribute)
Retrieves a previously set attribute for the specified leaf |
LeafNode<F> |
getLeafNode()
Get the Underlying LeafNode list |
BranchNode<F> |
getParent()
Get the parent BranchNode . |
Tree<F> |
getTree()
|
BranchNode<F> |
leafAdd(F leaf)
Appends the specified Element to the end the LeafNode list. Same as getLeaf(int index) |
BranchNode<F> |
leafAdd(int index,
F leaf)
Inserts the specified Element at the specified position in the LeafNode list. |
BranchNode<F> |
leafAdd(Leaf<F> leaf)
Appends the specified leaf to the end the LeafNode list. Note: if you want set attributes on the Leaf you can chain the attributes to the new Leaf<>() constructor because Leaf<>().setAttribute returns the Leaf<> again. branchNode.addLead(new Leaf Same as addLleaf(Leaf |
F |
leafGet(int index)
Returns the element at the specified position in the LeafNode list.same as getLeaf(int index) |
int |
leafIndexOf(F elem)
Searches for the first occurence of the given argument in the LeafNode list, testing
for equality using the equals method. |
int |
leafLastIndexOf(F elem)
Returns the index of the last occurrence of the specified object in the LeafNode list. |
void |
leafNodeClear()
Removes all of the elements from the LeafNode list. |
boolean |
leafNodeContains(F elem)
Returns true if the LeafNode contains the specified element. |
void |
leafNodeEnsureCapacity(int minCapacity)
Increases the capacity of the LeafNode list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
boolean |
leafNodeIsEmpty()
Tests if The LeafNode list has no Objects . |
int |
leafNodeSize()
Returns the number of JComponent s in the LeafNode list. |
java.lang.Object[] |
leafNodeToArray()
Returns an array containing all of the elements in the LeafNode list
in the correct order. |
F[] |
leafNodeToArray(F[] a)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array. |
boolean |
leafRemove(F o)
Removes a single instance of the specified element from the LeafNode
list, if it is present (optional operation). |
F |
leafRemove(int index)
Removes the element at the specified position in the LeafNode list. |
boolean |
leafRemove(Leaf<F> o)
Removes a single instance of the specified leaf from the LeafNode
list, if it is present (optional operation). |
F |
leafSet(int index,
F element)
Replaces the element at the specified position in the LeafNode list with
the specified element.Same as setLeaf(int index, F element) |
boolean |
removeLeaf(F o)
Removes a single instance of the specified element from the LeafNode
list, if it is present (optional operation). |
F |
removeLeaf(int index)
Removes the element at the specified position in the LeafNode list. |
boolean |
removeLeaf(Leaf<F> o)
Removes a single instance of the specified leaf from the LeafNode
list, if it is present (optional operation). |
BranchNode<F> |
setAttribute(java.lang.String attribute,
java.lang.Object value)
Set attributes relating to this branch. |
F |
setLeaf(int index,
F element)
Replaces the element at the specified position in the LeafNode list with
the specified element.Same as leafSet(int index, F element) |
void |
setLeafAttribute(int index,
java.lang.String attribute,
java.lang.Object value)
Adds or overwrites an attribute for the specified leat at the specified position in this list. |
void |
setLeafNode(LeafNode<F> leafNode)
Replace the LeafNode list |
void |
setTree(Tree<F> tree)
Tree to which this Branch Node belongs. |
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
protected transient java.util.HashMap<java.lang.String,java.lang.Object> attributes
protected transient LeafNode<F> leafNode
protected BranchNode<F> parent
protected Tree<F> tree
protected int depth
Constructor Detail |
---|
public BranchNode(int initialCapacity, int initialLeafCapacity, BranchNode<F> parent)
BranchNode
with the specified initial capacity.
initialCapacity
- the initial capacity of the list.initialLeafCapacity
- the initial capacity of the LeafNode list
java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic BranchNode(BranchNode<F> parent)
Method Detail |
---|
public void setTree(Tree<F> tree)
tree
- the tree to which this BranchNode
belongspublic Tree<F> getTree()
BranchNode
belongs.public BranchNode<F> getParent()
BranchNode
. null means that this is the trunk.
public int getDepth()
public BranchNode<F> setAttribute(java.lang.String attribute, java.lang.Object value)
HashMap
attribute
- namevalue
- of attribute
public java.lang.Object getAttribute(java.lang.String attribute)
attribute
- name
public java.util.HashMap<java.lang.String,java.lang.Object> getAttributeHashMap()
HashMap
so that the rest of the methods are accessable.
HashMap
public void leafNodeEnsureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.public int leafNodeSize()
JComponent
s in the LeafNode
list.
JComponent
s in this list.public boolean leafNodeIsEmpty()
LeafNode
list has no Objects
.
public boolean leafNodeContains(F elem)
LeafNode
contains the specified element.
elem
- element whose presence in this List is to be tested.
true
if the specified element is present;
false
otherwise.public int leafIndexOf(F elem)
LeafNode
list, testing
for equality using the equals method.
elem
- an object.
Object.equals(Object)
public int leafLastIndexOf(F elem)
LeafNode
list.
elem
- the desired element.
public java.lang.Object[] leafNodeToArray()
LeafNode
list
in the correct order.
public F[] leafNodeToArray(F[] a)
If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.
a
- the array into which the elements of the list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
java.lang.ArrayStoreException
- if the runtime type of a is not a supertype
of the runtime type of every element in this list.public F leafGet(int index)
LeafNode
list.getLeaf(int index)
index
- index of element to return.
java.lang.IndexOutOfBoundsException
- if index is out of range (index
< 0 || index >= size()).public F getLeaf(int index)
LeafNode
list.leafGet(int index)
index
- index of element to return.
java.lang.IndexOutOfBoundsException
- if index is out of range (index
< 0 || index >= size()).public F leafSet(int index, F element)
LeafNode
list with
the specified element.setLeaf(int index, F element)
index
- index of element to replace.element
- element to be stored at the specified position.
java.lang.IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size()).public F setLeaf(int index, F element)
LeafNode
list with
the specified element.leafSet(int index, F element)
index
- index of element to replace.element
- element to be stored at the specified position.
java.lang.IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size()).public BranchNode<F> leafAdd(F leaf)
getLeaf(int index)
leaf
- element to be appended to this list.
public BranchNode<F> addLeaf(F leaf)
leafAdd(F leaf)
leaf
- element to be appended to this list.
public BranchNode<F> addLeaf(Leaf<F> leaf)
branchNode.addLead(new Leaf(component).setAttribute("horizontalPref",20).setAttribute("verticalPref",7));
leafAdd(Leaf leaf)
leaf
- element to be appended to this list.
public BranchNode<F> leafAdd(Leaf<F> leaf)
branchNode.addLead(new Leaf(component).setAttribute("horizontalPref",20).setAttribute("verticalPref",7));
addLleaf(Leaf leaf)
leaf
- element to be appended to this list.
public BranchNode<F> leafAdd(int index, F leaf)
addLeaf(int index, F leaf)
index
- index at which the specified element is to be inserted.leaf
- leaf to be inserted.
java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).public BranchNode<F> addLeaf(int index, F leaf)
leafAdd(int index, F leaf)
index
- index at which the specified element is to be inserted.leaf
- leaf to be inserted.
java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).public F leafRemove(int index)
LeafNode
list.
Shifts any subsequent elements to the left (subtracts one from their
indices).removeLeaf(int index)
index
- the index of the element to removed.
java.lang.IndexOutOfBoundsException
- if index out of range (index
< 0 || index >= size()).public F removeLeaf(int index)
LeafNode
list.
Shifts any subsequent elements to the left (subtracts one from their
indices).leafRemove(int index)
index
- the index of the element to removed.
java.lang.IndexOutOfBoundsException
- if index out of range (index
< 0 || index >= size()).public boolean leafRemove(F o)
LeafNode
list, if it is present (optional operation). More formally,
removes an element e such that (o==null ? e==null :
o.equals(e)), if the list contains one or more such
elements. Returns true if the list contained the
specified element (or equivalently, if the list changed as a
result of the call).
Sames as removeLeaf(F o)
o
- element to be removed from this list, if present.
public boolean removeLeaf(F o)
LeafNode
list, if it is present (optional operation). More formally,
removes an element e such that (o==null ? e==null :
o.equals(e)), if the list contains one or more such
elements. Returns true if the list contained the
specified element (or equivalently, if the list changed as a
result of the call).
Same as leafRemove(F o)
o
- element to be removed from this list, if present.
public boolean leafRemove(Leaf<F> o)
LeafNode
list, if it is present (optional operation). More formally,
removes an element e such that (o==null ? e==null :
o.equals(e)), if the list contains one or more such
elements. Returns true if the list contained the
specified element (or equivalently, if the list changed as a
result of the call).
Sames as removeLeaf(Leaf
o
- leaf to be removed from this list, if present.
public boolean removeLeaf(Leaf<F> o)
LeafNode
list, if it is present (optional operation). More formally,
removes an element e such that (o==null ? e==null :
o.equals(e)), if the list contains one or more such
elements. Returns true if the list contained the
specified element (or equivalently, if the list changed as a
result of the call).
Same as leafRemove(Leaf
o
- leaf to be removed from this list, if present.
public void leafNodeClear()
LeafNode
list. The list will
be empty after this call returns.clearLeafNode
public void clearLeafNode()
LeafNode
list. The list will
be empty after this call returns.leafNodeClear()
public LeafNode<F> getLeafNode()
public void setLeafNode(LeafNode<F> leafNode)
LeafNode
list
leafNode
- the newLeafNodes listpublic BranchNode<F> createNewBranchNode(java.lang.String branchName)
BranchNode
entry and return it.BranchNode
doesn't need to know what
the Generic was cast.
branchName
- a branch name to help rapidly identify this branch again from the Tree
class.
public BranchNode<F> createNewBranchNode()
BranchNode
entry and return it.BranchNode
doesn't need to know what
the Generic was cast.
public void setLeafAttribute(int index, java.lang.String attribute, java.lang.Object value)
index
- index at which the specified element is to be inserted.attribute
- attribute namevalue
- attribute value to be added
java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).public java.lang.Object getLeafAttribute(int index, java.lang.String attribute)
index
- index at which the specified attribute is to be retrieved.attribute
- attribute name
java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |