KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > value > ValueNull


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.value;
6
7 import java.io.InputStream JavaDoc;
8 import java.io.Reader JavaDoc;
9 import java.math.BigDecimal JavaDoc;
10 import java.sql.Date JavaDoc;
11 import java.sql.PreparedStatement JavaDoc;
12 import java.sql.SQLException JavaDoc;
13 import java.sql.Time JavaDoc;
14 import java.sql.Timestamp JavaDoc;
15
16 import org.h2.message.Message;
17
18 /**
19  * @author Thomas
20  */

21 public class ValueNull extends Value {
22
23     public static final ValueNull INSTANCE = new ValueNull();
24     public static final ValueNull DELETED = new ValueNull();
25
26     public static final int PRECISION = 1;
27
28     private ValueNull() {
29     }
30
31     public String JavaDoc getSQL() {
32         return "NULL";
33     }
34
35     public int getType() {
36         return Value.NULL;
37     }
38
39     public String JavaDoc getString() {
40         return null;
41     }
42
43     public Boolean JavaDoc getBoolean() throws SQLException JavaDoc {
44         return null;
45     }
46
47     public Date JavaDoc getDate() throws SQLException JavaDoc {
48         return null;
49     }
50
51     public Time JavaDoc getTime() throws SQLException JavaDoc {
52         return null;
53     }
54
55     public Timestamp JavaDoc getTimestamp() throws SQLException JavaDoc {
56         return null;
57     }
58
59     public byte[] getBytes() throws SQLException JavaDoc {
60         return null;
61     }
62
63     public byte getByte() throws SQLException JavaDoc {
64         return 0;
65     }
66
67     public short getShort() throws SQLException JavaDoc {
68         return 0;
69     }
70
71     public BigDecimal JavaDoc getBigDecimal() throws SQLException JavaDoc {
72         return null;
73     }
74
75     public double getDouble() throws SQLException JavaDoc {
76         return 0.0;
77     }
78
79     public float getFloat() throws SQLException JavaDoc {
80         return 0.0F;
81     }
82
83     public int getInt() throws SQLException JavaDoc {
84         return 0;
85     }
86
87     public long getLong() throws SQLException JavaDoc {
88         return 0;
89     }
90
91     public InputStream JavaDoc getInputStream() throws SQLException JavaDoc {
92         return null;
93     }
94
95     public Reader JavaDoc getReader() throws SQLException JavaDoc {
96         return null;
97     }
98
99     public Value convertTo(int type) throws SQLException JavaDoc {
100         return this;
101     }
102
103     protected int compareSecure(Value v, CompareMode mode) {
104         throw Message.getInternalError("compare null");
105     }
106
107     public long getPrecision() {
108         return PRECISION;
109     }
110
111     public int hashCode() {
112         return 0;
113     }
114
115     public Object JavaDoc getObject() {
116         return null;
117     }
118
119     public void set(PreparedStatement JavaDoc prep, int parameterIndex) throws SQLException JavaDoc {
120         prep.setNull(parameterIndex, DataType.convertTypeToSQLType(Value.NULL));
121     }
122
123 // public String getJavaString() {
124
// return "null";
125
// }
126

127     public int getDisplaySize() {
128         return "null".length();
129     }
130
131     protected boolean isEqual(Value v) {
132         return v == ValueNull.INSTANCE;
133     }
134
135 }
136
Popular Tags