View Javadoc
1   //
2   // THIS FILE IS AUTOMATICALLY GENERATED!!
3   //
4   // Generated at 2009-08-09 by the VDM++ to JAVA Code Generator
5   // (v8.2.1b - Wed 15-Jul-2009 14:09:22)
6   //
7   // Supported compilers: jdk 1.4/1.5/1.6
8   //
9   
10  // ***** VDMTOOLS START Name=HeaderComment KEEP=NO
11  // ***** VDMTOOLS END Name=HeaderComment
12  
13  // ***** VDMTOOLS START Name=package KEEP=NO
14  package org.overturetool.api.xml;
15  
16  // ***** VDMTOOLS END Name=package
17  
18  // ***** VDMTOOLS START Name=imports KEEP=NO
19  
20  import jp.co.csk.vdm.toolbox.VDM.*;
21  import java.util.*;
22  // ***** VDMTOOLS END Name=imports
23  
24  
25  
26  public abstract class XmlFileOutputVisitor extends XmlVisitor {
27  
28  // ***** VDMTOOLS START Name=vdmComp KEEP=NO
29    static UTIL.VDMCompare vdmComp = new UTIL.VDMCompare();
30  // ***** VDMTOOLS END Name=vdmComp
31  
32  // ***** VDMTOOLS START Name=encoding KEEP=NO
33    private String encoding = null;
34  // ***** VDMTOOLS END Name=encoding
35  
36  // ***** VDMTOOLS START Name=indentCount KEEP=NO
37    private Long indentCount = null;
38  // ***** VDMTOOLS END Name=indentCount
39  
40  // ***** VDMTOOLS START Name=INDENT KEEP=NO
41    private static final String INDENT = new String("  ");
42  // ***** VDMTOOLS END Name=INDENT
43  
44  
45  // ***** VDMTOOLS START Name=vdm_init_XmlFileOutputVisitor KEEP=NO
46    private void vdm_init_XmlFileOutputVisitor () throws CGException {
47      try {
48  
49        encoding = new String("");
50        indentCount = new Long(0);
51      }
52      catch (Exception e){
53  
54        e.printStackTrace(System.out);
55        System.out.println(e.getMessage());
56      }
57    }
58  // ***** VDMTOOLS END Name=vdm_init_XmlFileOutputVisitor
59  
60  
61  // ***** VDMTOOLS START Name=XmlFileOutputVisitor KEEP=NO
62    public XmlFileOutputVisitor () throws CGException {
63      vdm_init_XmlFileOutputVisitor();
64    }
65  // ***** VDMTOOLS END Name=XmlFileOutputVisitor
66  
67  
68  // ***** VDMTOOLS START Name=setEncoding#1|String KEEP=NO
69    public void setEncoding (final String encodingType) throws CGException {
70      encoding = UTIL.ConvertToString(UTIL.clone(encodingType));
71    }
72  // ***** VDMTOOLS END Name=setEncoding#1|String
73  
74  
75  // ***** VDMTOOLS START Name=print#1|String KEEP=NO
76    abstract protected void print (final String text) throws CGException ;
77  // ***** VDMTOOLS END Name=print#1|String
78  
79  
80  // ***** VDMTOOLS START Name=printData#1|String KEEP=NO
81    private void printData (final String pval) throws CGException {
82      print(pval);
83    }
84  // ***** VDMTOOLS END Name=printData#1|String
85  
86  
87  // ***** VDMTOOLS START Name=printAttribute#1|String KEEP=NO
88    private void printAttribute (final String pval) throws CGException {
89  
90      String tmpArg_v_3 = null;
91      String var1_4 = null;
92      var1_4 = new String("\"").concat(pval);
93      tmpArg_v_3 = var1_4.concat(new String("\""));
94      print(tmpArg_v_3);
95    }
96  // ***** VDMTOOLS END Name=printAttribute#1|String
97  
98  
99  // ***** VDMTOOLS START Name=XmlFileOutputVisitor#1|String KEEP=NO
100   public XmlFileOutputVisitor (final String var_1_1) throws CGException {
101     vdm_init_XmlFileOutputVisitor();
102   }
103 // ***** VDMTOOLS END Name=XmlFileOutputVisitor#1|String
104 
105 
106 // ***** VDMTOOLS START Name=VisitXmlDocument#1|XmlDocument KEEP=NO
107   public void VisitXmlDocument (final XmlDocument pxmld) throws CGException {
108 
109     Boolean cont = null;
110     XmlEntityList obj_2 = null;
111     obj_2 = pxmld.entities;
112     cont = obj_2.First();
113     if ((new Long(encoding.length()).intValue() == new Long(0).intValue())) 
114       print(new String("<?xml version=\"1.0\"?>\n"));
115     else {
116 
117       String tmpArg_v_9 = null;
118       String var1_10 = null;
119       var1_10 = new String("<?xml version=\"1.0\" encoding=\"").concat(encoding);
120       tmpArg_v_9 = var1_10.concat(new String("\"?>\n"));
121       print(tmpArg_v_9);
122     }
123     while ( cont.booleanValue()){
124 
125       XmlEntity ent = null;
126       XmlEntityList obj_17 = null;
127       obj_17 = pxmld.entities;
128       ent = (XmlEntity) obj_17.getEntity();
129       ent.accept((XmlVisitor) this);
130       Boolean rhs_21 = null;
131       XmlEntityList obj_22 = null;
132       obj_22 = pxmld.entities;
133       rhs_21 = obj_22.Next();
134       cont = (Boolean) UTIL.clone(rhs_21);
135     }
136   }
137 // ***** VDMTOOLS END Name=VisitXmlDocument#1|XmlDocument
138 
139 
140 // ***** VDMTOOLS START Name=VisitXmlEntity#1|XmlEntity KEEP=NO
141   public void VisitXmlEntity (final XmlEntity pxmle) throws CGException {
142 
143     Boolean cont = null;
144     XmlAttributeList obj_2 = null;
145     obj_2 = pxmle.attributes;
146     cont = obj_2.First();
147     indentCount = UTIL.NumberToLong(UTIL.clone(new Long(indentCount.intValue() + new Long(1).intValue())));
148     String tmpArg_v_8 = null;
149     String var1_9 = null;
150     var1_9 = GetIndent().concat(new String("<"));
151     String var2_12 = null;
152     var2_12 = pxmle.name;
153     tmpArg_v_8 = var1_9.concat(var2_12);
154     print(tmpArg_v_8);
155     while ( cont.booleanValue()){
156 
157       XmlAttribute attr = null;
158       XmlAttributeList obj_15 = null;
159       obj_15 = pxmle.attributes;
160       attr = (XmlAttribute) obj_15.getAttribute();
161       attr.accept((XmlVisitor) this);
162       Boolean rhs_19 = null;
163       XmlAttributeList obj_20 = null;
164       obj_20 = pxmle.attributes;
165       rhs_19 = obj_20.Next();
166       cont = (Boolean) UTIL.clone(rhs_19);
167     }
168     Boolean cond_22 = null;
169     Long var1_23 = null;
170     XmlEntityList obj_24 = null;
171     obj_24 = pxmle.entities;
172     var1_23 = obj_24.Length();
173     cond_22 = new Boolean((var1_23.intValue()) > (new Long(0).intValue()));
174     if (cond_22.booleanValue()) {
175 
176       print(new String(">\n"));
177       Boolean rhs_50 = null;
178       XmlEntityList obj_51 = null;
179       obj_51 = pxmle.entities;
180       rhs_50 = obj_51.First();
181       cont = (Boolean) UTIL.clone(rhs_50);
182       while ( cont.booleanValue()){
183 
184         XmlEntity ent = null;
185         XmlEntityList obj_54 = null;
186         obj_54 = pxmle.entities;
187         ent = (XmlEntity) obj_54.getEntity();
188         ent.accept((XmlVisitor) this);
189         Boolean rhs_58 = null;
190         XmlEntityList obj_59 = null;
191         obj_59 = pxmle.entities;
192         rhs_58 = obj_59.Next();
193         cont = (Boolean) UTIL.clone(rhs_58);
194       }
195       String tmpArg_v_62 = null;
196       String var1_63 = null;
197       String var1_64 = null;
198       var1_64 = GetIndent().concat(new String("</"));
199       String var2_67 = null;
200       var2_67 = pxmle.name;
201       var1_63 = var1_64.concat(var2_67);
202       tmpArg_v_62 = var1_63.concat(new String(">\n"));
203       print(tmpArg_v_62);
204     }
205     else {
206 
207       Boolean cond_42 = null;
208       XmlData var1_43 = null;
209       var1_43 = pxmle.data;
210       cond_42 = new Boolean(UTIL.equals(var1_43, null));
211       if (cond_42.booleanValue()) 
212         print(new String("/>\n"));
213       else {
214 
215         print(new String(">"));
216         XmlData obj_30 = null;
217         obj_30 = pxmle.data;
218         obj_30.accept((XmlVisitor) this);
219         String tmpArg_v_34 = null;
220         String var1_35 = null;
221         String var1_36 = null;
222         var1_36 = GetIndent().concat(new String("</"));
223         String var2_39 = null;
224         var2_39 = pxmle.name;
225         var1_35 = var1_36.concat(var2_39);
226         tmpArg_v_34 = var1_35.concat(new String(">\n"));
227         print(tmpArg_v_34);
228       }
229     }
230     indentCount = UTIL.NumberToLong(UTIL.clone(new Long(indentCount.intValue() - new Long(1).intValue())));
231   }
232 // ***** VDMTOOLS END Name=VisitXmlEntity#1|XmlEntity
233 
234 
235 // ***** VDMTOOLS START Name=VisitXmlAttribute#1|XmlAttribute KEEP=NO
236   public void VisitXmlAttribute (final XmlAttribute pattr) throws CGException {
237 
238     String tmpArg_v_3 = null;
239     String var1_4 = null;
240     String var2_6 = null;
241     var2_6 = pattr.name;
242     var1_4 = new String(" ").concat(var2_6);
243     tmpArg_v_3 = var1_4.concat(new String("="));
244     print(tmpArg_v_3);
245     String tmpArg_v_10 = null;
246     tmpArg_v_10 = pattr.val;
247     printAttribute(tmpArg_v_10);
248   }
249 // ***** VDMTOOLS END Name=VisitXmlAttribute#1|XmlAttribute
250 
251 
252 // ***** VDMTOOLS START Name=VisitXmlData#1|XmlData KEEP=NO
253   public void VisitXmlData (final XmlData pdata) throws CGException {
254 
255     String tmpArg_v_3 = null;
256     tmpArg_v_3 = pdata.data;
257     printData(tmpArg_v_3);
258   }
259 // ***** VDMTOOLS END Name=VisitXmlData#1|XmlData
260 
261 
262 // ***** VDMTOOLS START Name=GetIndent KEEP=NO
263   private String GetIndent () throws CGException {
264 
265     String ind = new String("");
266     Long i = new Long(0);
267     while ( ((i.intValue()) < (indentCount.intValue()))){
268 
269       i = UTIL.NumberToLong(UTIL.clone(new Long(i.intValue() + new Long(1).intValue())));
270       String rhs_7 = null;
271       rhs_7 = ind.concat(INDENT);
272       ind = UTIL.ConvertToString(UTIL.clone(rhs_7));
273     }
274     return ind;
275   }
276 // ***** VDMTOOLS END Name=GetIndent
277 
278 }
279 ;