本文整理汇总了Java中org.apache.metamodel.util.LegacyDeserializationObjectInputStream类的典型用法代码示例。如果您正苦于以下问题:Java LegacyDeserializationObjectInputStream类的具体用法?Java LegacyDeserializationObjectInputStream怎么用?Java LegacyDeserializationObjectInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LegacyDeserializationObjectInputStream类属于org.apache.metamodel.util包,在下文中一共展示了LegacyDeserializationObjectInputStream类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
final GetField getFields = stream.readFields();
Object primaryColumns = getFields.get("_primaryColumns", null);
Object foreignColumns = getFields.get("_foreignColumns", null);
if (primaryColumns instanceof Column[] && foreignColumns instanceof Column[]) {
primaryColumns = Arrays.<Column> asList((Column[]) primaryColumns);
foreignColumns = Arrays.<Column> asList((Column[]) foreignColumns);
}
LegacyDeserializationObjectInputStream.setField(MutableRelationship.class, this, "_primaryColumns",
primaryColumns);
LegacyDeserializationObjectInputStream.setField(MutableRelationship.class, this, "_foreignColumns",
foreignColumns);
}
示例2: readObject
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
final GetField getFields = stream.readFields();
Object primaryColumns = getFields.get("primaryColumns", null);
Object foreignColumns = getFields.get("foreignColumns", null);
if (primaryColumns instanceof Column[] && foreignColumns instanceof Column[]) {
primaryColumns = Arrays.<Column> asList((Column[]) primaryColumns);
foreignColumns = Arrays.<Column> asList((Column[]) foreignColumns);
}
LegacyDeserializationObjectInputStream.setField(ImmutableRelationship.class, this, "primaryColumns",
primaryColumns);
LegacyDeserializationObjectInputStream.setField(ImmutableRelationship.class, this, "foreignColumns",
foreignColumns);
}
示例3: testDeserializeBackwardsCompatible
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
public void testDeserializeBackwardsCompatible() throws Exception {
Object obj;
FileInputStream fileIn = new FileInputStream("src/test/resources/metamodel-3.0-default-row.ser");
try {
ObjectInputStream ois = new LegacyDeserializationObjectInputStream(fileIn);
obj = ois.readObject();
ois.close();
} finally {
FileHelper.safeClose(fileIn);
}
assertTrue(obj instanceof Row);
assertTrue(obj instanceof DefaultRow);
Row row = (Row) obj;
assertEquals(2, row.size());
List<SelectItem> selectItems = row.getSelectItems();
assertEquals("foo", selectItems.get(0).toString());
assertEquals("bar", selectItems.get(1).toString());
assertEquals("foo", row.getValue(0));
assertEquals("bar", row.getValue(1));
assertEquals(Style.NO_STYLE, row.getStyle(0));
assertEquals(Style.NO_STYLE, row.getStyle(1));
Column column = selectItems.get(0).getColumn();
assertNotNull(column);
// the columns used to create the object did not have column types assigned.
ColumnType type = column.getType();
assertNull(type);
}
示例4: testDeserializeOldFormat
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
@Test
public void testDeserializeOldFormat() throws Exception {
final File file = new File("src/test/resources/metamodel-4.6.0-mutableschema-etc.ser");
assertTrue(file.exists());
try (final FileInputStream in = new FileInputStream(file)) {
final LegacyDeserializationObjectInputStream ois = new LegacyDeserializationObjectInputStream(in);
final Object obj = ois.readObject();
assertTrue(obj instanceof MutableSchema);
ois.close();
final MutableSchema sch = (MutableSchema) obj;
assertEquals("schema", sch.getName());
assertEquals(2, sch.getTableCount());
final Table table1 = sch.getTable(0);
assertTrue(table1 instanceof MutableTable);
assertEquals("t1", table1.getName());
assertEquals(Arrays.asList("t1_c1", "t1_c2"), table1.getColumnNames());
assertEquals(1, table1.getRelationshipCount());
final Table table2 = sch.getTable(1);
assertTrue(table2 instanceof MutableTable);
assertEquals("t2", table2.getName());
assertEquals(Arrays.asList("t2_c1"), table2.getColumnNames());
assertEquals(1, table2.getRelationshipCount());
final Relationship rel1 = table1.getRelationships().iterator().next();
final Relationship rel2 = table2.getRelationships().iterator().next();
assertSame(rel1, rel2);
assertTrue(rel1 instanceof MutableRelationship);
}
}
示例5: testDeserializeOldFormat
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
@Test
public void testDeserializeOldFormat() throws Exception {
final File file = new File("src/test/resources/metamodel-4.6.0-immutableschema-etc.ser");
assertTrue(file.exists());
try (final FileInputStream in = new FileInputStream(file)) {
final LegacyDeserializationObjectInputStream ois = new LegacyDeserializationObjectInputStream(in);
final Object obj = ois.readObject();
assertTrue(obj instanceof ImmutableSchema);
ois.close();
final ImmutableSchema sch = (ImmutableSchema) obj;
assertEquals("schema", sch.getName());
assertEquals(2, sch.getTableCount());
final Table table1 = sch.getTable(0);
assertTrue(table1 instanceof ImmutableTable);
assertEquals("t1", table1.getName());
assertEquals(Arrays.asList("t1_c1", "t1_c2"), table1.getColumnNames());
assertEquals(1, table1.getRelationshipCount());
final Table table2 = sch.getTable(1);
assertTrue(table2 instanceof ImmutableTable);
assertEquals("t2", table2.getName());
assertEquals(Arrays.asList("t2_c1"), table2.getColumnNames());
assertEquals(1, table2.getRelationshipCount());
final Relationship rel1 = table1.getRelationships().iterator().next();
final Relationship rel2 = table2.getRelationships().iterator().next();
assertSame(rel1, rel2);
assertTrue(rel1 instanceof ImmutableRelationship);
}
}
示例6: readObject
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
final GetField getFields = stream.readFields();
Object columns = getFields.get("_columns", null);
if (columns instanceof Column[]) {
columns = Arrays.<Column> asList((Column[]) columns);
}
final Object schema = getFields.get("_schema", null);
final Object tableName = getFields.get("_tableName", null);
LegacyDeserializationObjectInputStream.setField(CsvTable.class, this, "_columns", columns);
LegacyDeserializationObjectInputStream.setField(CsvTable.class, this, "_schema", schema);
LegacyDeserializationObjectInputStream.setField(CsvTable.class, this, "_tableName", tableName);
}
示例7: testDeserializeOldTable
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
@Test
public void testDeserializeOldTable() throws Exception {
final File file = new File("src/test/resources/MetaModel-4.6.0-CsvTable.ser");
try (LegacyDeserializationObjectInputStream in =
new LegacyDeserializationObjectInputStream(new FileInputStream(file))) {
final Object object = in.readObject();
assertPeopleCsv(object);
}
}
示例8: testSerializeAndDeserializeCurrentVersion
import org.apache.metamodel.util.LegacyDeserializationObjectInputStream; //导入依赖的package包/类
@Test
public void testSerializeAndDeserializeCurrentVersion() throws Exception {
final DataContext dc = new CsvDataContext(new File("src/test/resources/csv_people.csv"));
final Table table1 = dc.getDefaultSchema().getTables().get(0);
assertPeopleCsv(table1);
final byte[] bytes = SerializationUtils.serialize(table1);
try (LegacyDeserializationObjectInputStream in =
new LegacyDeserializationObjectInputStream(new ByteArrayInputStream(bytes))) {
final Object object = in.readObject();
assertPeopleCsv(object);
}
}