Revision 9489
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/sqlQueryValidation/SQLQueryValidation.java | ||
---|---|---|
57 | 57 |
private boolean onlyWhereStatement; |
58 | 58 |
private int[] errorPosition; //[0] -> line, [1] -> column ( (-1, -1) -> no error ) ( (-2, -2) -> error: query = null) |
59 | 59 |
private String errorMessage; |
60 |
private String errorPositionAsMessage; |
|
60 | 61 |
private final String preQuery = "SELECT a FROM b WHERE "; |
61 | 62 |
private final int preQueryLenght = preQuery.length(); |
62 | 63 |
|
... | ... | |
75 | 76 |
errorPosition[0] = -1; |
76 | 77 |
errorPosition[1] = -1; |
77 | 78 |
|
79 |
errorPositionAsMessage = null; |
|
80 |
|
|
78 | 81 |
// By default no error message |
79 | 82 |
errorMessage = null; |
80 | 83 |
} |
... | ... | |
89 | 92 |
|
90 | 93 |
// If the query is null -> error |
91 | 94 |
if (query == null) { |
92 |
errorMessage = new String( PluginServices.getText(null, "queryIsNull")); |
|
93 | 95 |
errorPosition[0] = -2; |
94 | 96 |
errorPosition[1] = -2; |
97 |
defineErrorPositionAsMessageAttribute(errorPosition); |
|
98 |
errorMessage = new String( PluginServices.getText(null, "queryIsNull")); |
|
95 | 99 |
|
96 | 100 |
return false; |
97 | 101 |
} |
... | ... | |
100 | 104 |
if ((query.compareTo("")) == 0) { |
101 | 105 |
errorPosition[0] = -1; |
102 | 106 |
errorPosition[1] = -1; |
107 |
defineErrorPositionAsMessageAttribute(errorPosition); |
|
103 | 108 |
errorMessage = null; |
104 | 109 |
|
105 | 110 |
return true; |
... | ... | |
124 | 129 |
// If arrives here -> there has been no errors |
125 | 130 |
errorPosition[0] = -1; |
126 | 131 |
errorPosition[1] = -1; |
132 |
defineErrorPositionAsMessageAttribute(errorPosition); |
|
127 | 133 |
errorMessage = null; |
128 | 134 |
return true; |
129 | 135 |
} catch (Exception e) { |
... | ... | |
133 | 139 |
|
134 | 140 |
String column = new String(e.getMessage().substring(e.getMessage().indexOf("column"), e.getMessage().indexOf('.'))); |
135 | 141 |
column = column.substring(column.indexOf(' ')+1, column.length()); |
136 |
|
|
137 |
// Defines the error message |
|
138 |
errorMessage = new String( PluginServices.getText(null, "line") + ": " + line + ", " + PluginServices.getText(null, "column") + ": " + column ); |
|
139 |
|
|
142 |
|
|
140 | 143 |
// Get the line an column of the error |
141 | 144 |
errorPosition[0] = Integer.valueOf(line.trim()).intValue(); |
142 | 145 |
errorPosition[1] = Integer.valueOf(column.trim()).intValue(); |
... | ... | |
145 | 148 |
this.errorPosition[1] -= this.preQueryLenght; // Substract the lenght of the pre-query added |
146 | 149 |
} |
147 | 150 |
|
151 |
defineErrorPositionAsMessageAttribute(this.errorPosition); |
|
152 |
|
|
153 |
// Defines the error message |
|
154 |
errorMessage = e.getMessage(); |
|
155 |
|
|
148 | 156 |
return false; |
149 | 157 |
} |
150 | 158 |
} |
... | ... | |
159 | 167 |
} |
160 | 168 |
|
161 | 169 |
/** |
170 |
* Returns an string with a text describing the (first) position of the error |
|
171 |
* |
|
172 |
* @return An string or null |
|
173 |
*/ |
|
174 |
public String getErrorPositionAsMessage() { |
|
175 |
return this.errorPositionAsMessage; |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
162 | 179 |
* Returns the error position (line, column) or (-1, -1) if there hasn't been any error |
163 | 180 |
* |
164 | 181 |
* @return An array of 2 integer values (first: line, second: column) |
... | ... | |
166 | 183 |
public int[] getErrorPosition() { |
167 | 184 |
return errorPosition; |
168 | 185 |
} |
186 |
|
|
187 |
/** |
|
188 |
* Creates a message with information about the message |
|
189 |
* |
|
190 |
* @param position An array with 2 elements: (row, column) |
|
191 |
*/ |
|
192 |
private void defineErrorPositionAsMessageAttribute(int position[]) { |
|
193 |
|
|
194 |
// Defines the error message |
|
195 |
errorPositionAsMessage = new String( PluginServices.getText(null, "line") + ": " + errorPosition[0] + ", " + PluginServices.getText(null, "column") + ": " + errorPosition[1] ); |
|
196 |
} |
|
169 | 197 |
} |
Also available in: Unified diff