Skip to content

Commit f9a2b7b

Browse files
committed
reformat and reordering of code
1 parent 6e778fd commit f9a2b7b

19 files changed

Lines changed: 272 additions & 247 deletions

jbbp/src/main/java/com/igormaznitsa/jbbp/JBBPCustomFieldTypeProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ boolean isAllowed(JBBPFieldTypeParameterContainer fieldType, String fieldName, i
6161
* @param extraData extra numeric value for the field, followed by ':', if not presented then 0
6262
* @param readWholeStream if true then the field is array which should contain parse data for whole stream till the end
6363
* @param arrayLength -1 if it is not array else length of the array to be read.
64-
* @param arraySizeLimiter limiter to check number of elements during whole stream array read, must not be null
64+
* @param arraySizeLimiter limiter to check number of elements during whole stream array read, must not be null
6565
* @return parsed data as JBBP field, must not be null
6666
* @throws IOException it can be thrown for transport errors
6767
* @throws JBBPReachedArraySizeLimitException thrown if reached limit for a whole stream array
68-
* @since 2.1.0
6968
* @see JBBPArraySizeLimiter#isBreakReadWholeStream(int, JBBPArraySizeLimiter)
7069
* @see JBBPArraySizeLimiter#NO_LIMIT_FOR_ARRAY_SIZE
70+
* @since 2.1.0
7171
*/
7272
JBBPAbstractField readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder bitOrder,
7373
int parserFlags,

jbbp/src/main/java/com/igormaznitsa/jbbp/JBBPParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public final class JBBPParser {
133133
* The Variable contains the last parsing counter value.
134134
*/
135135
private long finalStreamByteCounter;
136+
136137
/**
137138
* Constructor.
138139
*

jbbp/src/main/java/com/igormaznitsa/jbbp/JBBPVarFieldProcessor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ public interface JBBPVarFieldProcessor {
3434
/**
3535
* Read a field array from a stream. The Method must read a field array from a stream and return the value with the provided field name info.
3636
*
37-
* @param inStream the data source bit stream, it must not be null
38-
* @param arraySize the array size, if it is negative one then whole stream must be read
39-
* @param fieldName the field name info for the VAR field, it can be null for anonymous fields
40-
* @param extraValue the extra value for the field, by default it is 0, it is the integer value after ':' char in the field type
41-
* @param byteOrder the byte order for the field, it must not be null
42-
* @param numericFieldMap the numeric field map for the session, it must not be null, it can be used for access to already read values of another numeric fields.
37+
* @param inStream the data source bit stream, it must not be null
38+
* @param arraySize the array size, if it is negative one then whole stream must be read
39+
* @param fieldName the field name info for the VAR field, it can be null for anonymous fields
40+
* @param extraValue the extra value for the field, by default it is 0, it is the integer value after ':' char in the field type
41+
* @param byteOrder the byte order for the field, it must not be null
42+
* @param numericFieldMap the numeric field map for the session, it must not be null, it can be used for access to already read values of another numeric fields.
4343
* @param arraySizeLimiter limiter to check number of elements during whole stream array read, must not be null
4444
* @return a field array without nulls as values, it must not return null
4545
* @throws IOException it can be thrown for transport errors or another process exceptions
4646
* @throws JBBPReachedArraySizeLimitException thrown if reached limit for whole stream array
47-
* @since 2.1.0
4847
* @see JBBPArraySizeLimiter#isBreakReadWholeStream(int, JBBPArraySizeLimiter)
4948
* @see JBBPArraySizeLimiter#NO_LIMIT_FOR_ARRAY_SIZE
49+
* @since 2.1.0
5050
*/
5151
JBBPAbstractArrayField<? extends JBBPAbstractField> readVarArray(JBBPBitInputStream inStream,
5252
int arraySize,

jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ private static int prepareCodeForToken(final JBBPToken token,
602602
final boolean hasExpressionAsExtraNumber = descriptor.hasExpressionAsExtraData();
603603

604604
result |= token.getArraySizeAsString() == null ? 0 : (token.isVarArrayLength() ?
605-
FLAG_ARRAY | FLAG_WIDE | (EXT_FLAG_EXPRESSION_OR_WHOLESTREAM << 8) : FLAG_ARRAY);
605+
FLAG_ARRAY | FLAG_WIDE |
606+
(EXT_FLAG_EXPRESSION_OR_WHOLESTREAM <<
607+
8) : FLAG_ARRAY);
606608
result |= hasExpressionAsExtraNumber ? FLAG_WIDE | (EXT_FLAG_EXTRA_AS_EXPRESSION << 8) : 0;
607609
result |= token.getFieldTypeParameters().isSpecialField() ?
608610
FLAG_WIDE | (EXT_FLAG_EXTRA_DIFF_TYPE << 8) : 0;
@@ -676,7 +678,9 @@ private static int prepareCodeForToken(final JBBPToken token,
676678
break;
677679
case STRUCT_START: {
678680
result = token.getArraySizeAsString() == null ? 0 : (token.isVarArrayLength() ?
679-
FLAG_ARRAY | FLAG_WIDE | (EXT_FLAG_EXPRESSION_OR_WHOLESTREAM << 8) : FLAG_ARRAY);
681+
FLAG_ARRAY | FLAG_WIDE |
682+
(EXT_FLAG_EXPRESSION_OR_WHOLESTREAM <<
683+
8) : FLAG_ARRAY);
680684
result |= token.getFieldName() == null ? 0 : FLAG_NAMED;
681685
result |= CODE_STRUCT_START;
682686
}

jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/conversion/JBBPToJavaConverter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,15 +715,15 @@ private void registerMaker(final String rawFieldType, final String fieldName,
715715
if (array) {
716716
this.getCurrentStruct()
717717
.getGettersSetters().indent().printf(
718-
"public %1$s[] make%2$s(int _Len_){ this.%3$s = new %1$s[_Len_]; for(int i=0;i < _Len_;i++) this.%3$s[i]=new %1$s(%4$s); return this.%3$s; }",
719-
rawFieldType, fieldName.toUpperCase(Locale.ENGLISH), fieldName, pathToRootObject
720-
);
718+
"public %1$s[] make%2$s(int _Len_){ this.%3$s = new %1$s[_Len_]; for(int i=0;i < _Len_;i++) this.%3$s[i]=new %1$s(%4$s); return this.%3$s; }",
719+
rawFieldType, fieldName.toUpperCase(Locale.ENGLISH), fieldName, pathToRootObject
720+
);
721721
} else {
722722
this.getCurrentStruct()
723723
.getGettersSetters().indent().printf(
724-
"public %1$s make%2$s(){ this.%3$s = new %1$s(%4$s); return this.%3$s; }",
725-
rawFieldType, fieldName.toUpperCase(Locale.ENGLISH), fieldName, pathToRootObject
726-
);
724+
"public %1$s make%2$s(){ this.%3$s = new %1$s(%4$s); return this.%3$s; }",
725+
rawFieldType, fieldName.toUpperCase(Locale.ENGLISH), fieldName, pathToRootObject
726+
);
727727
}
728728
}
729729

@@ -1787,7 +1787,7 @@ void write(
17871787
superClass != null ? " extends " + superClass + ' ' : "",
17881788
interfaceForGetSet == null ?
17891789
implementedInterfaces != null && !implementedInterfaces.isEmpty() ?
1790-
" implements " + interfaces2str(implementedInterfaces) + ' ' : "" :
1790+
" implements " + interfaces2str(implementedInterfaces) + ' ' : "" :
17911791
" implements " + interfaceForGetSet
17921792
);
17931793
buffer.incIndent();

jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/varlen/JBBPExpressionEvaluator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ public int eval(final JBBPBitInputStream inStream, final int currentCompiledBloc
642642
if (code == CODE_EXTVAR) {
643643
value = "$".equals(this.externalValueNames[index]) ? (int) inStream.getCounter() :
644644
fieldMap
645-
.getExternalFieldValue(this.externalValueNames[index], compiledBlockData, this);
645+
.getExternalFieldValue(this.externalValueNames[index], compiledBlockData, this);
646646
} else {
647647
final JBBPNamedFieldInfo namedField = compiledBlockData.getNamedFields()[index];
648648
final JBBPNumericField numericField = fieldMap.get(namedField);

jbbp/src/main/java/com/igormaznitsa/jbbp/exceptions/JBBPNumericFieldValueConversionException.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ public class JBBPNumericFieldValueConversionException extends JBBPException {
1111

1212
private final JBBPNumericField source;
1313

14-
/**
15-
* Get source field.
16-
*
17-
* @return source field for exception, can be null
18-
*/
19-
public JBBPNumericField getSource() {
20-
return this.source;
21-
}
22-
2314
/**
2415
* Constructor to provide source field and message.
2516
*
@@ -44,6 +35,15 @@ public JBBPNumericFieldValueConversionException(final JBBPNumericField source,
4435
this.source = source;
4536
}
4637

38+
/**
39+
* Get source field.
40+
*
41+
* @return source field for exception, can be null
42+
*/
43+
public JBBPNumericField getSource() {
44+
return this.source;
45+
}
46+
4747
@Override
4848
public String toString() {
4949
final StringBuilder result = new StringBuilder(getClass().getName());

jbbp/src/main/java/com/igormaznitsa/jbbp/io/AbstractMappedClassFieldObserver.java

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static Object readFieldValue(final Object obj, final MappedFieldRecord r
7070
private static void assertFieldArray(final Field field) {
7171
if (!field.getType().isArray()) {
7272
throw new IllegalArgumentException(
73-
"Detected non-array field marked to be written as an array [" + field + ']');
73+
"Detected non-array field marked to be written as an array [" + field + ']');
7474
}
7575
}
7676

@@ -85,10 +85,10 @@ private static void assertFieldArray(final Field field) {
8585
* @since 2.0.2
8686
*/
8787
protected void processObject(
88-
final Object obj,
89-
final Field field,
90-
final BinAnnotationWrapper binAnnotationWrapper,
91-
final Object customFieldProcessor
88+
final Object obj,
89+
final Field field,
90+
final BinAnnotationWrapper binAnnotationWrapper,
91+
final Object customFieldProcessor
9292
) {
9393
this.processObject(obj, field, binAnnotationWrapper, null, customFieldProcessor);
9494
}
@@ -105,15 +105,16 @@ protected void processObject(
105105
* @since 2.0.4
106106
*/
107107
protected void processObject(
108-
final Object obj,
109-
final Field field,
110-
final BinAnnotationWrapper binAnnotationWrapper,
111-
final BinFieldFilter binFieldFilter,
112-
final Object customFieldProcessor
108+
final Object obj,
109+
final Field field,
110+
final BinAnnotationWrapper binAnnotationWrapper,
111+
final BinFieldFilter binFieldFilter,
112+
final Object customFieldProcessor
113113
) {
114114
JBBPUtils.assertNotNull(obj, "Object must not be null");
115115

116-
final List<MappedFieldRecord> orderedFields = JBBPMapper.findAffectedFields(obj, binFieldFilter);
116+
final List<MappedFieldRecord> orderedFields =
117+
JBBPMapper.findAffectedFields(obj, binFieldFilter);
117118

118119
final Bin clazzAnno = obj.getClass().getAnnotation(Bin.class);
119120
final Bin fieldAnno = field == null ? null : field.getAnnotation(Bin.class);
@@ -125,14 +126,14 @@ protected void processObject(
125126

126127
for (final MappedFieldRecord rec : orderedFields) {
127128
final Bin annotation = binAnnotationWrapper == null ? rec.binAnnotation :
128-
binAnnotationWrapper.setWrapped(rec.binAnnotation);
129+
binAnnotationWrapper.setWrapped(rec.binAnnotation);
129130

130131
if (binFieldFilter == null || binFieldFilter.isAllowed(annotation, rec.mappingField)) {
131132
if (annotation.custom() && customFieldProcessor == null) {
132133
throw new JBBPIllegalArgumentException(
133-
"Class '" + obj.getClass().getName() + "' contains field '" +
134-
rec.mappingField.getName() +
135-
"' which is custom one, you must provide JBBPCustomFieldWriter instance to save it.");
134+
"Class '" + obj.getClass().getName() + "' contains field '" +
135+
rec.mappingField.getName() +
136+
"' which is custom one, you must provide JBBPCustomFieldWriter instance to save it.");
136137
}
137138
processObjectField(obj, rec, annotation, customFieldProcessor, binFieldFilter);
138139
}
@@ -154,10 +155,10 @@ protected void processObject(
154155
* @since 2.0.4
155156
*/
156157
protected void processObjectField(
157-
final Object obj,
158-
final MappedFieldRecord fieldRecord,
159-
final Bin annotation,
160-
final Object customFieldProcessor
158+
final Object obj,
159+
final MappedFieldRecord fieldRecord,
160+
final Bin annotation,
161+
final Object customFieldProcessor
161162
) {
162163
this.processObjectField(obj, fieldRecord, annotation, customFieldProcessor, null);
163164
}
@@ -175,21 +176,21 @@ protected void processObjectField(
175176
* @since 2.0.4
176177
*/
177178
protected void processObjectField(
178-
final Object obj,
179-
final MappedFieldRecord fieldRecord,
180-
final Bin annotation,
181-
final Object customFieldProcessor,
182-
final BinFieldFilter binFieldFilter
179+
final Object obj,
180+
final MappedFieldRecord fieldRecord,
181+
final Bin annotation,
182+
final Object customFieldProcessor,
183+
final BinFieldFilter binFieldFilter
183184
) {
184185
final Field field = fieldRecord.mappingField;
185186

186187
if (annotation.custom()) {
187188
this.onFieldCustom(obj, field, annotation, customFieldProcessor,
188-
readFieldValue(obj, fieldRecord));
189+
readFieldValue(obj, fieldRecord));
189190
} else {
190191
final Class<?> fieldType = field.getType();
191192
final BinAnnotationWrapper wrapper =
192-
annotation instanceof BinAnnotationWrapper ? (BinAnnotationWrapper) annotation : null;
193+
annotation instanceof BinAnnotationWrapper ? (BinAnnotationWrapper) annotation : null;
193194

194195
final BinType type;
195196
if (annotation.type() == BinType.UNDEFINED) {
@@ -205,7 +206,7 @@ protected void processObjectField(
205206
final JBBPBitNumber bitNumber = annotation.bitNumber();
206207
if (fieldType == boolean.class) {
207208
this.onFieldBits(obj, field, annotation, bitNumber,
208-
((Boolean) readFieldValue(obj, fieldRecord)) ? 0xFF : 0x00);
209+
((Boolean) readFieldValue(obj, fieldRecord)) ? 0xFF : 0x00);
209210
} else {
210211
byte value = ((Number) readFieldValue(obj, fieldRecord)).byteValue();
211212
if (reverseBits) {
@@ -220,7 +221,7 @@ protected void processObjectField(
220221
onFieldBool(obj, field, annotation, (Boolean) readFieldValue(obj, fieldRecord));
221222
} else {
222223
onFieldBool(obj, field, annotation,
223-
((Number) readFieldValue(obj, fieldRecord)).longValue() != 0);
224+
((Number) readFieldValue(obj, fieldRecord)).longValue() != 0);
224225
}
225226
}
226227
break;
@@ -313,13 +314,14 @@ protected void processObjectField(
313314

314315
if (reverseBits) {
315316
value =
316-
Double.longBitsToDouble(JBBPFieldLong.reverseBits(Double.doubleToLongBits(value)));
317+
Double.longBitsToDouble(JBBPFieldLong.reverseBits(Double.doubleToLongBits(value)));
317318
}
318319
this.onFieldDouble(obj, field, annotation, value);
319320
}
320321
break;
321322
case STRUCT: {
322-
processObject(readFieldValue(obj, fieldRecord), field, wrapper, binFieldFilter, customFieldProcessor);
323+
processObject(readFieldValue(obj, fieldRecord), field, wrapper, binFieldFilter,
324+
customFieldProcessor);
323325
}
324326
break;
325327
default: {
@@ -336,7 +338,7 @@ protected void processObjectField(
336338
if (fieldType.getComponentType() == boolean.class) {
337339
for (int i = 0; i < len; i++) {
338340
this.onFieldBits(obj, field, annotation, bitNumber,
339-
(Boolean) Array.get(array, i) ? 0xFF : 0x00);
341+
(Boolean) Array.get(array, i) ? 0xFF : 0x00);
340342
}
341343
} else {
342344
for (int i = 0; i < len; i++) {
@@ -520,7 +522,7 @@ protected void processObjectField(
520522
double value = ((Number) Array.get(array, i)).doubleValue();
521523
if (reverseBits) {
522524
value = Double
523-
.longBitsToDouble(JBBPFieldLong.reverseBits(Double.doubleToLongBits(value)));
525+
.longBitsToDouble(JBBPFieldLong.reverseBits(Double.doubleToLongBits(value)));
524526
}
525527
this.onFieldDouble(obj, field, annotation, value);
526528
}
@@ -532,14 +534,15 @@ protected void processObjectField(
532534
final int len = Array.getLength(array);
533535
this.onArrayStart(obj, field, annotation, len);
534536
for (int i = 0; i < len; i++) {
535-
this.processObject(Array.get(array, i), field, wrapper, binFieldFilter, customFieldProcessor);
537+
this.processObject(Array.get(array, i), field, wrapper, binFieldFilter,
538+
customFieldProcessor);
536539
}
537540
this.onArrayEnd(obj, field, annotation);
538541
}
539542
break;
540543
default: {
541544
throw new Error(
542-
"Unexpected situation for field type, contact developer [" + type + ']');
545+
"Unexpected situation for field type, contact developer [" + type + ']');
543546
}
544547
}
545548
}

jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public byte[] readByteArray(final int items, final JBBPArraySizeLimiter arraySiz
396396
* stream till the end
397397
* @param byteOrder big-endian or little-endian for this field's byte sequence
398398
* @return read byte items as a byte array; for {@code LITTLE_ENDIAN}, the buffer is reversed
399-
* after read
399+
* after read
400400
* @throws IOException it will be thrown for any transport problem during the
401401
* operation
402402
* @see JBBPByteOrder

jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPOut.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ private JBBPOut(final OutputStream outStream, final JBBPByteOrder byteOrder,
8888
assertNotNull(bitOrder, "Bit order must not be null");
8989

9090
this.outStream = outStream instanceof JBBPBitOutputStream ? (JBBPBitOutputStream) outStream :
91-
new JBBPBitOutputStream(outStream, bitOrder);
91+
new JBBPBitOutputStream(outStream, bitOrder);
9292
this.bitOrder = this.outStream.getBitOrder();
9393
if (this.bitOrder != bitOrder) {
9494
throw new IllegalArgumentException(
95-
"Detected JBBPBitOutputStream as argument with already defined different bit order [" +
96-
this.bitOrder + ']');
95+
"Detected JBBPBitOutputStream as argument with already defined different bit order [" +
96+
this.bitOrder + ']');
9797
}
9898
this.byteOrder = byteOrder;
9999

@@ -150,7 +150,7 @@ public static JBBPOut BeginBin() {
150150
*/
151151
public static JBBPOut BeginBin(final int initialSize) {
152152
return new JBBPOut(new ByteArrayOutputStream(initialSize), DEFAULT_BYTE_ORDER,
153-
DEFAULT_BIT_ORDER);
153+
DEFAULT_BIT_ORDER);
154154
}
155155

156156
/**
@@ -1093,7 +1093,8 @@ public JBBPOut Bin(final Object object, final JBBPCustomFieldWriter customFieldW
10931093
* @see #BinForceByteOrder(Object, JBBPCustomFieldWriter)
10941094
* @since 2.0.4
10951095
*/
1096-
public JBBPOut Bin(final Object object, final JBBPCustomFieldWriter customFieldWriter, final BinFieldFilter binFieldFilter) {
1096+
public JBBPOut Bin(final Object object, final JBBPCustomFieldWriter customFieldWriter,
1097+
final BinFieldFilter binFieldFilter) {
10971098
return this.Bin(object, null, customFieldWriter, binFieldFilter);
10981099
}
10991100

@@ -1163,7 +1164,7 @@ public JBBPOut BinForceByteOrder(final Object object) throws IOException {
11631164
public JBBPOut BinForceByteOrder(final Object object,
11641165
final JBBPCustomFieldWriter customFieldWriter) {
11651166
return this
1166-
.Bin(object, new BinAnnotationWrapper().setByteOrder(this.byteOrder), customFieldWriter);
1167+
.Bin(object, new BinAnnotationWrapper().setByteOrder(this.byteOrder), customFieldWriter);
11671168
}
11681169

11691170
@Override

0 commit comments

Comments
 (0)