1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 package org.melati.poem.prepro;
47
48 import java.util.Vector;
49 import java.io.Writer;
50 import java.io.IOException;
51
52
53
54
55
56
57
58
59
60 public class IntegrityFixFieldDef extends FieldDef {
61
62
63
64
65
66
67
68
69
70
71
72
73
74 public IntegrityFixFieldDef(int lineNo, TableDef table, String name, int displayOrder,
75 Vector<FieldQualifier> qualifiers) throws IllegalityException {
76 super(lineNo, table, name, "StandardIntegrityFix", "Integer", displayOrder,
77 qualifiers);
78 table.addImport("org.melati.poem.IntegrityFixPoemType",
79 "table");
80 table.addImport("org.melati.poem.StandardIntegrityFix",
81 "table");
82 table.addImport("org.melati.poem.StandardIntegrityFix",
83 "persistent");
84 }
85
86
87
88
89
90
91 protected void generateColRawAccessors(Writer w) throws IOException {
92 super.generateColRawAccessors(w);
93
94 w.write(
95 "\n" +
96 " public Object getRaw(Persistent g)\n" +
97 " throws AccessPoemException {\n" +
98 " return ((" + shortestUnambiguousClassname + ")g).get" + capitalisedName + "Index();\n" +
99 " }\n" +
100 "\n");
101 w.write(
102 " public void setRaw(Persistent g, Object raw)\n" +
103 " throws AccessPoemException {\n" +
104 " ((" + shortestUnambiguousClassname + ")g).set" + capitalisedName + "Index((" +
105 rawType + ")raw);\n" +
106 " }\n");
107 }
108
109
110
111
112
113
114 public void generateBaseMethods(Writer w) throws IOException {
115 super.generateBaseMethods(w);
116
117
118
119
120 w.write(
121 "\n /**\n"
122 + " * Retrieves the "
123 + capitalisedName
124 + " index value \n"
125 + " * of this <code>Persistent</code>.\n"
126 + ((description != null) ? " * Field description: \n"
127 + DSD.javadocFormat(2, 3, description)
128 + " * \n"
129 : "")
130 + " * \n"
131 + " * Generated by "
132 + "org.melati.poem.prepro.IntegrityFixFieldDef"
133 + "#generateBaseMethods \n"
134 + " * @throws AccessPoemException \n"
135 + " * if the current <code>AccessToken</code> \n"
136 + " * does not confer read access rights\n"
137 + " * @return the " + rawType + " " + name + "\n"
138 + " */\n");
139 w.write("\n" +
140 " public Integer get" + capitalisedName + "Index()\n" +
141 " throws AccessPoemException {\n" +
142 " readLock();\n" +
143 " return get" + capitalisedName + "_unsafe();\n" +
144 " }\n" +
145 "\n");
146
147 w.write(
148 "\n /**\n"
149 + " * Sets the <code>"
150 + capitalisedName
151 + "</code> index value, with checking, \n"
152 + "for this <code>Persistent</code>.\n"
153 + ((description != null) ? " * Field description: \n"
154 + DSD.javadocFormat(2, 3, description)
155 + " * \n"
156 : "")
157 + " * \n"
158 + " * Generated by "
159 + "org.melati.poem.prepro.IntegrityFixFieldDef"
160 + "#generateBaseMethods \n"
161 + " * @param raw the value to set \n"
162 + " * @throws AccessPoemException \n"
163 + " * if the current <code>AccessToken</code> \n"
164 + " * does not confer write access rights\n"
165 + " */\n");
166 w.write(" public void set" + capitalisedName + "Index(Integer raw)\n" +
167 " throws AccessPoemException {\n" +
168 " " + rootTableAccessorMethod + "().get" + capitalisedName + "Column()." +
169 "getType().assertValidRaw(raw);\n" +
170 " writeLock();\n" +
171 " set" + capitalisedName + "_unsafe(raw);\n" +
172 " }\n" +
173 "\n");
174 w.write(
175 "\n /**\n"
176 + " * Retrieves the "
177 + capitalisedName
178 + " value \n"
179 + " * of this <code>Persistent</code>.\n"
180 + ((description != null) ? " * Field description: \n"
181 + DSD.javadocFormat(2, 3, description)
182 : "")
183 + " *\n"
184 + " * Generated by "
185 + "org.melati.poem.prepro.IntegrityFixFieldDef"
186 + "#generateBaseMethods \n"
187 + " * @throws AccessPoemException \n"
188 + " * if the current <code>AccessToken</code> \n"
189 + " * does not confer read access rights\n"
190 + " * @return the " + typeShortName + "\n"
191 + " */\n");
192 w.write(" public " + typeShortName + " get" + capitalisedName + "()\n" +
193 " throws AccessPoemException {\n" +
194 " Integer index = get" + capitalisedName + "Index();\n" +
195 " return index == null ? null :\n" +
196 " StandardIntegrityFix.forIndex(index.intValue());\n" +
197 " }\n" +
198 "\n");
199 w.write(
200 "\n /**\n"
201 + " * Sets the <code>"
202 + capitalisedName
203 + "</code> value, with checking, \n"
204 + " for the <code>Persistent</code> argument.\n"
205 + ((description != null) ? " * Field description: \n"
206 + DSD.javadocFormat(2, 3, description)
207 + " * \n"
208 : "")
209 + " * \n"
210 + " * Generated by "
211 + "org.melati.poem.prepro.IntegrityFixFieldDef"
212 + "#generateBaseMethods \n"
213 + " * @param cooked the value to set \n"
214 + " * @throws AccessPoemException \n"
215 + " * if the current <code>AccessToken</code> \n"
216 + " * does not confer write access rights\n"
217 + " */\n");
218 w.write(" public void set" + capitalisedName + "(" + typeShortName + " cooked)\n" +
219 " throws AccessPoemException {\n" +
220 " set" + capitalisedName +
221 "Index(cooked == null ? null : cooked.getIndex());\n" +
222 " }\n");
223 }
224
225
226
227
228
229
230
231
232 public void generateJavaDeclaration(Writer w) throws IOException {
233 w.write("Integer " + name);
234 }
235
236
237 public String poemTypeJava() {
238 return "new IntegrityFixPoemType(" + isNullable() + ")";
239 }
240 }