Java Doc for BTreeNode.java in  » Portal » Open-Portal » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   util.BTreeNode

BTreeNode
public class BTreeNode implements Cloneable(Code)
A binary tree node.

Structure. BTreeNodes and the BinaryTree enumeration are designed to allow for binary trees to be treated as though they had left-right children or next-child children. Relevant methods for each are visible; internally, left is treated as being equivalent to next and right is treated as being equivalent to child.

Visibility. A CLOSED node is visible to enumeration but it's children aren't. A node that is OPEN is fully visible to BinaryTree enumeration and the node's children are accessible, though they themselves may not be visible. LEFT/NEXT/RIGHT/CHILD implies the node itself is OPEN. BTreeNodes have a sense of their visibility in enumeration. If the node is LEFTVISIBLE or NEXTVISIBLE, enumeration will attempt to traverse only it's left or next child if they are visible. If the node is RIGHTVISIBLE or CHILDVISIBLE, enumeration will attempt to traverse only it's right or child child if they are visible. The default visibility is OPEN. Visibility restrictions can be circumvented with the getAll methods.

Terminal Policy. Terminal policy affects whether a node accepts expansion and in what way it accepts expansion. In other words, what kind of terminal it is. The policy values are the same as the visibility values and are used similarly. The default terminal policy is OPEN, meaning that either a right or left branch can be created. LEFTVISIBLE and NEXTVISIBLE allow only left (next) branches to be created. RIGHTVISIBLE and CHILDVISIBLE allow only right (child) branches to be created. CLOSED means no branches can be created. Currently, rejection based on terminal policy is silent.

Depth. BTreeNodes maintain a sense of their "depth". Both binary and unary depth are kept. Binary depth is the depth a node is in a left-right tree, unary depth is the depth a node is in a next-child tree, the difference being that the next reference doesn't cause depth to increment. Depth 0 nodes are root nodes.

Management. All alterations to the structure of a binary tree are expected to take place through the Enumeration class. While this class is public (compare with HashtableNode in the JDK util.Hashtable class) enough to be viewed and referenced, methods that alter the parent, left and right are restricted to the BinaryTree enumeration class to ensure the integrity of the enumeration.

Open Issues

  • Certain advanced operations (e.g., the deleting and inserting operations required by QueryNode) will require methods that are less or differently deterred by visibility.
  • Need to support clone() (done) plus Enumeration/Dictionary operations like: contains(), containsKey(), get() (done), keys(). Some maybe in the Enumeration class.
  • Need toString() and toStringList().
  • Adding children should verify that the tree doesn't loop back on itself, i.e. no inclusive descendant of a node being added should point to an inclusive ancestor of the node it is being added to. If access is restricted to the enumerator, we can assume this is not necessary, assuming the creator of the enumerator is not a pinhead.
  • There are times when it would be useful for the BTreeNode to point at it's BinaryTree. Dicey though; then it'd need to be maintained and everything would become just slightly more complicated. It would all be managed w/in the util package though, so consistency/correctness would be doable.
  • getNodeByKey() and getNodeByValue() ignore the enumeration order, are used by BinaryTree and return only the first possible value. Very, very bad.


Field Summary
final public static  intCHILDVISIBLE
    
final public static  intCLOSED
    
final public static  intLEFTVISIBLE
    
final public static  intNEXTVISIBLE
    
final public static  intOPEN
    
final public static  intRIGHTVISIBLE
    
public  booleandisplay
    
protected  Objectkey
    
protected  Objectvalue
    

Constructor Summary
public  BTreeNode()
     Constructor.
public  BTreeNode(Object key, Object value)
     Constructor.
public  BTreeNode(Object key, Object value, int visibility)
     Constructor.

Method Summary
protected  Objectclone()
    
public  BTreeNodedetachFromParent(int leaveBehind)
     Detach the current node from it's parent and return it.
public  intgetBinaryDepth()
     Return the node's binary (left/right) depth within the tree.
public  BTreeNodegetChild()
     Get the child (right).
public  BTreeNodegetChild(boolean all)
     Get the child (right).
public  ObjectgetKey()
     Return the key.
public  BTreeNodegetLeft()
     Get the left (next).
public  BTreeNodegetLeft(boolean all)
     Get the left (next).
public  BTreeNodegetNext()
     Get the next (left).
public  BTreeNodegetNext(boolean all)
     Get the next (left).
protected  BTreeNodegetNodeByKey(Object o)
     Locate a node by checking keys.
protected  BTreeNodegetNodeByValue(Object o)
     Locate a node by checking values.
public  BTreeNodegetParent()
     Get the parent.
public  BTreeNodegetRight()
     Get the right (child).
public  BTreeNodegetRight(boolean all)
     Get the right (child).
public  intgetTerminalPolicy()
     Get the current terminal policy.
public  intgetUnaryDepth()
     Return the node's binary (next/child) depth within the tree.
public  BTreeNodegetUnaryParent()
     Get the parent.
public  ObjectgetValue()
     Return the value.
public  intgetVisibility()
     Return the visiblility.
public  booleanhasAncestor(BTreeNode btn)
     Return true if the caller has as an ancestor the passed node.
public  voidrecursiveDump()
     Debugging aid.
public  voidrecursiveDump(int dumper)
     Debugging aid.
protected  voidsetChild(BTreeNode node)
     Set the child (right) of this node to the passed node.
protected  voidsetDepths()
    
protected  voidsetDepths(int u, int b)
    
protected  voidsetLeft(BTreeNode node)
     Set the left (next) of this node to the passed node.
protected  voidsetNext(BTreeNode node)
     Set the next (left) of this node to the passed node.
protected  voidsetRight(BTreeNode node)
     Set the right (child) of this node to the passed node.
public  voidsetTerminalPolicy(int terminalPolicy)
     Set terminal policy.
public  voidsetVisibility(int visibility)
     Set visibility.
public  StringtoString()
    
public  StringtoStringSummary()
     Debugging aid.

Field Detail
CHILDVISIBLE
final public static int CHILDVISIBLE(Code)
See Visibility and Terminal Policy discussions above



CLOSED
final public static int CLOSED(Code)
See Visibility and Terminal Policy discussions above



LEFTVISIBLE
final public static int LEFTVISIBLE(Code)
See Visibility and Terminal Policy discussions above



NEXTVISIBLE
final public static int NEXTVISIBLE(Code)
See Visibility and Terminal Policy discussions above



OPEN
final public static int OPEN(Code)
See Visibility and Terminal Policy discussions above



RIGHTVISIBLE
final public static int RIGHTVISIBLE(Code)
See Visibility and Terminal Policy discussions above



display
public boolean display(Code)



key
protected Object key(Code)
Key for the node



value
protected Object value(Code)
Value for the node




Constructor Detail
BTreeNode
public BTreeNode()(Code)
Constructor.



BTreeNode
public BTreeNode(Object key, Object value)(Code)
Constructor.
Parameters:
  key - key
Parameters:
  value - value



BTreeNode
public BTreeNode(Object key, Object value, int visibility)(Code)
Constructor.
Parameters:
  key - key
Parameters:
  value - value
Parameters:
  visibility - visibility




Method Detail
clone
protected Object clone()(Code)



detachFromParent
public BTreeNode detachFromParent(int leaveBehind) throws IllegalArgumentException(Code)
Detach the current node from it's parent and return it. leaveBehind indicates what is left behind for the parent. If leaveBehind is BinaryTree.LEFT, the left branch of current is attached to the parent. If leaveBehind is BinaryTree.RIGHT, the right branch of current is attached to the parent. If leaveBehind is BinaryTree.PARENT, the parent is left with a smouldering stub.
Parameters:
  leaveBehind - LEFT, RIGHT or PARENT



getBinaryDepth
public int getBinaryDepth()(Code)
Return the node's binary (left/right) depth within the tree.



getChild
public BTreeNode getChild()(Code)
Get the child (right).



getChild
public BTreeNode getChild(boolean all)(Code)
Get the child (right).
Parameters:
  all - respect visibility or not



getKey
public Object getKey()(Code)
Return the key.



getLeft
public BTreeNode getLeft()(Code)
Get the left (next).



getLeft
public BTreeNode getLeft(boolean all)(Code)
Get the left (next).
Parameters:
  all - respect visibility or not



getNext
public BTreeNode getNext()(Code)
Get the next (left).



getNext
public BTreeNode getNext(boolean all)(Code)
Get the next (left).
Parameters:
  all - respect visibility or not



getNodeByKey
protected BTreeNode getNodeByKey(Object o)(Code)
Locate a node by checking keys. Note that this method doesn't currently respect the tree's enumeration type or visibility, future releases will. Does a left (next) first search. Note that several BinaryTree methods use this method to conduct their searches, also violating the enumeration and visibility rules.
Parameters:
  o - the target key



getNodeByValue
protected BTreeNode getNodeByValue(Object o)(Code)
Locate a node by checking values. Note that this method doesn't currently respect the tree's enumeration type or visibility, future releases will. Does a left (next) first search. Note that several BinaryTree methods use this method to conduct their searches, also violating the enumeration and visibility rules.
Parameters:
  o - the target value



getParent
public BTreeNode getParent()(Code)
Get the parent. CAERFUL, parent is previous node, which may be a sibbling, this is not really a get parent method IMHO.



getRight
public BTreeNode getRight()(Code)
Get the right (child).



getRight
public BTreeNode getRight(boolean all)(Code)
Get the right (child).
Parameters:
  all - respect visibility or not



getTerminalPolicy
public int getTerminalPolicy()(Code)
Get the current terminal policy.



getUnaryDepth
public int getUnaryDepth()(Code)
Return the node's binary (next/child) depth within the tree.



getUnaryParent
public BTreeNode getUnaryParent()(Code)
Get the parent. This returns the REAL parent.



getValue
public Object getValue()(Code)
Return the value.



getVisibility
public int getVisibility()(Code)
Return the visiblility.



hasAncestor
public boolean hasAncestor(BTreeNode btn)(Code)
Return true if the caller has as an ancestor the passed node. If this node and the passed node match, the passed node is not considered an ancestor, so let's be careful out there.
Parameters:
  btn - the proposed ancestor



recursiveDump
public void recursiveDump()(Code)
Debugging aid.



recursiveDump
public void recursiveDump(int dumper)(Code)
Debugging aid.



setChild
protected void setChild(BTreeNode node)(Code)
Set the child (right) of this node to the passed node.
Parameters:
  node - the new child



setDepths
protected void setDepths()(Code)



setDepths
protected void setDepths(int u, int b)(Code)



setLeft
protected void setLeft(BTreeNode node)(Code)
Set the left (next) of this node to the passed node.
Parameters:
  node - the new left



setNext
protected void setNext(BTreeNode node)(Code)
Set the next (left) of this node to the passed node.
Parameters:
  node - the new next



setRight
protected void setRight(BTreeNode node)(Code)
Set the right (child) of this node to the passed node.
Parameters:
  node - the new right



setTerminalPolicy
public void setTerminalPolicy(int terminalPolicy) throws IllegalArgumentException(Code)
Set terminal policy.
Parameters:
  terminalPolicy - terminal policy
exception:
  IllegalArgumentException - if not passed a legal visibility



setVisibility
public void setVisibility(int visibility) throws IllegalArgumentException(Code)
Set visibility.
Parameters:
  visibility - visibility
exception:
  IllegalArgumentException - if not passed a legal visibility



toString
public String toString()(Code)



toStringSummary
public String toStringSummary()(Code)
Debugging aid.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.