1 package net.jaekl.cfb.db;
3 import net.jaekl.cfb.util.Util;
5 // Copyright (C) 2015 Christian Jaekl
9 CHAR, INTEGER, TIMESTAMPTZ, VARCHAR
20 public Column(String name, Type type, int width, Null canBeNull)
28 public String getName() { return m_name; }
29 public Type getType() { return m_type; }
30 public int getWidth() { return m_width; }
31 public Null getNull() { return m_null; }
33 // Create a column based on an array of Objects
34 // Input format: { name, type, width, can_be_null }
35 public static Column construct(Object[] spec) {
37 assert(4 == spec.length);
38 assert(spec[0] instanceof String);
39 assert(spec[1] instanceof Type);
40 assert(spec[2] instanceof Number);
41 assert(spec[3] instanceof Null);
43 String name = (String)(spec[0]);
44 Type type = (Type)(spec[1]);
45 Number width = (Number)(spec[2]);
46 Null canBeNull = (Null)(spec[3]);
48 return new Column(name, type, width.intValue(), canBeNull);
52 public boolean equals(Object obj)
57 if (! (obj instanceof Column)) {
60 Column other = (Column)obj;
62 if (! Util.objsAreEqual(this.getName(), other.getName())) {
65 if (! Util.objsAreEqual(this.getType(), other.getType())) {
68 if (this.getWidth() != other.getWidth()) {
71 if (! Util.objsAreEqual(this.getNull(), other.getNull())) {
79 public int hashCode() {
80 int code = Util.objHashCode(getName())
81 ^ Util.objHashCode(getType())
83 ^ Util.objHashCode(getNull());