private int _varLenTableIndex;
/** the collating sort order for a text field */
private SortOrder _textSortOrder;
+ /** the code page for a text field (for certain db versions) */
+ private short _textCodePage;
/** the auto number generator for this column (if autonumber column) */
private AutoNumberGenerator _autoNumberGenerator;
/** properties for this column, if any */
} else if(_type.isTextual()) {
// co-located w/ precision/scale
_textSortOrder = readSortOrder(
- buffer, offset + getFormat().OFFSET_COLUMN_PRECISION, getFormat());
+ buffer, offset + getFormat().OFFSET_COLUMN_SORT_ORDER, getFormat());
+ int cpOffset = getFormat().OFFSET_COLUMN_CODE_PAGE;
+ if(cpOffset >= 0) {
+ _textCodePage = buffer.getShort(offset + cpOffset);
+ }
}
byte flags = buffer.get(offset + getFormat().OFFSET_COLUMN_FLAGS);
_variableLength = ((flags & FIXED_LEN_FLAG_MASK) == 0);
public void setTextSortOrder(SortOrder newTextSortOrder) {
_textSortOrder = newTextSortOrder;
}
+
+ public short getTextCodePage() {
+ return _textCodePage;
+ }
public void setLength(short length) {
_columnLength = length;
}
if(_type.isTextual()) {
rtn.append("\n\tText Sort order: " + _textSortOrder);
+ if(_textCodePage > 0) {
+ rtn.append("\n\tText Code Page: " + _textCodePage);
+ }
}
rtn.append("\n\n");
return rtn.toString();
/** Name of the system object that is the parent of all databases */
private static final String SYSTEM_OBJECT_NAME_DATABASES = "Databases";
/** Name of the system object that is the parent of all relationships */
- private static final String SYSTEM_OBJECT_NAME_RELATIONSHIPS = "Relationships";
+ private static final String SYSTEM_OBJECT_NAME_RELATIONSHIPS =
+ "Relationships";
/** Name of the table that contains system access control entries */
private static final String TABLE_SYSTEM_ACES = "MSysACEs";
/** Name of the table that contains table relationships */
private TimeZone _timeZone;
/** language sort order to be used for textual columns */
private Column.SortOrder _defaultSortOrder;
+ /** default code page to be used for textual columns (in some dbs) */
+ private Short _defaultCodePage;
/** the ordering used for table columns */
private Table.ColumnOrder _columnOrder;
/** cache of in-use tables */
public Column.SortOrder getDefaultSortOrder() throws IOException {
if(_defaultSortOrder == null) {
- _pageChannel.readPage(_buffer, 0);
- _defaultSortOrder = Column.readSortOrder(
- _buffer, _format.OFFSET_SORT_ORDER, _format);
+ initRootPageInfo();
}
return _defaultSortOrder;
}
+
+ /**
+ * @return the currently configured database default code page for textual
+ * data (may not be relevant to all database versions)
+ */
+ public short getDefaultCodePage() throws IOException {
+
+ if(_defaultCodePage == null) {
+ initRootPageInfo();
+ }
+ return _defaultCodePage;
+ }
+
+ /**
+ * Reads various config info from the db page 0.
+ */
+ private void initRootPageInfo() throws IOException {
+ _pageChannel.readPage(_buffer, 0);
+ _defaultSortOrder = Column.readSortOrder(
+ _buffer, _format.OFFSET_SORT_ORDER, _format);
+ _defaultCodePage = _buffer.getShort(_format.OFFSET_CODE_PAGE);
+ }
/**
* @return a PropertyMaps instance decoded from the given bytes (always
public final int SIZE_PASSWORD;
public final int OFFSET_SORT_ORDER;
public final int SIZE_SORT_ORDER;
+ public final int OFFSET_CODE_PAGE;
public final int OFFSET_ENCODING_KEY;
public final int OFFSET_NEXT_TABLE_DEF_PAGE;
public final int OFFSET_NUM_ROWS;
public final int OFFSET_COLUMN_NUMBER;
public final int OFFSET_COLUMN_PRECISION;
public final int OFFSET_COLUMN_SCALE;
+ public final int OFFSET_COLUMN_SORT_ORDER;
+ public final int OFFSET_COLUMN_CODE_PAGE;
public final int OFFSET_COLUMN_FLAGS;
public final int OFFSET_COLUMN_COMPRESSED_UNICODE;
public final int OFFSET_COLUMN_LENGTH;
SIZE_PASSWORD = defineSizePassword();
OFFSET_SORT_ORDER = defineOffsetSortOrder();
SIZE_SORT_ORDER = defineSizeSortOrder();
+ OFFSET_CODE_PAGE = defineOffsetCodePage();
OFFSET_ENCODING_KEY = defineOffsetEncodingKey();
OFFSET_NEXT_TABLE_DEF_PAGE = defineOffsetNextTableDefPage();
OFFSET_NUM_ROWS = defineOffsetNumRows();
OFFSET_COLUMN_NUMBER = defineOffsetColumnNumber();
OFFSET_COLUMN_PRECISION = defineOffsetColumnPrecision();
OFFSET_COLUMN_SCALE = defineOffsetColumnScale();
+ OFFSET_COLUMN_SORT_ORDER = defineOffsetColumnSortOrder();
+ OFFSET_COLUMN_CODE_PAGE = defineOffsetColumnCodePage();
OFFSET_COLUMN_FLAGS = defineOffsetColumnFlags();
OFFSET_COLUMN_COMPRESSED_UNICODE = defineOffsetColumnCompressedUnicode();
OFFSET_COLUMN_LENGTH = defineOffsetColumnLength();
protected abstract int defineSizePassword();
protected abstract int defineOffsetSortOrder();
protected abstract int defineSizeSortOrder();
+ protected abstract int defineOffsetCodePage();
protected abstract int defineOffsetEncodingKey();
protected abstract int defineOffsetNextTableDefPage();
protected abstract int defineOffsetNumRows();
protected abstract int defineOffsetColumnNumber();
protected abstract int defineOffsetColumnPrecision();
protected abstract int defineOffsetColumnScale();
+ protected abstract int defineOffsetColumnSortOrder();
+ protected abstract int defineOffsetColumnCodePage();
protected abstract int defineOffsetColumnFlags();
protected abstract int defineOffsetColumnCompressedUnicode();
protected abstract int defineOffsetColumnLength();
@Override
protected int defineSizeSortOrder() { return 2; }
@Override
+ protected int defineOffsetCodePage() { return 60; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }
@Override
protected int defineOffsetColumnScale() { return 12; }
@Override
+ protected int defineOffsetColumnSortOrder() { return 9; }
+ @Override
+ protected int defineOffsetColumnCodePage() { return 11; }
+ @Override
protected int defineOffsetColumnFlags() { return 13; }
@Override
protected int defineOffsetColumnCompressedUnicode() { return 16; }
@Override
protected int defineSizeSortOrder() { return 4; }
@Override
+ protected int defineOffsetCodePage() { return 60; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }
@Override
protected int defineOffsetColumnScale() { return 12; }
@Override
+ protected int defineOffsetColumnSortOrder() { return 11; }
+ @Override
+ protected int defineOffsetColumnCodePage() { return -1; }
+ @Override
protected int defineOffsetColumnFlags() { return 15; }
@Override
protected int defineOffsetColumnCompressedUnicode() { return 16; }