/** the auto number generator for this column (if autonumber column) */
private final AutoNumberGenerator _autoNumberGenerator;
/** additional information specific to complex columns */
- private ComplexColumnInfo<? extends ComplexValue> _complexInfo;
+ private final ComplexColumnInfo<? extends ComplexValue> _complexInfo;
/** properties for this column, if any */
private PropertyMap _props;
_displayIndex = colNumber;
_fixedDataOffset = fixedOffset;
_varLenTableIndex = varLenIndex;
+ _complexInfo = null;
}
/**
// load complex info
if(_type == DataType.COMPLEX_TYPE) {
- _complexInfo = ComplexColumnInfo.create(this, buffer, offset);
- }
+ _complexInfo = ComplexColumnSupport.create(this, buffer, offset);
+ } else {
+ _complexInfo = null;
+ }
}
/**
return _textInfo._sortOrder;
}
- /**
- * @usage _advanced_method_
- */
- public void setTextSortOrder(SortOrder newTextSortOrder) {
- modifyTextInfo();
- _textInfo._sortOrder = newTextSortOrder;
- }
-
/**
* @usage _intermediate_method_
*/
--- /dev/null
+/*
+Copyright (c) 2013 James Ahlborn
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+USA
+*/
+
+package com.healthmarketscience.jackcess;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.healthmarketscience.jackcess.complex.AttachmentColumnInfo;
+import com.healthmarketscience.jackcess.complex.ComplexColumnInfo;
+import com.healthmarketscience.jackcess.complex.ComplexValue;
+import com.healthmarketscience.jackcess.complex.MultiValueColumnInfo;
+import com.healthmarketscience.jackcess.complex.UnsupportedColumnInfo;
+import com.healthmarketscience.jackcess.complex.VersionHistoryColumnInfo;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author James Ahlborn
+ */
+public class ComplexColumnSupport
+{
+ private static final Log LOG = LogFactory.getLog(ComplexColumnSupport.class);
+
+ private static final String COL_COMPLEX_TYPE_OBJECT_ID = "ComplexTypeObjectID";
+ private static final String COL_TABLE_ID = "ConceptualTableID";
+ private static final String COL_FLAT_TABLE_ID = "FlatTableID";
+
+ private static final Set<DataType> MULTI_VALUE_TYPES = EnumSet.of(
+ DataType.BYTE, DataType.INT, DataType.LONG, DataType.FLOAT,
+ DataType.DOUBLE, DataType.GUID, DataType.NUMERIC, DataType.TEXT);
+
+
+ /**
+ * Creates a ComplexColumnInfo for a complex column.
+ */
+ public static ComplexColumnInfo<? extends ComplexValue> create(
+ ColumnImpl column, ByteBuffer buffer, int offset)
+ throws IOException
+ {
+ int complexTypeId = buffer.getInt(
+ offset + column.getFormat().OFFSET_COLUMN_COMPLEX_ID);
+
+ DatabaseImpl db = column.getDatabase();
+ TableImpl complexColumns = db.getSystemComplexColumns();
+ IndexCursor cursor = CursorBuilder.createCursor(
+ complexColumns, complexColumns.getPrimaryKeyIndex());
+ if(!cursor.findFirstRowByEntry(complexTypeId)) {
+ throw new IOException(
+ "Could not find complex column info for complex column with id " +
+ complexTypeId);
+ }
+ Map<String,Object> cColRow = cursor.getCurrentRow();
+ int tableId = (Integer)cColRow.get(COL_TABLE_ID);
+ if(tableId != column.getTable().getTableDefPageNumber()) {
+ throw new IOException(
+ "Found complex column for table " + tableId + " but expected table " +
+ column.getTable().getTableDefPageNumber());
+ }
+ int flatTableId = (Integer)cColRow.get(COL_FLAT_TABLE_ID);
+ int typeObjId = (Integer)cColRow.get(COL_COMPLEX_TYPE_OBJECT_ID);
+
+ TableImpl typeObjTable = db.getTable(typeObjId);
+ TableImpl flatTable = db.getTable(flatTableId);
+
+ if((typeObjTable == null) || (flatTable == null)) {
+ throw new IOException(
+ "Could not find supporting tables (" + typeObjId + ", " + flatTableId
+ + ") for complex column with id " + complexTypeId);
+ }
+
+ // we inspect the structore of the "type table" to determine what kind of
+ // complex info we are dealing with
+ if(isMultiValueColumn(typeObjTable)) {
+ return new MultiValueColumnInfo(column, complexTypeId, typeObjTable,
+ flatTable);
+ } else if(isAttachmentColumn(typeObjTable)) {
+ return new AttachmentColumnInfo(column, complexTypeId, typeObjTable,
+ flatTable);
+ } else if(isVersionHistoryColumn(typeObjTable)) {
+ return new VersionHistoryColumnInfo(column, complexTypeId, typeObjTable,
+ flatTable);
+ }
+
+ LOG.warn("Unsupported complex column type " + typeObjTable.getName());
+ return new UnsupportedColumnInfo(column, complexTypeId, typeObjTable,
+ flatTable);
+ }
+
+
+ public static boolean isMultiValueColumn(Table typeObjTable) {
+ // if we found a single value of a "simple" type, then we are dealing with
+ // a multi-value column
+ List<? extends Column> typeCols = typeObjTable.getColumns();
+ return ((typeCols.size() == 1) &&
+ MULTI_VALUE_TYPES.contains(typeCols.get(0).getType()));
+ }
+
+ public static boolean isAttachmentColumn(Table typeObjTable) {
+ // attachment data has these columns FileURL(MEMO), FileName(TEXT),
+ // FileType(TEXT), FileData(OLE), FileTimeStamp(SHORT_DATE_TIME),
+ // FileFlags(LONG)
+ List<? extends Column> typeCols = typeObjTable.getColumns();
+ if(typeCols.size() < 6) {
+ return false;
+ }
+
+ int numMemo = 0;
+ int numText = 0;
+ int numDate = 0;
+ int numOle= 0;
+ int numLong = 0;
+
+ for(Column col : typeCols) {
+ switch(col.getType()) {
+ case TEXT:
+ ++numText;
+ break;
+ case LONG:
+ ++numLong;
+ break;
+ case SHORT_DATE_TIME:
+ ++numDate;
+ break;
+ case OLE:
+ ++numOle;
+ break;
+ case MEMO:
+ ++numMemo;
+ break;
+ default:
+ // ignore
+ }
+ }
+
+ // be flexible, allow for extra columns...
+ return((numMemo >= 1) && (numText >= 2) && (numOle >= 1) &&
+ (numDate >= 1) && (numLong >= 1));
+ }
+
+ public static boolean isVersionHistoryColumn(Table typeObjTable) {
+ // version history data has these columns <value>(MEMO),
+ // <modified>(SHORT_DATE_TIME)
+ List<? extends Column> typeCols = typeObjTable.getColumns();
+ if(typeCols.size() < 2) {
+ return false;
+ }
+
+ int numMemo = 0;
+ int numDate = 0;
+
+ for(Column col : typeCols) {
+ switch(col.getType()) {
+ case SHORT_DATE_TIME:
+ ++numDate;
+ break;
+ case MEMO:
+ ++numMemo;
+ break;
+ default:
+ // ignore
+ }
+ }
+
+ // be flexible, allow for extra columns...
+ return((numMemo >= 1) && (numDate >= 1));
+ }
+}
import java.io.IOException;
import java.util.Date;
-import java.util.List;
import java.util.Map;
import com.healthmarketscience.jackcess.ByteUtil;
-import com.healthmarketscience.jackcess.ColumnImpl;
-import com.healthmarketscience.jackcess.TableImpl;
+import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Table;
/**
private static final String FILE_NAME_COL_NAME = "FileName";
private static final String FILE_TYPE_COL_NAME = "FileType";
- private final ColumnImpl _fileUrlCol;
- private final ColumnImpl _fileNameCol;
- private final ColumnImpl _fileTypeCol;
- private final ColumnImpl _fileDataCol;
- private final ColumnImpl _fileTimeStampCol;
- private final ColumnImpl _fileFlagsCol;
+ private final Column _fileUrlCol;
+ private final Column _fileNameCol;
+ private final Column _fileTypeCol;
+ private final Column _fileDataCol;
+ private final Column _fileTimeStampCol;
+ private final Column _fileFlagsCol;
- public AttachmentColumnInfo(ColumnImpl column, int complexId,
- TableImpl typeObjTable, TableImpl flatTable)
+ public AttachmentColumnInfo(Column column, int complexId,
+ Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
- ColumnImpl fileUrlCol = null;
- ColumnImpl fileNameCol = null;
- ColumnImpl fileTypeCol = null;
- ColumnImpl fileDataCol = null;
- ColumnImpl fileTimeStampCol = null;
- ColumnImpl fileFlagsCol = null;
+ Column fileUrlCol = null;
+ Column fileNameCol = null;
+ Column fileTypeCol = null;
+ Column fileDataCol = null;
+ Column fileTimeStampCol = null;
+ Column fileFlagsCol = null;
- for(ColumnImpl col : getTypeColumns()) {
+ for(Column col : getTypeColumns()) {
switch(col.getType()) {
case TEXT:
if(FILE_NAME_COL_NAME.equalsIgnoreCase(col.getName())) {
_fileFlagsCol = fileFlagsCol;
}
- public ColumnImpl getFileUrlColumn() {
+ public Column getFileUrlColumn() {
return _fileUrlCol;
}
- public ColumnImpl getFileNameColumn() {
+ public Column getFileNameColumn() {
return _fileNameCol;
}
- public ColumnImpl getFileTypeColumn() {
+ public Column getFileTypeColumn() {
return _fileTypeCol;
}
- public ColumnImpl getFileDataColumn() {
+ public Column getFileDataColumn() {
return _fileDataCol;
}
- public ColumnImpl getFileTimeStampColumn() {
+ public Column getFileTimeStampColumn() {
return _fileTimeStampCol;
}
- public ColumnImpl getFileFlagsColumn() {
+ public Column getFileFlagsColumn() {
return _fileFlagsCol;
}
}
- public static boolean isAttachmentColumn(TableImpl typeObjTable) {
- // attachment data has these columns FileURL(MEMO), FileName(TEXT),
- // FileType(TEXT), FileData(OLE), FileTimeStamp(SHORT_DATE_TIME),
- // FileFlags(LONG)
- List<ColumnImpl> typeCols = typeObjTable.getColumns();
- if(typeCols.size() < 6) {
- return false;
- }
-
- int numMemo = 0;
- int numText = 0;
- int numDate = 0;
- int numOle= 0;
- int numLong = 0;
-
- for(ColumnImpl col : typeCols) {
- switch(col.getType()) {
- case TEXT:
- ++numText;
- break;
- case LONG:
- ++numLong;
- break;
- case SHORT_DATE_TIME:
- ++numDate;
- break;
- case OLE:
- ++numOle;
- break;
- case MEMO:
- ++numMemo;
- break;
- default:
- // ignore
- }
- }
-
- // be flexible, allow for extra columns...
- return((numMemo >= 1) && (numText >= 2) && (numOle >= 1) &&
- (numDate >= 1) && (numLong >= 1));
- }
-
-
private static class AttachmentImpl extends ComplexValueImpl
implements Attachment
{
package com.healthmarketscience.jackcess.complex;
import java.io.IOException;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
-import com.healthmarketscience.jackcess.ColumnImpl;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.DatabaseImpl;
+import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.IndexCursor;
-import com.healthmarketscience.jackcess.JetFormat;
-import com.healthmarketscience.jackcess.PageChannel;
-import com.healthmarketscience.jackcess.TableImpl;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.healthmarketscience.jackcess.Table;
/**
* Base class for the additional information tracked for complex columns.
*/
public abstract class ComplexColumnInfo<V extends ComplexValue>
{
- private static final Log LOG = LogFactory.getLog(ComplexColumnInfo.class);
-
public static final int INVALID_ID = -1;
public static final ComplexValueForeignKey INVALID_COMPLEX_VALUE_ID =
new ComplexValueForeignKey(null, INVALID_ID);
-
- private static final String COL_COMPLEX_TYPE_OBJECT_ID = "ComplexTypeObjectID";
- private static final String COL_TABLE_ID = "ConceptualTableID";
- private static final String COL_FLAT_TABLE_ID = "FlatTableID";
- private final ColumnImpl _column;
+ private final Column _column;
private final int _complexTypeId;
- private final TableImpl _flatTable;
- private final List<ColumnImpl> _typeCols;
- private final ColumnImpl _pkCol;
- private final ColumnImpl _complexValFkCol;
+ private final Table _flatTable;
+ private final List<Column> _typeCols;
+ private final Column _pkCol;
+ private final Column _complexValFkCol;
private IndexCursor _pkCursor;
private IndexCursor _complexValIdCursor;
- protected ComplexColumnInfo(ColumnImpl column, int complexTypeId,
- TableImpl typeObjTable, TableImpl flatTable)
+ protected ComplexColumnInfo(Column column, int complexTypeId,
+ Table typeObjTable, Table flatTable)
throws IOException
{
_column = column;
// the flat table has all the "value" columns and 2 extra columns, a
// primary key for each row, and a LONG value which is essentially a
// foreign key to the main table.
- List<ColumnImpl> typeCols = new ArrayList<ColumnImpl>();
- List<ColumnImpl> otherCols = new ArrayList<ColumnImpl>();
+ List<Column> typeCols = new ArrayList<Column>();
+ List<Column> otherCols = new ArrayList<Column>();
diffFlatColumns(typeObjTable, flatTable, typeCols, otherCols);
_typeCols = Collections.unmodifiableList(typeCols);
- ColumnImpl pkCol = null;
- ColumnImpl complexValFkCol = null;
- for(ColumnImpl col : otherCols) {
+ Column pkCol = null;
+ Column complexValFkCol = null;
+ for(Column col : otherCols) {
if(col.isAutoNumber()) {
pkCol = col;
} else if(col.getType() == DataType.LONG) {
_complexValFkCol = complexValFkCol;
}
- public static ComplexColumnInfo<? extends ComplexValue> create(
- ColumnImpl column, ByteBuffer buffer, int offset)
- throws IOException
- {
- int complexTypeId = buffer.getInt(
- offset + column.getFormat().OFFSET_COLUMN_COMPLEX_ID);
-
- DatabaseImpl db = column.getDatabase();
- TableImpl complexColumns = db.getSystemComplexColumns();
- IndexCursor cursor = CursorBuilder.createCursor(
- complexColumns, complexColumns.getPrimaryKeyIndex());
- if(!cursor.findFirstRowByEntry(complexTypeId)) {
- throw new IOException(
- "Could not find complex column info for complex column with id " +
- complexTypeId);
- }
- Map<String,Object> cColRow = cursor.getCurrentRow();
- int tableId = (Integer)cColRow.get(COL_TABLE_ID);
- if(tableId != column.getTable().getTableDefPageNumber()) {
- throw new IOException(
- "Found complex column for table " + tableId + " but expected table " +
- column.getTable().getTableDefPageNumber());
- }
- int flatTableId = (Integer)cColRow.get(COL_FLAT_TABLE_ID);
- int typeObjId = (Integer)cColRow.get(COL_COMPLEX_TYPE_OBJECT_ID);
-
- TableImpl typeObjTable = db.getTable(typeObjId);
- TableImpl flatTable = db.getTable(flatTableId);
-
- if((typeObjTable == null) || (flatTable == null)) {
- throw new IOException(
- "Could not find supporting tables (" + typeObjId + ", " + flatTableId
- + ") for complex column with id " + complexTypeId);
- }
-
- // we inspect the structore of the "type table" to determine what kind of
- // complex info we are dealing with
- if(MultiValueColumnInfo.isMultiValueColumn(typeObjTable)) {
- return new MultiValueColumnInfo(column, complexTypeId, typeObjTable,
- flatTable);
- } else if(AttachmentColumnInfo.isAttachmentColumn(typeObjTable)) {
- return new AttachmentColumnInfo(column, complexTypeId, typeObjTable,
- flatTable);
- } else if(VersionHistoryColumnInfo.isVersionHistoryColumn(typeObjTable)) {
- return new VersionHistoryColumnInfo(column, complexTypeId, typeObjTable,
- flatTable);
- }
-
- LOG.warn("Unsupported complex column type " + typeObjTable.getName());
- return new UnsupportedColumnInfo(column, complexTypeId, typeObjTable,
- flatTable);
- }
-
public void postTableLoadInit() throws IOException {
// nothing to do in base class
}
- public ColumnImpl getColumn() {
+ public Column getColumn() {
return _column;
}
- public DatabaseImpl getDatabase() {
+ public Database getDatabase() {
return getColumn().getDatabase();
}
-
- public JetFormat getFormat() {
- return getDatabase().getFormat();
- }
-
- public PageChannel getPageChannel() {
- return getDatabase().getPageChannel();
- }
- public ColumnImpl getPrimaryKeyColumn() {
+ public Column getPrimaryKeyColumn() {
return _pkCol;
}
- public ColumnImpl getComplexValueForeignKeyColumn() {
+ public Column getComplexValueForeignKeyColumn() {
return _complexValFkCol;
}
- protected List<ColumnImpl> getTypeColumns() {
+ protected List<Column> getTypeColumns() {
return _typeCols;
}
return rtn.toString();
}
- protected static void diffFlatColumns(TableImpl typeObjTable,
- TableImpl flatTable,
- List<ColumnImpl> typeCols,
- List<ColumnImpl> otherCols)
+ protected static void diffFlatColumns(Table typeObjTable,
+ Table flatTable,
+ List<Column> typeCols,
+ List<Column> otherCols)
{
// each "flat"" table has the columns from the "type" table, plus some
// others. separate the "flat" columns into these 2 buckets
- for(ColumnImpl col : flatTable.getColumns()) {
+ for(Column col : flatTable.getColumns()) {
boolean found = false;
try {
typeObjTable.getColumn(col.getName());
_complexValueFk = complexValueFk;
}
- public ColumnImpl getColumn() {
+ public Column getColumn() {
return _complexValueFk.getColumn();
}
import java.util.List;
import java.util.Map;
-import com.healthmarketscience.jackcess.ColumnImpl;
+import com.healthmarketscience.jackcess.Column;
/**
* Value which is returned for a complex column. This value corresponds to a
{
private static final long serialVersionUID = 20110805L;
- private transient final ColumnImpl _column;
+ private transient final Column _column;
private final int _value;
private transient List<? extends ComplexValue> _values;
- public ComplexValueForeignKey(ColumnImpl column, int value) {
+ public ComplexValueForeignKey(Column column, int value) {
_column = column;
_value = value;
}
return _value;
}
- public ColumnImpl getColumn() {
+ public Column getColumn() {
return _column;
}
package com.healthmarketscience.jackcess.complex;
import java.io.IOException;
-import java.util.EnumSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-import com.healthmarketscience.jackcess.ColumnImpl;
-import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.TableImpl;
+import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Table;
/**
* Complex column info for a column holding multiple values per row.
*/
public class MultiValueColumnInfo extends ComplexColumnInfo<SingleValue>
{
- private static final Set<DataType> VALUE_TYPES = EnumSet.of(
- DataType.BYTE, DataType.INT, DataType.LONG, DataType.FLOAT,
- DataType.DOUBLE, DataType.GUID, DataType.NUMERIC, DataType.TEXT);
-
- private final ColumnImpl _valueCol;
+ private final Column _valueCol;
- public MultiValueColumnInfo(ColumnImpl column, int complexId,
- TableImpl typeObjTable, TableImpl flatTable)
+ public MultiValueColumnInfo(Column column, int complexId,
+ Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
return ComplexDataType.MULTI_VALUE;
}
- public ColumnImpl getValueColumn() {
+ public Column getValueColumn() {
return _valueCol;
}
return new SingleValueImpl(INVALID_ID, complexValueFk, value);
}
- public static boolean isMultiValueColumn(TableImpl typeObjTable) {
- // if we found a single value of a "simple" type, then we are dealing with
- // a multi-value column
- List<ColumnImpl> typeCols = typeObjTable.getColumns();
- return ((typeCols.size() == 1) &&
- VALUE_TYPES.contains(typeCols.get(0).getType()));
- }
private static class SingleValueImpl extends ComplexValueImpl
implements SingleValue
import java.util.List;
import java.util.Map;
-import com.healthmarketscience.jackcess.ColumnImpl;
-import com.healthmarketscience.jackcess.TableImpl;
+import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Table;
/**
* Complex column info for an unsupported complex type.
public class UnsupportedColumnInfo extends ComplexColumnInfo<UnsupportedValue>
{
- public UnsupportedColumnInfo(ColumnImpl column, int complexId, TableImpl typeObjTable,
- TableImpl flatTable)
+ public UnsupportedColumnInfo(Column column, int complexId, Table typeObjTable,
+ Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
}
- public List<ColumnImpl> getValueColumns() {
+ public List<Column> getValueColumns() {
return getTypeColumns();
}
int id = (Integer)getPrimaryKeyColumn().getRowValue(rawValue);
Map<String,Object> values = new LinkedHashMap<String,Object>();
- for(ColumnImpl col : getValueColumns()) {
+ for(Column col : getValueColumns()) {
col.setRowValue(values, col.getRowValue(rawValue));
}
super.asRow(row, value);
Map<String,Object> values = value.getValues();
- for(ColumnImpl col : getValueColumns()) {
+ for(Column col : getValueColumns()) {
col.setRowValue(row, col.getRowValue(values));
}
import java.util.List;
import java.util.Map;
+import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.ColumnImpl;
-import com.healthmarketscience.jackcess.TableImpl;
+import com.healthmarketscience.jackcess.Table;
/**
* Complex column info for a column which tracking the version history of an
*/
public class VersionHistoryColumnInfo extends ComplexColumnInfo<Version>
{
- private final ColumnImpl _valueCol;
- private final ColumnImpl _modifiedCol;
+ private final Column _valueCol;
+ private final Column _modifiedCol;
- public VersionHistoryColumnInfo(ColumnImpl column, int complexId,
- TableImpl typeObjTable, TableImpl flatTable)
+ public VersionHistoryColumnInfo(Column column, int complexId,
+ Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
- ColumnImpl valueCol = null;
- ColumnImpl modifiedCol = null;
- for(ColumnImpl col : getTypeColumns()) {
+ Column valueCol = null;
+ Column modifiedCol = null;
+ for(Column col : getTypeColumns()) {
switch(col.getType()) {
case SHORT_DATE_TIME:
modifiedCol = col;
// link up with the actual versioned column. it should have the same name
// as the "value" column in the type table.
- ColumnImpl versionedCol = getColumn().getTable().getColumn(
+ Column versionedCol = getColumn().getTable().getColumn(
getValueColumn().getName());
- versionedCol.setVersionHistoryColumn(getColumn());
+ ((ColumnImpl)versionedCol).setVersionHistoryColumn((ColumnImpl)getColumn());
}
- public ColumnImpl getValueColumn() {
+ public Column getValueColumn() {
return _valueCol;
}
- public ColumnImpl getModifiedDateColumn() {
+ public Column getModifiedDateColumn() {
return _modifiedCol;
}
return new VersionImpl(INVALID_ID, complexValueFk, value, modifiedDate);
}
- public static boolean isVersionHistoryColumn(TableImpl typeObjTable) {
- // version history data has these columns <value>(MEMO),
- // <modified>(SHORT_DATE_TIME)
- List<ColumnImpl> typeCols = typeObjTable.getColumns();
- if(typeCols.size() < 2) {
- return false;
- }
-
- int numMemo = 0;
- int numDate = 0;
-
- for(ColumnImpl col : typeCols) {
- switch(col.getType()) {
- case SHORT_DATE_TIME:
- ++numDate;
- break;
- case MEMO:
- ++numMemo;
- break;
- default:
- // ignore
- }
- }
-
- // be flexible, allow for extra columns...
- return((numMemo >= 1) && (numDate >= 1));
- }
private static class VersionImpl extends ComplexValueImpl implements Version
{