1 5 package org.h2.value; 6 7 import java.io.InputStream ; 8 import java.io.Reader ; 9 import java.math.BigDecimal ; 10 import java.sql.Date ; 11 import java.sql.PreparedStatement ; 12 import java.sql.SQLException ; 13 import java.sql.Time ; 14 import java.sql.Timestamp ; 15 16 import org.h2.message.Message; 17 18 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 getSQL() { 32 return "NULL"; 33 } 34 35 public int getType() { 36 return Value.NULL; 37 } 38 39 public String getString() { 40 return null; 41 } 42 43 public Boolean getBoolean() throws SQLException { 44 return null; 45 } 46 47 public Date getDate() throws SQLException { 48 return null; 49 } 50 51 public Time getTime() throws SQLException { 52 return null; 53 } 54 55 public Timestamp getTimestamp() throws SQLException { 56 return null; 57 } 58 59 public byte[] getBytes() throws SQLException { 60 return null; 61 } 62 63 public byte getByte() throws SQLException { 64 return 0; 65 } 66 67 public short getShort() throws SQLException { 68 return 0; 69 } 70 71 public BigDecimal getBigDecimal() throws SQLException { 72 return null; 73 } 74 75 public double getDouble() throws SQLException { 76 return 0.0; 77 } 78 79 public float getFloat() throws SQLException { 80 return 0.0F; 81 } 82 83 public int getInt() throws SQLException { 84 return 0; 85 } 86 87 public long getLong() throws SQLException { 88 return 0; 89 } 90 91 public InputStream getInputStream() throws SQLException { 92 return null; 93 } 94 95 public Reader getReader() throws SQLException { 96 return null; 97 } 98 99 public Value convertTo(int type) throws SQLException { 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 getObject() { 116 return null; 117 } 118 119 public void set(PreparedStatement prep, int parameterIndex) throws SQLException { 120 prep.setNull(parameterIndex, DataType.convertTypeToSQLType(Value.NULL)); 121 } 122 123 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 |