Author: dashorst
Date: Tue Dec 15 22:00:27 2009
New Revision: 891026
URL: http://svn.apache.org/viewvc?rev=891026&view=rev
Log:
Removed JDK 1.6 dependency by copying code from Apache Harmony's
java.util.Arrays into org.wicket.apache.utils.Arrays. This way Wicket should
still work on Java 5 JDKs
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Arrays.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java?rev=891026&r1=891025&r2=891026&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/Url.java Tue
Dec 15 22:00:27 2009
@@ -18,13 +18,13 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.wicket.ng.protocol.http.WicketURLDecoder;
import org.apache.wicket.ng.protocol.http.WicketURLEncoder;
+import org.apache.wicket.util.lang.Arrays;
import org.apache.wicket.util.lang.Checks;
import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.util.string.StringValue;
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Arrays.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Arrays.java?rev=891026&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Arrays.java
(added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Arrays.java
Tue Dec 15 22:00:27 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.wicket.util.lang;
+
+import java.lang.reflect.Array;
+
+/**
+ * {...@code Arrays} contains static methods which operate on arrays. This
code is taken from the
+ * Apache Harmony JDK, licensed under the Apache Software License 2.0.
+ *
+ * @since 1.2
+ */
+public class Arrays
+{
+ /**
+ * Copies specified number of elements in original array to a new
array. The padding value whose
+ * index is bigger than or equal to original.length is null.
+ *
+ * @param <T>
+ * type of element in array
+ *
+ * @param original
+ * the original array
+ * @param newLength
+ * the length of copied array
+ * @return the new array
+ * @throws NegativeArraySizeException
+ * if the newLength is smaller than zero
+ * @throws NullPointerException
+ * if the original array is null
+ * @since 1.6
+ */
+ public static <T> T[] copyOf(T[] original, int newLength)
+ {
+ if (null == original)
+ {
+ throw new NullPointerException();
+ }
+ if (0 <= newLength)
+ {
+ return copyOfRange(original, 0, newLength);
+ }
+ throw new NegativeArraySizeException();
+ }
+
+ /**
+ * Copies elements in original array to a new array, from index
start(inclusive) to
+ * end(exclusive). The first element (if any) in the new array is
original[from], and other
+ * elements in the new array are in the original order. The padding
value whose index is bigger
+ * than or equal to original.length - start is null.
+ *
+ * @param <T>
+ * type of element in array
+ *
+ * @param original
+ * the original array
+ * @param start
+ * the start index, inclusive
+ * @param end
+ * the end index, exclusive, may bigger than length of the
array
+ * @return the new copied array
+ * @throws ArrayIndexOutOfBoundsException
+ * if start is smaller than 0 or bigger than original.length
+ * @throws IllegalArgumentException
+ * if start is bigger than end
+ * @throws NullPointerException
+ * if original is null
+ * @since 1.6
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T[] copyOfRange(T[] original, int start, int end)
+ {
+ if (original.length >= start && 0 <= start)
+ {
+ if (start <= end)
+ {
+ int length = end - start;
+ int copyLength = Math.min(length,
original.length - start);
+ T[] copy =
(T[])Array.newInstance(original.getClass().getComponentType(), length);
+ System.arraycopy(original, start, copy, 0,
copyLength);
+ return copy;
+ }
+ throw new IllegalArgumentException();
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+}