Source Code Cross Referenced for LeafNodeEntry.java in  » Search-Engine » Jofti » com » jofti » btree » 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 » Search Engine » Jofti » com.jofti.btree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * NodeEntry.java
003:         *
004:         * Created on 25 May 2003, 09:36
005:         */
006:
007:        package com.jofti.btree;
008:
009:        import java.util.Set;
010:
011:        import com.jofti.util.FastSet;
012:
013:        /**
014:         * The leaf node entry contains a value, qand a set of uniqueIds that are the ids passed into the node for that value. <br>
015:         * Adding a new id,value pair will result in the id being added to the set and the value remaining unchanged.<p>
016:         * 
017:         *
018:         * @author Steve Woodcock
019:         * @version 1.14<br>
020:         */
021:        public class LeafNodeEntry implements  NodeEntry {
022:
023:            /**
024:             * 
025:             */
026:            private static final long serialVersionUID = -181573341072167495L;
027:
028:            public Set uniqueIdSet = null;
029:
030:            public Comparable value = null;
031:
032:            protected volatile int hashCode = 0;
033:
034:            /** Creates a new instance of NodeEntry */
035:            public LeafNodeEntry() {
036:            }
037:
038:            public LeafNodeEntry(Object uniqueId, Comparable value) {
039:                uniqueIdSet = new FastSet();
040:                uniqueIdSet.add(uniqueId);
041:                this .value = value;
042:            }
043:
044:            /** Getter for property uniqueIdList.
045:             * @return Value of property uniqueIdList.
046:             *
047:             */
048:            Set getUniqueIdSet() {
049:                if (uniqueIdSet == null) {
050:                    return new FastSet();
051:                }
052:                return uniqueIdSet;
053:            }
054:
055:            /**
056:             * Return the size of the Set.
057:             * @return
058:             */
059:            public int getUniqueIdSize() {
060:                if (uniqueIdSet == null) {
061:                    return 0;
062:                }
063:                return uniqueIdSet.size();
064:            }
065:
066:            /** Setter for property uniqueIdList.
067:             * @param uniqueIdList New value of property uniqueIdList.
068:             *
069:             */
070:            void setUniqueIdSet(Set uniqueIdList) {
071:                if (uniqueIdSet == null) {
072:                    uniqueIdSet = new FastSet();
073:                }
074:                this .uniqueIdSet.clear();
075:                this .uniqueIdSet.addAll(uniqueIdList);
076:            }
077:
078:            /**
079:             * Adds an object to the existing Set.
080:             * @param uniqueId
081:             */
082:            public void addUniqueId(Object uniqueId) {
083:                if (uniqueIdSet == null) {
084:                    uniqueIdSet = new FastSet();
085:                }
086:                uniqueIdSet.add(uniqueId);
087:            }
088:
089:            /**
090:             * Adds the elements of a set to the existing set.
091:             * @param uniqueIdList
092:             */
093:            void addUniqueIdSet(Set uniqueIdList) {
094:                this .uniqueIdSet.addAll(uniqueIdList);
095:            }
096:
097:            void removeUniqueId(Object Id) {
098:                if (uniqueIdSet == null) {
099:                    return;
100:                }
101:                uniqueIdSet.remove(Id);
102:            }
103:
104:            void removeAllIds(Set idSet) {
105:                if (uniqueIdSet == null) {
106:                    return;
107:                }
108:                uniqueIdSet.removeAll(idSet);
109:            }
110:
111:            /** Getter for property value.
112:             * @return Value of property value.
113:             *
114:             */
115:            public Comparable getValue() {
116:                return value;
117:            }
118:
119:            /** Setter for property value.
120:             * @param value New value of property value.
121:             *
122:             */
123:
124:            public void setValue(Comparable value) {
125:                this .value = value;
126:            }
127:
128:            public String toString() {
129:                StringBuffer buf = new StringBuffer();
130:                buf.append("value:" + value);
131:                buf.append(",");
132:                buf.append("uniqueIds:" + uniqueIdSet);
133:
134:                return buf.toString();
135:            }
136:
137:            /** Compares this object with the specified object for order.  Returns a
138:             * negative integer, zero, or a positive integer as this object is less
139:             * than, equal to, or greater than the specified object.<p>
140:             *
141:             * In the foregoing description, the notation
142:             * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
143:             * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
144:             * <tt>0</tt>, or <tt>1</tt> according to whether the value of <i>expression</i>
145:             * is negative, zero or positive.
146:             *
147:             * The implementor must ensure <tt>sgn(x.compareTo(y)) ==
148:             * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>.  (This
149:             * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
150:             * <tt>y.compareTo(x)</tt> throws an exception.)<p>
151:             *
152:             * The implementor must also ensure that the relation is transitive:
153:             * <tt>(x.compareTo(y)&gt;0 &amp;&amp; y.compareTo(z)&gt;0)</tt> implies
154:             * <tt>x.compareTo(z)&gt;0</tt>.<p>
155:             *
156:             * Finally, the implementer must ensure that <tt>x.compareTo(y)==0</tt>
157:             * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
158:             * all <tt>z</tt>.<p>
159:             *
160:             * It is strongly recommended, but <i>not</i> strictly required that
161:             * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.  Generally speaking, any
162:             * class that implements the <tt>Comparable</tt> interface and violates
163:             * this condition should clearly indicate this fact.  The recommended
164:             * language is "Note: this class has a natural ordering that is
165:             * inconsistent with equals."
166:             *
167:             * @param   o the Object to be compared.
168:             * @return  a negative integer, zero, or a positive integer as this object
169:             * 		is less than, equal to, or greater than the specified object.
170:             *
171:             * @throws ClassCastException if the specified object's type prevents it
172:             *         from being compared to this Object.
173:             *
174:             */
175:            public int compareTo(Object o) {
176:
177:                if (o instanceof  LeafNodeEntry) {
178:                    return value.compareTo(((LeafNodeEntry) o).value);
179:                }
180:                throw new IllegalArgumentException(
181:                        "Cannot compare with a non leafnode");
182:
183:            }
184:
185:            /* (non-Javadoc)
186:             * @see java.lang.Object#equals(java.lang.Object)
187:             */
188:            public boolean equals(Object o) {
189:
190:                if (o instanceof  LeafNodeEntry) {
191:                    return value.compareTo(((LeafNodeEntry) o).value) == 0;
192:                } else {
193:                    return false;
194:                }
195:            }
196:
197:            /* (non-Javadoc)
198:             * @see java.lang.Object#hashCode()
199:             */
200:            public int hashCode() {
201:                if (hashCode == 0) {
202:                    int result = 17;
203:                    result = 37 * result + value.hashCode();
204:                    hashCode = result;
205:                }
206:                return hashCode;
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.