equal
deleted
inserted
replaced
108 * @throws IllegalStateException if superior state was not one from expected or if there is no |
108 * @throws IllegalStateException if superior state was not one from expected or if there is no |
109 * more superior state (we are at root level) |
109 * more superior state (we are at root level) |
110 */ |
110 */ |
111 private State popState(EnumSet expected) { |
111 private State popState(EnumSet expected) { |
112 try { |
112 try { |
113 State superior = state.pop(); |
113 state.pop(); |
|
114 State superior = state.peek(); |
114 if (expected.contains(superior)) { |
115 if (expected.contains(superior)) { |
115 return superior; |
116 return superior; |
116 } else { |
117 } else { |
117 throw new IllegalStateException("Formatter had wrong superior state: " + superior + " when it should be in one of: " + expected); |
118 throw new IllegalStateException("Formatter had wrong superior state: " + superior + " when it should be in one of: " + expected); |
118 } |
119 } |
153 throw new IllegalStateException("Query string '" + sql + "' must be set before columns header – was already set: " + currentColumnsHeader); |
154 throw new IllegalStateException("Query string '" + sql + "' must be set before columns header – was already set: " + currentColumnsHeader); |
154 } |
155 } |
155 } |
156 } |
156 |
157 |
157 @Override |
158 @Override |
158 public void writeParameters(List<Parameter> parameters) { |
159 public void writeParameters(List<? extends Parameter> parameters) { |
159 peekState(EnumSet.of(State.RESULT_SET, State.UPDATES_RESULT)); |
160 peekState(EnumSet.of(State.RESULT_SET, State.UPDATES_RESULT)); |
160 |
161 |
161 if (currentColumnsHeader != null) { |
162 if (currentColumnsHeader != null) { |
162 throw new IllegalStateException("Parameters '" + parameters + "' must be set before columns header – was already set: " + currentColumnsHeader); |
163 throw new IllegalStateException("Parameters '" + parameters + "' must be set before columns header – was already set: " + currentColumnsHeader); |
163 } |
164 } |
240 */ |
241 */ |
241 protected int getCurrentColumnsCount() { |
242 protected int getCurrentColumnsCount() { |
242 return currentColumnsCount; |
243 return currentColumnsCount; |
243 } |
244 } |
244 |
245 |
|
246 protected boolean isCurrentColumnFirst() { |
|
247 return currentColumnsCount == 1; |
|
248 } |
|
249 |
|
250 protected boolean isCurrentColumnLast() { |
|
251 return currentColumnsCount == currentColumnsHeader.getColumnCount(); |
|
252 } |
|
253 |
245 /** |
254 /** |
246 * @return row number, 1 = first |
255 * @return row number, 1 = first |
247 */ |
256 */ |
248 protected int getCurrentRowCount() { |
257 protected int getCurrentRowCount() { |
249 return currentRowCount; |
258 return currentRowCount; |