cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r647333 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: gen/StringUtils.java query/NamedQuery.java query/ObjectIdQuery.java query/RelationshipQuery.java util/Util.java
Date Fri, 11 Apr 2008 22:07:07 GMT
Author: aadamchik
Date: Fri Apr 11 15:07:06 2008
New Revision: 647333

URL: http://svn.apache.org/viewvc?rev=647333&view=rev
Log:
clearing a random commons.lang dependency

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/StringUtils.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/Util.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/StringUtils.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/StringUtils.java?rev=647333&r1=647332&r2=647333&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/StringUtils.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/StringUtils.java
Fri Apr 11 15:07:06 2008
@@ -21,6 +21,7 @@
 
 import org.apache.cayenne.project.validator.MappingNamesHelper;
 import org.apache.cayenne.util.NameConverter;
+import org.apache.cayenne.util.Util;
 
 /**
  * Methods for mangling strings.
@@ -57,16 +58,8 @@
      * 
      * @since 1.2
      */
-    public String stripPackageName(String aString) {
-        if (aString == null || aString.length() == 0)
-            return aString;
-
-        int lastDot = aString.lastIndexOf('.');
-
-        if ((-1 == lastDot) || ((aString.length() - 1) == lastDot))
-            return aString;
-
-        return aString.substring(lastDot + 1);
+    public String stripPackageName(String fullyQualifiedClassName) {
+        return Util.stripPackageName(fullyQualifiedClassName);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java?rev=647333&r1=647332&r2=647333&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
Fri Apr 11 15:07:06 2008
@@ -28,7 +28,6 @@
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.util.Util;
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 
@@ -180,9 +179,8 @@
      */
     @Override
     public String toString() {
-        return StringUtils.substringAfterLast(getClass().getName(), ".")
-                + ":"
-                + getName();
+        String className = getClass().getName();
+        return Util.stripPackageName(className) + ":" + getName();
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java?rev=647333&r1=647332&r2=647333&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
Fri Apr 11 15:07:06 2008
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.query;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.exp.Expression;
@@ -34,7 +33,7 @@
  * internally by Cayenne to lookup objects by id. Notice that cache policies of
  * ObjectIdQuery are different from generic {@link QueryMetadata} cache policies.
  * ObjectIdQuery is special - it is the only query that can be done against Cayenne main
- * cache, thus cache handling is singnificantly different from all other of the queries.
+ * cache, thus cache handling is significantly different from all other of the queries.
  * 
  * @since 1.2
  * @author Andrus Adamchik
@@ -157,7 +156,7 @@
      */
     @Override
     public String toString() {
-        return StringUtils.substringAfterLast(getClass().getName(), ".") + ":" + objectId;
+        return Util.stripPackageName(getClass().getName()) + ":" + objectId;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RelationshipQuery.java?rev=647333&r1=647332&r2=647333&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
Fri Apr 11 15:07:06 2008
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.query;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.exp.Expression;
@@ -29,6 +28,7 @@
 import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.reflect.ArcProperty;
 import org.apache.cayenne.reflect.ClassDescriptor;
+import org.apache.cayenne.util.Util;
 
 /**
  * A query that selects objects related to a given object via a mapped relationship.
@@ -187,8 +187,6 @@
      */
     @Override
     public String toString() {
-        return StringUtils.substringAfterLast(getClass().getName(), ".")
-                + ":"
-                + getRelationshipName();
+        return Util.stripPackageName(getClass().getName()) + ":" + getRelationshipName();
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/Util.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/Util.java?rev=647333&r1=647332&r2=647333&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/Util.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/Util.java
Fri Apr 11 15:07:06 2008
@@ -201,8 +201,9 @@
             return file.delete();
 
         String[] contents = file.list();
-        
-        // list can be null if directory doesn't have an 'x' permission bit set for the user
+
+        // list can be null if directory doesn't have an 'x' permission bit set for the
+        // user
         if (contents != null) {
             for (String item : contents) {
                 if (!delete(filePath + File.separator + item, true)) {
@@ -358,17 +359,34 @@
     }
 
     /**
+     * Returns an unqualified class name for the fully qualified name.
+     * 
+     * @since 3.0
+     */
+    public static String stripPackageName(String className) {
+        if (className == null || className.length() == 0)
+            return className;
+
+        int lastDot = className.lastIndexOf('.');
+
+        if ((-1 == lastDot) || ((className.length() - 1) == lastDot))
+            return className;
+
+        return className.substring(lastDot + 1);
+    }
+
+    /**
      * Creates a mutable map out of two arrays with keys and values.
      * 
      * @since 1.2
      */
-    public static <K,V> Map<K,V> toMap(K[] keys, V[] values) {
+    public static <K, V> Map<K, V> toMap(K[] keys, V[] values) {
         int keysSize = (keys != null) ? keys.length : 0;
         int valuesSize = (values != null) ? values.length : 0;
 
         if (keysSize == 0 && valuesSize == 0) {
             // return mutable map
-            return new HashMap<K,V>();
+            return new HashMap<K, V>();
         }
 
         if (keysSize != valuesSize) {
@@ -376,7 +394,7 @@
                     "The number of keys doesn't match the number of values.");
         }
 
-        Map<K,V> map = new HashMap<K,V>();
+        Map<K, V> map = new HashMap<K, V>();
         for (int i = 0; i < keysSize; i++) {
             map.put(keys[i], values[i]);
         }



Mime
View raw message