XML formatter: use singleAttribute(qname(""), "") v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 08 Jan 2014 23:50:22 +0100
branchv_0
changeset 1527a3382823fc3
parent 151 21eb46c5e2ec
child 153 5bb73142671d
XML formatter: use singleAttribute(qname(""), "")
java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java	Wed Jan 08 23:39:47 2014 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java	Wed Jan 08 23:50:22 2014 +0100
     1.3 @@ -90,7 +90,7 @@
     1.4  	}
     1.5  
     1.6  	protected Map<QName, String> singleAttribute(QName name, String value) {
     1.7 -		Map<QName, String> attributes = new HashMap<>(1);
     1.8 +		Map<QName, String> attributes = new HashMap<>(2);
     1.9  		attributes.put(name, value);
    1.10  		return attributes;
    1.11  	}
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java	Wed Jan 08 23:39:47 2014 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java	Wed Jan 08 23:50:22 2014 +0100
     2.3 @@ -28,7 +28,6 @@
     2.4  import java.sql.Array;
     2.5  import java.sql.SQLException;
     2.6  import java.util.Date;
     2.7 -import java.util.HashMap;
     2.8  import java.util.List;
     2.9  import java.util.Map;
    2.10  import java.util.Scanner;
    2.11 @@ -69,9 +68,7 @@
    2.12  		super.writeStartBatch();
    2.13  		printStartDocument();
    2.14  		printDoctype(DOCTYPE);
    2.15 -		Map<QName, String> attributes = new HashMap<>(1);
    2.16 -		attributes.put(qname("xmlns"), Xmlns.XHTML);
    2.17 -		printStartElement(qname("html"), attributes);
    2.18 +		printStartElement(qname("html"), singleAttribute(qname("xmlns"), Xmlns.XHTML));
    2.19  
    2.20  		printStartElement(qname("head"));
    2.21  		printTextElement(qname("title"), null, Constants.PROGRAM_NAME + ": batch results");
    2.22 @@ -84,9 +81,7 @@
    2.23  	private void printCss() {
    2.24  
    2.25  		try (Scanner css = new Scanner(getClass().getClassLoader().getResourceAsStream(CSS_FILE))) {
    2.26 -			Map<QName, String> attributes = new HashMap<>(1);
    2.27 -			attributes.put(qname("type"), "text/css");
    2.28 -			printStartElement(qname("style"), attributes);
    2.29 +			printStartElement(qname("style"), singleAttribute(qname("type"), "text/css"));
    2.30  			while (css.hasNext()) {
    2.31  				printText(css.nextLine(), true);
    2.32  			}
    2.33 @@ -173,11 +168,11 @@
    2.34  				printTableData(String.valueOf(value));
    2.35  			}
    2.36  		} else {
    2.37 -			Map<QName, String> attributes = new HashMap<>(1);
    2.38 +			Map<QName, String> attributes = null;
    2.39  			if (value instanceof Number) {
    2.40 -				attributes.put(qname("class"), "number");
    2.41 +				attributes = singleAttribute(qname("class"), "number");
    2.42  			} else if (value instanceof Boolean) {
    2.43 -				attributes.put(qname("class"), "boolean");
    2.44 +				attributes = singleAttribute(qname("class"), "boolean");
    2.45  			}
    2.46  			printTextElement(qname("td"), attributes, String.valueOf(value));
    2.47  		}