equal
deleted
inserted
replaced
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 package info.globalcode.sql.dk.formatting; |
18 package info.globalcode.sql.dk.formatting; |
19 |
19 |
20 import info.globalcode.sql.dk.Parameter; |
20 import info.globalcode.sql.dk.Parameter; |
21 import java.io.OutputStream; |
|
22 import java.util.EmptyStackException; |
21 import java.util.EmptyStackException; |
23 import java.util.EnumSet; |
22 import java.util.EnumSet; |
24 import java.util.List; |
23 import java.util.List; |
25 import java.util.Stack; |
24 import java.util.Stack; |
26 |
25 |
29 * @author Ing. František Kučera (frantovo.cz) |
28 * @author Ing. František Kučera (frantovo.cz) |
30 */ |
29 */ |
31 public abstract class AbstractFormatter implements Formatter { |
30 public abstract class AbstractFormatter implements Formatter { |
32 |
31 |
33 private Stack<State> state = new Stack<>(); |
32 private Stack<State> state = new Stack<>(); |
34 private OutputStream outputStream; |
33 private FormatterContext formatterContext; |
35 private ColumnsHeader currentColumnsHeader; |
34 private ColumnsHeader currentColumnsHeader; |
36 private String currentQuery; |
35 private String currentQuery; |
37 private int currentColumnsCount; |
36 private int currentColumnsCount; |
38 |
37 |
39 public AbstractFormatter(OutputStream outputStream) { |
38 public AbstractFormatter(FormatterContext formatterContext) { |
40 this.outputStream = outputStream; |
39 this.formatterContext = formatterContext; |
41 state.push(State.ROOT); |
40 state.push(State.ROOT); |
42 } |
41 } |
43 |
42 |
44 /* |
43 /* |
45 * root |
44 * root |
222 @Override |
221 @Override |
223 public void writeEndGeneratedKeys() { |
222 public void writeEndGeneratedKeys() { |
224 popState(EnumSet.of(State.UPDATES_RESULT)); |
223 popState(EnumSet.of(State.UPDATES_RESULT)); |
225 } |
224 } |
226 |
225 |
227 protected OutputStream getOutputStream() { |
226 public FormatterContext getFormatterContext() { |
228 return outputStream; |
227 return formatterContext; |
229 } |
228 } |
230 |
229 |
231 protected ColumnsHeader getCurrentColumnsHeader() { |
230 protected ColumnsHeader getCurrentColumnsHeader() { |
232 return currentColumnsHeader; |
231 return currentColumnsHeader; |
233 } |
232 } |