01: /*
02: * ColumnData.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.storage;
13:
14: import workbench.db.ColumnIdentifier;
15:
16: /**
17: * A wrapper class do hold the current value of a column
18: * and it's definition.
19: *
20: * The column definition is represented by a {@link workbench.db.ColumnIdentifier}
21: *
22: * The value can be any Java object
23: * This is used by {@link workbench.storage.DmlStatement} to store the values
24: * when creating PreparedStatements
25: *
26: * @author support@sql-workbench.net
27: */
28: public class ColumnData {
29: final private Object data;
30: final private ColumnIdentifier id;
31:
32: /**
33: * Creates a new instance of ColumnData
34: *
35: * @param value The current value of the column
36: * @param colid The definition of the column
37: */
38: public ColumnData(Object value, ColumnIdentifier colid) {
39: data = value;
40: id = colid;
41: }
42:
43: public Object getValue() {
44: return data;
45: }
46:
47: public ColumnIdentifier getIdentifier() {
48: return id;
49: }
50:
51: public boolean isNull() {
52: return (data == null);
53: }
54:
55: @Override
56: public boolean equals(Object obj) {
57: if (obj == null)
58: return false;
59: if (obj instanceof ColumnData) {
60: final ColumnData other = (ColumnData) obj;
61: return this .id.equals(other.id);
62: } else if (obj instanceof ColumnIdentifier) {
63: return this .id.equals((ColumnIdentifier) obj);
64: }
65: return false;
66: }
67:
68: @Override
69: public int hashCode() {
70: return id.hashCode();
71: }
72:
73: public String toString() {
74: return id.getColumnName() + " = "
75: + (data == null ? "NULL" : data.toString());
76: }
77:
78: }
|