2 Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.core.store;
20 import com.mysql.clusterj.ColumnType;
22 /** Column metadata for ndb columns.
25 public interface Column {
27 /** Get the name of the column.
30 public String getName();
32 /** Get the store type of the column.
34 * @return the store type
36 public ColumnType getType();
38 /** Is this column a primary key column?
39 * @return true if this column is a primary key column
41 public boolean isPrimaryKey();
43 /** Is this column a partition key column?
44 * @return true if this column is a partition key column
46 public boolean isPartitionKey();
48 /** Get the Charset name of the column. This is the value of the
49 * CHARACTER SET parameter in the column definition, or if not specified,
50 * the value of the DEFAULT CHARACTER SET parameter in the table definition.
52 * @return the Charset name
54 public String getCharsetName();
56 /** The charset number.
58 * @return the Charset number
60 public int getCharsetNumber();
62 /** For character columns, get the maximum length in bytes that can be stored
63 * in the column, excluding the prefix, after conversion via the charset.
65 public int getLength();
67 /** For variable size columns, get the length of the prefix (one or two bytes)
68 * that specifies the length of the column data.
69 * @return the prefix length, either one or two bytes for variable sized columns, zero otherwise
71 public int getPrefixLength();
73 /** The column ID, used for scans to compare column values.
75 * @return the column id
77 public int getColumnId();
79 /** The space needed to retrieve the value into memory,
80 * including the length byte or bytes at the beginning of the field.
82 * @return the space required by the column
84 public int getColumnSpace();
86 /** The precision of a decimal column (number of decimal digits before plus after
89 * @return the precision
91 public int getPrecision();
93 /** The scale of a decimal column (the number of decimal digits after the decimal point).
97 public int getScale();
99 /** Decode a byte[] into a String using this column's charset.
101 * @param bytes the byte[] from the database
102 * @return the decoded String
104 public String decode(byte[] bytes);
106 /** Encode a String into a byte[] for storage or comparison.
108 * @param string the String
109 * @return the encoded byte[]
111 public byte[] encode(String string);
113 /** Is this column nullable?
115 * @return true if the column is nullable
117 public boolean getNullable();