01: /*
02:
03: Derby - Class org.apache.derby.catalog.types.DecimalTypeIdImpl
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.catalog.types;
23:
24: import org.apache.derby.iapi.services.io.StoredFormatIds;
25: import java.io.ObjectOutput;
26: import java.io.ObjectInput;
27: import java.io.IOException;
28: import java.sql.Types;
29:
30: public class DecimalTypeIdImpl extends BaseTypeIdImpl {
31: /* this class is needed because writeexternal for this class stores
32: extra information; when the object is sent over the wire the niladic
33: constructor is first called and then we call the readExternal method.
34: the readExternal needs to know the formatId atleast for decimal types
35: to read the extra information.
36: */
37: public DecimalTypeIdImpl() {
38: super (StoredFormatIds.DECIMAL_TYPE_ID_IMPL);
39: }
40:
41: /**
42: * Read this object from a stream of stored objects.
43: *
44: * @param in read this.
45: *
46: * @exception IOException thrown on error
47: * @exception ClassNotFoundException thrown on error
48: */
49: public void readExternal(ObjectInput in) throws IOException,
50: ClassNotFoundException {
51: boolean isNumeric = in.readBoolean();
52:
53: super .readExternal(in);
54:
55: if (isNumeric) {
56: setNumericType();
57: }
58:
59: }
60:
61: /**
62: * Write this object to a stream of stored objects.
63: *
64: * @param out write bytes here.
65: *
66: * @exception IOException thrown on error
67: */
68: public void writeExternal(ObjectOutput out) throws IOException {
69: out.writeBoolean(JDBCTypeId == Types.NUMERIC);
70:
71: super .writeExternal(out);
72: }
73:
74: public void setNumericType() {
75: SQLTypeName = "NUMERIC";
76: JDBCTypeId = Types.NUMERIC;
77: }
78: }
|