
dk.eobjects.metamodel.schema.JdbcColumn Maven / Gradle / Ivy
The newest version!
/**
* This file is part of MetaModel.
*
* MetaModel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MetaModel 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MetaModel. If not, see .
*/
package dk.eobjects.metamodel.schema;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class JdbcColumn extends Column {
private static final long serialVersionUID = 389872697452157919L;
public JdbcColumn(String columnName, ColumnType columnType,
JdbcTable table, int columnNumber, Boolean nullable) {
super(columnName, columnType, table, columnNumber, nullable);
}
@Override
public boolean isIndexed() {
Table table = getTable();
if (table instanceof JdbcTable) {
((JdbcTable) table).loadIndexes();
}
return super.isIndexed();
}
/**
* Called by the Java Serialization API to serialize the object.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
Table table = getTable();
Schema schema = table.getSchema();
if (schema instanceof JdbcSchema) {
schema = ((JdbcSchema) schema).toSerializableForm();
}
stream.writeObject(schema);
stream.writeObject(table.getName());
stream.writeObject(getName());
}
/**
* Called by the Java Serialization API to deserialize the object.
*/
private void readObject(ObjectInputStream stream) throws IOException,
ClassNotFoundException {
Schema schema = (Schema) stream.readObject();
String tableName = (String) stream.readObject();
String columnName = (String) stream.readObject();
Table table = schema.getTableByName(tableName);
Column column = table.getColumnByName(columnName);
setName(columnName);
setTable(table);
setQuote(column.getQuote());
setRemarks(column.getRemarks());
setType(column.getType());
setColumnNumber(column.getColumnNumber());
setColumnSize(column.getColumnSize());
setIndexed(column.isIndexed());
setNativeType(column.getNativeType());
setNullable(column.isNullable());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy