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 XmlEntityList {
27
28
29 static UTIL.VDMCompare vdmComp = new UTIL.VDMCompare();
30
31
32
33 public Vector entities = null;
34
35
36
37 private Long index = null;
38
39
40
41
42 private void vdm_init_XmlEntityList () throws CGException {
43 try {
44
45 entities = new Vector();
46 index = new Long(0);
47 }
48 catch (Exception e){
49
50 e.printStackTrace(System.out);
51 System.out.println(e.getMessage());
52 }
53 }
54
55
56
57
58 public XmlEntityList () throws CGException {
59
60 vdm_init_XmlEntityList();
61 entities = (Vector) UTIL.ConvertToList(UTIL.clone(new Vector()));
62 }
63
64
65
66
67 public void addHead (final XmlEntity pxe) throws CGException {
68
69 Vector rhs_2 = null;
70 Vector var1_3 = null;
71 var1_3 = new Vector();
72 var1_3.add(pxe);
73 rhs_2 = (Vector) var1_3.clone();
74 rhs_2.addAll(entities);
75 entities = (Vector) UTIL.ConvertToList(UTIL.clone(rhs_2));
76 }
77
78
79
80
81 public void addTail (final XmlEntity pxe) throws CGException {
82 entities.add(pxe);
83 }
84
85
86
87
88 public Long Length () throws CGException {
89 return new Long(entities.size());
90 }
91
92
93
94
95 public Boolean First () throws CGException {
96 if (((new Long(entities.size()).intValue()) > (new Long(0).intValue()))) {
97
98 index = UTIL.NumberToLong(UTIL.clone(new Long(1)));
99 return new Boolean(true);
100 }
101 else {
102
103 index = UTIL.NumberToLong(UTIL.clone(new Long(0)));
104 return new Boolean(false);
105 }
106 }
107
108
109
110
111 public Boolean Next () throws CGException {
112
113 Boolean cond_1 = null;
114 {
115 if ((cond_1 = new Boolean((new Long(entities.size()).intValue()) > (new Long(0).intValue()))).booleanValue())
116 cond_1 = new Boolean((index.intValue()) < (new Long(entities.size()).intValue()));
117 }
118 if (cond_1.booleanValue()) {
119
120 index = UTIL.NumberToLong(UTIL.clone(new Long(index.intValue() + new Long(1).intValue())));
121 return new Boolean(true);
122 }
123 else {
124
125 index = UTIL.NumberToLong(UTIL.clone(new Long(0)));
126 return new Boolean(false);
127 }
128 }
129
130
131
132
133 public Boolean Last () throws CGException {
134 if (((new Long(entities.size()).intValue()) > (new Long(0).intValue()))) {
135
136 index = UTIL.NumberToLong(UTIL.clone(new Long(entities.size())));
137 return new Boolean(true);
138 }
139 else {
140
141 index = UTIL.NumberToLong(UTIL.clone(new Long(0)));
142 return new Boolean(false);
143 }
144 }
145
146
147
148
149 public Boolean Previous () throws CGException {
150
151 Boolean cond_1 = null;
152 {
153 if ((cond_1 = new Boolean((new Long(entities.size()).intValue()) > (new Long(0).intValue()))).booleanValue())
154 cond_1 = new Boolean((index.intValue()) > (new Long(1).intValue()));
155 }
156 if (cond_1.booleanValue()) {
157
158 index = UTIL.NumberToLong(UTIL.clone(new Long(index.intValue() - new Long(1).intValue())));
159 return new Boolean(true);
160 }
161 else {
162
163 index = UTIL.NumberToLong(UTIL.clone(new Long(0)));
164 return new Boolean(false);
165 }
166 }
167
168
169
170
171 public XmlEntity getEntity () throws CGException {
172
173 XmlEntity rexpr_1 = null;
174 if ((1 <= index.intValue()) && (index.intValue() <= entities.size()))
175 rexpr_1 = (XmlEntity) entities.get(index.intValue() - 1);
176 else
177 UTIL.RunTime("Run-Time Error:Illegal index");
178 return (XmlEntity) rexpr_1;
179 }
180
181
182 }
183 ;