Debian Codegraph @

src/main/org/h2/value/ValueNull.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.value;
7
8 import java.io.InputStream;
9 import java.io.Reader;
10 import java.math.BigDecimal;
11
12 import org.h2.engine.CastDataProvider;
13 import org.h2.message.DbException;
14
15 /**
16 * Implementation of NULL. NULL is not a regular data type.
17 */
18 public final class ValueNull extends Value {
19
20 /**
21 * The main NULL instance.
22 */
23 public static final ValueNull INSTANCE = new ValueNull();
24
25 /**
26 * The precision of NULL.
27 */
28 static final int PRECISION = 1;
29
30 /**
31 * The display size of the textual representation of NULL.
32 */
33 static final int DISPLAY_SIZE = 4;
34
35 private ValueNull() {
36 // don't allow construction
37 }
38
39 @Override
40 public StringBuilder getSQL(StringBuilder builder, int sqlFlags) {
41 return builder.append("NULL");
42 }
43
44 @Override
45 public TypeInfo getType() {
46 return TypeInfo.TYPE_NULL;
47 }
48
49 @Override
50 public int getValueType() {
51 return NULL;
52 }
53
54 @Override
55 public int getMemory() {
56 // Singleton value
57 return 0;
58 }
59
60 @Override
61 public String getString() {
62 return null;
63 }
64
65 @Override
66 public Reader getReader() {
67 return null;
68 }
69
70 @Override
71 public Reader getReader(long oneBasedOffset, long length) {
72 return null;
73 }
74
75 @Override
76 public byte[] getBytes() {
77 return null;
78 }
79
80 @Override
81 public InputStream getInputStream() {
82 return null;
83 }
84
85 @Override
86 public InputStream getInputStream(long oneBasedOffset, long length) {
87 return null;
88 }
89
90 @Override
91 public boolean getBoolean() {
92 throw DbException.getInternalError();
93 }
94
95 @Override
96 public byte getByte() {
97 throw DbException.getInternalError();
98 }
99
100 @Override
101 public short getShort() {
102 throw DbException.getInternalError();
103 }
104
105 @Override
106 public int getInt() {
107 throw DbException.getInternalError();
108 }
109
110 @Override
111 public long getLong() {
112 throw DbException.getInternalError();
113 }
114
115 @Override
116 public BigDecimal getBigDecimal() {
117 return null;
118 }
119
120 @Override
121 public float getFloat() {
122 throw DbException.getInternalError();
123 }
124
125 @Override
126 public double getDouble() {
127 throw DbException.getInternalError();
128 }
129
130 @Override
131 public int compareTypeSafe(Value v, CompareMode mode, CastDataProvider provider) {
132 throw DbException.getInternalError("compare null");
133 }
134
135 @Override
136 public boolean containsNull() {
137 return true;
138 }
139
140 @Override
141 public int hashCode() {
142 return 0;
143 }
144
145 @Override
146 public boolean equals(Object other) {
147 return other == this;
148 }
149
150 }