001: /*
002:
003: Derby - Class org.apache.derby.impl.store.access.conglomerate.GenericConglomerate
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.conglomerate;
023:
024: import org.apache.derby.iapi.reference.SQLState;
025:
026: import org.apache.derby.iapi.services.sanity.SanityManager;
027:
028: import org.apache.derby.iapi.error.StandardException;
029:
030: import org.apache.derby.iapi.store.access.conglomerate.Conglomerate;
031:
032: import org.apache.derby.iapi.types.DataValueDescriptor;
033: import org.apache.derby.iapi.types.Orderable;
034:
035: import org.apache.derby.iapi.types.DataType;
036:
037: import java.sql.ResultSet;
038: import java.sql.SQLException;
039:
040: /**
041:
042: A class that implements the methods shared across all implementations of
043: the Conglomerate interface.
044:
045: **/
046:
047: public abstract class GenericConglomerate extends DataType implements
048: Conglomerate {
049:
050: /**************************************************************************
051: * Public Methods implementing DataValueDescriptor interface.
052: **************************************************************************
053: */
054:
055: /**
056: * Gets the length of the data value. The meaning of this is
057: * implementation-dependent. For string types, it is the number of
058: * characters in the string. For numeric types, it is the number of
059: * bytes used to store the number. This is the actual length
060: * of this value, not the length of the type it was defined as.
061: * For example, a VARCHAR value may be shorter than the declared
062: * VARCHAR (maximum) length.
063: *
064: * @return The length of the data value
065: *
066: * @exception StandardException On error
067: *
068: * @see org.apache.derby.iapi.types.DataValueDescriptor#getLength
069: */
070: public int getLength() throws StandardException {
071: throw (StandardException
072: .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
073: }
074:
075: /**
076: * Gets the value in the data value descriptor as a String.
077: * Throws an exception if the data value is not a string.
078: *
079: * @return The data value as a String.
080: *
081: * @exception StandardException Thrown on error
082: *
083: * @see org.apache.derby.iapi.types.DataValueDescriptor#getString
084: */
085: public String getString() throws StandardException {
086: throw (StandardException
087: .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
088: }
089:
090: /**
091: * Gets the value in the data value descriptor as a Java Object.
092: * The type of the Object will be the Java object type corresponding
093: * to the data value's SQL type. JDBC defines a mapping between Java
094: * object types and SQL types - we will allow that to be extended
095: * through user type definitions. Throws an exception if the data
096: * value is not an object (yeah, right).
097: *
098: * @return The data value as an Object.
099: *
100: * @exception StandardException Thrown on error
101: *
102: * @see org.apache.derby.iapi.types.DataValueDescriptor#getObject
103: */
104: public Object getObject() throws StandardException {
105: return (this );
106: }
107:
108: /**
109: * <U>Shallow copy</U>.
110: * <p>
111: * Clone the DataValueDescriptor and copy its contents.
112: * We clone the data value wrapper (e.g. SQLDecimal)
113: * and reuse its contents (the underlying BigDecimal).
114: * The resultant DataValueDescriptor will point to the same
115: * value as the original DataValueDescriptor (unless the value
116: * is a primitive type, e.g. SQLInteger/integer).
117: *
118: * @return A clone of the DataValueDescriptor reusing its contents.
119: *
120: * @see org.apache.derby.iapi.types.DataValueDescriptor#getClone
121: */
122: public DataValueDescriptor getClone() {
123: if (SanityManager.DEBUG)
124: SanityManager.THROWASSERT("Not implemented!.");
125:
126: return (null);
127: }
128:
129: /**
130: * Get a new null value of the same type as this data value.
131: *
132: * @see org.apache.derby.iapi.types.DataValueDescriptor#getNewNull
133: */
134: public DataValueDescriptor getNewNull() {
135: if (SanityManager.DEBUG)
136: SanityManager.THROWASSERT("Not implemented!.");
137:
138: return (null);
139: }
140:
141: /**
142: * Set the value based on the value for the specified DataValueDescriptor
143: * from the specified ResultSet.
144: *
145: * @param resultSet The specified ResultSet.
146: * @param colNumber The 1-based column # into the resultSet.
147: * @param isNullable Whether or not the column is nullable
148: * (No need to call wasNull() if not)
149: *
150: * @exception StandardException Thrown on error
151: * @exception SQLException Error accessing the result set
152: *
153: * @see org.apache.derby.iapi.types.DataValueDescriptor#setValueFromResultSet
154: */
155: public void setValueFromResultSet(ResultSet resultSet,
156: int colNumber, boolean isNullable)
157: throws StandardException, SQLException {
158: throw (StandardException
159: .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
160: }
161:
162: /**
163: * Set the value of this DataValueDescriptor from another.
164: *
165: * @param theValue The Date value to set this DataValueDescriptor to
166: *
167: * @see org.apache.derby.iapi.types.DataValueDescriptor#setValue
168: */
169: protected void setFrom(DataValueDescriptor theValue)
170: throws StandardException {
171: throw (StandardException
172: .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
173: }
174:
175: /**
176: * Get the SQL name of the datatype
177: *
178: * @return The SQL name of the datatype
179: *
180: * @see org.apache.derby.iapi.types.DataValueDescriptor#getTypeName
181: */
182: public String getTypeName() {
183: if (SanityManager.DEBUG)
184: SanityManager.THROWASSERT("Not implemented!.");
185:
186: return (null);
187: }
188:
189: /**
190: * Compare this Orderable with a given Orderable for the purpose of
191: * index positioning. This method treats nulls as ordered values -
192: * that is, it treats SQL null as equal to null and less than all
193: * other values.
194: *
195: * @param other The Orderable to compare this one to.
196: *
197: * @return <0 - this Orderable is less than other.
198: * 0 - this Orderable equals other.
199: * >0 - this Orderable is greater than other.
200: *
201: * The code should not explicitly look for -1, or 1.
202: *
203: * @exception StandardException Thrown on error
204: *
205: * @see DataValueDescriptor#compare
206: */
207: public int compare(DataValueDescriptor other)
208: throws StandardException {
209: throw (StandardException
210: .newException(SQLState.HEAP_UNIMPLEMENTED_FEATURE));
211: }
212: }
|