1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  package org.overturetool.api.xml;
15  
16  
17  
18  
19  
20  import jp.co.csk.vdm.toolbox.VDM.*;
21  import java.util.*;
22  
23  
24  
25  
26  public class XmlDocument extends XmlEvent {
27  
28  
29    static UTIL.VDMCompare vdmComp = new UTIL.VDMCompare();
30  
31  
32  
33    public XmlEntityList entities = null;
34  
35  
36  
37  
38    private void vdm_init_XmlDocument () throws CGException {
39      try {
40        entities = (XmlEntityList) new XmlEntityList();
41      }
42      catch (Exception e){
43  
44        e.printStackTrace(System.out);
45        System.out.println(e.getMessage());
46      }
47    }
48  
49  
50  
51  
52    public XmlDocument () throws CGException {
53      vdm_init_XmlDocument();
54    }
55  
56  
57  
58  
59    public void addEntity (final XmlEntity pent) throws CGException {
60      entities.addTail((XmlEntity) pent);
61    }
62  
63  
64  
65  
66    public void accept (final XmlVisitor pxv) throws CGException {
67      pxv.VisitXmlDocument((XmlDocument) this);
68    }
69  
70  
71  
72  
73    protected Boolean StartDocument () throws CGException {
74      return new Boolean(true);
75    }
76  
77  
78  
79  
80    protected Boolean StopDocument () throws CGException {
81      return new Boolean(true);
82    }
83  
84  
85  
86  
87    protected Boolean StartEntity (final String pname) throws CGException {
88  
89      XmlEntity nxe = new XmlEntity(pname);
90      if ((stackDepth().intValue() == new Long(0).intValue())) {
91  
92        addEntity((XmlEntity) nxe);
93        pushEntity((XmlEntity) nxe);
94      }
95      else {
96  
97        XmlEntity obj_7 = null;
98        obj_7 = (XmlEntity) peekEntity();
99        obj_7.addEntity((XmlEntity) nxe);
100       pushEntity((XmlEntity) nxe);
101     }
102     return new Boolean(true);
103   }
104 
105 
106 
107 
108   protected Boolean StopEntity (final String pname) throws CGException {
109     if (((stackDepth().intValue()) > (new Long(0).intValue()))) {
110 
111       Boolean cond_6 = null;
112       String var1_7 = null;
113       var1_7 = peekEntity().name;
114       cond_6 = new Boolean(UTIL.equals(var1_7, pname));
115       if (cond_6.booleanValue()) {
116 
117         popEntity();
118         return new Boolean(true);
119       }
120       else 
121         return new Boolean(false);
122     }
123     else 
124       return new Boolean(false);
125   }
126 
127 
128 
129 
130   protected Boolean StartAttribute (final String pattr, final String pval) throws CGException {
131     if (((stackDepth().intValue()) > (new Long(0).intValue()))) {
132 
133       XmlEntity obj_8 = null;
134       obj_8 = (XmlEntity) peekEntity();
135       obj_8.addAttribute((XmlAttribute) new XmlAttribute(pattr, pval));
136       return new Boolean(true);
137     }
138     else 
139       return new Boolean(false);
140   }
141 
142 
143 
144 
145   protected Boolean StartData (final String pdata) throws CGException {
146     if (((stackDepth().intValue()) > (new Long(0).intValue()))) {
147 
148       XmlEntity obj_7 = null;
149       obj_7 = (XmlEntity) peekEntity();
150       obj_7.addData((XmlData) new XmlData(pdata));
151       return new Boolean(true);
152     }
153     else 
154       return new Boolean(false);
155   }
156 
157 
158 }
159 ;