Source Code Cross Referenced for RowInputBinary.java in  » Database-DBMS » hsql » org » hsqldb » rowio » 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 » Database DBMS » hsql » org.hsqldb.rowio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001-2005, The HSQL Development Group
002:         * All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * Redistributions of source code must retain the above copyright notice, this
008:         * list of conditions and the following disclaimer.
009:         *
010:         * Redistributions in binary form must reproduce the above copyright notice,
011:         * this list of conditions and the following disclaimer in the documentation
012:         * and/or other materials provided with the distribution.
013:         *
014:         * Neither the name of the HSQL Development Group nor the names of its
015:         * contributors may be used to endorse or promote products derived from this
016:         * software without specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
022:         * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
026:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:         */
030:
031:        package org.hsqldb.rowio;
032:
033:        import java.io.IOException;
034:        import java.math.BigDecimal;
035:        import java.math.BigInteger;
036:        import java.sql.Date;
037:        import java.sql.Time;
038:        import java.sql.Timestamp;
039:
040:        import org.hsqldb.HsqlDateTime;
041:        import org.hsqldb.HsqlException;
042:        import org.hsqldb.lib.StringConverter;
043:        import org.hsqldb.store.ValuePool;
044:        import org.hsqldb.types.Binary;
045:        import org.hsqldb.types.JavaObject;
046:
047:        /**
048:         *  Provides methods for reading the data for a row from a
049:         *  byte array. The format of data is that used for storage of cached
050:         *  tables by v.1.6.x databases, apart from strings.
051:         *
052:         * @author sqlbob@users (RMP)
053:         * @author fredt@users
054:         * @version 1.7.2
055:         * @since 1.7.0
056:         */
057:        public class RowInputBinary extends RowInputBase implements 
058:                org.hsqldb.rowio.RowInputInterface {
059:
060:            private RowOutputBinary out;
061:
062:            public RowInputBinary() {
063:                super ();
064:            }
065:
066:            public RowInputBinary(byte[] buf) {
067:                super (buf);
068:            }
069:
070:            /**
071:             * uses the byte[] buffer from out. At each reset, the buffer is set
072:             * to the current one for out.
073:             */
074:            public RowInputBinary(RowOutputBinary out) {
075:
076:                super (out.getBuffer());
077:
078:                this .out = out;
079:            }
080:
081:            protected byte[] readByteArray() throws IOException {
082:
083:                byte[] b = new byte[readInt()];
084:
085:                readFully(b);
086:
087:                return b;
088:            }
089:
090:            public int readType() throws IOException {
091:                return readShort();
092:            }
093:
094:            public short readShortData() throws IOException {
095:                return readShort();
096:            }
097:
098:            public int readIntData() throws IOException {
099:                return readInt();
100:            }
101:
102:            public long readLongData() throws IOException {
103:                return readLong();
104:            }
105:
106:            public String readString() throws IOException {
107:
108:                int length = readInt();
109:                String s = StringConverter.readUTF(buf, pos, length);
110:
111:                s = ValuePool.getString(s);
112:                pos += length;
113:
114:                return s;
115:            }
116:
117:            protected boolean checkNull() throws IOException {
118:
119:                int b = readByte();
120:
121:                return b == 0 ? true : false;
122:            }
123:
124:            protected String readChar(int type) throws IOException {
125:                return readString();
126:            }
127:
128:            protected Integer readSmallint() throws IOException, HsqlException {
129:                return ValuePool.getInt(readShort());
130:            }
131:
132:            protected Integer readInteger() throws IOException, HsqlException {
133:                return ValuePool.getInt(readInt());
134:            }
135:
136:            protected Long readBigint() throws IOException, HsqlException {
137:                return ValuePool.getLong(readLong());
138:            }
139:
140:            protected Double readReal(int type) throws IOException,
141:                    HsqlException {
142:                return ValuePool.getDouble(readLong());
143:            }
144:
145:            protected BigDecimal readDecimal() throws IOException,
146:                    HsqlException {
147:
148:                byte[] bytes = readByteArray();
149:                int scale = readInt();
150:                BigInteger bigint = new BigInteger(bytes);
151:
152:                return ValuePool.getBigDecimal(new BigDecimal(bigint, scale));
153:            }
154:
155:            protected Boolean readBit() throws IOException, HsqlException {
156:                return readBoolean() ? Boolean.TRUE : Boolean.FALSE;
157:            }
158:
159:            protected Time readTime() throws IOException, HsqlException {
160:                return new Time(HsqlDateTime.getNormalisedTime(readLong()));
161:            }
162:
163:            protected Date readDate() throws IOException, HsqlException {
164:
165:                long date = HsqlDateTime.getNormalisedDate(readLong());
166:
167:                return ValuePool.getDate(date);
168:            }
169:
170:            protected Timestamp readTimestamp() throws IOException,
171:                    HsqlException {
172:                return HsqlDateTime.timestampValue(readLong(), readInt());
173:            }
174:
175:            protected Object readOther() throws IOException, HsqlException {
176:                return new JavaObject(readByteArray());
177:            }
178:
179:            protected Binary readBinary(int type) throws IOException,
180:                    HsqlException {
181:                return new Binary(readByteArray(), false);
182:            }
183:
184:            /**
185:             *  Used to reset the row, ready for Result data to be written into the
186:             *  byte[] buffer by an external routine.
187:             *
188:             */
189:            public void resetRow(int rowsize) {
190:
191:                if (out != null) {
192:                    out.reset(rowsize);
193:
194:                    buf = out.getBuffer();
195:                }
196:
197:                super .reset();
198:            }
199:
200:            /**
201:             *  Used to reset the row, ready for a new db row to be written into the
202:             *  byte[] buffer by an external routine.
203:             *
204:             */
205:            public void resetRow(int filepos, int rowsize) throws IOException {
206:
207:                if (out != null) {
208:                    out.reset(rowsize);
209:
210:                    buf = out.getBuffer();
211:                }
212:
213:                super.resetRow(filepos, rowsize);
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.