Source Code Cross Referenced for SQLRef.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » types » 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 » db derby 10.2 » org.apache.derby.iapi.types 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.types.SQLRef
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.types;
023:
024:        import org.apache.derby.iapi.services.io.ArrayInputStream;
025:
026:        import org.apache.derby.iapi.error.StandardException;
027:
028:        import org.apache.derby.iapi.types.DataTypeDescriptor;
029:        import org.apache.derby.iapi.types.DataValueDescriptor;
030:        import org.apache.derby.iapi.types.TypeId;
031:        import org.apache.derby.iapi.reference.SQLState;
032:
033:        import org.apache.derby.iapi.types.DataValueDescriptor;
034:
035:        import org.apache.derby.iapi.types.RowLocation;
036:        import org.apache.derby.iapi.types.Orderable;
037:
038:        import org.apache.derby.iapi.services.io.StoredFormatIds;
039:
040:        import org.apache.derby.iapi.services.sanity.SanityManager;
041:
042:        import org.apache.derby.catalog.TypeDescriptor;
043:
044:        import org.apache.derby.iapi.types.DataType;
045:        import org.apache.derby.iapi.types.RefDataValue;
046:        import org.apache.derby.iapi.services.cache.ClassSize;
047:
048:        import java.io.ObjectOutput;
049:        import java.io.ObjectInput;
050:        import java.io.IOException;
051:
052:        import java.sql.ResultSet;
053:        import java.sql.PreparedStatement;
054:
055:        public class SQLRef extends DataType implements  RefDataValue {
056:            protected RowLocation value;
057:
058:            private static final int BASE_MEMORY_USAGE = ClassSize
059:                    .estimateBaseFromCatalog(SQLRef.class);
060:
061:            public int estimateMemoryUsage() {
062:                int sz = BASE_MEMORY_USAGE;
063:                if (null != value)
064:                    sz += value.estimateMemoryUsage();
065:                return sz;
066:            } // end of estimateMemoryUsage
067:
068:            /*
069:             ** DataValueDescriptor interface
070:             ** (mostly implemented in DataType)
071:             */
072:
073:            public String getString() {
074:                if (value != null) {
075:                    return value.toString();
076:                } else {
077:                    return null;
078:                }
079:            }
080:
081:            public Object getObject() {
082:                return value;
083:            }
084:
085:            protected void setFrom(DataValueDescriptor theValue)
086:                    throws StandardException {
087:
088:                if (theValue.isNull())
089:                    setToNull();
090:                else
091:                    value = (RowLocation) theValue.getObject();
092:            }
093:
094:            public int getLength() {
095:                return TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN;
096:            }
097:
098:            /* this is for DataType's error generator */
099:            public String getTypeName() {
100:                return TypeId.REF_NAME;
101:            }
102:
103:            /*
104:             * Storable interface, implies Externalizable, TypedFormat
105:             */
106:
107:            /**
108:            	Return my format identifier.
109:
110:            	@see org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
111:             */
112:            public int getTypeFormatId() {
113:                return StoredFormatIds.SQL_REF_ID;
114:            }
115:
116:            public boolean isNull() {
117:                return (value == null);
118:            }
119:
120:            public void writeExternal(ObjectOutput out) throws IOException {
121:
122:                if (SanityManager.DEBUG)
123:                    SanityManager
124:                            .ASSERT(value != null,
125:                                    "writeExternal() is not supposed to be called for null values.");
126:
127:                out.writeObject(value);
128:            }
129:
130:            /**
131:             * @see java.io.Externalizable#readExternal
132:             *
133:             * @exception IOException	Thrown on error reading the object
134:             * @exception ClassNotFoundException	Thrown if the class of the object
135:             *										read from the stream can't be found
136:             *										(not likely, since it's supposed to
137:             *										be SQLRef).
138:             */
139:            public void readExternal(ObjectInput in) throws IOException,
140:                    ClassNotFoundException {
141:                value = (RowLocation) in.readObject();
142:            }
143:
144:            public void readExternalFromArray(ArrayInputStream in)
145:                    throws IOException, ClassNotFoundException {
146:                value = (RowLocation) in.readObject();
147:            }
148:
149:            /**
150:             * @see org.apache.derby.iapi.services.io.Storable#restoreToNull
151:             */
152:
153:            public void restoreToNull() {
154:                value = null;
155:            }
156:
157:            /*
158:             ** Orderable interface
159:             */
160:
161:            /** @exception StandardException	Thrown on error */
162:            public boolean compare(int op, DataValueDescriptor other,
163:                    boolean orderedNulls, boolean unknownRV)
164:                    throws StandardException {
165:                return value.compare(op, ((SQLRef) other).value, orderedNulls,
166:                        unknownRV);
167:            }
168:
169:            /** @exception StandardException	Thrown on error */
170:            public int compare(DataValueDescriptor other)
171:                    throws StandardException {
172:                return value.compare(((SQLRef) other).value);
173:            }
174:
175:            /*
176:             * DataValueDescriptor interface
177:             */
178:
179:            /** @see DataValueDescriptor#getClone */
180:            public DataValueDescriptor getClone() {
181:                /* In order to avoid a throws clause nightmare, we only call
182:                 * the constructors which do not have a throws clause.
183:                 *
184:                 * Clone the underlying RowLocation, if possible, so that we
185:                 * don't clobber the value in the clone.
186:                 */
187:                if (value == null)
188:                    return new SQLRef();
189:                else
190:                    return new SQLRef((RowLocation) value.cloneObject());
191:            }
192:
193:            /**
194:             * @see DataValueDescriptor#getNewNull
195:             */
196:            public DataValueDescriptor getNewNull() {
197:                return new SQLRef();
198:            }
199:
200:            /** 
201:             * @see DataValueDescriptor#setValueFromResultSet 
202:             *
203:             */
204:            public void setValueFromResultSet(ResultSet resultSet,
205:                    int colNumber, boolean isNullable) {
206:                if (SanityManager.DEBUG)
207:                    SanityManager
208:                            .THROWASSERT("setValueFromResultSet() is not supposed to be called for SQLRef.");
209:            }
210:
211:            public void setInto(PreparedStatement ps, int position) {
212:                if (SanityManager.DEBUG)
213:                    SanityManager
214:                            .THROWASSERT("setValueInto(PreparedStatement) is not supposed to be called for SQLRef.");
215:            }
216:
217:            /*
218:             ** Class interface
219:             */
220:
221:            /*
222:             ** Constructors
223:             */
224:
225:            public SQLRef() {
226:            }
227:
228:            public SQLRef(RowLocation rowLocation) {
229:                value = rowLocation;
230:            }
231:
232:            public void setValue(RowLocation rowLocation) {
233:                value = rowLocation;
234:            }
235:
236:            /*
237:             ** String display of value
238:             */
239:
240:            public String toString() {
241:                if (value == null)
242:                    return "NULL";
243:                else
244:                    return value.toString();
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.