poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1722500 - /poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
Date Fri, 01 Jan 2016 16:27:27 GMT
Author: centic
Date: Fri Jan  1 16:27:27 2016
New Revision: 1722500

URL: http://svn.apache.org/viewvc?rev=1722500&view=rev
Log:
Combine common functionality in POIXMLTypeLoader into helper method

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java?rev=1722500&r1=1722499&r2=1722500&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java Fri Jan  1 16:27:27 2016
@@ -67,53 +67,48 @@ public class POIXMLTypeLoader {
         DEFAULT_XML_OPTIONS.setSaveSuggestedPrefixes(Collections.unmodifiableMap(map));
     }
     
-    public static XmlObject newInstance(SchemaType type, XmlOptions options) {
+    private static XmlOptions getXmlOptions(XmlOptions options) {
         XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().newInstance(type, opt);
+        return opt;
+    }
+
+    public static XmlObject newInstance(SchemaType type, XmlOptions options) {
+        return XmlBeans.getContextTypeLoader().newInstance(type, getXmlOptions(options));
     }
 
     public static XmlObject parse(String xmlText, SchemaType type, XmlOptions options) throws
XmlException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(xmlText, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(xmlText, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws
XmlException, IOException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(file, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(file, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException,
IOException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(file, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(file, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(InputStream jiois, SchemaType type, XmlOptions options)
throws XmlException, IOException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(jiois, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(jiois, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(XMLStreamReader xsr, SchemaType type, XmlOptions options)
throws XmlException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(xsr, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(xsr, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(Reader jior, SchemaType type, XmlOptions options) throws
XmlException, IOException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(jior, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(jior, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(Node node, SchemaType type, XmlOptions options) throws
XmlException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(node, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(node, type, getXmlOptions(options));
     }
 
     public static XmlObject parse(XMLInputStream xis, SchemaType type, XmlOptions options)
throws XmlException, XMLStreamException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().parse(xis, type, opt);
+        return XmlBeans.getContextTypeLoader().parse(xis, type, getXmlOptions(options));
     }
     
     public static XMLInputStream newValidatingXMLInputStream ( XMLInputStream xis, SchemaType
type, XmlOptions options ) throws XmlException, XMLStreamException {
-        XmlOptions opt = (options == null) ? DEFAULT_XML_OPTIONS : options;
-        return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream(xis, type, opt);
+        return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream(xis, type, getXmlOptions(options));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message