1
|
1 package plparser;
|
|
2
|
6
|
3 import java.io.PrintStream;
|
1
|
4 import java.util.HashMap;
|
|
5 import java.util.LinkedList;
|
6
|
6 import java.util.Set;
|
1
|
7
|
|
8 public class DictProperty extends Property {
|
|
9 HashMap<Property, Property> map;
|
|
10
|
|
11 public DictProperty(LinkedList<Property> list) {
|
|
12 map = new HashMap<Property, Property>();
|
|
13 while(!list.isEmpty()) {
|
|
14 Property key = list.poll();
|
|
15 Property value = list.poll();
|
|
16 map.put(key, value);
|
|
17 }
|
|
18 }
|
|
19
|
|
20 public String toString() {
|
|
21 String s = "Dictionary{" ;
|
|
22 for(Property p:map.keySet()) {
|
|
23 s += p;
|
|
24 s += "->";
|
|
25 s += map.get(p);
|
|
26 s += ",";
|
|
27 }
|
3
|
28 s = s.substring(0, s.length()-1);
|
1
|
29 s += "}";
|
|
30 return s;
|
|
31 }
|
|
32
|
6
|
33 public void pp(PrintStream out, int indent,int flag) {
|
|
34 indent(out, indent,flag); out.print("Dict{");
|
|
35 int i = 0; int size = map.size();
|
|
36 flag = 0;
|
|
37 for(Property p:map.keySet()) {
|
|
38 p.pp(out,indent+indent_step,flag);out.print("->");
|
|
39 flag = 1;
|
|
40 map.get(p).pp(out,indent+indent_step+2,0);
|
|
41 if (i<size-1) out.println(",");
|
|
42 else {
|
|
43 if (size>1) indent(out,indent,1);
|
|
44 out.print("}");
|
|
45 }
|
|
46 i++;
|
|
47 }
|
|
48 }
|
|
49
|
1
|
50 }
|