Source Code Cross Referenced for DatabaseEntry.java in  » JMX » je » com » sleepycat » je » 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 » JMX » je » com.sleepycat.je 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: DatabaseEntry.java,v 1.41.2.3 2008/01/07 15:14:07 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je;
010:
011:        import com.sleepycat.je.tree.TreeUtils;
012:        import com.sleepycat.util.keyrange.KeyRange;
013:
014:        /**
015:         * Javadoc for this public class is generated
016:         * via the doc templates in the doc_src directory.
017:         */
018:        public class DatabaseEntry {
019:
020:            /* Currently, JE stores all data records as byte array */
021:            private byte[] data;
022:            private int dlen = 0;
023:            private int doff = 0;
024:            private int offset = 0;
025:            private int size = 0;
026:            private boolean partial = false;
027:
028:            /* The maximum number of bytes to show when toString() is called. */
029:            /* FindBugs - ignore not "final" since a user can set this. */
030:            public static int MAX_DUMP_BYTES = 100;
031:
032:            public String toString() {
033:                StringBuffer sb = new StringBuffer("<DatabaseEntry");
034:                sb.append(" dlen=\"").append(dlen);
035:                sb.append("\" doff=\"").append(doff);
036:                sb.append("\" doff=\"").append(doff);
037:                sb.append("\" offset=\"").append(offset);
038:                sb.append("\" size=\"").append(size);
039:                sb.append("\" data=\"").append(dumpData());
040:                if ((size - 1) > MAX_DUMP_BYTES) {
041:                    sb.append(" ... ").append(
042:                            (size - MAX_DUMP_BYTES) + " bytes not shown ");
043:                }
044:                sb.append("\"/>");
045:                return sb.toString();
046:            }
047:
048:            /*
049:             * Constructors
050:             */
051:
052:            /**
053:             * Javadoc for this public method is generated via
054:             * the doc templates in the doc_src directory.
055:             */
056:            public DatabaseEntry() {
057:            }
058:
059:            /**
060:             * Javadoc for this public method is generated via
061:             * the doc templates in the doc_src directory.
062:             */
063:            public DatabaseEntry(byte[] data) {
064:                this .data = data;
065:                if (data != null) {
066:                    this .size = data.length;
067:                }
068:            }
069:
070:            /**
071:             * Javadoc for this public method is generated via
072:             * the doc templates in the doc_src directory.
073:             */
074:            public DatabaseEntry(byte[] data, int offset, int size) {
075:                this .data = data;
076:                this .offset = offset;
077:                this .size = size;
078:            }
079:
080:            /*
081:             * Accessors
082:             */
083:
084:            /**
085:             * Javadoc for this public method is generated via
086:             * the doc templates in the doc_src directory.
087:             */
088:            public byte[] getData() {
089:                return data;
090:            }
091:
092:            /**
093:             * Javadoc for this public method is generated via
094:             * the doc templates in the doc_src directory.
095:             */
096:            public void setData(byte[] data) {
097:                this .data = data;
098:                offset = 0;
099:                size = (data == null) ? 0 : data.length;
100:            }
101:
102:            /**
103:             * Javadoc for this public method is generated via
104:             * the doc templates in the doc_src directory.
105:             */
106:            public void setData(byte[] data, int offset, int size) {
107:                this .data = data;
108:                this .offset = offset;
109:                this .size = size;
110:            }
111:
112:            /**
113:             * Javadoc for this public method is generated via
114:             * the doc templates in the doc_src directory.
115:             */
116:            public void setPartial(int doff, int dlen, boolean partial) {
117:                setPartialOffset(doff);
118:                setPartialLength(dlen);
119:                setPartial(partial);
120:            }
121:
122:            /**
123:             * Javadoc for this public method is generated via
124:             * the doc templates in the doc_src directory.
125:             */
126:            public int getPartialLength() {
127:                return dlen;
128:            }
129:
130:            /**
131:             * Javadoc for this public method is generated via
132:             * the doc templates in the doc_src directory.
133:             */
134:            public void setPartialLength(int dlen) {
135:                this .dlen = dlen;
136:            }
137:
138:            /**
139:             * Javadoc for this public method is generated via
140:             * the doc templates in the doc_src directory.
141:             */
142:            public int getPartialOffset() {
143:                return doff;
144:            }
145:
146:            /**
147:             * Javadoc for this public method is generated via
148:             * the doc templates in the doc_src directory.
149:             */
150:            public void setPartialOffset(int doff) {
151:                this .doff = doff;
152:            }
153:
154:            /**
155:             * Javadoc for this public method is generated via
156:             * the doc templates in the doc_src directory.
157:             */
158:            public boolean getPartial() {
159:                return partial;
160:            }
161:
162:            /**
163:             * Javadoc for this public method is generated via
164:             * the doc templates in the doc_src directory.
165:             */
166:            public void setPartial(boolean partial) {
167:                this .partial = partial;
168:            }
169:
170:            /**
171:             * Javadoc for this public method is generated via
172:             * the doc templates in the doc_src directory.
173:             */
174:            public int getOffset() {
175:                return offset;
176:            }
177:
178:            /**
179:             * Javadoc for this public method is generated via
180:             * the doc templates in the doc_src directory.
181:             */
182:            public void setOffset(int offset) {
183:                this .offset = offset;
184:            }
185:
186:            /**
187:             * Javadoc for this public method is generated via
188:             * the doc templates in the doc_src directory.
189:             */
190:            public int getSize() {
191:                return size;
192:            }
193:
194:            /**
195:             * Javadoc for this public method is generated via
196:             * the doc templates in the doc_src directory.
197:             */
198:            public void setSize(int size) {
199:                this .size = size;
200:            }
201:
202:            /**
203:             * Dumps the data as a byte array, for tracing purposes
204:             */
205:            String dumpData() {
206:                return TreeUtils.dumpByteArray(KeyRange.getByteArray(this ,
207:                        MAX_DUMP_BYTES));
208:            }
209:
210:            /**
211:             * Compares the data of two entries for byte-by-byte equality.
212:             *
213:             * <p>In either entry, if the offset is non-zero or the size is not equal
214:             * to the data array length, then only the data bounded by these values is
215:             * compared.  The data array length and offset need not be the same in both
216:             * entries for them to be considered equal.</p>
217:             *
218:             * <p>If the data array is null in one entry, then to be considered equal
219:             * both entries must have a null data array.</p>
220:             *
221:             * <p>If the partial property is set in either entry, then to be considered
222:             * equal both entries must have the same partial properties: partial,
223:             * partialOffset and partialLength.
224:             */
225:            public boolean equals(Object o) {
226:                if (!(o instanceof  DatabaseEntry)) {
227:                    return false;
228:                }
229:                DatabaseEntry e = (DatabaseEntry) o;
230:                if (partial || e.partial) {
231:                    if (partial != e.partial || dlen != e.dlen
232:                            || doff != e.doff) {
233:                        return false;
234:                    }
235:                }
236:                if (data == null && e.data == null) {
237:                    return true;
238:                }
239:                if (data == null || e.data == null) {
240:                    return false;
241:                }
242:                if (size != e.size) {
243:                    return false;
244:                }
245:                for (int i = 0; i < size; i += 1) {
246:                    if (data[offset + i] != e.data[e.offset + i]) {
247:                        return false;
248:                    }
249:                }
250:                return true;
251:            }
252:
253:            /**
254:             * Returns a hash code based on the data value.
255:             */
256:            public int hashCode() {
257:                int hash = 0;
258:                if (data != null) {
259:                    for (int i = 0; i < size; i += 1) {
260:                        hash += data[offset + i];
261:                    }
262:                }
263:                return hash;
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.