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 class XmlAttributeList {
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=attributes KEEP=NO
33    public Vector attributes = null;
34  // ***** VDMTOOLS END Name=attributes
35  
36  // ***** VDMTOOLS START Name=index KEEP=NO
37    private Long index = null;
38  // ***** VDMTOOLS END Name=index
39  
40  
41  // ***** VDMTOOLS START Name=vdm_init_XmlAttributeList KEEP=NO
42    private void vdm_init_XmlAttributeList () throws CGException {
43      try {
44  
45        attributes = 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  // ***** VDMTOOLS END Name=vdm_init_XmlAttributeList
55  
56  
57  // ***** VDMTOOLS START Name=XmlAttributeList KEEP=NO
58    public XmlAttributeList () throws CGException {
59  
60      vdm_init_XmlAttributeList();
61      attributes = (Vector) UTIL.ConvertToList(UTIL.clone(new Vector()));
62    }
63  // ***** VDMTOOLS END Name=XmlAttributeList
64  
65  
66  // ***** VDMTOOLS START Name=addHead#1|XmlAttribute KEEP=NO
67    public void addHead (final XmlAttribute 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(attributes);
75      attributes = (Vector) UTIL.ConvertToList(UTIL.clone(rhs_2));
76    }
77  // ***** VDMTOOLS END Name=addHead#1|XmlAttribute
78  
79  
80  // ***** VDMTOOLS START Name=addTail#1|XmlAttribute KEEP=NO
81    public void addTail (final XmlAttribute pxe) throws CGException {
82      attributes.add(pxe);
83    }
84  // ***** VDMTOOLS END Name=addTail#1|XmlAttribute
85  
86  
87  // ***** VDMTOOLS START Name=Length KEEP=NO
88    public Long Length () throws CGException {
89      return new Long(attributes.size());
90    }
91  // ***** VDMTOOLS END Name=Length
92  
93  
94  // ***** VDMTOOLS START Name=First KEEP=NO
95    public Boolean First () throws CGException {
96      if (((new Long(attributes.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 // ***** VDMTOOLS END Name=First
108 
109 
110 // ***** VDMTOOLS START Name=Next KEEP=NO
111   public Boolean Next () throws CGException {
112 
113     Boolean cond_1 = null;
114     {
115       if ((cond_1 = new Boolean((new Long(attributes.size()).intValue()) > (new Long(0).intValue()))).booleanValue()) 
116         cond_1 = new Boolean((index.intValue()) < (new Long(attributes.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 // ***** VDMTOOLS END Name=Next
130 
131 
132 // ***** VDMTOOLS START Name=Last KEEP=NO
133   public Boolean Last () throws CGException {
134     if (((new Long(attributes.size()).intValue()) > (new Long(0).intValue()))) {
135 
136       index = UTIL.NumberToLong(UTIL.clone(new Long(attributes.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 // ***** VDMTOOLS END Name=Last
146 
147 
148 // ***** VDMTOOLS START Name=Previous KEEP=NO
149   public Boolean Previous () throws CGException {
150 
151     Boolean cond_1 = null;
152     {
153       if ((cond_1 = new Boolean((new Long(attributes.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 // ***** VDMTOOLS END Name=Previous
168 
169 
170 // ***** VDMTOOLS START Name=getAttribute KEEP=NO
171   public XmlAttribute getAttribute () throws CGException {
172 
173     XmlAttribute rexpr_1 = null;
174     if ((1 <= index.intValue()) && (index.intValue() <= attributes.size())) 
175       rexpr_1 = (XmlAttribute) attributes.get(index.intValue() - 1);
176     else 
177       UTIL.RunTime("Run-Time Error:Illegal index");
178     return (XmlAttribute) rexpr_1;
179   }
180 // ***** VDMTOOLS END Name=getAttribute
181 
182 }
183 ;