java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java
branchv_0
changeset 34 9335cf31c0f2
parent 32 5e412dbd9362
child 37 9e6f8e5d5f98
equal deleted inserted replaced
33:04db6ccd6c48 34:9335cf31c0f2
    15  * You should have received a copy of the GNU General Public License
    15  * You should have received a copy of the GNU General Public License
    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.ColorfulPrintWriter;
       
    21 
    20 /**
    22 /**
    21  *
    23  *
    22  * @author Ing. František Kučera (frantovo.cz)
    24  * @author Ing. František Kučera (frantovo.cz)
    23  */
    25  */
    24 public class TabularFormatter extends AbstractFormatter {
    26 public class TabularFormatter extends AbstractFormatter {
    25 
    27 
    26 	public static final String NAME = "tabular";
    28 	public static final String NAME = "tabular";
       
    29 	private ColorfulPrintWriter out;
    27 
    30 
    28 	public TabularFormatter(FormatterContext formatterContext) {
    31 	public TabularFormatter(FormatterContext formatterContext) {
    29 		super(formatterContext);
    32 		super(formatterContext);
       
    33 		out = new ColorfulPrintWriter(formatterContext.getOutputStream());
       
    34 	}
       
    35 
       
    36 	@Override
       
    37 	public void writeColumnValue(Object value) {
       
    38 		super.writeColumnValue(value);
       
    39 
       
    40 		if (!isCurrentColumnFirst()) {
       
    41 			out.print(ColorfulPrintWriter.TerminalColor.Green, " | ");
       
    42 		}
       
    43 		
       
    44 		out.print(ColorfulPrintWriter.TerminalColor.Cyan, String.valueOf(value));
       
    45 	}
       
    46 
       
    47 	@Override
       
    48 	public void writeEndRow() {
       
    49 		super.writeEndRow();
       
    50 		out.println();
       
    51 		out.flush();
    30 	}
    52 	}
    31 }
    53 }