19 package com.mysql.clusterj.bindings;
21 import java.util.HashMap;
24 import com.mysql.cluster.ndbj.NdbColumn;
25 import com.mysql.cluster.ndbj.NdbTable;
27 import com.mysql.clusterj.ClusterJDatastoreException;
28 import com.mysql.clusterj.ClusterJFatalInternalException;
30 import com.mysql.clusterj.core.store.Column;
32 import com.mysql.clusterj.core.util.I18NHelper;
33 import com.mysql.clusterj.core.util.Logger;
34 import com.mysql.clusterj.core.util.LoggerFactoryService;
39 class ColumnImpl
implements Column {
42 static final I18NHelper local = I18NHelper
43 .getInstance(ColumnImpl.class);
46 static final Logger logger = LoggerFactoryService.getFactory()
47 .getInstance(ColumnImpl.class);
54 charsetMap.put(
"latin1",
"windows-1252");
55 charsetMap.put(
"utf8",
"UTF-8");
56 charsetMap.put(
"sjis",
"SJIS");
57 charsetMap.put(
"big5",
"big5");
61 private NdbColumn column;
64 private String nativeCharsetName;
67 private String charsetName;
70 private Column.Type columnType;
75 private int prefixLength;
83 this.columnName = column.getName();
85 this.tableName = table.
getName();
86 this.columnType = convertType(this.column.getType());
87 switch(column.getType()) {
107 private void mapCharsetName() {
108 this.nativeCharsetName = column.getCharsetName();
109 this.charsetName = charsetMap.get(nativeCharsetName);
110 if (charsetName == null) {
111 throw new ClusterJDatastoreException(
112 local.message(
"ERR_Unknown_Charset_Name",
113 tableName, columnName, nativeCharsetName));
121 public Column.Type getType() {
125 private Type convertType(com.mysql.cluster.ndbj.NdbColumn.Type
type) {
127 case Bigint:
return Column.Type.Bigint;
128 case Bigunsigned:
return Column.Type.Bigunsigned;
129 case Binary:
return Column.Type.Binary;
130 case Bit:
return Column.Type.Bit;
131 case Blob:
return Column.Type.Blob;
132 case Char:
return Column.Type.Char;
133 case Date:
return Column.Type.Date;
134 case Datetime:
return Column.Type.Datetime;
135 case Decimal:
return Column.Type.Decimal;
136 case Decimalunsigned:
return Column.Type.Decimalunsigned;
137 case Double:
return Column.Type.Double;
138 case Float:
return Column.Type.Float;
139 case Int:
return Column.Type.Int;
140 case Longvarbinary:
return Column.Type.Longvarbinary;
141 case Longvarchar:
return Column.Type.Longvarchar;
142 case Mediumint:
return Column.Type.Mediumint;
143 case Mediumunsigned:
return Column.Type.Mediumunsigned;
144 case Olddecimal:
return Column.Type.Olddecimal;
145 case Olddecimalunsigned:
return Column.Type.Olddecimalunsigned;
146 case Smallint:
return Column.Type.Smallint;
147 case Smallunsigned:
return Column.Type.Smallunsigned;
148 case Text:
return Column.Type.Text;
149 case Time:
return Column.Type.Time;
150 case Timestamp:
return Column.Type.Timestamp;
151 case Tinyint:
return Column.Type.Tinyint;
152 case Tinyunsigned:
return Column.Type.Tinyunsigned;
153 case Undefined:
return Column.Type.Undefined;
154 case Unsigned:
return Column.Type.Unsigned;
155 case Varbinary:
return Column.Type.Varbinary;
156 case Varchar:
return Column.Type.Varchar;
157 case Year:
return Column.Type.Year;
158 default:
throw new ClusterJFatalInternalException(
159 local.message(
"ERR_Unknown_Column_Type",
160 table.
getName(), column.getName(),
type.toString()));
164 public String getCharsetName() {
168 public int getPrefixLength() {
169 if (prefixLength != 0) {
172 throw new ClusterJFatalInternalException(local.message(
173 "ERR_Prefix_Length_Not_Defined", tableName, columnName));
177 public int getColumnId() {
178 throw new ClusterJFatalInternalException(
"Not implemented");
181 public int getColumnSpace() {
182 throw new ClusterJFatalInternalException(
"Not implemented");
185 public int getPrecision() {
186 throw new ClusterJFatalInternalException(
"Not implemented");
189 public int getScale() {
190 throw new ClusterJFatalInternalException(
"Not implemented");