CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
File | Line |
---|---|
org/djutils/serialization/TypedObject.java | 1170 |
org/djutils/serialization/TypedObject.java | 1246 |
Serializer[] serializers = TypedMessage.buildEncoderList(false, objectArray); for (int i = 0; i < objectArray.length; i++) { buffer[pointer.getAndIncrement(1)] = serializers[i].fieldType(); } for (int i = 0; i < objects.length; i++) { List<Object> row = objects[i].exportAsList(); Throw.when(row.size() != objectArray.length, SerializationException.class, "List in row %d has %d elements which differs from the %d elements in row 0", i, row.size(), objectArray.length); for (int j = 0; j < row.size(); j++) { serializers[j].serialize(row.get(j), buffer, pointer, endianUtil); } } } @Override public SerializableObject<?>[] deSerialize(final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { int arraySize = endianUtil.decodeInt(buffer, pointer.getAndIncrement(4)); int fieldCount = endianUtil.decodeInt(buffer, pointer.getAndIncrement(4)); Serializer<?>[] deSerializers = new Serializer[fieldCount]; for (int i = 0; i < fieldCount; i++) { Byte key = buffer[pointer.getAndIncrement(1)]; Serializer<?> deSerializer = PRIMITIVE_DATA_DECODERS.get(key); Throw.whenNull(SerializationException.class, "No decoder for %d", key); deSerializers[i] = deSerializer; } MinimalSerializableObject[] result = new MinimalSerializableObject[arraySize]; for (int i = 0; i < arraySize; i++) { List<Object> element = new ArrayList<>(); for (int j = 0; j < fieldCount; j++) { element.add(deSerializers[j].deSerialize(buffer, pointer, endianUtil)); } result[i] = new MinimalSerializableObject(element); } return result; } }; /** Converter for array of SerializebleObject using UTF8 for strings and characters. */ protected static final Serializer<SerializableObject<?>[]> COMPOUND_ARRAY_SERIALIZER_UTF8 = |
File | Line |
---|---|
org/djutils/serialization/TypedObject.java | 1152 |
org/djutils/serialization/TypedObject.java | 1228 |
Serializer[] serializers = TypedMessage.buildEncoderList(false, objectArray); result += serializers.length; for (int i = 0; i < objectArray.length; i++) { result += objects.length * serializers[i].size(objectArray[i]); } return result; } @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void serialize(final SerializableObject<?>[] objects, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { SerializableObject<?> so = objects[0]; Object[] objectArray = so.exportAsList().toArray(); endianUtil.encodeInt(objects.length, buffer, pointer.getAndIncrement(4)); endianUtil.encodeInt(objectArray.length, buffer, pointer.getAndIncrement(4)); Serializer[] serializers = TypedMessage.buildEncoderList(false, objectArray); |
File | Line |
---|---|
org/djutils/serialization/EndianUtil.java | 260 |
org/djutils/serialization/EndianUtil.java | 290 |
message[p++] = (byte) ((v >> 24) & 0xFF); message[p++] = (byte) ((v >> 16) & 0xFF); message[p++] = (byte) ((v >> 8) & 0xFF); message[p++] = (byte) (v & 0xFF); } else { message[p++] = (byte) (v & 0xFF); message[p++] = (byte) ((v >> 8) & 0xFF); message[p++] = (byte) ((v >> 16) & 0xFF); message[p++] = (byte) ((v >> 24) & 0xFF); |
File | Line |
---|---|
org/djutils/serialization/serializers/ArrayOrMatrixWithUnitSerializer.java | 67 |
org/djutils/serialization/serializers/ObjectWithUnitSerializer.java | 28 |
} /** * Code a unit. * @param unit the unit to code in the byte array * @param message the byte array * @param pointer the start pointer in the byte array * @param endianUtil encoder to use for multi-byte values */ protected void encodeUnit(final U unit, final byte[] message, final Pointer pointer, final EndianUtil endianUtil) { SerializationUnits unitType = SerializationUnits.getUnitType(unit); message[pointer.getAndIncrement(1)] = unitType.getCode(); DisplayType displayType = DisplayType.getDisplayType(unit); message[pointer.getAndIncrement(1)] = displayType.getByteCode(); } /** * Retrieve and decode a DJUNITS unit. * @param buffer the encoded data * @param pointer position in the encoded data where the unit is to be decoded from * @param endianUtil decoder for multi-byte values * @return Unit */ @SuppressWarnings("unchecked") protected U getUnit(final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) { SerializationUnits unitType = SerializationUnits.getUnitType(buffer[pointer.getAndIncrement(1)]); DisplayType displayType = DisplayType.getDisplayType(unitType, 0 + buffer[pointer.getAndIncrement(1)]); return (U) displayType.getDjunitsType(); } |
File | Line |
---|---|
org/djutils/serialization/TypedObject.java | 1401 |
org/djutils/serialization/TypedObject.java | 1463 |
size += 4 + string.getBytes(UTF8).length; } } return size; } @Override public void serialize(final String[][] stringMatrix, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { int height = stringMatrix.length; int width = stringMatrix[0].length; endianUtil.encodeInt(height, buffer, pointer.getAndIncrement(4)); endianUtil.encodeInt(width, buffer, pointer.getAndIncrement(4)); for (int i = 0; i < height; i++) { Throw.when(stringMatrix[i].length != width, SerializationException.class, "Jagged matrix is not allowed"); for (int j = 0; j < width; j++) { |
File | Line |
---|---|
org/djutils/serialization/TypedObject.java | 670 |
org/djutils/serialization/TypedObject.java | 1054 |
public void serialize(final byte[][] matrix, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { int height = matrix.length; int width = matrix[0].length; endianUtil.encodeInt(height, buffer, pointer.getAndIncrement(4)); endianUtil.encodeInt(width, buffer, pointer.getAndIncrement(4)); for (int i = 0; i < height; i++) { Throw.when(matrix[i].length != width, SerializationException.class, "Jagged matrix is not allowed"); for (int j = 0; j < width; j++) { buffer[pointer.getAndIncrement(getElementSize())] = matrix[i][j]; |
File | Line |
---|---|
org/djutils/serialization/serializers/DoubleVectorArraySerializer.java | 49 |
org/djutils/serialization/serializers/FloatVectorArraySerializer.java | 49 |
return result; } @Override public void serialize(final V[] adva, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { int width = adva.length; int height = adva[0].size(); endianUtil.encodeInt(height, buffer, pointer.getAndIncrement(4)); endianUtil.encodeInt(adva.length, buffer, pointer.getAndIncrement(4)); for (int i = 0; i < width; i++) { V adv = adva[i]; Throw.when(adv.size() != height, SerializationException.class, |
File | Line |
---|---|
org/djutils/serialization/TypedObject.java | 670 |
org/djutils/serialization/TypedObject.java | 734 |
org/djutils/serialization/TypedObject.java | 798 |
org/djutils/serialization/TypedObject.java | 862 |
org/djutils/serialization/TypedObject.java | 926 |
org/djutils/serialization/TypedObject.java | 990 |
org/djutils/serialization/TypedObject.java | 1054 |
public void serialize(final byte[][] matrix, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil) throws SerializationException { int height = matrix.length; int width = matrix[0].length; endianUtil.encodeInt(height, buffer, pointer.getAndIncrement(4)); endianUtil.encodeInt(width, buffer, pointer.getAndIncrement(4)); for (int i = 0; i < height; i++) { Throw.when(matrix[i].length != width, SerializationException.class, "Jagged matrix is not allowed"); for (int j = 0; j < width; j++) { |