Skip to content

Commit d6db671

Browse files
committed
renaming
1 parent f199f48 commit d6db671

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed

jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@
4545
/**
4646
* Name of a structure element to be mapped to the field.
4747
*
48-
* @return string name, if it is empty then the name of a field will be used
48+
* @return string name, if it is empty then field name will be used
4949
* as name
5050
*/
5151
String name() default "";
5252

5353
/**
54-
* Path inside structure to an element to be mapped to the field.
54+
* Structure path inside to be mapped to the field.
5555
*
5656
* @return string path, if it is empty then the path is not used
5757
*/
5858
String path() default "";
5959

6060
/**
61-
* Name of the custom type.
61+
* Custom type. It plays role only if {@link #type()} is UNDEFINED
6262
*
6363
* @return type of the field, if empty then undefined
6464
* @since 2.0.0
@@ -71,7 +71,7 @@
7171
* @return array size of the field, if empty then not defined
7272
* @since 2.0.0
7373
*/
74-
String arraySizeExpression() default "";
74+
String arraySizeExpr() default "";
7575

7676
/**
7777
* Type of mapped parsed structure element.
@@ -106,7 +106,7 @@
106106
* @return extra value, if empty then undefined
107107
* @since 2.0.0
108108
*/
109-
String typeExtraPartExpression() default "";
109+
String paramExpr() default "";
110110

111111
/**
112112
* The Value defines how many bytes are actual ones in the field, works for numeric field and arrays and allows make mapping to bit fields.

jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ private void validateAnnotatedField(
16181618
if ((bin.type() == BinType.UNDEFINED
16191619
&& field.getType().isArray()
16201620
|| bin.type().name().endsWith("_ARRAY"))
1621-
&& bin.arraySizeExpression().isEmpty()) {
1621+
&& bin.arraySizeExpr().isEmpty()) {
16221622
throw new IllegalArgumentException(field.toString() + ": missing expression in Bin#arraySizeExpression");
16231623
}
16241624
}
@@ -1696,7 +1696,7 @@ class Pair {
16961696
this.CloseStruct();
16971697
} else {
16981698
if (field.isArrayField()) {
1699-
this.StructArray(conty.getName(), conty.bin.arraySizeExpression());
1699+
this.StructArray(conty.getName(), conty.bin.arraySizeExpr());
17001700
} else {
17011701
this.Struct(conty.getName());
17021702
}
@@ -1709,18 +1709,18 @@ class Pair {
17091709
this.ByteOrder(pair.container.getByteOrder(field));
17101710
switch (type) {
17111711
case BIT_ARRAY: {
1712-
if (field.bin.typeExtraPartExpression().isEmpty()) {
1713-
this.BitArray(field.getName(), pair.container.getBitNumber(field), field.bin.arraySizeExpression());
1712+
if (field.bin.paramExpr().isEmpty()) {
1713+
this.BitArray(field.getName(), pair.container.getBitNumber(field), field.bin.arraySizeExpr());
17141714
} else {
1715-
this.CustomArray("bit", field.getName(), field.bin.arraySizeExpression(), field.bin.typeExtraPartExpression());
1715+
this.CustomArray("bit", field.getName(), field.bin.arraySizeExpr(), field.bin.paramExpr());
17161716
}
17171717
}
17181718
break;
17191719
case BIT: {
1720-
if (field.bin.typeExtraPartExpression().isEmpty()) {
1720+
if (field.bin.paramExpr().isEmpty()) {
17211721
this.Bits(field.getName(), pair.container.getBitNumber(field));
17221722
} else {
1723-
this.Custom("bit", field.getName(), field.bin.typeExtraPartExpression());
1723+
this.Custom("bit", field.getName(), field.bin.paramExpr());
17241724
}
17251725
}
17261726
break;
@@ -1729,88 +1729,88 @@ class Pair {
17291729
}
17301730
break;
17311731
case BOOL_ARRAY: {
1732-
this.BoolArray(field.getName(), field.bin.arraySizeExpression());
1732+
this.BoolArray(field.getName(), field.bin.arraySizeExpr());
17331733
}
17341734
break;
17351735
case BYTE: {
17361736
this.Byte(field.getName());
17371737
}
17381738
break;
17391739
case BYTE_ARRAY: {
1740-
this.ByteArray(field.getName(), field.bin.arraySizeExpression());
1740+
this.ByteArray(field.getName(), field.bin.arraySizeExpr());
17411741
}
17421742
break;
17431743
case UBYTE: {
17441744
this.UByte(field.getName());
17451745
}
17461746
break;
17471747
case UBYTE_ARRAY: {
1748-
this.UByteArray(field.getName(), field.bin.arraySizeExpression());
1748+
this.UByteArray(field.getName(), field.bin.arraySizeExpr());
17491749
}
17501750
break;
17511751
case SHORT: {
17521752
this.Short(field.getName());
17531753
}
17541754
break;
17551755
case SHORT_ARRAY: {
1756-
this.ShortArray(field.getName(), field.bin.arraySizeExpression());
1756+
this.ShortArray(field.getName(), field.bin.arraySizeExpr());
17571757
}
17581758
break;
17591759
case USHORT: {
17601760
this.UShort(field.getName());
17611761
}
17621762
break;
17631763
case USHORT_ARRAY: {
1764-
this.UShortArray(field.getName(), field.bin.arraySizeExpression());
1764+
this.UShortArray(field.getName(), field.bin.arraySizeExpr());
17651765
}
17661766
break;
17671767
case INT: {
17681768
this.Int(field.getName());
17691769
}
17701770
break;
17711771
case INT_ARRAY: {
1772-
this.IntArray(field.getName(), field.bin.arraySizeExpression());
1772+
this.IntArray(field.getName(), field.bin.arraySizeExpr());
17731773
}
17741774
break;
17751775
case LONG: {
17761776
this.Long(field.getName());
17771777
}
17781778
break;
17791779
case LONG_ARRAY: {
1780-
this.LongArray(field.getName(), field.bin.arraySizeExpression());
1780+
this.LongArray(field.getName(), field.bin.arraySizeExpr());
17811781
}
17821782
break;
17831783
case FLOAT: {
17841784
this.Float(field.getName());
17851785
}
17861786
break;
17871787
case FLOAT_ARRAY: {
1788-
this.FloatArray(field.getName(), field.bin.arraySizeExpression());
1788+
this.FloatArray(field.getName(), field.bin.arraySizeExpr());
17891789
}
17901790
break;
17911791
case DOUBLE: {
17921792
this.Double(field.getName());
17931793
}
17941794
break;
17951795
case DOUBLE_ARRAY: {
1796-
this.DoubleArray(field.getName(), field.bin.arraySizeExpression());
1796+
this.DoubleArray(field.getName(), field.bin.arraySizeExpr());
17971797
}
17981798
break;
17991799
case STRING: {
18001800
this.String(field.getName());
18011801
}
18021802
break;
18031803
case STRING_ARRAY: {
1804-
this.StringArray(field.getName(), field.bin.arraySizeExpression());
1804+
this.StringArray(field.getName(), field.bin.arraySizeExpr());
18051805
}
18061806
break;
18071807
case UNDEFINED: {
18081808
if (!field.getCustomType().isEmpty()) {
18091809
this.ByteOrder(pair.container.getByteOrder(field));
1810-
if (field.isArrayField() || !field.bin.arraySizeExpression().isEmpty()) {
1811-
this.CustomArray(field.bin.customType(), field.getName(), field.bin.arraySizeExpression(), field.bin.typeExtraPartExpression());
1810+
if (field.isArrayField() || !field.bin.arraySizeExpr().isEmpty()) {
1811+
this.CustomArray(field.bin.customType(), field.getName(), field.bin.arraySizeExpr(), field.bin.paramExpr());
18121812
} else {
1813-
this.Custom(field.bin.customType(), field.getName(), field.bin.arraySizeExpression());
1813+
this.Custom(field.bin.customType(), field.getName(), field.bin.arraySizeExpr());
18141814
}
18151815
}
18161816
}

jbbp/src/test/java/com/igormaznitsa/jbbp/it/BasedOnQuestionsAndCasesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void testMutlithredUsageOfParser() throws Exception {
221221
@Test
222222
public void testParseBitsThroughDslBasedScriptAndMapping() throws Exception {
223223
class Bits {
224-
@Bin(name = "a", type = BinType.BIT_ARRAY, bitNumber = JBBPBitNumber.BITS_1, arraySizeExpression = "_")
224+
@Bin(name = "a", type = BinType.BIT_ARRAY, bitNumber = JBBPBitNumber.BITS_1, arraySizeExpr = "_")
225225
byte[] bit;
226226
}
227227

jbbp/src/test/java/com/igormaznitsa/jbbp/it/SNAParsingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private class SNA {
139139
int im;
140140
@Bin(type = BinType.UBYTE, order = 16, comment = "Border color")
141141
int borderColor;
142-
@Bin(order = 17, comment = "Dump of memory since 16384 address", arraySizeExpression = "49152")
142+
@Bin(order = 17, comment = "Dump of memory since 16384 address", arraySizeExpr = "49152")
143143
byte[] ramDump;
144144
}
145145

jbbp/src/test/java/com/igormaznitsa/jbbp/mapper/JBBPMapperTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,14 @@ final class Mapped {
568568

569569
@Bin
570570
int a;
571-
@Bin(custom = true, typeExtraPartExpression = "TEST_TEXT")
571+
@Bin(custom = true, paramExpr = "TEST_TEXT")
572572
String b;
573573
@Bin
574574
int c;
575575
}
576576

577577
final Mapped mapped = JBBPParser.prepare("int a; int b; int c;").parse(new byte[] {1, 2, 3, 4, 0x4A, 0x46, 0x49, 0x46, 5, 6, 7, 8}).mapTo(new Mapped(), (parsedBlock, annotation, field) -> {
578-
if ("b".equals(field.getName()) && "TEST_TEXT".equals(annotation.typeExtraPartExpression())) {
578+
if ("b".equals(field.getName()) && "TEST_TEXT".equals(annotation.paramExpr())) {
579579
final int bvalue = parsedBlock.findFieldForNameAndType("b", JBBPFieldInt.class).getAsInt();
580580
return String.valueOf((char) ((bvalue >>> 24) & 0xFF)) + (char) ((bvalue >>> 16) & 0xFF) + (char) ((bvalue >>> 8) & 0xFF) + (char) (bvalue & 0xFF);
581581
} else {
@@ -594,7 +594,7 @@ void testMap_customMappingFields_ClassInstance() throws Exception {
594594
final class Mapped {
595595
@Bin
596596
int a;
597-
@Bin(custom = true, typeExtraPartExpression = "TEST_TEXT")
597+
@Bin(custom = true, paramExpr = "TEST_TEXT")
598598
String b;
599599
@Bin
600600
int c;
@@ -603,7 +603,7 @@ final class Mapped {
603603
final Mapped mapped = new Mapped();
604604

605605
final Mapped result = JBBPParser.prepare("int a; int b; int c;").parse(new byte[] {1, 2, 3, 4, 0x4A, 0x46, 0x49, 0x46, 5, 6, 7, 8}).mapTo(mapped, (parsedBlock, annotation, field) -> {
606-
if ("b".equals(field.getName()) && "TEST_TEXT".equals(annotation.typeExtraPartExpression())) {
606+
if ("b".equals(field.getName()) && "TEST_TEXT".equals(annotation.paramExpr())) {
607607
final int bvalue = parsedBlock.findFieldForNameAndType("b", JBBPFieldInt.class).getAsInt();
608608
return String.valueOf((char) ((bvalue >>> 24) & 0xFF)) + (char) ((bvalue >>> 16) & 0xFF) + (char) ((bvalue >>> 8) & 0xFF) + (char) (bvalue & 0xFF);
609609
} else {

jbbp/src/test/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilderTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ class Test {
408408
int c;
409409
@Bin(order = 2, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
410410
int b;
411-
@Bin(order = 4, arraySizeExpression = "a+b")
411+
@Bin(order = 4, arraySizeExpr = "a+b")
412412
Internal[] d;
413413

414414
class Internal {
415415
@Bin(order = 1)
416416
short a;
417-
@Bin(order = 2, arraySizeExpression = "8")
417+
@Bin(order = 2, arraySizeExpr = "8")
418418
short[] b;
419419
}
420420
}
@@ -457,7 +457,7 @@ class BreakJBBPDslBuilderArrayField {
457457
@Test
458458
public void testReportedIssue_20_NPEforOutBitNumber() throws Exception {
459459
class BreakJBBPDslBuilder {
460-
@Bin(order = 1, comment = "Reserved", type = BinType.BIT_ARRAY, arraySizeExpression = "4")
460+
@Bin(order = 1, comment = "Reserved", type = BinType.BIT_ARRAY, arraySizeExpr = "4")
461461
public byte[] reserved;
462462
}
463463

@@ -499,7 +499,7 @@ class Internal {
499499
int c;
500500
}
501501

502-
@Bin(arraySizeExpression = "_")
502+
@Bin(arraySizeExpr = "_")
503503
Internal[] array;
504504
}
505505
assertEquals("Test{bit:5 a;array[_]{long a;long b;long c;}bit:5 b;bit:5 c;bool dd;}", Begin().AnnotatedClass(Test.class).End(false));
@@ -510,55 +510,55 @@ public void testAnotatedClass_AnnottatedAllTypes() {
510510
class Test {
511511
@Bin(order = 1, type = BinType.BIT, bitNumber = JBBPBitNumber.BITS_4, comment = "bit field")
512512
byte a;
513-
@Bin(order = 2, bitNumber = JBBPBitNumber.BITS_2, arraySizeExpression = "123")
513+
@Bin(order = 2, bitNumber = JBBPBitNumber.BITS_2, arraySizeExpr = "123")
514514
byte[] a1;
515515
@Bin(order = 3)
516516
boolean b;
517-
@Bin(order = 4, arraySizeExpression = "456")
517+
@Bin(order = 4, arraySizeExpr = "456")
518518
boolean[] b1;
519519
@Bin(order = 5)
520520
byte c;
521-
@Bin(order = 6, arraySizeExpression = "456")
521+
@Bin(order = 6, arraySizeExpr = "456")
522522
byte[] c1;
523523
@Bin(order = 7, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
524524
short d;
525-
@Bin(order = 8, arraySizeExpression = "2")
525+
@Bin(order = 8, arraySizeExpr = "2")
526526
short[] d1;
527527
@Bin(order = 9, type = BinType.USHORT, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
528528
short e;
529-
@Bin(order = 10, type = BinType.USHORT_ARRAY, arraySizeExpression = "21")
529+
@Bin(order = 10, type = BinType.USHORT_ARRAY, arraySizeExpr = "21")
530530
short[] e1;
531531
@Bin(order = 11, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
532532
int f;
533-
@Bin(order = 12, arraySizeExpression = "211")
533+
@Bin(order = 12, arraySizeExpr = "211")
534534
int[] f1;
535535
@Bin(order = 13, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
536536
long g;
537-
@Bin(order = 14, arraySizeExpression = "211")
537+
@Bin(order = 14, arraySizeExpr = "211")
538538
long[] g1;
539539
@Bin(order = 15, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
540540
float h;
541-
@Bin(order = 16, arraySizeExpression = "1211")
541+
@Bin(order = 16, arraySizeExpr = "1211")
542542
float[] h1;
543543
@Bin(order = 17, byteOrder = JBBPByteOrder.LITTLE_ENDIAN)
544544
double i;
545-
@Bin(order = 18, arraySizeExpression = "3")
545+
@Bin(order = 18, arraySizeExpr = "3")
546546
double[] i1;
547547
@Bin(order = 19)
548548
String l;
549-
@Bin(order = 20, arraySizeExpression = "a+b")
549+
@Bin(order = 20, arraySizeExpr = "a+b")
550550
String[] l1;
551-
@Bin(customType = "int9", typeExtraPartExpression = "a+b", arraySizeExpression = "c*d", byteOrder = JBBPByteOrder.LITTLE_ENDIAN, comment = "some comment")
551+
@Bin(customType = "int9", paramExpr = "a+b", arraySizeExpr = "c*d", byteOrder = JBBPByteOrder.LITTLE_ENDIAN, comment = "some comment")
552552
int[] cus;
553553
@Bin(order = 21)
554554
Test.Some x;
555-
@Bin(order = 22, arraySizeExpression = "998")
555+
@Bin(order = 22, arraySizeExpr = "998")
556556
Test.Some[] x1;
557557

558558
class Some {
559559
@Bin(order = 1, type = BinType.UBYTE)
560560
int a;
561-
@Bin(order = 2, type = BinType.UBYTE_ARRAY, arraySizeExpression = "223")
561+
@Bin(order = 2, type = BinType.UBYTE_ARRAY, arraySizeExpr = "223")
562562
byte[] a1;
563563

564564
@Bin

0 commit comments

Comments
 (0)