Mercurial > hg > Members > kono > PLparser
comparison src/plparser/DictProperty.java @ 6:563bcb96e4fa
pretty printer
author | one |
---|---|
date | Mon, 30 Aug 2010 12:35:23 +0900 |
parents | 1f46c9d09c1e |
children | 79d492bce828 |
comparison
equal
deleted
inserted
replaced
5:29b5497fc942 | 6:563bcb96e4fa |
---|---|
1 package plparser; | 1 package plparser; |
2 | 2 |
3 import java.io.PrintStream; | |
3 import java.util.HashMap; | 4 import java.util.HashMap; |
4 import java.util.LinkedList; | 5 import java.util.LinkedList; |
6 import java.util.Set; | |
5 | 7 |
6 public class DictProperty extends Property { | 8 public class DictProperty extends Property { |
7 HashMap<Property, Property> map; | 9 HashMap<Property, Property> map; |
8 | 10 |
9 public DictProperty(LinkedList<Property> list) { | 11 public DictProperty(LinkedList<Property> list) { |
26 s = s.substring(0, s.length()-1); | 28 s = s.substring(0, s.length()-1); |
27 s += "}"; | 29 s += "}"; |
28 return s; | 30 return s; |
29 } | 31 } |
30 | 32 |
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 | |
31 } | 50 } |