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


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.access.StorableFormatId
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.impl.store.access;
023:
024:        import org.apache.derby.iapi.reference.SQLState;
025:
026:        import org.apache.derby.iapi.services.io.ArrayInputStream;
027:
028:        import org.apache.derby.iapi.services.sanity.SanityManager;
029:
030:        import org.apache.derby.iapi.services.io.Storable;
031:
032:        import org.apache.derby.iapi.services.io.FormatIdUtil;
033:        import org.apache.derby.iapi.services.io.StoredFormatIds;
034:
035:        import org.apache.derby.iapi.error.StandardException;
036:
037:        import org.apache.derby.iapi.types.DataValueDescriptor;
038:
039:        import org.apache.derby.iapi.types.Orderable;
040:
041:        import org.apache.derby.iapi.services.cache.ClassSize;
042:
043:        import org.apache.derby.iapi.types.DataType;
044:
045:        import java.sql.ResultSet;
046:        import java.sql.SQLException;
047:
048:        import java.io.ObjectOutput;
049:        import java.io.ObjectInput;
050:        import java.io.IOException;
051:
052:        public class StorableFormatId extends DataType {
053:
054:            private int format_id;
055:
056:            private static final int BASE_MEMORY_USAGE = ClassSize
057:                    .estimateBaseFromCatalog(StorableFormatId.class);
058:
059:            public int estimateMemoryUsage() {
060:                return BASE_MEMORY_USAGE;
061:            }
062:
063:            /* Constructors: */
064:
065:            public StorableFormatId() {
066:            }
067:
068:            public StorableFormatId(int value) {
069:                this .format_id = value;
070:            }
071:
072:            /* Private methods */
073:
074:            public int getValue() {
075:                // RESOLVE (mikem) just temporary; value could be null
076:                return format_id;
077:            }
078:
079:            public void setValue(int input_value) {
080:                this .format_id = input_value;
081:            }
082:
083:            /*
084:             * Storable interface, implies Externalizable, TypedFormat
085:             */
086:
087:            /**
088:            	Return my format identifier.
089:
090:            	@see org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
091:             */
092:            public int getTypeFormatId() {
093:                return StoredFormatIds.ACCESS_FORMAT_ID;
094:            }
095:
096:            public boolean isNull() {
097:                return false;
098:            }
099:
100:            public void writeExternal(ObjectOutput out) throws IOException {
101:                FormatIdUtil.writeFormatIdInteger(out, format_id);
102:            }
103:
104:            /** @see java.io.Externalizable#readExternal */
105:            public void readExternal(ObjectInput in) throws IOException {
106:                format_id = FormatIdUtil.readFormatIdInteger(in);
107:            }
108:
109:            public void readExternalFromArray(ArrayInputStream in)
110:                    throws IOException {
111:                format_id = FormatIdUtil.readFormatIdInteger(in);
112:            }
113:
114:            public void restoreToNull() {
115:                format_id = 0;
116:            }
117:
118:            /**************************************************************************
119:             * Public Methods implementing DataValueDescriptor interface.
120:             **************************************************************************
121:             */
122:
123:            /**
124:             * Gets the length of the data value.  The meaning of this is
125:             * implementation-dependent.  For string types, it is the number of
126:             * characters in the string.  For numeric types, it is the number of
127:             * bytes used to store the number.  This is the actual length
128:             * of this value, not the length of the type it was defined as.
129:             * For example, a VARCHAR value may be shorter than the declared
130:             * VARCHAR (maximum) length.
131:             *
132:             * @return	The length of the data value
133:             *
134:             * @exception StandardException   On error
135:             * 
136:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getLength
137:             */
138:            public int getLength() throws StandardException {
139:                throw (StandardException
140:                        .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
141:            }
142:
143:            /**
144:             * Gets the value in the data value descriptor as a String.
145:             * Throws an exception if the data value is not a string.
146:             *
147:             * @return	The data value as a String.
148:             *
149:             * @exception StandardException   Thrown on error
150:             *
151:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getString
152:             */
153:            public String getString() throws StandardException {
154:                throw (StandardException
155:                        .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
156:            }
157:
158:            /**
159:             * Gets the value in the data value descriptor as a Java Object.
160:             * The type of the Object will be the Java object type corresponding
161:             * to the data value's SQL type. JDBC defines a mapping between Java
162:             * object types and SQL types - we will allow that to be extended
163:             * through user type definitions. Throws an exception if the data
164:             * value is not an object (yeah, right).
165:             *
166:             * @return	The data value as an Object.
167:             *
168:             * @exception StandardException   Thrown on error
169:             *
170:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getObject
171:             */
172:            public Object getObject() throws StandardException {
173:                return (this );
174:            }
175:
176:            /**
177:             * <U>Shallow copy</U>. 
178:             * <p> 
179:             * Clone the DataValueDescriptor and copy its contents.
180:             * We clone the data value wrapper (e.g. SQLDecimal)
181:             * and reuse its contents (the underlying BigDecimal).
182:             * The resultant DataValueDescriptor will point to the same
183:             * value as the original DataValueDescriptor (unless the value
184:             * is a primitive type, e.g. SQLInteger/integer).
185:             *
186:             * @return A clone of the DataValueDescriptor reusing its contents.
187:             *
188:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getClone
189:             */
190:            public DataValueDescriptor getClone() {
191:                if (SanityManager.DEBUG)
192:                    SanityManager.THROWASSERT("Not implemented!.");
193:
194:                return (null);
195:            }
196:
197:            /**
198:             * Get a new null value of the same type as this data value.
199:             *
200:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getNewNull
201:             */
202:            public DataValueDescriptor getNewNull() {
203:                if (SanityManager.DEBUG)
204:                    SanityManager.THROWASSERT("Not implemented!.");
205:
206:                return (null);
207:            }
208:
209:            /**
210:             * Set the value based on the value for the specified DataValueDescriptor
211:             * from the specified ResultSet.
212:             *
213:             * @param resultSet		The specified ResultSet.
214:             * @param colNumber		The 1-based column # into the resultSet.
215:             * @param isNullable	Whether or not the column is nullable
216:             *						(No need to call wasNull() if not)
217:             * 
218:             * @exception StandardException		Thrown on error
219:             * @exception SQLException		Error accessing the result set
220:             *
221:             * @see org.apache.derby.iapi.types.DataValueDescriptor#setValueFromResultSet
222:             */
223:            public void setValueFromResultSet(ResultSet resultSet,
224:                    int colNumber, boolean isNullable)
225:                    throws StandardException, SQLException {
226:                throw (StandardException
227:                        .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
228:            }
229:
230:            /**
231:             * Set the value of this DataValueDescriptor from another.
232:             *
233:             * @param theValue	The Date value to set this DataValueDescriptor to
234:             *
235:             * @see org.apache.derby.iapi.types.DataValueDescriptor#setValue
236:             */
237:            protected void setFrom(DataValueDescriptor theValue)
238:                    throws StandardException {
239:                throw (StandardException
240:                        .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
241:            }
242:
243:            /**
244:             * Get the SQL name of the datatype
245:             *
246:             * @return	The SQL name of the datatype
247:             *
248:             * @see org.apache.derby.iapi.types.DataValueDescriptor#getTypeName
249:             */
250:            public String getTypeName() {
251:                if (SanityManager.DEBUG)
252:                    SanityManager.THROWASSERT("Not implemented!.");
253:
254:                return (null);
255:            }
256:
257:            /**
258:             * Compare this Orderable with a given Orderable for the purpose of
259:             * index positioning.  This method treats nulls as ordered values -
260:             * that is, it treats SQL null as equal to null and less than all
261:             * other values.
262:             *
263:             * @param other		The Orderable to compare this one to.
264:             *
265:             * @return  <0 - this Orderable is less than other.
266:             * 			 0 - this Orderable equals other.
267:             *			>0 - this Orderable is greater than other.
268:             *
269:             *			The code should not explicitly look for -1, or 1.
270:             *
271:             * @exception StandardException		Thrown on error
272:             *
273:             * @see DataValueDescriptor#compare
274:             */
275:            public int compare(DataValueDescriptor other)
276:                    throws StandardException {
277:                throw (StandardException
278:                        .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
279:            }
280:
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.