ClassDefinitionWriter(PortableContext context, int factoryId, int classId, int version) { this.context = context; builder = new ClassDefinitionBuilder(factoryId, classId, version); }
@Override public void writeBooleanArray(String fieldName, boolean[] booleans) throws IOException { builder.addBooleanArrayField(fieldName); }
@Override public void writeBoolean(String fieldName, boolean value) throws IOException { builder.addBooleanField(fieldName); }
ClassDefinition readClassDefinition(BufferObjectDataInput in, int factoryId, int classId, int version) throws IOException { boolean register = true; ClassDefinitionBuilder builder = new ClassDefinitionBuilder(factoryId, classId, version); builder.addField(new FieldDefinitionImpl(i, name, type, fieldFactoryId, fieldClassId, fieldVersion)); ClassDefinition classDefinition = builder.build(); if (register) { classDefinition = registerClassDefinition(classDefinition);
@Override public void writePortable(String fieldName, Portable portable) throws IOException { if (portable == null) { throw new HazelcastSerializationException("Cannot write null portable without explicitly " + "registering class definition!"); } int version = SerializationUtil.getPortableVersion(portable, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(portable, new ClassDefinitionBuilder(portable.getFactoryId(), portable.getClassId(), version)); builder.addPortableField(fieldName, nestedClassDef); }
@Override public void writePortableArray(String fieldName, Portable[] portables) throws IOException { if (portables == null || portables.length == 0) { throw new HazelcastSerializationException("Cannot write null portable array without explicitly " + "registering class definition!"); } Portable p = portables[0]; int classId = p.getClassId(); for (int i = 1; i < portables.length; i++) { if (portables[i].getClassId() != classId) { throw new IllegalArgumentException("Detected different class-ids in portable array!"); } } int version = SerializationUtil.getPortableVersion(p, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(p, new ClassDefinitionBuilder(p.getFactoryId(), classId, version)); builder.addPortableArrayField(fieldName, nestedClassDef); }
@Override public void writeChar(String fieldName, int value) throws IOException { builder.addCharField(fieldName); }
@Override public void writeByte(String fieldName, byte value) throws IOException { builder.addByteField(fieldName); }
@Override public void writeByteArray(String fieldName, byte[] bytes) throws IOException { builder.addByteArrayField(fieldName); }
@Override public void writeDoubleArray(String fieldName, double[] values) throws IOException { builder.addDoubleArrayField(fieldName); }
@Override public void writeCharArray(String fieldName, char[] chars) throws IOException { builder.addCharArrayField(fieldName); }
@Override public void writeDouble(String fieldName, double value) throws IOException { builder.addDoubleField(fieldName); }
ClassDefinition readClassDefinition(BufferObjectDataInput in, int factoryId, int classId, int version) throws IOException { boolean register = true; ClassDefinitionBuilder builder = new ClassDefinitionBuilder(factoryId, classId, version); builder.addField(new FieldDefinitionImpl(i, name, type, fieldFactoryId, fieldClassId, fieldVersion)); ClassDefinition classDefinition = builder.build(); if (register) { classDefinition = registerClassDefinition(classDefinition);
@Override public void writePortable(String fieldName, Portable portable) throws IOException { if (portable == null) { throw new HazelcastSerializationException("Cannot write null portable without explicitly " + "registering class definition!"); } int version = SerializationUtil.getPortableVersion(portable, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(portable, new ClassDefinitionBuilder(portable.getFactoryId(), portable.getClassId(), version)); builder.addPortableField(fieldName, nestedClassDef); }
@Override public void writePortableArray(String fieldName, Portable[] portables) throws IOException { if (portables == null || portables.length == 0) { throw new HazelcastSerializationException("Cannot write null portable array without explicitly " + "registering class definition!"); } Portable p = portables[0]; int classId = p.getClassId(); for (int i = 1; i < portables.length; i++) { if (portables[i].getClassId() != classId) { throw new IllegalArgumentException("Detected different class-ids in portable array!"); } } int version = SerializationUtil.getPortableVersion(p, context.getVersion()); ClassDefinition nestedClassDef = createNestedClassDef(p, new ClassDefinitionBuilder(p.getFactoryId(), classId, version)); builder.addPortableArrayField(fieldName, nestedClassDef); }
@Override public void writeChar(String fieldName, int value) throws IOException { builder.addCharField(fieldName); }
@Override public void writeByte(String fieldName, byte value) throws IOException { builder.addByteField(fieldName); }
@Override public void writeByteArray(String fieldName, byte[] bytes) throws IOException { builder.addByteArrayField(fieldName); }
@Override public void writeDoubleArray(String fieldName, double[] values) throws IOException { builder.addDoubleArrayField(fieldName); }
@Override public void writeCharArray(String fieldName, char[] chars) throws IOException { builder.addCharArrayField(fieldName); }