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 SearchabilityFieldDef extends FieldDef {
61
62
63
64
65
66
67
68
69
70
71
72
73
74 public SearchabilityFieldDef(int lineNo, TableDef table, String name, int displayOrder,
75 Vector<FieldQualifier> qualifiers) throws IllegalityException {
76 super(lineNo, table, name, "Searchability", "Integer", displayOrder, qualifiers);
77 table.addImport("org.melati.poem.SearchabilityPoemType",
78 "table");
79 table.addImport("org.melati.poem.Searchability",
80 "table");
81 table.addImport("org.melati.poem.Searchability",
82 "persistent");
83 }
84
85
86
87
88
89
90 protected void generateColRawAccessors(Writer w) throws IOException {
91 super.generateColRawAccessors(w);
92
93 w.write(
94 "\n" +
95 " public Object getRaw(Persistent g)\n" +
96 " throws AccessPoemException {\n" +
97 " return ((" + shortestUnambiguousClassname + ")g).get" + capitalisedName + "Index();\n" +
98 " }\n" +
99 "\n");
100 w.write(
101 " public void setRaw(Persistent g, Object raw)\n" +
102 " throws AccessPoemException {\n" +
103 " ((" + shortestUnambiguousClassname + ")g).set" + capitalisedName + "Index((" +
104 rawType + ")raw);\n" +
105 " }\n");
106 }
107
108
109
110
111
112
113 public void generateBaseMethods(Writer w) throws IOException {
114 super.generateBaseMethods(w);
115
116
117
118
119 w.write(
120 "\n /**\n"
121 + " * Retrieves the "
122 + capitalisedName
123 + " index value \n"
124 + " * of this <code>Persistent</code>.\n"
125 + ((description != null) ? " * Field description: \n"
126 + DSD.javadocFormat(2, 3, description)
127 + " * \n"
128 : "")
129 + " * \n"
130 + " * Generated by "
131 + "org.melati.poem.prepro.SearchabiltyFieldDef"
132 + "#generateBaseMethods \n"
133 + " * @throws AccessPoemException \n"
134 + " * if the current <code>AccessToken</code> \n"
135 + " * does not confer read access rights\n"
136 + " * @return the " + rawType + " " + name + "\n"
137 + " */\n");
138 w.write("\n" +
139 " public Integer get" + capitalisedName + "Index()\n" +
140 " throws AccessPoemException {\n" +
141 " readLock();\n" +
142 " return get" + capitalisedName + "_unsafe();\n" +
143 " }\n" +
144 "\n");
145 w.write(
146 "\n /**\n"
147 + " * Sets the <code>"
148 + capitalisedName
149 + "</code> index value, with checking, for this "
150 + "<code>Persistent</code>.\n"
151 + ((description != null) ? " * Field description: \n"
152 + DSD.javadocFormat(2, 3, description)
153 + " * \n"
154 : "")
155 + " * \n"
156 + " * Generated by "
157 + "org.melati.poem.prepro.SearchabiltyFieldDef"
158 + "#generateBaseMethods \n"
159 + " * @param raw the value to set \n"
160 + " * @throws AccessPoemException \n"
161 + " * if the current <code>AccessToken</code> \n"
162 + " * does not confer write access rights\n"
163 + " */\n");
164 w.write(
165 " public void set" + capitalisedName + "Index(Integer raw)\n" +
166 " throws AccessPoemException {\n" +
167 " " + rootTableAccessorMethod + "().get" + capitalisedName + "Column()." +
168 "getType().assertValidRaw(raw);\n" +
169 " writeLock();\n" +
170 " set" + capitalisedName + "_unsafe(raw);\n" +
171 " }\n" +
172 "\n");
173 w.write(
174 "\n /**\n"
175 + " * Retrieves the "
176 + capitalisedName
177 + " value \n"
178 + " * of this <code>Persistent</code>.\n"
179 + ((description != null) ? " * Field description: \n"
180 + DSD.javadocFormat(2, 3, description)
181 + " * \n"
182 : "")
183 + " *\n"
184 + " * Generated by "
185 + "org.melati.poem.prepro.SearchabiltyFieldDef"
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(
193 " public " + typeShortName + " get" + capitalisedName + "()\n" +
194 " throws AccessPoemException {\n" +
195 " Integer index = get" + capitalisedName + "Index();\n" +
196 " return index == null ? null :\n" +
197 " Searchability.forIndex(index.intValue());\n" +
198 " }\n" +
199 "\n");
200 w.write(
201 "\n /**\n"
202 + " * Sets the <code>"
203 + capitalisedName
204 + "</code> value, with checking, for the "
205 + "<code>Persistent</code> argument.\n"
206 + ((description != null) ? " * Field description: \n"
207 + DSD.javadocFormat(2, 3, description)
208 + " * \n"
209 : "")
210 + " * \n"
211 + " * Generated by "
212 + "org.melati.poem.prepro.SearchabiltyFieldDef"
213 + "#generateBaseMethods \n"
214 + " * @param cooked the value to set \n"
215 + " * @throws AccessPoemException \n"
216 + " * if the current <code>AccessToken</code> \n"
217 + " * does not confer write access rights\n"
218 + " */\n");
219 w.write(
220 " public void set" + capitalisedName + "(" + typeShortName + " cooked)\n" +
221 " throws AccessPoemException {\n" +
222 " set" + capitalisedName +
223 "Index(cooked == null ? null : cooked.index);\n" +
224 " }\n");
225 }
226
227
228
229
230
231
232
233
234 public void generateJavaDeclaration(Writer w) throws IOException {
235 w.write("Integer " + name);
236 }
237
238
239 public String poemTypeJava() {
240 return "new SearchabilityPoemType()";
241 }
242 }