Value formatting: Object → String conversion is job for particular formatter v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 29 Dec 2013 15:53:58 +0100 (2013-12-29)
branchv_0
changeset 984d420f8b3320
parent 97 0dcaa48809f2
child 99 b969176512dd
Value formatting: Object → String conversion is job for particular formatter
java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java	Sun Dec 29 15:49:25 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java	Sun Dec 29 15:53:58 2013 +0100
     1.3 @@ -211,17 +211,6 @@
     1.4  		}
     1.5  	}
     1.6  
     1.7 -	/**
     1.8 -	 * @param value from ResultSet
     1.9 -	 * @return String representation of given value
    1.10 -	 */
    1.11 -	protected String toString(Object value) {
    1.12 -		/**
    1.13 -		 * TODO: basic formatting: boolean, null, date, numbers…
    1.14 -		 */
    1.15 -		return String.valueOf(value);
    1.16 -	}
    1.17 -
    1.18  	@Override
    1.19  	public void writeStartUpdatesResult() {
    1.20  		pushState(State.UPDATES_RESULT, EnumSet.of(State.DATABASE));
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Sun Dec 29 15:49:25 2013 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/TabularFormatter.java	Sun Dec 29 15:53:58 2013 +0100
     2.3 @@ -163,14 +163,13 @@
     2.4  
     2.5  	}
     2.6  
     2.7 -	@Override
     2.8  	protected String toString(Object value) {
     2.9  		final int width = getColumnWidth(getCurrentColumnsCount());
    2.10  		String result;
    2.11  		if (value instanceof Number || value instanceof Boolean) {
    2.12 -			result = lpad(super.toString(value), width);
    2.13 +			result = lpad(String.valueOf(value), width);
    2.14  		} else {
    2.15 -			result = rpad(super.toString(value), width);
    2.16 +			result = rpad(String.valueOf(value), width);
    2.17  		}
    2.18  		// ?	value = (boolean) value ? "✔" : "✗";
    2.19