poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881860 - in /xmlbeans/trunk/src: main/java/org/apache/xmlbeans/ main/java/org/apache/xmlbeans/impl/tool/ main/java/org/apache/xmlbeans/impl/values/ test/java/compile/scomp/common/mockobj/
Date Sat, 19 Sep 2020 21:57:37 GMT
Author: kiwiwings
Date: Sat Sep 19 21:57:37 2020
New Revision: 1881860

URL: http://svn.apache.org/viewvc?rev=1881860&view=rev
Log:
a few more cleanups and deprecation removal

Modified:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/BindingConfig.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/CodeGenUtil.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlListImpl.java
    xmlbeans/trunk/src/test/java/compile/scomp/common/mockobj/TestBindingConfig.java

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/BindingConfig.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/BindingConfig.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/BindingConfig.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/BindingConfig.java Sat Sep 19 21:57:37
2020
@@ -1,17 +1,17 @@
 /*   Copyright 2004 The Apache Software Foundation
-*
-*   Licensed under the Apache License, Version 2.0 (the "License");
-*   you may not use this file except in compliance with the License.
-*   You may obtain a copy of the License at
-*
-*       http://www.apache.org/licenses/LICENSE-2.0
-*
-*   Unless required by applicable law or agreed to in writing, software
-*   distributed under the License is distributed on an "AS IS" BASIS,
-*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*   See the License for the specific language governing permissions and
-*  limitations under the License.
-*/
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 
 package org.apache.xmlbeans;
 
@@ -23,8 +23,7 @@ import javax.xml.namespace.QName;
  *
  * @see XmlBeans#compileXmlBeans(String, SchemaTypeSystem, XmlObject[], BindingConfig, SchemaTypeLoader,
Filer, XmlOptions) XmlBeans.compileXmlBeans()
  */
-public class BindingConfig
-{
+public class BindingConfig {
     private static final InterfaceExtension[] EMPTY_INTERFACE_EXT_ARRAY = new InterfaceExtension[0];
     private static final PrePostExtension[] EMPTY_PREPOST_EXT_ARRAY = new PrePostExtension[0];
     private static final UserType[] EMPTY_USER_TYPE_ARRY = new UserType[0];
@@ -38,69 +37,82 @@ public class BindingConfig
      * @param uri the namespace uri
      * @return the package name for a namespace or null.
      */
-    public String lookupPackageForNamespace(String uri) { return null; }
+    public String lookupPackageForNamespace(String uri) {
+        return null;
+    }
 
     /**
      * @param uri the namespace uri
      * @return the prefix applied to each java name for a namespace or null.
      */
-    public String lookupPrefixForNamespace(String uri) { return null; }
+    public String lookupPrefixForNamespace(String uri) {
+        return null;
+    }
 
     /**
      * @param uri the namespace uri
      * @return Get the suffix applied to each java name for a namespace or null.
      */
-    public String lookupSuffixForNamespace(String uri) { return null; }
+    public String lookupSuffixForNamespace(String uri) {
+        return null;
+    }
 
-    /**
-     * @param qname the qname of the java name
-     * @return the java name for a QName or null.
-     * @deprecated replaced with {@link #lookupJavanameForQName(QName, int)}
-     */
-    public String lookupJavanameForQName(QName qname) { return null; }
 
     /**
      * @param qname the qname of the java name
-     * @param kind the type of the qname, which one of {@link #QNAME_TYPE}, {@link #QNAME_DOCUMENT_TYPE},
-     *             {@link #QNAME_ACCESSOR_ELEMENT}, {@link #QNAME_ACCESSOR_ATTRIBUTE}
-     *
+     * @param kind  the type of the qname, which one of {@link #QNAME_TYPE}, {@link #QNAME_DOCUMENT_TYPE},
+     *              {@link #QNAME_ACCESSOR_ELEMENT}, {@link #QNAME_ACCESSOR_ATTRIBUTE}
      * @return Get the java name for a QName of a specific component kind, or null.
      */
-    public String lookupJavanameForQName(QName qname, int kind) { return null; }
+    public String lookupJavanameForQName(QName qname, int kind) {
+        return null;
+    }
 
     /**
      * @return all configured InterfaceExtensions or an empty array.
      */
-    public InterfaceExtension[] getInterfaceExtensions() { return EMPTY_INTERFACE_EXT_ARRAY;
}
+    public InterfaceExtension[] getInterfaceExtensions() {
+        return EMPTY_INTERFACE_EXT_ARRAY;
+    }
 
     /**
      * @param fullJavaName the fully qualified java type name
      * @return all InterfaceExtensions defined for the fully qualified java
      * type generated from schema compilation or an empty array.
      */
-    public InterfaceExtension[] getInterfaceExtensions(String fullJavaName) { return EMPTY_INTERFACE_EXT_ARRAY;
}
+    public InterfaceExtension[] getInterfaceExtensions(String fullJavaName) {
+        return EMPTY_INTERFACE_EXT_ARRAY;
+    }
 
     /**
      * @return all configued PrePostExtensions or an empty array.
      */
-    public PrePostExtension[] getPrePostExtensions() { return EMPTY_PREPOST_EXT_ARRAY; }
+    public PrePostExtension[] getPrePostExtensions() {
+        return EMPTY_PREPOST_EXT_ARRAY;
+    }
 
     /**
      * @param fullJavaName the fully qualified java type name
      * @return the PrePostExtension defined for the fully qualified java
      * type generated from schema compilation or null.
      */
-    public PrePostExtension getPrePostExtension(String fullJavaName) { return null; }
+    public PrePostExtension getPrePostExtension(String fullJavaName) {
+        return null;
+    }
 
     /**
      * @return all defined user types.
      */
-    public UserType[] getUserTypes() { return EMPTY_USER_TYPE_ARRY; }
+    public UserType[] getUserTypes() {
+        return EMPTY_USER_TYPE_ARRY;
+    }
 
     /**
      * @param qname the qname of the user type
      * @return a user defined Java type for a given QName.
      */
-    public UserType lookupUserTypeForQName(QName qname) { return null; }
+    public UserType lookupUserTypeForQName(QName qname) {
+        return null;
+    }
 
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java Sat Sep 19 21:57:37
2020
@@ -27,17 +27,17 @@ import java.util.ListIterator;
  * contents, so two XmlSimpleLists are the same if they have the same
  * values in the same order.
  */
-public class XmlSimpleList implements List, java.io.Serializable {
+public class XmlSimpleList implements List<Object>, java.io.Serializable {
     private static final long serialVersionUID = 1L;
 
-    private List underlying;
+    private final List<Object> underlying;
 
     /**
      * Constructs an immutable XmlSimpleList that wraps (does not copy)
      * the given {@link List}.  All non-mutating methods delegate to
      * the underlying List instance.
      */
-    public XmlSimpleList(List list) {
+    public XmlSimpleList(List<Object> list) {
         this.underlying = list;
     }
 
@@ -73,13 +73,13 @@ public class XmlSimpleList implements Li
      * Copies the collection to an array.
      */
     public Object[] toArray() {
-        return underlying.toArray();
+        return underlying.toArray(new Object[0]);
     }
 
     /**
      * Copies the collection to an array of a specified type.
      */
-    public Object[] toArray(Object[] a) {
+    public <T> T[] toArray(T[] a) {
         return underlying.toArray(a);
     }
 
@@ -177,16 +177,16 @@ public class XmlSimpleList implements Li
     /**
      * Returns a view of the portion of this list between the specified fromIndex, inclusive,
and toIndex, exclusive.
      */
-    public List subList(int from, int to) {
+    public List<Object> subList(int from, int to) {
         return new XmlSimpleList(underlying.subList(from, to));
     }
 
     /**
      * Returns an iterator over the elements in this list in proper sequence.
      */
-    public Iterator iterator() {
-        return new Iterator() {
-            Iterator i = underlying.iterator();
+    public Iterator<Object> iterator() {
+        return new Iterator<Object>() {
+            final Iterator<Object> i = underlying.iterator();
 
             public boolean hasNext() {
                 return i.hasNext();
@@ -205,16 +205,16 @@ public class XmlSimpleList implements Li
     /**
      * Returns a list iterator of the elements in this list in proper sequence.
      */
-    public ListIterator listIterator() {
+    public ListIterator<Object> listIterator() {
         return listIterator(0);
     }
 
     /**
      * Returns a list iterator of the elements in this list in proper sequence, starting
at the specified position in this list.
      */
-    public ListIterator listIterator(final int index) {
-        return new ListIterator() {
-            ListIterator i = underlying.listIterator(index);
+    public ListIterator<Object> listIterator(final int index) {
+        return new ListIterator<Object>() {
+            final ListIterator<Object> i = underlying.listIterator(index);
 
             public boolean hasNext() {
                 return i.hasNext();
@@ -296,7 +296,7 @@ public class XmlSimpleList implements Li
             return false;
         }
         final XmlSimpleList xmlSimpleList = (XmlSimpleList) o;
-        List underlying2 = xmlSimpleList.underlying;
+        List<Object> underlying2 = xmlSimpleList.underlying;
         int size = underlying.size();
         if (size != underlying2.size()) {
             return false;
@@ -315,10 +315,8 @@ public class XmlSimpleList implements Li
      * Combines the hash codes of all the list items.
      */
     public int hashCode() {
-        int size = underlying.size();
         int hash = 0;
-        for (int i = 0; i < size; i++) {
-            Object item = underlying.get(i);
+        for (Object item : underlying) {
             hash *= 19;
             hash += item.hashCode();
         }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/CodeGenUtil.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/CodeGenUtil.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/CodeGenUtil.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/CodeGenUtil.java Sat Sep 19
21:57:37 2020
@@ -31,7 +31,6 @@ public class CodeGenUtil {
     public static final String DEFAULT_MEM_START = "8m";
     public static final String DEFAULT_MEM_MAX = "256m";
     public static final String DEFAULT_COMPILER = "javac";
-    public static final String DEFAULT_JAR = "jar";
 
     //workaround for Sun bug # 4723726
     public static URI resolve(URI base, URI child) {
@@ -76,10 +75,6 @@ public class CodeGenUtil {
         return "\"" + filename.replaceAll("\\\\", "\\\\\\\\") + "\"";
     }
 
-    static private String quoteNoEscapeFilename(String filename) {
-        // don't quote if there's no space, and don't quote on linux
-        return (!filename.contains(" ") || File.separatorChar == '/') ? filename : "\"" +
filename + "\"";
-    }
 
     /**
      * Invokes javac on the generated source files in order to turn them
@@ -247,72 +242,6 @@ public class CodeGenUtil {
         return cp.toArray(new File[0]);
     }
 
-    /**
-     * @deprecated Use org.apache.xmlbeans.impl.common.JarHelper instead.
-     */
-    public static boolean externalJar(File srcdir, File outfile) {
-        return externalJar(srcdir, outfile, DEFAULT_JAR, false, false);
-    }
-
-    /**
-     * @deprecated Use org.apache.xmlbeans.impl.common.JarHelper instead.
-     */
-    public static boolean externalJar(File srcdir, File outfile, String jarPath, boolean
quiet, boolean verbose) {
-        List<String> args = new ArrayList<>();
-
-        File jar = findJavaTool(jarPath == null ? DEFAULT_JAR : jarPath);
-        assert (jar.exists()) : "jar not found " + jar;
-        args.add(jar.getAbsolutePath());
-
-        args.add("cf");
-        args.add(quoteNoEscapeFilename(outfile.getAbsolutePath()));
-
-        args.add("-C");
-        args.add(quoteNoEscapeFilename(srcdir.getAbsolutePath()));
-
-        args.add(".");
-
-        try {
-            String[] strArgs = args.toArray(new String[0]);
-
-            if (verbose) {
-                System.out.print("jar command:");
-                for (String strArg : strArgs) {
-                    System.out.print(" " + strArg);
-                }
-                System.out.println();
-            }
-
-            final Process proc = Runtime.getRuntime().exec(strArgs);
-
-            StringBuilder errorBuffer = new StringBuilder();
-            StringBuilder outputBuffer = new StringBuilder();
-
-            Thread out = copy(proc.getInputStream(), outputBuffer);
-            Thread err = copy(proc.getErrorStream(), errorBuffer);
-
-            proc.waitFor();
-
-            if (verbose || proc.exitValue() != 0) {
-                if (outputBuffer.length() > 0) {
-                    System.out.println(outputBuffer.toString());
-                    System.out.flush();
-                }
-                if (errorBuffer.length() > 0) {
-                    System.err.println(errorBuffer.toString());
-                    System.err.flush();
-                }
-
-                if (proc.exitValue() != 0) {
-                    return false;
-                }
-            }
-        } catch (Throwable e) {
-            e.printStackTrace(System.err);
-            return false;
-        }
-        return true;
-    }
 
     /**
      * Look for tool in current directory and ${JAVA_HOME}/../bin and

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaDecimalHolderEx.java
Sat Sep 19 21:57:37 2020
@@ -22,6 +22,7 @@ import org.apache.xmlbeans.impl.common.Q
 import org.apache.xmlbeans.impl.common.ValidationContext;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 public abstract class JavaDecimalHolderEx extends JavaDecimalHolder {
     private final SchemaType _schemaType;
@@ -86,13 +87,14 @@ public abstract class JavaDecimalHolderE
             try {
                 // used only for side-effect - this does not change v despite
                 // the name of the method
-                v.setScale(scale);
+                // noinspection ResultOfMethodCallIgnored
+                v.setScale(scale, RoundingMode.UNNECESSARY);
             } catch (ArithmeticException e) {
                 // ArithmeticException will be thrown if cannot represent as an Integer
                 // with this scale - i.e. would need a fraction which would correspond
                 // to digits beyond the allowed number
                 context.invalid(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_VALID,
-                    new Object[]{new Integer(v.scale()), v.toString(), new Integer(scale),
QNameHelper.readable(sType)});
+                    new Object[]{v.scale(), v.toString(), scale, QNameHelper.readable(sType)});
                 return;
             }
         }
@@ -124,7 +126,7 @@ public abstract class JavaDecimalHolderE
 
             if (len > tdf) {
                 context.invalid(XmlErrorCodes.DATATYPE_TOTAL_DIGITS_VALID,
-                    new Object[]{new Integer(len), v.toString(), new Integer(tdf), QNameHelper.readable(sType)});
+                    new Object[]{len, v.toString(), tdf, QNameHelper.readable(sType)});
                 return;
             }
         }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java Sat
Sep 19 21:57:37 2020
@@ -68,7 +68,7 @@ public abstract class JavaStringHolderEx
             int m = ((XmlObjectBase) len).getBigIntegerValue().intValue();
             if (v.length() != m) {
                 context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$STRING,
-                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
+                    new Object[]{"string", v.length(), m, QNameHelper.readable(sType)});
                 return;
             }
         }
@@ -79,7 +79,7 @@ public abstract class JavaStringHolderEx
             int m = ((XmlObjectBase) min).getBigIntegerValue().intValue();
             if (v.length() < m) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$STRING,
-                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
+                    new Object[]{"string", v.length(), m, QNameHelper.readable(sType)});
                 return;
             }
         }
@@ -90,7 +90,7 @@ public abstract class JavaStringHolderEx
             int m = ((XmlObjectBase) max).getBigIntegerValue().intValue();
             if (v.length() > m) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$STRING,
-                    new Object[]{"string", new Integer(v.length()), new Integer(m), QNameHelper.readable(sType)});
+                    new Object[]{"string", v.length(), m, QNameHelper.readable(sType)});
                 return;
             }
         }
@@ -102,8 +102,8 @@ public abstract class JavaStringHolderEx
         // enum table hasn't been constructed yet.
         XmlAnySimpleType[] vals = sType.getEnumerationValues();
         if (vals != null) {
-            for (int i = 0; i < vals.length; i++) {
-                if (v.equals(vals[i].getStringValue())) {
+            for (XmlAnySimpleType val : vals) {
+                if (v.equals(val.getStringValue())) {
                     return;
                 }
             }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlListImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlListImpl.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlListImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlListImpl.java Sat Sep
19 21:57:37 2020
@@ -22,8 +22,10 @@ import org.apache.xmlbeans.impl.common.V
 import org.apache.xmlbeans.impl.common.XMLChar;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 public class XmlListImpl extends XmlObjectBase implements XmlAnySimpleType {
     public XmlListImpl(SchemaType type, boolean complex) {
@@ -43,27 +45,14 @@ public class XmlListImpl extends XmlObje
     // SIMPLE VALUE ACCESSORS BELOW -------------------------------------------
     // gets raw text value
 
-    private static String nullAsEmpty(String s) {
-        if (s == null) {
-            return "";
-        }
-        return s;
-    }
-
-    private static String compute_list_text(List xList) {
-        if (xList.size() == 0) {
-            return "";
-        }
+    private static String compute_list_text(List<Object> xList) {
+        return xList.isEmpty() ? "" : xList.stream().map(XmlListImpl::object2String).collect(Collectors.joining("
"));
 
-        StringBuilder sb = new StringBuilder();
-        sb.append(nullAsEmpty(((SimpleValue) xList.get(0)).getStringValue()));
-
-        for (int i = 1; i < xList.size(); i++) {
-            sb.append(' ');
-            sb.append(nullAsEmpty(((SimpleValue) xList.get(i)).getStringValue()));
-        }
+    }
 
-        return sb.toString();
+    private static String object2String(Object o) {
+        String s = (o instanceof SimpleValue) ? ((SimpleValue) o).getStringValue() : o.toString();
+        return (s == null) ? "" : s;
     }
 
     protected String compute_text(NamespaceManager nsm) {
@@ -112,15 +101,15 @@ public class XmlListImpl extends XmlObje
             return EMPTY_STRINGARRAY;
         }
 
-        List result = new ArrayList();
+        List<String> result = new ArrayList<>();
         int i = 0;
-        int start = 0;
+        int start;
         for (; ; ) {
             while (i < s.length() && XMLChar.isSpace(s.charAt(i))) {
                 i += 1;
             }
             if (i >= s.length()) {
-                return (String[]) result.toArray(EMPTY_STRINGARRAY);
+                return result.toArray(EMPTY_STRINGARRAY);
             }
             start = i;
             while (i < s.length() && !XMLChar.isSpace(s.charAt(i))) {
@@ -133,39 +122,40 @@ public class XmlListImpl extends XmlObje
     public static XmlSimpleList lex(String s, SchemaType itemType, ValidationContext ctx,
PrefixResolver resolver) {
         String[] parts = split_list(s);
 
-        XmlAnySimpleType[] newArray = new XmlAnySimpleType[parts.length];
+        Function<String, XmlAnySimpleType> fun = (str) -> {
+            try {
+                return itemType.newValue(str);
+            } catch (XmlValueOutOfRangeException e) {
+                Object[] obj = {"item '" + str + "' is not a valid value of " + QNameHelper.readable(itemType)};
+                ctx.invalid(XmlErrorCodes.LIST, obj);
+                return null;
+            }
+        };
         boolean pushed = false;
         if (resolver != null) {
             NamespaceContext.push(new NamespaceContext(resolver));
             pushed = true;
         }
-        int i = 0;
         try {
-            for (i = 0; i < parts.length; i++) {
-                try {
-                    newArray[i] = itemType.newValue(parts[i]);
-                } catch (XmlValueOutOfRangeException e) {
-                    ctx.invalid(XmlErrorCodes.LIST, new Object[]{"item '" + parts[i] + "'
is not a valid value of " + QNameHelper.readable(itemType)});
-                }
-            }
+            List<? super Object> list = Stream.of(parts).map(fun).collect(Collectors.toList());
+            return new XmlSimpleList(list);
         } finally {
             if (pushed) {
                 NamespaceContext.pop();
             }
         }
-        return new XmlSimpleList(Arrays.asList(newArray));
     }
 
     protected void set_nil() {
         _value = null;
     }
 
-    public List xgetListValue() {
+    public List<?> xgetListValue() {
         check_dated();
         return _value;
     }
 
-    public List getListValue() {
+    public List<?> getListValue() {
         check_dated();
         if (_value == null) {
             return null;
@@ -173,9 +163,9 @@ public class XmlListImpl extends XmlObje
         if (_jvalue != null) {
             return _jvalue;
         }
-        List javaResult = new ArrayList();
-        for (int i = 0; i < _value.size(); i++) {
-            javaResult.add(java_value((XmlObject) _value.get(i)));
+        List<Object> javaResult = new ArrayList<>();
+        for (Object o : _value) {
+            javaResult.add(java_value((XmlObject) o));
         }
         _jvalue = new XmlSimpleList(javaResult);
         return _jvalue;
@@ -200,7 +190,7 @@ public class XmlListImpl extends XmlObje
                s.indexOf('\r') >= 0;
     }
 
-    public void set_list(List list) {
+    public void set_list(List<?> list) {
         SchemaType itemType = _schemaType.getListItemType();
         XmlSimpleList xList;
 
@@ -210,19 +200,19 @@ public class XmlListImpl extends XmlObje
             pushed = true;
         }
 
-        try {
-            XmlAnySimpleType[] newval = new XmlAnySimpleType[list.size()];
-            for (int i = 0; i < list.size(); i++) {
-                Object entry = list.get(i);
-                if ((entry instanceof XmlObject) && permits_inner_space((XmlObject)
list.get(i))) {
-                    String stringrep = list.get(i).toString();
-                    if (contains_white_space(stringrep)) {
-                        throw new XmlValueOutOfRangeException();
-                    }
+        Function<Object, XmlAnySimpleType> fun = (entry) -> {
+            if ((entry instanceof XmlObject) && permits_inner_space((XmlObject) entry))
{
+                String stringrep = entry.toString();
+                if (contains_white_space(stringrep)) {
+                    throw new XmlValueOutOfRangeException();
                 }
-                newval[i] = itemType.newValue(entry);
             }
-            xList = new XmlSimpleList(Arrays.asList(newval));
+            return itemType.newValue(entry);
+        };
+
+        try {
+            List<? super Object> l = list.stream().map(fun).collect(Collectors.toList());
+            xList = new XmlSimpleList(l);
         } finally {
             if (pushed) {
                 NamespaceContext.pop();
@@ -242,8 +232,8 @@ public class XmlListImpl extends XmlObje
         XmlObject[] enumvals = sType.getEnumerationValues();
         checkEnum:
         if (enumvals != null) {
-            for (int i = 0; i < enumvals.length; i++) {
-                if (equal_xmlLists(items, ((XmlObjectBase) enumvals[i]).xgetListValue()))
{
+            for (XmlObject enumval : enumvals) {
+                if (equal_xmlLists(items, ((XmlObjectBase) enumval).xgetListValue())) {
                     break checkEnum;
                 }
             }
@@ -257,21 +247,21 @@ public class XmlListImpl extends XmlObje
         if ((o = sType.getFacet(SchemaType.FACET_LENGTH)) != null) {
             if ((i = ((SimpleValue) o).getIntValue()) != items.size()) {
                 context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH,
-                    new Object[]{items, new Integer(items.size()), new Integer(i), QNameHelper.readable(sType)});
+                    new Object[]{items, items.size(), i, QNameHelper.readable(sType)});
             }
         }
 
         if ((o = sType.getFacet(SchemaType.FACET_MIN_LENGTH)) != null) {
             if ((i = ((SimpleValue) o).getIntValue()) > items.size()) {
                 context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$LIST_LENGTH,
-                    new Object[]{items, new Integer(items.size()), new Integer(i), QNameHelper.readable(sType)});
+                    new Object[]{items, items.size(), i, QNameHelper.readable(sType)});
             }
         }
 
         if ((o = sType.getFacet(SchemaType.FACET_MAX_LENGTH)) != null) {
             if ((i = ((SimpleValue) o).getIntValue()) < items.size()) {
                 context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$LIST_LENGTH,
-                    new Object[]{items, new Integer(items.size()), new Integer(i), QNameHelper.readable(sType)});
+                    new Object[]{items, items.size(), i, QNameHelper.readable(sType)});
             }
         }
     }
@@ -284,7 +274,7 @@ public class XmlListImpl extends XmlObje
     }
 
 
-    private static boolean equal_xmlLists(List a, List b) {
+    private static boolean equal_xmlLists(List<?> a, List<?> b) {
         if (a.size() != b.size()) {
             return false;
         }

Modified: xmlbeans/trunk/src/test/java/compile/scomp/common/mockobj/TestBindingConfig.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/common/mockobj/TestBindingConfig.java?rev=1881860&r1=1881859&r2=1881860&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/common/mockobj/TestBindingConfig.java (original)
+++ xmlbeans/trunk/src/test/java/compile/scomp/common/mockobj/TestBindingConfig.java Sat Sep
19 21:57:37 2020
@@ -18,23 +18,15 @@ import org.apache.xmlbeans.BindingConfig
 import org.apache.xmlbeans.InterfaceExtension;
 import org.apache.xmlbeans.PrePostExtension;
 import org.apache.xmlbeans.impl.config.BindingConfigImpl;
-
-import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config;
-import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig;
-import org.apache.xmlbeans.impl.xb.xmlconfig.Nsconfig;
-import org.apache.xmlbeans.impl.xb.xmlconfig.Qnameconfig;
 import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
-import org.apache.xmlbeans.BindingConfig;
 
 import javax.xml.namespace.QName;
 import java.io.File;
 
 /**
  *
- * 
  */
-public class TestBindingConfig extends BindingConfig
-{
+public class TestBindingConfig extends BindingConfig {
     BindingConfig bindingConfig;
     private boolean islookupPackageForNamespace;
     private boolean islookupPrefixForNamespace;
@@ -45,8 +37,7 @@ public class TestBindingConfig extends B
     private boolean isgetPrePostExtensions;
     private boolean isgetPrePostExtensionsString;
 
-    public TestBindingConfig(ConfigDocument.Config[] configs, File[] javaFiles, File[] classpath)
-    {
+    public TestBindingConfig(ConfigDocument.Config[] configs, File[] javaFiles, File[] classpath)
{
 
         bindingConfig = BindingConfigImpl.forConfigDocuments(configs, javaFiles, classpath);
         islookupPackageForNamespace = false;
@@ -59,106 +50,83 @@ public class TestBindingConfig extends B
         isgetPrePostExtensionsString = false;
     }
 
-    public boolean isIslookupPackageForNamespace()
-    {
+    public boolean isIslookupPackageForNamespace() {
         return islookupPackageForNamespace;
     }
-                                                         
-    public boolean isIslookupPrefixForNamespace()
-    {
+
+    public boolean isIslookupPrefixForNamespace() {
         return islookupPrefixForNamespace;
     }
 
-    public boolean isIslookupSuffixForNamespace()
-    {
+    public boolean isIslookupSuffixForNamespace() {
         return islookupSuffixForNamespace;
     }
 
-    public boolean isIslookupJavanameForQName()
-    {
+    public boolean isIslookupJavanameForQName() {
         return islookupJavanameForQName;
     }
 
-    public boolean isIsgetInterfaceExtensions()
-    {
+    public boolean isIsgetInterfaceExtensions() {
         return isgetInterfaceExtensions;
     }
 
-    public boolean isIsgetInterfaceExtensionsString()
-    {
+    public boolean isIsgetInterfaceExtensionsString() {
         return isgetInterfaceExtensionsString;
     }
 
-    public boolean isIsgetPrePostExtensions()
-    {
+    public boolean isIsgetPrePostExtensions() {
         return isgetPrePostExtensions;
     }
 
-    public boolean isIsgetPrePostExtensionsString()
-    {
+    public boolean isIsgetPrePostExtensionsString() {
         return isgetPrePostExtensionsString;
     }
 
-    public String lookupPackageForNamespace(String s)
-    {
-        System.out.println("lookupPackageForNamespace: "+s);
+    public String lookupPackageForNamespace(String s) {
+        System.out.println("lookupPackageForNamespace: " + s);
         islookupPackageForNamespace = true;
         return bindingConfig.lookupPackageForNamespace(s);
     }
 
-    public String lookupPrefixForNamespace(String s)
-    {
-        System.out.println("lookupPrefixForNamespace: "+s);
+    public String lookupPrefixForNamespace(String s) {
+        System.out.println("lookupPrefixForNamespace: " + s);
         islookupPrefixForNamespace = true;
         return bindingConfig.lookupPrefixForNamespace(s);
     }
 
-    public String lookupSuffixForNamespace(String s)
-    {
-        System.out.println("lookupSuffixForNamespace: "+s);
+    public String lookupSuffixForNamespace(String s) {
+        System.out.println("lookupSuffixForNamespace: " + s);
         islookupSuffixForNamespace = true;
         return bindingConfig.lookupSuffixForNamespace(s);
     }
 
-    /** @deprecated */
-    public String lookupJavanameForQName(QName qName)
-    {
-        System.out.println("lookupJavanameForQName: "+qName);
-        islookupJavanameForQName = true;
-        return bindingConfig.lookupJavanameForQName(qName);
-    }
 
-    public String lookupJavanameForQName(QName qName, int kind)
-    {
-        System.out.println("lookupJavanameForQName: "+qName);
+    public String lookupJavanameForQName(QName qName, int kind) {
+        System.out.println("lookupJavanameForQName: " + qName);
         islookupJavanameForQName = true;
         return bindingConfig.lookupJavanameForQName(qName, kind);
     }
 
-    public InterfaceExtension[] getInterfaceExtensions()
-    {
+    public InterfaceExtension[] getInterfaceExtensions() {
         System.out.println("getInterfaceExtensions ");
         isgetInterfaceExtensions = true;
         return bindingConfig.getInterfaceExtensions();
     }
 
-    public InterfaceExtension[] getInterfaceExtensions(String s)
-    {
-        System.out.println("getInterfaceExtensions: "+s);
+    public InterfaceExtension[] getInterfaceExtensions(String s) {
+        System.out.println("getInterfaceExtensions: " + s);
         isgetInterfaceExtensionsString = true;
         return bindingConfig.getInterfaceExtensions(s);
     }
 
-    public PrePostExtension[] getPrePostExtensions()
-    {
+    public PrePostExtension[] getPrePostExtensions() {
         System.out.println("getPrePostExtensions");
         isgetPrePostExtensions = true;
         return bindingConfig.getPrePostExtensions();
     }
 
-    public PrePostExtension getPrePostExtension(String s)
-    {
-        System.out.println("getPrePostExtension: "+s);
+    public PrePostExtension getPrePostExtension(String s) {
+        System.out.println("getPrePostExtension: " + s);
         isgetPrePostExtensionsString = true;
         return bindingConfig.getPrePostExtension(s);
     }



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


Mime
View raw message