Source Code Cross Referenced for ResultNode.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:         * Created on 07-Oct-2004
003:         *
004:         */
005:        package com.jofti.btree;
006:
007:        import java.util.ArrayList;
008:        import java.util.Collection;
009:        import java.util.List;
010:
011:        import com.jofti.exception.JoftiException;
012:        import com.jofti.oswego.concurrent.ReadWriteLock;
013:
014:        /**
015:         * The implementation class for the IResultNode. 
016:         * 
017:         * @author Steve Woodcock
018:         * @version 1.0<br>
019:         */
020:        public class ResultNode implements  INode, IResultNode {
021:
022:            private Object[] entries = null;
023:            private Comparable rightValue;
024:            private int entryNumber;
025:            boolean isDeleted;
026:            NodeLink link;
027:            private INode node;
028:
029:            ResultNode(INode node) {
030:                entries = node.getEntries();
031:                if (entries == null) {
032:                    throw new RuntimeException("entries are null for "
033:                            + node.getRightValue());
034:                }
035:
036:                entryNumber = node.getEntryNumber();
037:                rightValue = node.getRightValue();
038:                isDeleted = node.isDeleted();
039:                link = node.getLinkNode();
040:                this .node = node;
041:            }
042:
043:            /* (non-Javadoc)
044:             * @see com.jofti.btree.Node#getRightValue()
045:             */
046:            public Comparable getRightValue() {
047:                return rightValue;
048:            }
049:
050:            /* (non-Javadoc)
051:             * @see com.jofti.btree.Node#setRightValue(java.lang.Comparable)
052:             */
053:            public void setRightValue(Comparable value) {
054:                throw new UnsupportedOperationException(
055:                        "Modification of node not supported");
056:
057:            }
058:
059:            /* (non-Javadoc)
060:             * @see com.jofti.btree.Node#contains(java.lang.Comparable)
061:             */
062:            public boolean contains(Comparable value) {
063:                if (value == null) {
064:                    return false;
065:                }
066:
067:                return rightValue.compareTo(value) >= 0;
068:            }
069:
070:            /* (non-Javadoc)
071:             * @see com.jofti.btree.Node#insertEntry(com.jofti.btree.NodeEntry)
072:             */
073:            public Object[] insertEntry(NodeEntry entry) throws JoftiException {
074:                throw new UnsupportedOperationException(
075:                        "Modification of node not supported");
076:
077:            }
078:
079:            /* (non-Javadoc)
080:             * @see com.jofti.btree.Node#deleteEntry(com.jofti.btree.NodeEntry)
081:             */
082:            public boolean deleteEntry(NodeEntry entry) {
083:                throw new UnsupportedOperationException(
084:                        "Modification of node not supported");
085:
086:            }
087:
088:            /* (non-Javadoc)
089:             * @see com.jofti.btree.Node#split()
090:             */
091:            public List split() {
092:                throw new UnsupportedOperationException(
093:                        "Modification of node not supported");
094:
095:            }
096:
097:            /* (non-Javadoc)
098:             * @see com.jofti.btree.Node#splitNode()
099:             */
100:            public Node splitNode(Object[] temp) {
101:
102:                throw new UnsupportedOperationException(
103:                        "Modification of node not supported");
104:
105:            }
106:
107:            /* (non-Javadoc)
108:             * @see com.jofti.btree.Node#getEntryNumber()
109:             */
110:            public int getEntryNumber() {
111:
112:                return entryNumber;
113:            }
114:
115:            /* (non-Javadoc)
116:             * @see com.jofti.btree.Node#isUnderFull()
117:             */
118:            public boolean isUnderFull() {
119:
120:                throw new UnsupportedOperationException(
121:                        "Modification of node not supported");
122:
123:            }
124:
125:            /* (non-Javadoc)
126:             * @see com.jofti.btree.Node#isEmpty()
127:             */
128:            public boolean isEmpty() {
129:
130:                return entryNumber == 0;
131:            }
132:
133:            /* (non-Javadoc)
134:             * @see com.jofti.btree.Node#isDeleted()
135:             */
136:            public boolean isDeleted() {
137:
138:                return isDeleted;
139:            }
140:
141:            /* (non-Javadoc)
142:             * @see com.jofti.btree.Node#setDeleted(boolean)
143:             */
144:            public void setDeleted(boolean deleted) {
145:                throw new UnsupportedOperationException(
146:                        "Modification of node not supported");
147:
148:            }
149:
150:            /* (non-Javadoc)
151:             * @see com.jofti.btree.Node#getEntries()
152:             */
153:            public Object[] getEntries() {
154:
155:                return entries;
156:
157:            }
158:
159:            /* (non-Javadoc)
160:             * @see com.jofti.btree.Node#setEntries(java.util.List)
161:             */
162:            public void setEntries(List entries) {
163:                throw new UnsupportedOperationException(
164:                        "Modification of node not supported");
165:
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see com.jofti.btree.Node#getLinkNode()
170:             */
171:            public NodeLink getLinkNode() {
172:
173:                return new ResultNodeLink(link);
174:            }
175:
176:            public IResultNode getNextNode() {
177:                return new ResultNode(link.getNode());
178:            }
179:
180:            /* (non-Javadoc)
181:             * @see com.jofti.btree.Node#setLinkNode(com.jofti.btree.NodeLink)
182:             */
183:            public void setLinkNode(NodeLink node) {
184:                throw new UnsupportedOperationException(
185:                        "Modification of node not supported");
186:
187:            }
188:
189:            /* (non-Javadoc)
190:             * @see com.jofti.btree.INode#getNodeLock()
191:             */
192:            public ReadWriteLock getNodeLock() {
193:
194:                throw new UnsupportedOperationException(
195:                        "Modification of node not supported");
196:
197:            }
198:
199:            /* (non-Javadoc)
200:             * @see com.jofti.btree.IResultNode#getEntry(java.lang.Comparable)
201:             */
202:            public LeafNodeEntry getEntry(Comparable value) {
203:
204:                if (entries.length == 0) {
205:                    return null;
206:                }
207:                // look through list and see if we have a match
208:
209:                return indexedBinaryRetrieve(entries, value);
210:
211:            }
212:
213:            INode getDelegate() {
214:                return node;
215:            }
216:
217:            protected int indexedBinarySearch(Object[] arr1, Object obj) {
218:                int low = 0;
219:                int high = entryNumber - 1;
220:
221:                LeafNodeEntry entry = null;
222:                while (low <= high) {
223:                    int mid = (low + high) >> 1;
224:
225:                    entry = (LeafNodeEntry) arr1[mid];
226:                    int cmp = entry.getValue().compareTo(obj);
227:
228:                    if (cmp < 0)
229:                        low = mid + 1;
230:                    else if (cmp > 0)
231:                        high = mid - 1;
232:                    else
233:                        return mid; // key found
234:                }
235:                return -(low + 1); // key not found
236:            }
237:
238:            protected LeafNodeEntry indexedBinaryRetrieve(Object[] list1,
239:                    Object obj) {
240:                int i = 0;
241:                int size = entryNumber;
242:                for (int j = size - 1; i <= j;) {
243:                    int k = i + j >> 1;
244:                    LeafNodeEntry obj1 = (LeafNodeEntry) list1[k];
245:                    int l = obj1.getValue().compareTo(obj);
246:                    if (l < 0)
247:                        i = k + 1;
248:                    else if (l > 0)
249:                        j = k - 1;
250:                    else
251:                        return obj1;
252:                }
253:
254:                return null;
255:            }
256:
257:            public int hashCode() {
258:                return node.hashCode();
259:            }
260:
261:            /* (non-Javadoc)
262:             * @see com.jofti.btree.IResultNode#getEntriesBefore(java.lang.Comparable)
263:             */
264:            public Collection getEntriesBefore(Comparable value) {
265:
266:                return null;
267:            }
268:
269:            public boolean equals(Object obj) {
270:                if (obj instanceof  IResultNode) {
271:                    return getDelegate() == ((ResultNode) obj).getDelegate();
272:                }
273:                return false;
274:            }
275:
276:            public void setEntries(Object[] entries) {
277:                throw new UnsupportedOperationException(
278:                        "Modification of node not supported");
279:
280:            }
281:
282:            public boolean isLeaf() {
283:                return true;
284:            }
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.