01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.value;
07:
08: import java.sql.PreparedStatement;
09: import java.sql.SQLException;
10:
11: import org.h2.util.StringUtils;
12:
13: /**
14: * The base class for all ValueString* classes.
15: */
16: abstract class ValueStringBase extends Value {
17:
18: /**
19: * The string data.
20: */
21: protected final String value;
22:
23: protected ValueStringBase(String value) {
24: this .value = value;
25: }
26:
27: public String getSQL() {
28: return StringUtils.quoteStringSQL(value);
29: }
30:
31: public String getString() {
32: return value;
33: }
34:
35: public long getPrecision() {
36: return value.length();
37: }
38:
39: public Object getObject() {
40: return value;
41: }
42:
43: public void set(PreparedStatement prep, int parameterIndex)
44: throws SQLException {
45: prep.setString(parameterIndex, value);
46: }
47:
48: public int getDisplaySize() {
49: return value.length();
50: }
51:
52: public abstract Value convertPrecision(long precision);
53:
54: public int getMemory() {
55: return value.length() * 2 + 30;
56: }
57:
58: }
|