poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881776 - in /xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl: schema/SchemaTypeCodePrinter.java values/XmlObjectBase.java
Date Wed, 16 Sep 2020 20:14:56 GMT
Author: kiwiwings
Date: Wed Sep 16 20:14:56 2020
New Revision: 1881776

URL: http://svn.apache.org/viewvc?rev=1881776&view=rev
Log:
move logic from generated classes to base class - xgetArray method

Modified:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?rev=1881776&r1=1881775&r2=1881776&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
Wed Sep 16 20:14:56 2020
@@ -2033,17 +2033,7 @@ public final class SchemaTypeCodePrinter
                 printJavaDoc("Gets (as xml) array of all " + propdesc + "s");
                 emit("public " + xtype + "[] xget" + arrayName + "() {");
                 startBlock();
-                emitImplementationPreamble();
-                if (_useJava15) {
-                    emit("java.util.List<" + xtype + "> targetList = new java.util.ArrayList<"
+ xtype + ">();");
-                } else {
-                    emit("java.util.List targetList = new java.util.ArrayList();");
-                }
-                emit("get_store().find_all_element_users(" + setIdentifier + ", targetList);");
-                emit(xtype + "[] result = new " + xtype + "[targetList.size()];");
-                emit("targetList.toArray(result);");
-                emit("return result;");
-                emitImplementationPostamble();
+                emit("return xgetArray(" + setIdentifier + ", " + xtype + "[]::new);");
                 endBlock();
 
                 // Value xgetProp(int i)

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java?rev=1881776&r1=1881775&r2=1881776&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java Wed Sep
16 20:14:56 2020
@@ -3643,4 +3643,21 @@ public abstract class XmlObjectBase impl
         }
     }
 
+    protected <T extends XmlObject> T[] xgetArray(QName elementName, IntFunction<T[]>
arrayCon) {
+        synchronized (monitor()) {
+            check_orphaned();
+            java.util.List<T> targetList = new java.util.ArrayList<>();
+            get_store().find_all_element_users(elementName, targetList);
+            return targetList.stream().toArray(arrayCon);
+        }
+    }
+
+    protected <T extends XmlObject> T[] xgetArray(QNameSet elementSet, IntFunction<T[]>
arrayCon) {
+        synchronized (monitor()) {
+            check_orphaned();
+            java.util.List<T> targetList = new java.util.ArrayList<>();
+            get_store().find_all_element_users(elementSet, targetList);
+            return targetList.stream().toArray(arrayCon);
+        }
+    }
 }



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


Mime
View raw message