Skip to content

Commit 881bfdf

Browse files
committed
Resolve this escape warnings
1 parent a624ec9 commit 881bfdf

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

src/main/JsonPrims.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public Object report(Argument args[], Context context)
5353

5454
try {
5555
Map<?,?> map = gson.fromJson(new FileReader(path), Map.class);
56-
Table t = new Table(map);
56+
Table t = Table.fromMap(map);
5757
TableExtension.tables.put(t, t.id);
5858
return t;
5959
} catch (JsonSyntaxException e) {
@@ -83,7 +83,7 @@ public Object report(Argument args[], Context context)
8383

8484
try {
8585
Map<?,?> map = gson.fromJson(json, Map.class);
86-
Table t = new Table(map);
86+
Table t = Table.fromMap(map);
8787
TableExtension.tables.put(t, t.id);
8888
return t;
8989
} catch (JsonSyntaxException e) {

src/main/Table.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,29 @@ public class Table
2727

2828
public final long id;
2929

30+
public static Table fromList(LogoList alist) throws ExtensionException {
31+
Table table = new Table();
32+
33+
table.addAll(alist);
34+
35+
return table;
36+
}
37+
38+
public static Table fromMap(Map<?,?> map) {
39+
Table table = new Table();
40+
41+
for (Map.Entry<?,?> entry : map.entrySet()) {
42+
table.put(entry.getKey(), table.getTableValue(entry.getValue()));
43+
}
44+
45+
return table;
46+
}
47+
3048
public Table() {
3149
this.id = Table.next;
3250
Table.next++;
3351
}
3452

35-
public Table(LogoList alist)
36-
throws ExtensionException {
37-
this();
38-
addAll(alist);
39-
}
40-
4153
public void addAll(LogoList alist)
4254
throws ExtensionException {
4355
for (Iterator<Object> it = alist.javaIterator(); it.hasNext();) {
@@ -59,19 +71,10 @@ public Table(long id) {
5971
next = StrictMath.max(next, id + 1);
6072
}
6173

62-
public Table(Map<?,?> map) {
63-
id = next;
64-
next++;
65-
66-
for (Map.Entry<?,?> entry : map.entrySet()) {
67-
this.put(entry.getKey(), getTableValue(entry.getValue()));
68-
}
69-
}
70-
7174
private Object getTableValue(Object value) {
7275
// return the value to be added in a table being constructed from a Map
7376
if (value instanceof LinkedTreeMap) {
74-
return new Table((Map<?,?>)value);
77+
return Table.fromMap((Map<?,?>)value);
7578
} else if (value instanceof ArrayList) {
7679
LogoListBuilder alist = new LogoListBuilder();
7780
((ArrayList<?>)value).forEach((temp) -> {

src/main/TableExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public String getAgentClassString() {
292292
public Object report(Argument args[], Context context)
293293
throws ExtensionException, LogoException {
294294
LogoList alist = args[0].getList();
295-
Table t = new Table(alist);
295+
Table t = Table.fromList(alist);
296296
tables.put(t, t.id);
297297
return t;
298298
}

0 commit comments

Comments
 (0)