@@ -40,30 +40,32 @@ public abstract class AbstractCobolField {
40
40
static CobolDataStorage lastdata = null ;
41
41
42
42
static final int [] cobExp10 = {
43
- 1 , 10 , 100 , 1000 , 10000 , 100000 , 1000000 , 10000000 , 100000000 , 1000000000
43
+ 1 , 10 , 100 , 1000 , 10000 , 100000 , 1000000 , 10000000 , 100000000 , 1000000000
44
44
};
45
45
46
46
/**
47
47
* moveAlphanumericToNumericで使用 C言語のgotoの代替機能を提供する
48
48
*
49
49
* @author y-sakamoto
50
50
*/
51
- protected class GotoException extends Exception {}
51
+ protected class GotoException extends Exception {
52
+ }
52
53
53
54
/**
54
55
* コンストラクタ
55
56
*
56
- * @param size データを格納するバイト配列の長さ
57
+ * @param size データを格納するバイト配列の長さ
57
58
* @param dataStorage データを格納するバイト配列を扱うオブジェクト
58
- * @param attribute 変数に関する様々な情報を保持するオブジェクト(符号付か,COMP-3指定かなど)
59
+ * @param attribute 変数に関する様々な情報を保持するオブジェクト(符号付か,COMP-3指定かなど)
59
60
*/
60
61
public AbstractCobolField (int size , CobolDataStorage dataStorage , CobolFieldAttribute attribute ) {
61
62
this .size = size ;
62
63
this .dataStorage = dataStorage ;
63
64
this .attribute = attribute ;
64
65
}
65
66
66
- public AbstractCobolField () {}
67
+ public AbstractCobolField () {
68
+ }
67
69
68
70
/**
69
71
* メンバ変数dataStorageのgetter
@@ -129,7 +131,8 @@ public CobolDataStorage getFieldData() {
129
131
}
130
132
131
133
/**
132
- * opensource COBOLのCOB_FIELD_DATAに相当するメソッド バイト配列の中で(符号データではなく)数値データの格納されている最小の添え字を返す opensource
134
+ * opensource COBOLのCOB_FIELD_DATAに相当するメソッド
135
+ * バイト配列の中で(符号データではなく)数値データの格納されている最小の添え字を返す opensource
133
136
* COBOLではポインタを返しているが,このメソッドは添え字を返す
134
137
*
135
138
* @return SIGN_LEADINGかつSIGN_SEPARATEなら1,それ以外は0
@@ -139,13 +142,12 @@ public int getFirstDataIndex() {
139
142
}
140
143
141
144
public byte [] getBytes () {
142
- CobolFieldAttribute attr =
143
- new CobolFieldAttribute (
144
- CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
145
- 9 ,
146
- 0 ,
147
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
148
- null );
145
+ CobolFieldAttribute attr = new CobolFieldAttribute (
146
+ CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
147
+ 9 ,
148
+ 0 ,
149
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
150
+ null );
149
151
CobolDataStorage n = new CobolDataStorage (new byte [4 ], 0 );
150
152
AbstractCobolField temp = CobolFieldFactory .makeCobolField (4 , n , attr );
151
153
temp .moveFrom (this );
@@ -163,13 +165,12 @@ public byte[] getBytes() {
163
165
* @return
164
166
*/
165
167
public int getInt () {
166
- CobolFieldAttribute attr =
167
- new CobolFieldAttribute (
168
- CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
169
- 9 ,
170
- 0 ,
171
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
172
- null );
168
+ CobolFieldAttribute attr = new CobolFieldAttribute (
169
+ CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
170
+ 9 ,
171
+ 0 ,
172
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
173
+ null );
173
174
CobolDataStorage n = new CobolDataStorage (new byte [4 ], 0 );
174
175
AbstractCobolField temp = CobolFieldFactory .makeCobolField (4 , n , attr );
175
176
temp .moveFrom (this );
@@ -280,7 +281,7 @@ public void setZero() {
280
281
* libcob/numeric.cのcob_addの実装 thisの保持する数値データに,引数で与えられたフィールドの保持する数値データを加算する
281
282
*
282
283
* @param field 加算する数値を保持するフィールド
283
- * @param opt 加算に関するオプション.詳しくはopensourceCOBOLを参照
284
+ * @param opt 加算に関するオプション.詳しくはopensourceCOBOLを参照
284
285
* @return 加算後のthisの保持する数値データ
285
286
*/
286
287
public int add (AbstractCobolField field , int opt ) throws CobolStopRunException {
@@ -294,7 +295,7 @@ public int add(AbstractCobolField field, int opt) throws CobolStopRunException {
294
295
* libcob/numeric.cのcob_subの実装 thisの保持する数値データに,引数で与えられたフィールドの保持する数値データを減算する
295
296
*
296
297
* @param field 減算する数値を保持するフィールド
297
- * @param opt 減算に関するオプション.詳しくはopensourceCOBOLを参照
298
+ * @param opt 減算に関するオプション.詳しくはopensourceCOBOLを参照
298
299
* @return 減算後のthisの保持する数値データ
299
300
*/
300
301
public int sub (AbstractCobolField field , int opt ) throws CobolStopRunException {
@@ -619,13 +620,12 @@ public void moveFrom(String s) {
619
620
CobolDataStorage storage = new CobolDataStorage (bytes .length );
620
621
storage .memcpy (bytes );
621
622
622
- CobolFieldAttribute attr =
623
- new CobolFieldAttribute (
624
- CobolFieldAttribute .COB_TYPE_ALPHANUMERIC ,
625
- bytes .length ,
626
- 0 ,
627
- 0 ,
628
- String .format ("X(%d)" , bytes .length ));
623
+ CobolFieldAttribute attr = new CobolFieldAttribute (
624
+ CobolFieldAttribute .COB_TYPE_ALPHANUMERIC ,
625
+ bytes .length ,
626
+ 0 ,
627
+ 0 ,
628
+ String .format ("X(%d)" , bytes .length ));
629
629
630
630
AbstractCobolField tmp = CobolFieldFactory .makeCobolField (bytes .length , storage , attr );
631
631
this .moveFrom (tmp );
@@ -647,13 +647,12 @@ public void moveFrom(int number) {
647
647
storage .setByte (length - 1 , (byte ) (storage .getByte (length - 1 ) + 0x40 ));
648
648
}
649
649
650
- CobolFieldAttribute attr =
651
- new CobolFieldAttribute (
652
- CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
653
- length ,
654
- 0 ,
655
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
656
- "S9(10)" );
650
+ CobolFieldAttribute attr = new CobolFieldAttribute (
651
+ CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
652
+ length ,
653
+ 0 ,
654
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
655
+ "S9(10)" );
657
656
658
657
AbstractCobolField tmp = CobolFieldFactory .makeCobolField (length , storage , attr );
659
658
this .moveFrom (tmp );
@@ -680,13 +679,12 @@ public void moveFrom(double number) {
680
679
CobolDataStorage storage = new CobolDataStorage (ss .length ());
681
680
storage .memcpy (ss , ss .length ());
682
681
683
- CobolFieldAttribute attr =
684
- new CobolFieldAttribute (
685
- CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
686
- ss .length (),
687
- scale ,
688
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
689
- "" );
682
+ CobolFieldAttribute attr = new CobolFieldAttribute (
683
+ CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
684
+ ss .length (),
685
+ scale ,
686
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
687
+ "" );
690
688
691
689
AbstractCobolField tmp = CobolFieldFactory .makeCobolField (ss .length (), storage , attr );
692
690
if (number < 0 ) {
@@ -707,7 +705,8 @@ public void moveFrom(double number) {
707
705
*
708
706
* @param s
709
707
*/
710
- public void checkNumeric (String s ) {}
708
+ public void checkNumeric (String s ) {
709
+ }
711
710
712
711
// TODO abstract指定
713
712
/**
@@ -840,24 +839,22 @@ private AbstractCobolField numericFieldToNumericDisplayField(AbstractCobolField
840
839
CobolDataStorage data = new CobolDataStorage (48 );
841
840
if (attr .isTypeNumeric ()) {
842
841
if (!attr .isTypeNumericDisplay ()) {
843
- CobolFieldAttribute newAttr =
844
- new CobolFieldAttribute (
845
- CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
846
- attr .getDigits (),
847
- attr .getScale (),
848
- attr .getFlags () & (~CobolFieldAttribute .COB_FLAG_HAVE_SIGN ),
849
- attr .getPic ());
842
+ CobolFieldAttribute newAttr = new CobolFieldAttribute (
843
+ CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
844
+ attr .getDigits (),
845
+ attr .getScale (),
846
+ attr .getFlags () & (~CobolFieldAttribute .COB_FLAG_HAVE_SIGN ),
847
+ attr .getPic ());
850
848
CobolNumericField temp = new CobolNumericField (attr .getDigits (), data , newAttr );
851
849
temp .moveFrom (field );
852
850
field = temp ;
853
851
} else if (attr .isFlagHaveSign ()) {
854
- CobolFieldAttribute newAttr =
855
- new CobolFieldAttribute (
856
- CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
857
- attr .getDigits (),
858
- attr .getScale (),
859
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
860
- attr .getPic ());
852
+ CobolFieldAttribute newAttr = new CobolFieldAttribute (
853
+ CobolFieldAttribute .COB_TYPE_NUMERIC_DISPLAY ,
854
+ attr .getDigits (),
855
+ attr .getScale (),
856
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
857
+ attr .getPic ());
861
858
CobolNumericField temp = new CobolNumericField (attr .getDigits (), data , newAttr );
862
859
temp .moveFrom (field );
863
860
field = temp ;
@@ -1021,7 +1018,8 @@ public String toString() {
1021
1018
}
1022
1019
1023
1020
/**
1024
- * libcob/common.cのcob_field_to_stringの実装 TODO CobolNationalFieldでオーバーライドしなくても済むように修正する.
1021
+ * libcob/common.cのcob_field_to_stringの実装 TODO
1022
+ * CobolNationalFieldでオーバーライドしなくても済むように修正する.
1025
1023
*
1026
1024
* @return this.dataの保持するデータを文字列にして返す.
1027
1025
*/
@@ -1038,13 +1036,12 @@ public String fieldToString() {
1038
1036
1039
1037
/** libcob/move.cのcob_set_intの実装 */
1040
1038
public void setInt (int n ) {
1041
- CobolFieldAttribute attr =
1042
- new CobolFieldAttribute (
1043
- CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
1044
- 9 ,
1045
- 0 ,
1046
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
1047
- null );
1039
+ CobolFieldAttribute attr = new CobolFieldAttribute (
1040
+ CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
1041
+ 9 ,
1042
+ 0 ,
1043
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
1044
+ null );
1048
1045
CobolDataStorage data = new CobolDataStorage (ByteBuffer .allocate (4 ).putInt (n ).array ());
1049
1046
AbstractCobolField temp = CobolFieldFactory .makeCobolField (4 , data , attr );
1050
1047
this .moveFrom (temp );
@@ -1062,10 +1059,8 @@ public void setInt(CobolDataStorage data) {
1062
1059
* @param size
1063
1060
*/
1064
1061
public void memcpy (byte [] src , int size ) {
1065
- CobolFieldAttribute attr =
1066
- new CobolFieldAttribute (CobolFieldAttribute .COB_TYPE_ALPHANUMERIC , 0 , 0 , 0 , null );
1067
- AbstractCobolField temp =
1068
- CobolFieldFactory .makeCobolField (size , new CobolDataStorage (src ), attr );
1062
+ CobolFieldAttribute attr = new CobolFieldAttribute (CobolFieldAttribute .COB_TYPE_ALPHANUMERIC , 0 , 0 , 0 , null );
1063
+ AbstractCobolField temp = CobolFieldFactory .makeCobolField (size , new CobolDataStorage (src ), attr );
1069
1064
this .moveFrom (temp );
1070
1065
}
1071
1066
@@ -1262,14 +1257,13 @@ public int cmpAll(AbstractCobolField other) {
1262
1257
int sign = 0 ;
1263
1258
1264
1259
if ((this .getAttribute ().getType () == CobolFieldAttribute .COB_TYPE_ALPHANUMERIC_ALL
1265
- || this .getAttribute ().getType () == CobolFieldAttribute .COB_TYPE_NATIONAL_ALL )
1260
+ || this .getAttribute ().getType () == CobolFieldAttribute .COB_TYPE_NATIONAL_ALL )
1266
1261
&& this .getSize () < other .getSize ()) {
1267
1262
int size = other .getSize ();
1268
1263
CobolDataStorage data = other .getDataStorage ();
1269
1264
sign = other .getSign ();
1270
1265
CobolDataStorage s = CobolModule .getCurrentModule ().collating_sequence ;
1271
- OUTSIDE :
1272
- do {
1266
+ OUTSIDE : do {
1273
1267
while (size >= this .getSize ()) {
1274
1268
ret = comparator .compare (this .getDataStorage (), data , this .getSize (), s );
1275
1269
if (ret != 0 ) {
@@ -1287,8 +1281,7 @@ public int cmpAll(AbstractCobolField other) {
1287
1281
CobolDataStorage data = this .getDataStorage ();
1288
1282
sign = this .getSign ();
1289
1283
CobolDataStorage s = CobolModule .getCurrentModule ().collating_sequence ;
1290
- OUTSIDE :
1291
- do {
1284
+ OUTSIDE : do {
1292
1285
while (size >= other .getSize ()) {
1293
1286
ret = comparator .compare (data , other .getDataStorage (), other .getSize (), s );
1294
1287
if (ret != 0 ) {
@@ -1330,15 +1323,13 @@ public int cmpSimpleStr(AbstractCobolField other) {
1330
1323
if (ret == 0 ) {
1331
1324
if (lf .getSize () > sf .getSize ()) {
1332
1325
if ((lf .getAttribute ().getType () & CobolFieldAttribute .COB_TYPE_NATIONAL ) != 0 ) {
1333
- ret =
1334
- CobolUtil .isNationalPadding (
1335
- lf .getDataStorage ().getSubDataStorage (sf .getSize ()), lf .getSize () - sf .getSize ());
1326
+ ret = CobolUtil .isNationalPadding (
1327
+ lf .getDataStorage ().getSubDataStorage (sf .getSize ()), lf .getSize () - sf .getSize ());
1336
1328
} else {
1337
- ret =
1338
- CobolUtil .commonCmpc (
1339
- lf .getDataStorage ().getSubDataStorage (sf .getSize ()),
1340
- (byte ) ' ' ,
1341
- lf .getSize () - sf .getSize ());
1329
+ ret = CobolUtil .commonCmpc (
1330
+ lf .getDataStorage ().getSubDataStorage (sf .getSize ()),
1331
+ (byte ) ' ' ,
1332
+ lf .getSize () - sf .getSize ());
1342
1333
}
1343
1334
if (this .getSize () < other .getSize ()) {
1344
1335
ret = -ret ;
@@ -1454,6 +1445,7 @@ public void realPutSign(int sign) {
1454
1445
} else if (sign < 0 ) {
1455
1446
p .setByte (0 , (byte ) (b + 0x40 ));
1456
1447
}
1448
+ return ;
1457
1449
case CobolFieldAttribute .COB_TYPE_NUMERIC_PACKED :
1458
1450
p = this .getDataStorage ().getSubDataStorage (this .size - 1 );
1459
1451
if (sign < 0 ) {
@@ -1474,13 +1466,12 @@ public void realPutSign(int sign) {
1474
1466
*/
1475
1467
public long getLong () {
1476
1468
long n ;
1477
- CobolFieldAttribute attr =
1478
- new CobolFieldAttribute (
1479
- CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
1480
- 18 ,
1481
- 0 ,
1482
- CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
1483
- null );
1469
+ CobolFieldAttribute attr = new CobolFieldAttribute (
1470
+ CobolFieldAttribute .COB_TYPE_NUMERIC_BINARY ,
1471
+ 18 ,
1472
+ 0 ,
1473
+ CobolFieldAttribute .COB_FLAG_HAVE_SIGN ,
1474
+ null );
1484
1475
byte [] data = new byte [8 ];
1485
1476
CobolDataStorage storage = new CobolDataStorage (data );
1486
1477
AbstractCobolField field = CobolFieldFactory .makeCobolField (8 , storage , attr );
@@ -1492,7 +1483,8 @@ public long getLongValue() {
1492
1483
return 0 ;
1493
1484
}
1494
1485
1495
- public void setLongValue (long n ) {}
1486
+ public void setLongValue (long n ) {
1487
+ }
1496
1488
1497
1489
/**
1498
1490
* libcob/move.cのcob_hankaku_moveの実装
0 commit comments