franta-hg@60: /** franta-hg@60: * SQL-DK franta-hg@60: * Copyright © 2013 František Kučera (frantovo.cz) franta-hg@60: * franta-hg@60: * This program is free software: you can redistribute it and/or modify franta-hg@60: * it under the terms of the GNU General Public License as published by franta-hg@250: * the Free Software Foundation, version 3 of the License. franta-hg@60: * franta-hg@60: * This program is distributed in the hope that it will be useful, franta-hg@60: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@60: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@60: * GNU General Public License for more details. franta-hg@60: * franta-hg@60: * You should have received a copy of the GNU General Public License franta-hg@60: * along with this program. If not, see . franta-hg@60: */ franta-hg@60: package info.globalcode.sql.dk.formatting; franta-hg@60: franta-hg@60: import java.io.PrintWriter; franta-hg@60: franta-hg@60: /** franta-hg@60: * Prints just the value without any formatting. If the result set contains multiple records or franta-hg@60: * columns, the values are simply concatenate without any separators. If updates result is returned, franta-hg@60: * the updated records count is printed. franta-hg@60: * franta-hg@60: * @author Ing. František Kučera (frantovo.cz) franta-hg@60: */ franta-hg@60: public class SingleValueFormatter extends AbstractFormatter { franta-hg@60: franta-hg@79: public static final String NAME = "single"; // bash-completion:formatter franta-hg@60: private PrintWriter out; franta-hg@60: franta-hg@60: public SingleValueFormatter(FormatterContext formatterContext) { franta-hg@60: super(formatterContext); franta-hg@60: this.out = new PrintWriter(formatterContext.getOutputStream()); franta-hg@60: } franta-hg@60: franta-hg@60: @Override franta-hg@60: public void writeColumnValue(Object value) { franta-hg@60: super.writeColumnValue(value); franta-hg@60: out.print(String.valueOf(value)); franta-hg@60: out.flush(); franta-hg@60: } franta-hg@60: franta-hg@60: @Override franta-hg@142: public void writeUpdatesResult(int updatedRowsCount) { franta-hg@142: super.writeUpdatesResult(updatedRowsCount); franta-hg@60: out.print(updatedRowsCount); franta-hg@60: out.flush(); franta-hg@60: } franta-hg@60: }