You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC
svn commit: r418401 [12/32] - in /incubator/openjpa/trunk: openjpa-lib/
openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/...
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -17,115 +14,108 @@
import java.util.*;
-
/**
- * Utilities for calculating string distance.
- *
- * @author Marc Prud'hommeaux
- * @nojavadoc */
+ * Utilities for calculating string distance.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
public class StringDistance {
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string.
- *
- * @see #getClosestLevenshteinDistance(String,Collection,int)
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string.
+ *
+ * @see #getClosestLevenshteinDistance(String,Collection,int)
*/
public static String getClosestLevenshteinDistance(String str,
String[] candidates) {
- if (candidates == null) {
+ if (candidates == null)
return null;
- }
-
return getClosestLevenshteinDistance(str, Arrays.asList(candidates));
}
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string.
- *
- * @see #getClosestLevenshteinDistance(String,Collection,int)
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string.
+ *
+ * @see #getClosestLevenshteinDistance(String,Collection,int)
*/
public static String getClosestLevenshteinDistance(String str,
Collection candidates) {
- return getClosestLevenshteinDistance(str, candidates, Integer.MAX_VALUE);
+ return getClosestLevenshteinDistance(str, candidates,
+ Integer.MAX_VALUE);
}
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string.
- *
- * @see #getClosestLevenshteinDistance(String,Collection,int)
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string.
+ *
+ * @see #getClosestLevenshteinDistance(String,Collection,int)
*/
public static String getClosestLevenshteinDistance(String str,
String[] candidates, int threshold) {
- if (candidates == null) {
+ if (candidates == null)
return null;
- }
-
return getClosestLevenshteinDistance(str, Arrays.asList(candidates),
threshold);
}
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string and using the threshold as the specified
- * percentage of the length of the candidate string (0.0f-1.0f).
- *
- * @see #getClosestLevenshteinDistance(String,Collection,int)
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string and using the threshold as the specified
+ * percentage of the length of the candidate string(0.0f-1.0f).
+ *
+ * @see #getClosestLevenshteinDistance(String,Collection,int)
*/
public static String getClosestLevenshteinDistance(String str,
String[] candidates, float thresholdPercentage) {
- if (candidates == null) {
+ if (candidates == null)
return null;
- }
return getClosestLevenshteinDistance(str, Arrays.asList(candidates),
thresholdPercentage);
}
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string and using the threshold as the specified
- * percentage of the length of the candidate string (0.0f-1.0f).
- *
- * @see #getClosestLevenshteinDistance(String,Collection,int)
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string and using the threshold as the specified
+ * percentage of the length of the candidate string(0.0f-1.0f).
+ *
+ * @see #getClosestLevenshteinDistance(String,Collection,int)
*/
public static String getClosestLevenshteinDistance(String str,
Collection candidates, float thresholdPercentage) {
- if (str == null) {
+ if (str == null)
return null;
- }
thresholdPercentage = Math.min(thresholdPercentage, 1.0f);
thresholdPercentage = Math.max(thresholdPercentage, 0.0f);
return getClosestLevenshteinDistance(str, candidates,
- (int) (str.length() * thresholdPercentage));
+ (int)(str.length() * thresholdPercentage));
}
/**
- * Returns the candidate string with the closest Levenshtein distance
- * to the given string.
- *
- * @param str the string to check
- * @param candidates the list of strings to test against
- * @param threshold the threshold distance a candidate must meet
- *
- * @see #getLevenshteinDistance
+ * Returns the candidate string with the closest Levenshtein distance
+ * to the given string.
+ *
+ * @param str the string to check
+ * @param candidates the list of strings to test against
+ * @param threshold the threshold distance a candidate must meet
+ *
+ * @see #getLevenshteinDistance
*/
public static String getClosestLevenshteinDistance(String str,
Collection candidates, int threshhold) {
- if ((candidates == null) || candidates.isEmpty()) {
+ if (candidates == null || candidates.isEmpty())
return null;
- }
String minString = null;
int minValue = Integer.MAX_VALUE;
- for (Iterator i = candidates.iterator(); i.hasNext();) {
+ for (Iterator i = candidates.iterator(); i.hasNext(); ) {
String candidate = (String) i.next();
int distance = getLevenshteinDistance(str, candidate);
-
if (distance < minValue) {
minValue = distance;
minString = candidate;
@@ -133,34 +123,31 @@
}
// return the lowest close string only if we surpass the threshhold
- if (minValue <= threshhold) {
+ if (minValue <= threshhold)
return minString;
- } else {
+ else
return null;
- }
}
/**
- * Returns the Levenshtein distance between the two strings.
- * The distance is the minimum number of changes that need to be
- * applied to the first string in order to get to the second
- * string. For details of the algorithm, see
- * <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">
- * http://en.wikipedia.org/wiki/Levenshtein_distance</a>.
+ * Returns the Levenshtein distance between the two strings.
+ * The distance is the minimum number of changes that need to be
+ * applied to the first string in order to get to the second
+ * string. For details of the algorithm, see
+ * <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">
+ * http://en.wikipedia.org/wiki/Levenshtein_distance</a>.
*/
public static int getLevenshteinDistance(String s, String t) {
int n = s.length();
int m = t.length();
- if (n == 0) {
+ if (n == 0)
return m;
- }
- if (m == 0) {
+ if (m == 0)
return n;
- }
- int[][] matrix = new int[n + 1][m + 1];
+ int[][] matrix = new int[n+1][m+1];
for (int i = 0; i <= n; i++)
matrix[i][0] = i;
@@ -176,14 +163,13 @@
int cost;
- if (si == tj) {
+ if (si == tj)
cost = 0;
- } else {
+ else
cost = 1;
- }
- matrix[i][j] = min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1,
- matrix[i - 1][j - 1] + cost);
+ matrix[i][j] = min(matrix[i-1][j]+1, matrix[i][j-1]+1,
+ matrix[i-1][j-1] + cost);
}
}
@@ -193,14 +179,13 @@
private static int min(int a, int b, int c) {
int mi = a;
- if (b < mi) {
+ if (b < mi)
mi = b;
- }
- if (c < mi) {
+ if (c < mi)
mi = c;
- }
return mi;
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -15,21 +12,19 @@
*/
package org.apache.openjpa.lib.util;
-import serp.bytecode.lowlevel.*;
-
import java.io.*;
-
import java.util.*;
-
+import serp.bytecode.lowlevel.*;
/**
- * <p>ClassLoader implementation that allows classes to be temporarily
- * loaded and then thrown away. Useful for the enhancer to be able
- * to run against a class without first loading (and thus polluting)
- * the parent ClassLoader.</p>
- *
- * @author Marc Prud'hommeaux
- * @nojavadoc */
+ * ClassLoader implementation that allows classes to be temporarily
+ * loaded and then thrown away. Useful for the enhancer to be able
+ * to run against a class without first loading(and thus polluting)
+ * the parent ClassLoader.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
public class TemporaryClassLoader extends ClassLoader {
public TemporaryClassLoader(ClassLoader parent) {
super(parent);
@@ -43,39 +38,30 @@
throws ClassNotFoundException {
// see if we've already loaded it
Class c = findLoadedClass(name);
-
- if (c != null) {
+ if (c != null)
return c;
- }
// bug #283. defer to system if the name is a protected name.
// "sun." is required for JDK 1.4, which has an access check for
// sun.reflect.GeneratedSerializationConstructorAccessor1
- if (name.startsWith("java.") || name.startsWith("javax.") ||
- name.startsWith("sun.")) {
+ if (name.startsWith("java.") || name.startsWith("javax.")
+ || name.startsWith("sun."))
return Class.forName(name, resolve, getClass().getClassLoader());
- }
String resourceName = name.replace('.', '/') + ".class";
InputStream resource = getResourceAsStream(resourceName);
-
- if (resource == null) {
+ if (resource == null)
throw new ClassNotFoundException(name);
- }
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] b = new byte[1024];
-
try {
for (int n = 0; (n = resource.read(b, 0, b.length)) != -1;
- bout.write(b, 0, n))
- ;
-
+ bout.write(b, 0, n));
byte[] classBytes = bout.toByteArray();
-
- if (isAnnotation(classBytes)) {
- return Class.forName(name, resolve, getClass().getClassLoader());
- }
+ if (isAnnotation(classBytes))
+ return Class.forName(name, resolve, getClass().
+ getClassLoader());
try {
return defineClass(name, classBytes, 0, classBytes.length);
@@ -90,17 +76,14 @@
}
/**
- * Fast-parse the given class bytecode to determine if it is an
- * annotation class.
+ * Fast-parse the given class bytecode to determine if it is an
+ * annotation class.
*/
private static boolean isAnnotation(byte[] b) {
- if (JavaVersions.VERSION < 5) {
+ if (JavaVersions.VERSION < 5)
return false;
- }
-
int idx = ConstantPoolTable.getEndIndex(b);
int access = ConstantPoolTable.readUnsignedShort(b, idx);
-
- return (access & 0x2000) != 0; // access constant for annotation type
+ return(access & 0x2000) != 0; // access constant for annotation type
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TypedProperties.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TypedProperties.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TypedProperties.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TypedProperties.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -17,339 +14,312 @@
import java.util.*;
-
/**
- * <p>A specialization of the {@link Properties} map type with added
- * convenience methods to retrieve and set options as primitive values.
- * The internal representation of all data is kept in string form.</p>
- *
- * @author Abe White
- * @nojavadoc */
+ * A specialization of the {@link Properties} map type with added
+ * convenience methods to retrieve and set options as primitive values.
+ * The internal representation of all data is kept in string form.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
public class TypedProperties extends Properties {
/**
- * Default constructor.
+ * Default constructor.
*/
public TypedProperties() {
super();
}
/**
- * Construct the properties instance with the given set of defaults.
- *
- * @see Properties#Properties(Properties)
+ * Construct the properties instance with the given set of defaults.
+ *
+ * @see Properties#Properties(Properties)
*/
public TypedProperties(Properties defaults) {
super(defaults);
}
/**
- * Return the property under the given key as a boolean, or false if
- * it does not exist and has no set default.
+ * Return the property under the given key as a boolean, or false if
+ * it does not exist and has no set default.
*/
public boolean getBooleanProperty(String key) {
return getBooleanProperty(key, false);
}
/**
- * Return the property under the given key as a boolean, or the given
- * default if it does not exist.
+ * Return the property under the given key as a boolean, or the given
+ * default if it does not exist.
*/
public boolean getBooleanProperty(String key, boolean def) {
String val = getProperty(key);
-
- if (val == null) {
+ if (val == null)
return def;
- }
-
return "t".equalsIgnoreCase(val) || "true".equalsIgnoreCase(val);
}
/**
- * Return the property under the given key as a float, or 0 if
- * it does not exist and has no set default.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a float, or 0 if
+ * it does not exist and has no set default.
+ *
+ * @throws NumberFormatException on parse error
*/
public float getFloatProperty(String key) {
return getFloatProperty(key, 0F);
}
/**
- * Return the property under the given key as a float, or the given
- * default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a float, or the given
+ * default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public float getFloatProperty(String key, float def) {
String val = getProperty(key);
-
- return (val == null) ? def : Float.parseFloat(val);
+ return(val == null) ? def : Float.parseFloat(val);
}
/**
- * Return the property under the given key as a double, or 0 if
- * it does not exist and has no set default.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a double, or 0 if
+ * it does not exist and has no set default.
+ *
+ * @throws NumberFormatException on parse error
*/
public double getDoubleProperty(String key) {
return getDoubleProperty(key, 0D);
}
/**
- * Return the property under the given key as a double, or the given
- * default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a double, or the given
+ * default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public double getDoubleProperty(String key, double def) {
String val = getProperty(key);
-
- return (val == null) ? def : Double.parseDouble(val);
+ return(val == null) ? def : Double.parseDouble(val);
}
/**
- * Return the property under the given key as a long, or 0 if
- * it does not exist and has no set default.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a long, or 0 if
+ * it does not exist and has no set default.
+ *
+ * @throws NumberFormatException on parse error
*/
public long getLongProperty(String key) {
return getLongProperty(key, 0L);
}
/**
- * Return the property under the given key as a double, or the given
- * default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as a double, or the given
+ * default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public long getLongProperty(String key, long def) {
String val = getProperty(key);
-
- return (val == null) ? def : Long.parseLong(val);
+ return(val == null) ? def : Long.parseLong(val);
}
/**
- * Return the property under the given key as an int, or 0 if
- * it does not exist and has no set default.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as an int, or 0 if
+ * it does not exist and has no set default.
+ *
+ * @throws NumberFormatException on parse error
*/
public int getIntProperty(String key) {
return getIntProperty(key, 0);
}
/**
- * Return the property under the given key as an int, or the given
- * default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Return the property under the given key as an int, or the given
+ * default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public int getIntProperty(String key, int def) {
String val = getProperty(key);
-
- return (val == null) ? def : Integer.parseInt(val);
+ return(val == null) ? def : Integer.parseInt(val);
}
/**
- * Overrides {@link Properties#setProperty(String,String)} to remove
- * the key if the given value is <code>null</code>.
- *
- * @see Properties#setProperty(String,String)
+ * Overrides {@link Properties#setProperty(String,String)} to remove
+ * the key if the given value is <code>null</code>.
+ *
+ * @see Properties#setProperty(String,String)
*/
public Object setProperty(String key, String val) {
- if (val == null) {
+ if (val == null)
return remove(key);
- }
-
return super.setProperty(key, val);
}
/**
- * Set the given key to a string version of the given value.
- *
- * @see Properties#setProperty(String,String)
+ * Set the given key to a string version of the given value.
+ *
+ * @see Properties#setProperty(String,String)
*/
public void setProperty(String key, boolean val) {
setProperty(key, String.valueOf(val));
}
/**
- * Set the given key to a string version of the given value.
- *
- * @see Properties#setProperty(String,String)
+ * Set the given key to a string version of the given value.
+ *
+ * @see Properties#setProperty(String,String)
*/
public void setProperty(String key, double val) {
setProperty(key, String.valueOf(val));
}
/**
- * Set the given key to a string version of the given value.
- *
- * @see Properties#setProperty(String,String)
+ * Set the given key to a string version of the given value.
+ *
+ * @see Properties#setProperty(String,String)
*/
public void setProperty(String key, float val) {
setProperty(key, String.valueOf(val));
}
/**
- * Set the given key to a string version of the given value.
- *
- * @see Properties#setProperty(String,String)
+ * Set the given key to a string version of the given value.
+ *
+ * @see Properties#setProperty(String,String)
*/
public void setProperty(String key, int val) {
setProperty(key, String.valueOf(val));
}
/**
- * Set the given key to a string version of the given value.
- *
- * @see Properties#setProperty(String,String)
+ * Set the given key to a string version of the given value.
+ *
+ * @see Properties#setProperty(String,String)
*/
public void setProperty(String key, long val) {
setProperty(key, String.valueOf(val));
}
/**
- * Remove the given property.
+ * Remove the given property.
*/
public String removeProperty(String key) {
Object val = remove(key);
-
- return (val == null) ? null : val.toString();
+ return(val == null) ? null : val.toString();
}
/**
- * Remove the given property, or return the given default if it does
- * not exist.
+ * Remove the given property, or return the given default if it does
+ * not exist.
*/
public String removeProperty(String key, String def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeProperty(key);
}
/**
- * Remove the property under the given key as a boolean.
+ * Remove the property under the given key as a boolean.
*/
public boolean removeBooleanProperty(String key) {
String val = removeProperty(key);
-
return "t".equalsIgnoreCase(val) || "true".equalsIgnoreCase(val);
}
/**
- * Remove the property under the given key as a boolean, or return the
- * given default if it does not exist.
+ * Remove the property under the given key as a boolean, or return the
+ * given default if it does not exist.
*/
public boolean removeBooleanProperty(String key, boolean def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeBooleanProperty(key);
}
/**
- * Remove the property under the given key as a double.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a double.
+ *
+ * @throws NumberFormatException on parse error
*/
public double removeDoubleProperty(String key) {
String val = removeProperty(key);
-
- return (val == null) ? 0D : Double.parseDouble(val);
+ return(val == null) ? 0D : Double.parseDouble(val);
}
/**
- * Remove the property under the given key as a double, or return the
- * given default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a double, or return the
+ * given default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public double removeDoubleProperty(String key, double def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeDoubleProperty(key);
}
/**
- * Remove the property under the given key as a float.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a float.
+ *
+ * @throws NumberFormatException on parse error
*/
public float removeFloatProperty(String key) {
String val = removeProperty(key);
-
- return (val == null) ? 0F : Float.parseFloat(val);
+ return(val == null) ? 0F : Float.parseFloat(val);
}
/**
- * Remove the property under the given key as a float, or return the
- * given default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a float, or return the
+ * given default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public float removeFloatProperty(String key, float def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeFloatProperty(key);
}
/**
- * Remove the property under the given key as a int.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a int.
+ *
+ * @throws NumberFormatException on parse error
*/
public int removeIntProperty(String key) {
String val = removeProperty(key);
-
- return (val == null) ? 0 : Integer.parseInt(val);
+ return(val == null) ? 0 : Integer.parseInt(val);
}
/**
- * Remove the property under the given key as a int, or return the
- * given default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a int, or return the
+ * given default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public int removeIntProperty(String key, int def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeIntProperty(key);
}
/**
- * Remove the property under the given key as a long.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a long.
+ *
+ * @throws NumberFormatException on parse error
*/
public long removeLongProperty(String key) {
String val = removeProperty(key);
-
- return (val == null) ? 0L : Long.parseLong(val);
+ return(val == null) ? 0L : Long.parseLong(val);
}
/**
- * Remove the property under the given key as a long, or return the
- * given default if it does not exist.
- *
- * @throws NumberFormatException on parse error
+ * Remove the property under the given key as a long, or return the
+ * given default if it does not exist.
+ *
+ * @throws NumberFormatException on parse error
*/
public long removeLongProperty(String key, long def) {
- if (!containsKey(key)) {
+ if (!containsKey(key))
return def;
- }
-
return removeLongProperty(key);
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -15,33 +12,26 @@
*/
package org.apache.openjpa.lib.util;
-import org.apache.commons.lang.exception.*;
-
import java.io.*;
-
import java.net.*;
-
import java.security.*;
-
import java.util.*;
-
+import org.apache.commons.lang.exception.*;
/**
- * <p>UUID value generator. Based on the time-based generator in the LGPL
- * project:<br />
- * http://www.doomdark.org/doomdark/proj/jug/<br />
- * The code has been vastly simplified and modified to replace the ethernet
- * address of the host machine with the IP, since we do not want to require
- * native libs and Java cannot access the MAC address directly.</p>
- *
- * <p>Aside from the above modification, implements the IETF UUID draft
- * specification, found here:
- * http://www1.ics.uci.edu/~ejw/authoring/uuid-guid
- * draft-leach-uuids-guids-01.txt</p>
- *
- * @author Abe White
- * @since 3.3
- * @nojavadoc */
+ * UUID value generator. Based on the time-based generator in the LGPL
+ * project:<br /> http://www.doomdark.org/doomdark/proj/jug/<br />
+ * The code has been vastly simplified and modified to replace the ethernet
+ * address of the host machine with the IP, since we do not want to require
+ * native libs and Java cannot access the MAC address directly.
+ * Aside from the above modification, implements the IETF UUID draft
+ * specification, found here: http://www1.ics.uci.edu/~ejw/authoring/uuid-guid/
+ * draft-leach-uuids-guids-01.txt
+ *
+ * @author Abe White
+ * @since 3.3
+ * @nojavadoc
+ */
public class UUIDGenerator {
// indexes within the uuid array for certain boundaries
private static final byte IDX_TIME_HI = 6;
@@ -59,7 +49,7 @@
// type of UUID; is this part of the spec?
private final static byte TYPE_TIME_BASED = 1;
- // random number generator used to reduce conflicts with other JVMs, and
+ // random number generator used to reduce conflicts with other JVMs, and
// hasher for strings. note that secure random is very slow the first time
// it is used; consider switching to a standard random
private static final Random RANDOM = new SecureRandom();
@@ -68,21 +58,20 @@
// the MAC address is usually 6 bytes
private static final byte[] IP;
- // counter is initialized not to 0 but to a random 8-bit number, and each
- // time clock changes, lowest 8-bits of counter are preserved. the purpose
+ // counter is initialized not to 0 but to a random 8-bit number, and each
+ // time clock changes, lowest 8-bits of counter are preserved. the purpose
// is to reduce chances of multi-JVM collisions without reducing perf
// awhite: I don't really understand this precaution, but it was in the
// original algo
private static int _counter;
- // last used millis time, and a randomized sequence that gets reset
+ // last used millis time, and a randomized sequence that gets reset
// whenever the time is reset
private static long _last = 0L;
private static byte[] _seq = new byte[2];
static {
byte[] ip = null;
-
try {
ip = InetAddress.getLocalHost().getAddress();
} catch (IOException ioe) {
@@ -97,7 +86,7 @@
}
/**
- * Return a unique UUID value.
+ * Return a unique UUID value.
*/
public static byte[] next() {
// set ip addr
@@ -106,12 +95,11 @@
// set time info
long now = System.currentTimeMillis();
-
synchronized (UUIDGenerator.class) {
// if time moves backwards somehow, spec says to reset randomization
- if (now < _last) {
+ if (now < _last)
resetTime();
- } else if ((now == _last) && (_counter == MILLI_MULT)) {
+ else if (now == _last && _counter == MILLI_MULT) {
// if we run out of slots in this milli, increment
now++;
_last = now;
@@ -121,7 +109,7 @@
_counter &= 0xFF; // rest counter?
}
- // translate timestamp to 100ns slot since beginning of gregorian
+ // translate timestamp to 100ns slot since beginning of gregorian
now *= MILLI_MULT;
now += GREG_OFFSET;
@@ -158,11 +146,10 @@
}
/**
- * Return the next unique uuid value as a 16-character string.
+ * Return the next unique uuid value as a 16-character string.
*/
public static String nextString() {
byte[] bytes = next();
-
try {
return new String(bytes, "ISO-8859-1");
} catch (Exception e) {
@@ -171,15 +158,15 @@
}
/**
- * Return the next unique uuid value as a 32-character hex string.
+ * Return the next unique uuid value as a 32-character hex string.
*/
public static String nextHex() {
return Base16Encoder.encode(next());
}
/**
- * Reset the random time sequence and counter. Must be called from
- * synchronized code.
+ * Reset the random time sequence and counter. Must be called from
+ * synchronized code.
*/
private static void resetTime() {
_last = 0L;
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ZipResourceBundleProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ZipResourceBundleProvider.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ZipResourceBundleProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ZipResourceBundleProvider.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -16,60 +13,46 @@
package org.apache.openjpa.lib.util;
import java.io.*;
-
import java.util.*;
import java.util.zip.*;
-
/**
- * <p>{@link ResourceBundleProvider} that expects the
- * {@link ClassLoader#getResourceAsStream} method to return a zipped input
- * stream. Created for use under Weblogic RARs.</p>
- *
- * @author Patrick Linskey
+ * {@link ResourceBundleProvider} that expects the
+ * {@link ClassLoader#getResourceAsStream} method to return a zipped input
+ * stream. Created for use under Weblogic RARs.
+ *
+ * @author Patrick Linskey
*/
class ZipResourceBundleProvider implements ResourceBundleProvider {
public ResourceBundle findResource(String name, Locale locale,
ClassLoader loader) {
String rsrc = name.replace('.', '/') + ".properties";
-
- if (loader == null) {
+ if (loader == null)
loader = Thread.currentThread().getContextClassLoader();
- }
InputStream in = loader.getResourceAsStream(rsrc);
-
- if (in == null) {
+ if (in == null)
return null;
- }
ZipInputStream zip = new ZipInputStream(in);
ResourceBundle bundle = null;
-
try {
ZipEntry ze;
-
while (true) {
ze = zip.getNextEntry();
-
- if (ze == null) {
+ if (ze == null)
break;
- }
- if (rsrc.equals(ze.getName())) {
+ if (rsrc.equals(ze.getName()))
return new PropertyResourceBundle(zip);
- }
zip.closeEntry();
}
} catch (Exception e) {
- } finally {
- try {
- zip.close();
- } catch (IOException ioe) {
- }
}
-
+ finally {
+ try { zip.close(); } catch (IOException ioe) {}
+ }
return null;
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractCollection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractCollection.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractCollection.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractCollection.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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.
*/
-
/*
* Written by Dawid Kurzyniec, based on public domain code written by Doug Lea
* and publictly available documentation, and released to the public domain, as
@@ -21,22 +17,20 @@
*/
package org.apache.openjpa.lib.util.concurrent;
-
/**
* Overrides toArray() and toArray(Object[]) in AbstractCollection to provide
* implementations valid for concurrent collections.
- *
+ *
* @author Doug Lea
* @author Dawid Kurzyniec
*/
abstract class AbstractCollection extends java.util.AbstractCollection {
+
/**
* Sole constructor. (For invocation by subclass constructors, typically
* implicit.)
*/
- protected AbstractCollection() {
- super();
- }
+ protected AbstractCollection() { super(); }
public Object[] toArray() {
return Utils.collectionToArray(this);
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractConcurrentEventManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractConcurrentEventManager.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractConcurrentEventManager.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractConcurrentEventManager.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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
@@ -15,91 +12,84 @@
*/
package org.apache.openjpa.lib.util.concurrent;
-import org.apache.openjpa.lib.util.*;
-
import java.util.*;
-
+import org.apache.openjpa.lib.util.*;
/**
- * <p>Base event manager that handles adding/removing listeners
- * and firing events. Meant for high concurrency. This class is
- * reentrant-safe; listeners can be added and removed by other listeners when * they receive events. The changes will not be visible until the event fire
- * that initiated the recursive sequence of calls completes, however.</p>
- *
- * @author Abe White
+ * Base event manager that handles adding/removing listeners
+ * and firing events. Meant for high concurrency. This class is
+ * reentrant-safe; listeners can be added and removed by other listeners when * they receive events. The changes will not be visible until the event fire
+ * that initiated the recursive sequence of calls completes, however.
+ *
+ * @author Abe White
*/
public abstract class AbstractConcurrentEventManager implements EventManager {
private static Exception[] EMPTY_EXCEPTIONS = new Exception[0];
+
private Collection _listeners = new CopyOnWriteArraySet();
/**
- * Register an event listener.
+ * Register an event listener.
*/
public void addListener(Object listener) {
- if (listener != null) {
+ if (listener != null)
_listeners.add(listener);
- }
}
/**
- * Remove an event listener.
+ * Remove an event listener.
*/
public boolean removeListener(Object listener) {
return _listeners.remove(listener);
}
/**
- * Return whether the given instance is in the list of listeners.
+ * Return whether the given instance is in the list of listeners.
*/
public boolean hasListener(Object listener) {
return _listeners.contains(listener);
}
/**
- * Return true if there are any registered listeners.
+ * Return true if there are any registered listeners.
*/
public boolean hasListeners() {
return !_listeners.isEmpty();
}
/**
- * Return a read-only list of listeners.
+ * Return a read-only list of listeners.
*/
public Collection getListeners() {
return Collections.unmodifiableCollection(_listeners);
}
/**
- * Fire the given event to all listeners.
+ * Fire the given event to all listeners.
*/
public Exception[] fireEvent(Object event) {
- if (_listeners.isEmpty()) {
+ if (_listeners.isEmpty())
return EMPTY_EXCEPTIONS;
- }
List exceptions = null;
-
for (Iterator itr = _listeners.iterator(); itr.hasNext();) {
try {
fireEvent(event, itr.next());
} catch (Exception e) {
- if (exceptions == null) {
+ if (exceptions == null)
exceptions = new LinkedList();
- }
-
exceptions.add(e);
}
}
- if (exceptions == null) {
+ if (exceptions == null)
return EMPTY_EXCEPTIONS;
- }
-
- return (Exception[]) exceptions.toArray(new Exception[exceptions.size()]);
+ return(Exception[]) exceptions.toArray
+ (new Exception[exceptions.size()]);
}
/**
- * Implement this method to fire the given event to the given listener.
+ * Implement this method to fire the given event to the given listener.
*/
protected abstract void fireEvent(Object event, Object listener)
throws Exception;
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractQueue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractQueue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractQueue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractQueue.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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.
*/
-
/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
@@ -25,18 +21,16 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-
/**
* This class provides skeletal implementations of some {@link Queue}
* operations. The implementations in this class are appropriate when
* the base implementation does <em>not</em> allow <tt>null</tt>
- * elements. Methods {@link #add add}, {@link #remove remove}, and
+ * elements. Methods {@link #add add}, {@link #remove remove}, and
* {@link #element element} are based on {@link #offer offer}, {@link
* #poll poll}, and {@link #peek peek}, respectively but throw
* exceptions instead of indicating failure via <tt>false</tt> or
* <tt>null</tt> returns.
- *
- * <p> A <tt>Queue</tt> implementation that extends this class must
+ * A <tt>Queue</tt> implementation that extends this class must
* minimally define a method {@link Queue#offer} which does not permit
* insertion of <tt>null</tt> elements, along with methods {@link
* Queue#peek}, {@link Queue#poll}, {@link Collection#size}, and a
@@ -44,11 +38,10 @@
* Iterator#remove}. Typically, additional methods will be overridden
* as well. If these requirements cannot be met, consider instead
* subclassing {@link AbstractCollection}.
- *
- * <p>This class is a member of the
+ * This class is a member of the
* <a href="{@docRoot}/../guide/collections/index.html">
* Java Collections Framework</a>.
- *
+ *
* @since 1.5
* @author Doug Lea
*/
@@ -64,76 +57,67 @@
* immediately without violating capacity restrictions, returning
* <tt>true</tt> upon success and throwing an <tt>IllegalStateException</tt>
* if no space is currently available.
- *
- * <p>This implementation returns <tt>true</tt> if <tt>offer</tt> succeeds,
+ * This implementation returns <tt>true</tt> if <tt>offer</tt> succeeds,
* else throws an <tt>IllegalStateException</tt>.
- *
+ *
* @param e the element to add
* @return <tt>true</tt> (as specified by {@link Collection#add})
* @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
+ * time due to capacity restrictions
* @throws ClassCastException if the class of the specified element
- * prevents it from being added to this queue
+ * prevents it from being added to this queue
* @throws NullPointerException if the specified element is null and
- * this queue not permit null elements
+ * this queue not permit null elements
* @throws IllegalArgumentException if some property of this element
- * prevents it from being added to this queue
+ * prevents it from being added to this queue
*/
public boolean add(Object e) {
- if (offer(e)) {
+ if (offer(e))
return true;
- } else {
+ else
throw new IllegalStateException("Queue full");
- }
}
/**
- * Retrieves and removes the head of this queue. This method differs
+ * Retrieves and removes the head of this queue. This method differs
* from {@link #poll poll} only in that it throws an exception if this
* queue is empty.
- *
- * <p>This implementation returns the result of <tt>poll</tt>
+ * This implementation returns the result of <tt>poll</tt>
* unless the queue is empty.
- *
+ *
* @return the head of this queue
* @throws NoSuchElementException if this queue is empty
*/
public Object remove() {
Object x = poll();
-
- if (x != null) {
+ if (x != null)
return x;
- } else {
+ else
throw new NoSuchElementException();
- }
}
/**
- * Retrieves, but does not remove, the head of this queue. This method
+ * Retrieves, but does not remove, the head of this queue. This method
* differs from {@link #peek peek} only in that it throws an exception if
* this queue is empty.
- *
- * <p>This implementation returns the result of <tt>peek</tt>
+ * This implementation returns the result of <tt>peek</tt>
* unless the queue is empty.
- *
+ *
* @return the head of this queue
* @throws NoSuchElementException if this queue is empty
*/
public Object element() {
Object x = peek();
-
- if (x != null) {
+ if (x != null)
return x;
- } else {
+ else
throw new NoSuchElementException();
- }
}
/**
* Removes all of the elements from this queue.
* The queue will be empty after this call returns.
- *
- * <p>This implementation repeatedly invokes {@link #poll poll} until it
+ * This implementation repeatedly invokes {@link #poll poll} until it
* returns <tt>null</tt>.
*/
public void clear() {
@@ -143,51 +127,42 @@
/**
* Adds all of the elements in the specified collection to this
- * queue. Attempts to addAll of a queue to itself result in
+ * queue. Attempts to addAll of a queue to itself result in
* <tt>IllegalArgumentException</tt>. Further, the behavior of
* this operation is undefined if the specified collection is
* modified while the operation is in progress.
- *
- * <p>This implementation iterates over the specified collection,
+ * This implementation iterates over the specified collection,
* and adds each element returned by the iterator to this
- * queue, in turn. A runtime exception encountered while
- * trying to add an element (including, in particular, a
+ * queue, in turn. A runtime exception encountered while
+ * trying to add an element(including, in particular, a
* <tt>null</tt> element) may result in only some of the elements
- * having been successfully added when the associated exception is
- * thrown.
- *
+ * having been successfully added when the associated exception is thrown.
+ *
* @param c collection containing elements to be added to this queue
* @return <tt>true</tt> if this queue changed as a result of the call
* @throws ClassCastException if the class of an element of the specified
- * collection prevents it from being added to this queue
+ * collection prevents it from being added to this queue
* @throws NullPointerException if the specified collection contains a
- * null element and this queue does not permit null elements,
- * or if the specified collection is null
+ * null element and this queue does not permit null elements,
+ * or if the specified collection is null
* @throws IllegalArgumentException if some property of an element of the
- * specified collection prevents it from being added to this
- * queue, or if the specified collection is this queue
+ * specified collection prevents it from being added to this
+ * queue, or if the specified collection is this queue
* @throws IllegalStateException if not all the elements can be added at
- * this time due to insertion restrictions
+ * this time due to insertion restrictions
* @see #add(Object)
*/
public boolean addAll(Collection c) {
- if (c == null) {
+ if (c == null)
throw new NullPointerException();
- }
-
- if (c == this) {
+ if (c == this)
throw new IllegalArgumentException();
- }
-
boolean modified = false;
Iterator e = c.iterator();
-
while (e.hasNext()) {
- if (add(e.next())) {
+ if (add(e.next()))
modified = true;
- }
}
-
return modified;
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractSet.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractSet.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractSet.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractSet.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (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
+ * 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.
*/
-
/*
* Written by Dawid Kurzyniec, based on public domain code written by Doug Lea
* and publictly available documentation, and released to the public domain, as
@@ -21,22 +17,20 @@
*/
package org.apache.openjpa.lib.util.concurrent;
-
/**
* Overrides toArray() and toArray(Object[]) in AbstractCollection to provide
* implementations valid for concurrent sets.
- *
+ *
* @author Doug Lea
* @author Dawid Kurzyniec
*/
abstract class AbstractSet extends java.util.AbstractSet {
+
/**
* Sole constructor. (For invocation by subclass constructors, typically
* implicit.)
*/
- protected AbstractSet() {
- super();
- }
+ protected AbstractSet() { super(); }
public Object[] toArray() {
return Utils.collectionToArray(this);