File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\value\ValueNull.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.value;
8
9 import java.io.InputStream;
10 import java.io.Reader;
11 import java.math.BigDecimal;
12 import java.sql.Date;
13 import java.sql.PreparedStatement;
14 import java.sql.SQLException;
15 import java.sql.Time;
16 import java.sql.Timestamp;
17
18 import org.h2.message.DbException;
19
20 /**
21 * Implementation of NULL. NULL is not a regular data type.
22 */
23 public class ValueNull extends Value {
24
25 /**
26 * The main NULL instance.
27 */
28 public static final ValueNull INSTANCE = new ValueNull();
29
30 /**
31 * This special instance is used as a marker for deleted entries in a map.
32 * It should not be used anywhere else.
33 */
34 public static final ValueNull DELETED = new ValueNull();
35
36 /**
37 * The precision of NULL.
38 */
39 private static final int PRECISION = 1;
40
41 /**
42 * The display size of the textual representation of NULL.
43 */
44 private static final int DISPLAY_SIZE = 4;
45
46 private ValueNull() {
47 // don't allow construction
48 }
49
50 public String getSQL() {
51 return "NULL";
52 }
53
54 public int getType() {
55 return Value.NULL;
56 }
57
58 public String getString() {
59 return null;
60 }
61
62 public Boolean getBoolean() {
63 return null;
64 }
65
66 public Date getDate() {
67 return null;
68 }
69
70 public Time getTime() {
71 return null;
72 }
73
74 public Timestamp getTimestamp() {
75 return null;
76 }
77
78 public byte[] getBytes() {
79 return null;
80 }
81
82 public byte getByte() {
83 return 0;
84 }
85
86 public short getShort() {
87 return 0;
88 }
89
90 public BigDecimal getBigDecimal() {
91 return null;
92 }
93
94 public double getDouble() {
95 return 0.0;
96 }
97
98 public float getFloat() {
99 return 0.0F;
100 }
101
102 public int getInt() {
103 return 0;
104 }
105
106 public long getLong() {
107 return 0;
108 }
109
110 public InputStream getInputStream() {
111 return null;
112 }
113
114 public Reader getReader() {
115 return null;
116 }
117
118 public Value convertTo(int type) {
119 return this;
120 }
121
122 protected int compareSecure(Value v, CompareMode mode) {
123 throw DbException.throwInternalError("compare null");
124 }
125
126 public long getPrecision() {
127 return PRECISION;
128 }
129
130 public int hashCode() {
131 return 0;
132 }
133
134 public Object getObject() {
135 return null;
136 }
137
138 public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
139 prep.setNull(parameterIndex, DataType.convertTypeToSQLType(Value.NULL));
140 }
141
142 public int getDisplaySize() {
143 return DISPLAY_SIZE;
144 }
145
146 public boolean equals(Object other) {
147 return other == this;
148 }
149
150 }
151