XmlFormatter: support for printing SQLXML types v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 06 Sep 2015 21:46:03 +0200
branchv_0
changeset 225906f767ef9b3
parent 224 36db9fd27436
child 226 b40153eb7716
XmlFormatter: support for printing SQLXML types
java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Sun Aug 30 02:28:15 2015 +0200
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Sun Sep 06 21:46:03 2015 +0200
     1.3 @@ -26,6 +26,7 @@
     1.4  import static info.globalcode.sql.dk.formatting.AbstractXmlFormatter.qname;
     1.5  import java.sql.Array;
     1.6  import java.sql.SQLException;
     1.7 +import java.sql.SQLXML;
     1.8  import java.util.LinkedHashMap;
     1.9  import java.util.List;
    1.10  import java.util.Map;
    1.11 @@ -174,6 +175,15 @@
    1.12  				writeColumnValue(String.valueOf(value));
    1.13  			}
    1.14  
    1.15 +		} else if (value instanceof SQLXML) {
    1.16 +			SQLXML xml = (SQLXML) value;
    1.17 +			// TODO: parse DOM/SAX and transplant XML, don't escape (optional)
    1.18 +			try {
    1.19 +				printTextElement(qname("column"), attributes, xml.getString());
    1.20 +			} catch (SQLException e) {
    1.21 +				log.log(Level.SEVERE, "Unable to format XML", e);
    1.22 +				writeColumnValue(String.valueOf(value));
    1.23 +			}
    1.24  		} else {
    1.25  			printTextElement(qname("column"), attributes, toString(value));
    1.26  		}