Skip to content

Commit 1c23655

Browse files
committed
Code improvements
1 parent c7258a9 commit 1c23655

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+259
-831
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
53
import java.io.Serializable;
6-
74
import javax.xml.bind.annotation.XmlRootElement;
85

9-
//~--- classes ----------------------------------------------------------------
10-
116
@XmlRootElement public class ASN1Model implements Serializable {
127
public String outputDirectory;
138
public String moduleNS;
149
public ASNModule module;
1510
}
16-
Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
53
import java.util.ArrayList;
6-
import java.util.Iterator;
74

8-
//~--- classes ----------------------------------------------------------------
95

10-
/** This class defines the class holding for ASN.1 modules and basic Types */
6+
/** This class defines the class holding for ASN.1 modules and basic Types */
117
public class ASNModule {
8+
129
public AsnTypes asnTypes;
1310
public ArrayList<AsnValue> asnValues;
14-
public ArrayList exportSymbolList;
11+
public ArrayList<String> exportSymbolList;
1512
public boolean exported;
1613
public boolean extensible;
1714
public ArrayList<SymbolsFromModule> importSymbolFromModuleList;
@@ -21,74 +18,45 @@ public class ASNModule {
2118
public boolean tag;
2219
public String tagDefault;
2320

24-
//~--- constructors -------------------------------------------------------
25-
26-
// Default Constructor
2721
public ASNModule() {
28-
exportSymbolList = new ArrayList();
22+
exportSymbolList = new ArrayList<String>();
2923
importSymbolList = new ArrayList();
3024
importSymbolFromModuleList = new ArrayList<SymbolsFromModule>();
3125
asnTypes = new AsnTypes();
3226
asnValues = new ArrayList<AsnValue>();
3327
tagDefault = "";
3428
}
3529

36-
//~--- methods ------------------------------------------------------------
37-
38-
// To String Method
3930
@Override
4031
public String toString() {
4132
String ts = "";
42-
Iterator ii;
4333

4434
ts += "MODULE NAME ::= \n";
4535
ts += moduleIdentifier + "\n";
36+
4637
ts += "IMPORT SYMBOL LIST" + "\n";
47-
ii = importSymbolList.iterator();
48-
49-
while (ii.hasNext()) {
50-
ts += ii.next() + "\n";
38+
for (Object obj: importSymbolList) {
39+
ts += obj + "\n";
5140
}
5241

5342
ts += "IMPORT SYMBOLS FROM MODULE \n";
54-
ii = importSymbolFromModuleList.iterator();
55-
56-
while (ii.hasNext()) {
57-
ts += ii.next() + "\n";
43+
for (SymbolsFromModule sfm: importSymbolFromModuleList) {
44+
ts += sfm + "\n";
5845
}
5946

6047
ts += "EXPORT SYMBOL LIST \n";
61-
ii = exportSymbolList.iterator();
62-
63-
while (ii.hasNext()) {
64-
ts += ii.next() + "\n";
48+
for (String exportSymbol: exportSymbolList) {
49+
ts += exportSymbol + "\n";
6550
}
6651

6752
ts += "ASN TYPES LIST \n";
6853
ts += asnTypes + "\n";
54+
6955
ts += "ASN VALUES LIST \n";
70-
ii = asnValues.iterator();
71-
72-
while (ii.hasNext()) {
73-
ts += ii.next() + "\n";
56+
for (AsnValue val: asnValues) {
57+
ts += val + "\n";
7458
}
7559

7660
return ts;
7761
}
78-
}
79-
80-
81-
82-
/* Causing infinite recursion
83-
//*********************************************
84-
// Definition of TypeAndConstraint
85-
//*********************************************
86-
class AsnTypeAndConstraint {
87-
Object type;
88-
AsnConstraint constraint;
89-
90-
AsnTypeAndConstraint(){
91-
}
92-
//Define To String Method
93-
}
94-
*/
62+
}

BNCompiler/src/main/java/org/bn/compiler/parser/model/ASNModules.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
53
import java.util.ArrayList;
64

7-
//~--- classes ----------------------------------------------------------------
8-
9-
//To hold all the parsed Modules
10-
11-
/**This class defines the class holding for ASN.1 modules and basic Types
12-
*/
5+
/** Instances of this class hold all the parsed Modules */
136
public class ASNModules {
14-
ArrayList<ASNModule> module_list;
7+
8+
final ArrayList<ASNModule> module_list;
159

16-
//~--- constructors -------------------------------------------------------
17-
18-
// Default Constructor
1910
ASNModules() {
2011
module_list = new ArrayList<ASNModule>();
2112
}
2213

23-
//~--- methods ------------------------------------------------------------
24-
2514
public void add(ASNModule module) {
2615
module_list.add(module);
2716
}
2817

29-
// toString Method
3018
@Override
3119
public String toString() {
3220
String ts = "";
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
package org.bn.compiler.parser.model;
22

3-
//
4-
//DefinitionofAnyType
5-
//
63
public class AsnAny {
7-
final String BUILTINTYPE = "ANY";
8-
public String definedByType;
9-
public boolean isDefinedBy;
10-
public String name;
4+
5+
public final String BUILTINTYPE = "ANY";
6+
public String definedByType;
7+
public boolean isDefinedBy;
8+
public String name;
119

12-
//~--- constructors -------------------------------------------------------
13-
14-
// Default Constructor
1510
public AsnAny() {
1611
name = "";
1712
isDefinedBy = false;
1813
definedByType = "";
1914
}
2015

21-
//~--- methods ------------------------------------------------------------
22-
16+
@Override
2317
public String toString() {
2418
return name;
2519
}
2620
}
27-
28-
29-
//~ Formatted by Jindent --- http://www.jindent.com
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
53
import java.util.ArrayList;
64

7-
//~--- classes ----------------------------------------------------------------
8-
95
public class AsnBitOrOctetStringValue {
6+
107
public String bhStr;
118
public ArrayList<String> idlist;
129
public boolean isBString;
1310
public boolean isHString;
1411

15-
//~--- constructors -------------------------------------------------------
16-
17-
// Default Constructor
1812
public AsnBitOrOctetStringValue() {
1913
idlist = new ArrayList<String>();
2014
}
2115

22-
//~--- methods ------------------------------------------------------------
23-
2416
@Override
2517
public String toString() {
2618
String ts = "";
@@ -38,4 +30,3 @@ public String toString() {
3830
return ts;
3931
}
4032
}
41-
Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
5-
import java.util.Iterator;
6-
7-
//~--- classes ----------------------------------------------------------------
8-
9-
//
10-
//DefinitionofBITSTRINGType
11-
//
123
public class AsnBitString {
13-
//public final String BUILTINTYPE = "BIT STRING";
14-
public final String BUILTINTYPE = "BIT STRING";
4+
5+
public final String BUILTINTYPE = "BIT STRING";
156
public AsnConstraint constraint;
167
public String name;
178
public AsnNamedNumberList namedNumberList;
189

19-
//~--- constructors -------------------------------------------------------
20-
21-
// Default Constructor
2210
public AsnBitString() {
2311
name = "";
2412
}
2513

26-
//~--- methods ------------------------------------------------------------
27-
28-
// toString definition
14+
@Override
2915
public String toString() {
30-
String ts = "";
31-
32-
ts += (name + "\t::=\t" + BUILTINTYPE + "\n {");
16+
String ts = (name + "\t::=\t" + BUILTINTYPE + "\n {");
3317

3418
if (namedNumberList != null) {
35-
Iterator nl = namedNumberList.namedNumbers.iterator();
36-
37-
while (nl.hasNext()) {
38-
ts += nl.next();
19+
for (AsnNamedNumber namedNumber: namedNumberList.namedNumbers) {
20+
ts += namedNumber;
3921
}
4022
}
4123

@@ -48,4 +30,3 @@ public String toString() {
4830
return ts;
4931
}
5032
}
51-
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
package org.bn.compiler.parser.model;
22

3-
//
4-
//DefinitionofBoolean
5-
//
63
public class AsnBoolean {
4+
75
public final String BUILTINTYPE = "BOOLEAN";
86
public String name;
97

10-
//~--- constructors -------------------------------------------------------
11-
12-
// Default Constructor
138
public AsnBoolean() {
149
name = "";
1510
}
1611

17-
// toString definition
18-
19-
//~--- methods ------------------------------------------------------------
20-
12+
@Override
2113
public String toString() {
22-
String ts = "";
23-
24-
ts += name + "\t::=\t" + BUILTINTYPE;
25-
26-
return ts;
14+
return name + "\t::=\t" + BUILTINTYPE;
2715
}
2816
}
2917

BNCompiler/src/main/java/org/bn/compiler/parser/model/AsnCharacterString.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
package org.bn.compiler.parser.model;
22

3-
//
4-
//DefinitionofCharacterString
5-
//
63
public class AsnCharacterString {
4+
75
public final String BUILTINTYPE = "CHARACTER STRING";
86
public AsnConstraint constraint;
97
public boolean isUCSType; // Is Unrestricted Character String Type
108
public String name;
119
public String stringtype;
1210

13-
//~--- constructors -------------------------------------------------------
14-
15-
// Default Constructor
1611
public AsnCharacterString() {
1712
name = "";
1813
stringtype = "";
1914
}
2015

21-
//~--- methods ------------------------------------------------------------
22-
16+
@Override
2317
public String toString() {
24-
String ts = "";
25-
26-
ts += name + "\t" + stringtype;
18+
String ts = name + "\t" + stringtype;
2719

2820
if (constraint != null) {
2921
ts += constraint;

BNCompiler/src/main/java/org/bn/compiler/parser/model/AsnCharacterStringValue.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
package org.bn.compiler.parser.model;
22

3-
//~--- JDK imports ------------------------------------------------------------
4-
53
import java.util.ArrayList;
64

7-
//~--- classes ----------------------------------------------------------------
8-
95
public class AsnCharacterStringValue {
6+
107
String cStr;
118
public ArrayList<CharDef> charDefsList;
129
public boolean isCharDefList;
1310
boolean isQuadruple;
1411
public boolean isTuple;
1512
public ArrayList<AsnSignedNumber> tupleQuad;
1613

17-
//~--- constructors -------------------------------------------------------
18-
19-
// Default Constructor
2014
public AsnCharacterStringValue() {
2115
charDefsList = new ArrayList<CharDef>();
2216
tupleQuad = new ArrayList<AsnSignedNumber>();
2317
}
2418

25-
//~--- methods ------------------------------------------------------------
26-
2719
@Override
2820
public String toString() {
2921
String ts = "";

0 commit comments

Comments
 (0)