1 24 25 package org.objectweb.cjdbc.common.sql.schema; 26 27 import java.io.Serializable ; 28 import java.sql.Types ; 29 30 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 31 32 42 public class DatabaseColumn implements Serializable 43 { 44 private static final long serialVersionUID = 1118853825798791836L; 45 46 47 private String name; 48 49 53 private boolean isUnique; 54 55 56 private int type; 57 58 65 public DatabaseColumn(String name, boolean isUnique) 66 { 67 this(name, isUnique, Types.NULL); 68 } 69 70 79 public DatabaseColumn(String name, boolean isUnique, int type) 80 { 81 if (name == null) 82 throw new IllegalArgumentException ( 83 "Illegal null column name in DatabaseColumn constructor"); 84 85 this.name = name; 86 this.isUnique = isUnique; 87 this.type = type; 88 } 89 90 95 public String getName() 96 { 97 return name; 98 } 99 100 107 public boolean isUnique() 108 { 109 return isUnique; 110 } 111 112 118 public void setIsUnique(boolean bool) 119 { 120 isUnique = bool; 121 } 122 123 130 public int getType() 131 { 132 return type; 133 } 134 135 142 public boolean equals(Object other) 143 { 144 if ((other == null) || !(other instanceof DatabaseColumn)) 145 return false; 146 147 DatabaseColumn c = (DatabaseColumn) other; 148 return (isUnique == c.isUnique()) && name.equals(c.getName()) 149 && (type == c.getType()); 150 } 151 152 159 public boolean equalsIgnoreType(Object other) 160 { 161 if ((other == null) || !(other instanceof DatabaseColumn)) 162 return false; 163 164 DatabaseColumn c = (DatabaseColumn) other; 165 return (isUnique == c.isUnique()) && name.equals(c.getName()); 166 } 167 168 173 public String getXml() 174 { 175 StringBuffer info = new StringBuffer (); 176 info.append("<" + DatabasesXmlTags.ELT_DatabaseColumn + " " 177 + DatabasesXmlTags.ATT_columnName + "=\"" + name + "\" " 178 + DatabasesXmlTags.ATT_isUnique + "=\"" + isUnique + "\">"); 179 info.append("</" + DatabasesXmlTags.ELT_DatabaseColumn + ">"); 180 return info.toString(); 181 } 182 } 183 | Popular Tags |