use of com.hazelcast.nio.serialization.FieldType in project hazelcast by hazelcast.
the class PortableContextImpl method readClassDefinition.
ClassDefinition readClassDefinition(BufferObjectDataInput in, int factoryId, int classId, int version) throws IOException {
boolean register = true;
ClassDefinitionBuilder builder = new ClassDefinitionBuilder(factoryId, classId, version);
// final position after portable is read
in.readInt();
// field count
int fieldCount = in.readInt();
int offset = in.position();
for (int i = 0; i < fieldCount; i++) {
int pos = in.readInt(offset + i * Bits.INT_SIZE_IN_BYTES);
in.position(pos);
short len = in.readShort();
char[] chars = new char[len];
for (int k = 0; k < len; k++) {
chars[k] = (char) in.readUnsignedByte();
}
FieldType type = FieldType.get(in.readByte());
String name = new String(chars);
int fieldFactoryId = 0;
int fieldClassId = 0;
int fieldVersion = 0;
if (type == FieldType.PORTABLE) {
// is null
if (in.readBoolean()) {
register = false;
}
fieldFactoryId = in.readInt();
fieldClassId = in.readInt();
// TODO: what there's a null inner Portable field
if (register) {
fieldVersion = in.readInt();
readClassDefinition(in, fieldFactoryId, fieldClassId, fieldVersion);
}
} else if (type == FieldType.PORTABLE_ARRAY) {
int k = in.readInt();
fieldFactoryId = in.readInt();
fieldClassId = in.readInt();
// TODO: what there's a null inner Portable field
if (k > 0) {
int p = in.readInt();
in.position(p);
fieldVersion = in.readInt();
readClassDefinition(in, fieldFactoryId, fieldClassId, fieldVersion);
} else {
register = false;
}
}
builder.addField(new FieldDefinitionImpl(i, name, type, fieldFactoryId, fieldClassId, fieldVersion));
}
ClassDefinition classDefinition = builder.build();
if (register) {
classDefinition = registerClassDefinition(classDefinition);
}
return classDefinition;
}
use of com.hazelcast.nio.serialization.FieldType in project hazelcast by hazelcast.
the class ClassAndFieldDefinitionTest method testClassDef_getFieldType.
@Test
public void testClassDef_getFieldType() throws Exception {
for (String fieldName : fieldNames) {
FieldType fieldType = classDefinition.getFieldType(fieldName);
assertNotNull(fieldType);
}
}
Aggregations