You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/05/19 16:27:25 UTC
svn commit: r776326 - in
/xerces/java/trunk/src/org/apache/xerces/impl/xs/util: LSInputListImpl.java
StringListImpl.java
Author: mrglavas
Date: Tue May 19 14:27:24 2009
New Revision: 776326
URL: http://svn.apache.org/viewvc?rev=776326&view=rev
Log:
Adding native implementations of toArray() and toArray(Object[]).
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/util/LSInputListImpl.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/util/StringListImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/util/LSInputListImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/util/LSInputListImpl.java?rev=776326&r1=776325&r2=776326&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/util/LSInputListImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/util/LSInputListImpl.java Tue May 19 14:27:24 2009
@@ -17,6 +17,7 @@
package org.apache.xerces.impl.xs.util;
+import java.lang.reflect.Array;
import java.util.AbstractList;
import org.apache.xerces.xs.LSInputList;
@@ -93,4 +94,29 @@
return getLength();
}
+ public Object[] toArray() {
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
+
} // LSInputListImpl
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/util/StringListImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/util/StringListImpl.java?rev=776326&r1=776325&r2=776326&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/util/StringListImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/util/StringListImpl.java Tue May 19 14:27:24 2009
@@ -17,6 +17,7 @@
package org.apache.xerces.impl.xs.util;
+import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Vector;
@@ -127,5 +128,36 @@
public int size() {
return getLength();
}
+
+ public Object[] toArray() {
+ if (fVector != null) {
+ return fVector.toArray();
+ }
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (fVector != null) {
+ return fVector.toArray(a);
+ }
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
} // class StringListImpl
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org