openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1759355 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/...
Date Mon, 05 Sep 2016 20:35:11 GMT
Author: struberg
Date: Mon Sep  5 20:35:11 2016
New Revision: 1759355

URL: http://svn.apache.org/viewvc?rev=1759355&view=rev
Log:
OPENJPA-2662 reimplement serp.util.Strings#getClassName

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/CodeGenerator.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
    openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ClassUtil.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/ClassUtilTest.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/StringUtilTest.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingSerializer.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppMultiA.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppSingleA.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
Mon Sep  5 20:35:11 2016
@@ -39,6 +39,8 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.identifier.IdentifierUtil;
+import org.apache.openjpa.lib.util.ClassUtil;
+import org.apache.openjpa.lib.util.StringUtil;
 import org.apache.openjpa.meta.JavaTypes;
 import serp.util.Strings;
 
@@ -547,8 +549,7 @@ public class MappingDefaultsImpl
         // WARNING: CHANGING THIS WILL INVALIDATE EXISTING DATA IF DEFAULTING
         // MISSING MAPPING INFO
         
-        String alias = Strings.getClassName(disc.getClassMapping()
-                .getTypeAlias());
+        String alias = ClassUtil.getClassName(disc.getClassMapping().getTypeAlias());
         
         switch (disc.getJavaType()) {
             case JavaTypes.INT:
@@ -562,7 +563,7 @@ public class MappingDefaultsImpl
     }
 
     public String getTableName(ClassMapping cls, Schema schema) {
-        String name = Strings.getClassName(cls.getDescribedType()).
+        String name = ClassUtil.getClassName(cls.getDescribedType()).
             replace(IdentifierUtil.DOLLAR_CHAR, IdentifierUtil.UNDERSCORE_CHAR);
         if (!_defMissing)
             name = dict.getValidTableName(name, schema);

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
Mon Sep  5 20:35:11 2016
@@ -41,6 +41,7 @@ import org.apache.openjpa.jdbc.schema.Ta
 import org.apache.openjpa.jdbc.schema.Unique;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Localizer.Message;
 import org.apache.openjpa.meta.JavaTypes;
@@ -1600,7 +1601,7 @@ public abstract class MappingInfo
         if (cls == null)
             return false;
         if (name.equals(cls.getDescribedType().getName())
-            || name.equals(Strings.getClassName(cls.getDescribedType())))
+            || name.equals(ClassUtil.getClassName(cls.getDescribedType())))
             return true;
         return isClassMappingName(name, cls.getPCSuperclassMapping());
     }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/NoneMappingDefaults.java
Mon Sep  5 20:35:11 2016
@@ -26,6 +26,7 @@ import org.apache.openjpa.jdbc.schema.Sc
 import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.jdbc.schema.Unique;
 
+import org.apache.openjpa.lib.util.ClassUtil;
 import serp.util.Strings;
 
 /**
@@ -72,7 +73,7 @@ public class NoneMappingDefaults
     }
 
     public String getTableName(ClassMapping cls, Schema schema) {
-        return Strings.getClassName(cls.getDescribedType()).replace('$', '_');
+        return ClassUtil.getClassName(cls.getDescribedType()).replace('$', '_');
     }
 
     public String getTableName(FieldMapping fm, Schema schema) {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
Mon Sep  5 20:35:11 2016
@@ -43,6 +43,7 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.ClassArgParser;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.CodeFormat;
 import org.apache.openjpa.lib.util.Files;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
@@ -264,7 +265,7 @@ public class ApplicationIdTool {
             return null;
 
         // convert from SomeClass$ID to ID
-        String className = Strings.getClassName(_meta.getObjectIdType());
+        String className = ClassUtil.getClassName(_meta.getObjectIdType());
         if (isInnerClass())
             className = className.substring(className.lastIndexOf('$') + 1);
         return className;
@@ -358,7 +359,7 @@ public class ApplicationIdTool {
             code.endl().tab();
 
         if (superOidClass != null) {
-            code.append("extends " + Strings.getClassName(superOidClass));
+            code.append("extends " + ClassUtil.getClassName(superOidClass));
             if (code.getBraceOnSameLine())
                 code.append(" ");
             else
@@ -541,7 +542,7 @@ public class ApplicationIdTool {
             return "char[]";
         if (type.getName().startsWith("java.sql."))
             return type.getName();
-        return Strings.getClassName(type);
+        return ClassUtil.getClassName(type);
     }
 
     /**
@@ -712,7 +713,7 @@ public class ApplicationIdTool {
         else if (type == char[].class)
             parse.append(var).append(".toCharArray").parens();
         else if (!type.isPrimitive()) {
-            parse.append("new ").append(Strings.getClassName(type)).
+            parse.append("new ").append(ClassUtil.getClassName(type)).
                 openParen(true).append(var).closeParen();
         } else // primitive
         {
@@ -1214,7 +1215,7 @@ public class ApplicationIdTool {
             return null;
 
         String packageName = Strings.getPackageName(_meta.getObjectIdType());
-        String fileName = Strings.getClassName(_meta.getObjectIdType())
+        String fileName = ClassUtil.getClassName(_meta.getObjectIdType())
             + ".java";
 
         // if pc class in same package as oid class, try to find pc .java file

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/CodeGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/CodeGenerator.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/CodeGenerator.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/CodeGenerator.java
Mon Sep  5 20:35:11 2016
@@ -28,6 +28,7 @@ import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.CodeFormat;
 import org.apache.openjpa.lib.util.Files;
 import org.apache.openjpa.lib.util.ParameterTemplate;
@@ -126,7 +127,7 @@ public class CodeGenerator {
      */
     public void generateCode() {
         // setup parameters
-        String className = Strings.getClassName(_type);
+        String className = ClassUtil.getClassName(_type);
         String packageName = Strings.getPackageName(_type);
         String packageDec = "";
         if (packageName.length() > 0)
@@ -135,7 +136,7 @@ public class CodeGenerator {
         String extendsDec = "";
         String extendsName = "";
         if (!_type.getSuperclass().getName().equals(Object.class.getName())) {
-            extendsName = Strings.getClassName(_type.getSuperclass());
+            extendsName = ClassUtil.getClassName(_type.getSuperclass());
             extendsDec = "extends " + extendsName;
         }
 
@@ -235,7 +236,7 @@ public class CodeGenerator {
         CodeFormat body = newCodeFormat();
 
         // public <class> (
-        cons.tab().append("public ").append(Strings.getClassName(_type));
+        cons.tab().append("public ").append(ClassUtil.getClassName(_type));
         cons.openParen(true);
 
         // append args to constructor, and build up body at same time
@@ -245,7 +246,7 @@ public class CodeGenerator {
             propertyName = fields[i].getName();
             if (propertyName.startsWith("_"))
                 propertyName = propertyName.substring(1);
-            fieldType = Strings.getClassName(fields[i].getDeclaredType());
+            fieldType = ClassUtil.getClassName(fields[i].getDeclaredType());
 
             if (i > 0)
                 cons.append(", ");
@@ -305,7 +306,7 @@ public class CodeGenerator {
         String propertyName = fieldName;
         if (propertyName.startsWith("_"))
             propertyName = propertyName.substring(1);
-        String fieldType = Strings.getClassName(fmd.getDeclaredType());
+        String fieldType = ClassUtil.getClassName(fmd.getDeclaredType());
 
         String keyType = null;
         String elementType = null;
@@ -313,14 +314,14 @@ public class CodeGenerator {
         if (useGenericCollections()) {
             if (fmd.getDeclaredTypeCode() == JavaTypes.COLLECTION) {
                 Class elmCls = fmd.getElement().getDeclaredType();
-                elementType = Strings.getClassName(elmCls);
+                elementType = ClassUtil.getClassName(elmCls);
                 paramType = decs.getParametrizedType(
                     new String[] {elementType});
             } else if (fmd.getDeclaredTypeCode() == JavaTypes.MAP) {
                 Class keyCls = fmd.getKey().getDeclaredType();
                 Class elmCls = fmd.getElement().getDeclaredType();
-                keyType = Strings.getClassName(keyCls);
-                elementType = Strings.getClassName(elmCls);
+                keyType = ClassUtil.getClassName(keyCls);
+                elementType = ClassUtil.getClassName(elmCls);
                 paramType = decs.getParametrizedType(
                     new String[] {keyType, elementType});
             }
@@ -504,7 +505,7 @@ public class CodeGenerator {
      */
     public File getFile() {
         String packageName = Strings.getPackageName(_type);
-        String fileName = Strings.getClassName(_type) + ".java";
+        String fileName = ClassUtil.getClassName(_type) + ".java";
 
         File dir = Files.getPackageFile(_dir, packageName, true);
         return new File(dir, fileName);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java Mon
Sep  5 20:35:11 2016
@@ -1509,7 +1509,7 @@ public class QueryImpl
         try {
             String alias = compileForExecutor().getAlias(_storeQuery);
             if (alias == null)
-                alias = Strings.getClassName(_class);
+                alias = ClassUtil.getClassName(_class);
             return alias;
         } finally {
             unlock();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Mon Sep  5 20:35:11 2016
@@ -47,6 +47,7 @@ import org.apache.openjpa.lib.conf.Value
 import org.apache.openjpa.lib.conf.ValueListener;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.SourceTracker;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.xml.Commentable;
@@ -70,7 +71,6 @@ import org.apache.openjpa.util.ShortId;
 import org.apache.openjpa.util.StringId;
 import org.apache.openjpa.util.UnsupportedException;
 
-import serp.util.Strings;
 
 /**
  * Contains metadata about a persistent type.
@@ -686,7 +686,7 @@ public class ClassMetaData
      */
     public String getTypeAlias() {
         if (_alias == null)
-            _alias = Strings.getClassName(_type);
+            _alias = ClassUtil.getClassName(_type);
         return _alias;
     }
 
@@ -1523,7 +1523,7 @@ public class ClassMetaData
     /**
      * Set the cache name for this class. 
      * 
-     * @param can be null to disable cache.
+     * @param name can be {@code null} to disable cache.
      */
     public void setDataCacheName(String name) {
         _cacheName = name;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
Mon Sep  5 20:35:11 2016
@@ -52,6 +52,7 @@ import org.apache.openjpa.kernel.OpenJPA
 import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
@@ -1626,7 +1627,7 @@ public class FieldMetaData
 
         // get class name and get package name divide on the last '.', so the
         // names don't apply in this case, but the methods do what we want
-        String methodName = Strings.getClassName(method);
+        String methodName = ClassUtil.getClassName(method);
         String clsName = Strings.getPackageName(method);
 
         Class<?> cls = null;
@@ -1635,7 +1636,7 @@ public class FieldMetaData
         if (clsName.length() == 0)
             cls = getDeclaredType();
         else if (clsName.equals(owner.getName())
-            || clsName.equals(Strings.getClassName(owner)))
+            || clsName.equals(ClassUtil.getClassName(owner)))
             cls = owner;
         else
             cls = JavaTypes.classForName(clsName, this);

Modified: openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
Mon Sep  5 20:35:11 2016
@@ -20,6 +20,7 @@ package org.apache.openjpa.ee;
 
 import junit.framework.TestCase;
 
+import org.apache.openjpa.lib.util.ClassUtil;
 import serp.util.Strings;
 
 /**
@@ -47,8 +48,7 @@ public class TestWASManagedRuntime exten
         } catch (NoClassDefFoundError e) {
             msg = e.getMessage();
         }
-        String interfaceName = Strings.
-            getClassName(WASManagedRuntime.INTERFACE);
+        String interfaceName = ClassUtil.getClassName(WASManagedRuntime.INTERFACE);
         assertTrue("message should have contained "
             + interfaceName + ", but was '" + msg + "'",
             msg.indexOf(interfaceName) != -1);

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
Mon Sep  5 20:35:11 2016
@@ -159,6 +159,6 @@ public class DelegatingDataSource implem
     // Java 7 methods follow
     
     public Logger getParentLogger() throws SQLFeatureNotSupportedException{
-    	throw new SQLFeatureNotSupportedException();
+        return _ds.getParentLogger();
     }
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
Mon Sep  5 20:35:11 2016
@@ -31,6 +31,7 @@ import java.util.Enumeration;
 import java.util.List;
 import java.util.NoSuchElementException;
 
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.MultiClassLoader;
 import serp.util.Strings;
@@ -129,7 +130,7 @@ public class ClassMetaDataIterator imple
                     _locs.add(path + pkgName + suffix); // legacy
                     _locs.add(upPath + pkgName + suffix); // legacy
                     if (idx == -1)
-                        _locs.add(path + Strings.getClassName(cls) + suffix);
+                        _locs.add(path + ClassUtil.getClassName(cls) + suffix);
 
                     start = idx + 1;
                     upPath = path;

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ClassUtil.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ClassUtil.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ClassUtil.java Mon
Sep  5 20:35:11 2016
@@ -22,6 +22,7 @@ package org.apache.openjpa.lib.util;
  */
 public final class ClassUtil {
 
+
     private static final Object[][] _codes = new Object[][]{
             {byte.class, "byte", "B"},
             {char.class, "char", "C"},
@@ -105,9 +106,68 @@ public final class ClassUtil {
 
         try {
             return Class.forName(str, resolve, loader);
-        } catch (ClassNotFoundException | NoClassDefFoundError e) {
+        }
+        catch (ClassNotFoundException | NoClassDefFoundError e) {
             throw new IllegalArgumentException(e.getMessage());
         }
     }
-}
 
+    /**
+     * Return only the class name, without package.
+     */
+    public static String getClassName(Class cls) {
+        if (cls == null) {
+            return null;
+        }
+        return getClassName(cls.getName());
+    }
+
+    /**
+     * Return only the class name.
+     */
+    public static String getClassName(String fullName) {
+        if (fullName == null) {
+            return null;
+        }
+        if (fullName.isEmpty()) {
+            return fullName;
+        }
+
+        int dims = 0;
+        while (fullName.charAt(dims) == '[') {
+            dims++;
+        }
+        if (dims > 0) {
+            if (fullName.length() == dims + 1) {
+                String classCode = fullName.substring(dims);
+                for (int i = 0; i < _codes.length; i++) {
+                    if (_codes[i][2].equals(classCode)) {
+                        fullName = (String)_codes[i][1];
+                        break;
+                    }
+                }
+            }
+            else {
+                if (fullName.charAt(fullName.length()-1) == ';') {
+                    fullName = fullName.substring(dims + 1, fullName.length() - 1);
+                }
+                else {
+                    fullName = fullName.substring(dims + 1);
+                }
+            }
+        }
+
+        int lastDot = fullName.lastIndexOf('.');
+        String simpleName = lastDot > -1 ? fullName.substring(lastDot + 1) : fullName;
+
+        if (dims > 0) {
+            StringBuilder sb = new StringBuilder(simpleName.length() + dims * 2);
+            sb.append(simpleName);
+            for (int i = 0; i < dims; i++) {
+                sb.append("[]");
+            }
+            simpleName = sb.toString();
+        }
+        return simpleName;
+    }
+}

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java Mon Sep
 5 20:35:11 2016
@@ -125,7 +125,7 @@ public class Files {
      * Return the file for the class resource with the given extension.
      */
     private static File getClassFile(Class cls, String ext) {
-        String name = Strings.getClassName(cls);
+        String name = ClassUtil.getClassName(cls);
 
         // if it's an inner class, use the parent class name
         int innerIdx = name.indexOf('$');

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/ClassUtilTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/ClassUtilTest.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/ClassUtilTest.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/ClassUtilTest.java
Mon Sep  5 20:35:11 2016
@@ -16,8 +16,12 @@
  */
 package org.apache.openjpa.lib.util;
 
+import java.util.concurrent.TimeUnit;
+
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
+import serp.util.Strings;
 
 public class ClassUtilTest {
 
@@ -53,4 +57,54 @@ public class ClassUtilTest {
         return ClassUtil.toClass(clazz, false, this.getClass().getClassLoader());
     }
 
+    @Test
+    public void testGetClassName() {
+        Assert.assertEquals("ClassUtilTest", ClassUtil.getClassName(ClassUtilTest.class));
+        Assert.assertEquals("ClassUtilTest$MyInnerClass", ClassUtil.getClassName(MyInnerClass.class));
+
+        // anonymous class
+        Assert.assertEquals("ClassUtilTest$1", ClassUtil.getClassName(INSTANCE.getClass()));
+
+        // primitives
+        Assert.assertEquals("byte", ClassUtil.getClassName(byte.class));
+        Assert.assertEquals("char", ClassUtil.getClassName(char.class));
+        Assert.assertEquals("double", ClassUtil.getClassName(double.class));
+        Assert.assertEquals("float", ClassUtil.getClassName(float.class));
+        Assert.assertEquals("int", ClassUtil.getClassName(int.class));
+        Assert.assertEquals("long", ClassUtil.getClassName(long.class));
+        Assert.assertEquals("short", ClassUtil.getClassName(short.class));
+        Assert.assertEquals("boolean", ClassUtil.getClassName(boolean.class));
+        Assert.assertEquals("void", ClassUtil.getClassName(void.class));
+
+        // arrays
+        Assert.assertEquals("long[]", ClassUtil.getClassName(long[].class));
+        Assert.assertEquals("long[][]", ClassUtil.getClassName(long[][].class));
+        Assert.assertEquals("float[][][]", ClassUtil.getClassName(float[][][].class));
+
+        Assert.assertEquals("ClassUtilTest[]", ClassUtil.getClassName(ClassUtilTest[].class));
+        Assert.assertEquals("ClassUtilTest$MyInnerClass[]", ClassUtil.getClassName(MyInnerClass[].class));
+        Assert.assertEquals("ClassUtilTest$MyInnerClass[][]", ClassUtil.getClassName(MyInnerClass[][].class));
+    }
+
+    @Test
+    @Ignore("only needed for manual performance tests")
+    public void testGetClassNamePerformance() {
+
+        long start = System.nanoTime();
+        for (int i = 1; i < 10000000; i++) {
+            //X String className = Strings.getClassName(MyInnerClass.class);
+            ClassUtil.getClassName(MyInnerClass.class);
+        }
+
+        long stop = System.nanoTime();
+        System.out.println("took: " + TimeUnit.NANOSECONDS.toMillis(stop - start));
+    }
+
+    private static abstract class MyInnerClass {
+        // not needed
+    }
+
+    private static final MyInnerClass INSTANCE = new MyInnerClass() {
+    };
+
 }

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/StringUtilTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/StringUtilTest.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/StringUtilTest.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/StringUtilTest.java
Mon Sep  5 20:35:11 2016
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
-import serp.util.Strings;
 
 public class StringUtilTest {
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingSerializer.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingSerializer.java
Mon Sep  5 20:35:11 2016
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.persistence.jdbc;
 
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer;
 import org.apache.openjpa.persistence.PersistenceStrategy;
 import org.apache.openjpa.persistence.AnnotationBuilder;
@@ -80,7 +81,6 @@ import javax.persistence.EntityResult;
 import javax.persistence.FieldResult;
 import javax.persistence.ColumnResult;
 
-//@todo: javadocs
 
 /**
  * Serializes persistence mappings as annotations.
@@ -220,8 +220,7 @@ public class AnnotationPersistenceMappin
         ClassMapping cls = (ClassMapping) mapping;
         ClassMappingInfo info = cls.getMappingInfo();
         AnnotationBuilder abTable = addAnnotation(Table.class, mapping);
-        serializeTable(info.getTableName(), Strings
-            .getClassName(mapping.getDescribedType()), null,
+        serializeTable(info.getTableName(), ClassUtil.getClassName(mapping.getDescribedType()),
null,
             info.getUniques(info.getTableName()), abTable);
         serializeColumns(info, ColType.PK_JOIN, null, abTable, cls);
         for (String second : info.getSecondaryTableNames()) {
@@ -241,7 +240,7 @@ public class AnnotationPersistenceMappin
         String strat = info.getHierarchyStrategy();
         if (null == strat)
             return;
-        String itypecls = Strings.getClassName(InheritanceType.class);
+        String itypecls = ClassUtil.getClassName(InheritanceType.class);
         AnnotationBuilder abInheritance =
             addAnnotation(Inheritance.class, mapping);
         if (FlatClassStrategy.ALIAS.equals(strat))

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
Mon Sep  5 20:35:11 2016
@@ -39,6 +39,7 @@ import org.apache.openjpa.jdbc.schema.Co
 import org.apache.openjpa.jdbc.schema.Schema;
 import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
 import serp.util.Strings;
@@ -127,7 +128,7 @@ public class PersistenceMappingDefaults
     public String getTableName(ClassMapping cls, Schema schema) {
         if (cls.getTypeAlias() != null)
             return cls.getTypeAlias();
-        return Strings.getClassName(cls.getDescribedType()).replace('$', '_');
+        return ClassUtil.getClassName(cls.getDescribedType()).replace('$', '_');
     }
 
     @Override

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingSerializer.java
Mon Sep  5 20:35:11 2016
@@ -29,6 +29,7 @@ import javax.persistence.EnumType;
 import javax.persistence.TemporalType;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.xml.sax.SAXException;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
@@ -56,7 +57,6 @@ import org.apache.openjpa.meta.MetaDataR
 import org.apache.openjpa.meta.SequenceMetaData;
 import org.apache.openjpa.persistence.PersistenceStrategy;
 import org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer;
-import serp.util.Strings;
 
 /**
  * Serializes persistence mapping to XML.
@@ -184,8 +184,7 @@ public class XMLPersistenceMappingSerial
         throws SAXException {
         ClassMapping cls = (ClassMapping) mapping;
         ClassMappingInfo info = cls.getMappingInfo();
-        serializeTable(info.getTableName(), "table", Strings
-            .getClassName(mapping.getDescribedType()), null, 
+        serializeTable(info.getTableName(), "table", ClassUtil.getClassName(mapping.getDescribedType()),
null,
             info.getUniques(info.getTableName()));
         for (String second : info.getSecondaryTableNames())
             serializeTable(second, "secondary-table", null, info,

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppMultiA.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppMultiA.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppMultiA.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppMultiA.java
Mon Sep  5 20:35:11 2016
@@ -30,7 +30,7 @@ public class HorizAppMultiA
     // initialize PK values to random values
 	//FIXME 
 	/*
-    private String pk1 = "PK-" + Strings.getClassName(getClass().getName());
+    private String pk1 = "PK-" + ClassUtil.getClassName(getClass().getName());
     private int pk2 = com.solarmetric.test.AbstractTestCase.
         randomInt().intValue();
     */

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppSingleA.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppSingleA.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppSingleA.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/common/apps/HorizAppSingleA.java
Mon Sep  5 20:35:11 2016
@@ -30,7 +30,7 @@ public class HorizAppSingleA
     // initialize PK values to random values
 	//FIXME 
 	/*
-    private String pk1 = "PK-" + Strings.getClassName(getClass().getName());
+    private String pk1 = "PK-" + ClassUtil.getClassName(getClass().getName());
     private int pk2 = com.solarmetric.test.AbstractTestCase.
         randomInt().intValue();
 	*/

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationBuilder.java
Mon Sep  5 20:35:11 2016
@@ -18,7 +18,7 @@
  */
 package org.apache.openjpa.persistence;
 
-import serp.util.Strings;
+import org.apache.openjpa.lib.util.ClassUtil;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -117,7 +117,7 @@ public class AnnotationBuilder {
 
     static String enumToString(Enum e) {
         StringBuilder sb = new StringBuilder();
-        sb.append(Strings.getClassName(e.getClass())).
+        sb.append(ClassUtil.getClassName(e.getClass())).
             append(".").append(e);
         return sb.toString();
     }
@@ -126,7 +126,7 @@ public class AnnotationBuilder {
         StringBuilder sb = new StringBuilder();
         for (Iterator i = set.iterator(); i.hasNext();) {
             Object e =  i.next();
-            sb.append(Strings.getClassName(e.getClass())).
+            sb.append(ClassUtil.getClassName(e.getClass())).
                 append(".").append(e);
             if (i.hasNext())
                 sb.append(", ");
@@ -135,7 +135,7 @@ public class AnnotationBuilder {
     }
 
     protected void toString(StringBuilder sb) {
-        sb.append("@").append(Strings.getClassName(type));
+        sb.append("@").append(ClassUtil.getClassName(type));
         if (components.size() == 0)
             return;
         sb.append("(");

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
Mon Sep  5 20:35:11 2016
@@ -72,6 +72,7 @@ import org.apache.openjpa.kernel.QueryLa
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.SourceTracker;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
@@ -87,7 +88,6 @@ import org.apache.openjpa.meta.SequenceM
 import org.apache.openjpa.meta.ValueMetaData;
 import org.apache.openjpa.util.InternalException;
 
-import serp.util.Strings;
 
 //@todo: javadocs
 
@@ -733,7 +733,7 @@ public class AnnotationPersistenceMetaDa
         AnnotationBuilder abEntity = addAnnotation(
             getEntityAnnotationType(meta), meta);
         if (isMetaDataMode()
-            && !meta.getTypeAlias().equals(Strings.getClassName(meta.
+            && !meta.getTypeAlias().equals(ClassUtil.getClassName(meta.
             getDescribedType())))
             abEntity.add("name", meta.getTypeAlias());
         
@@ -1172,8 +1172,7 @@ public class AnnotationPersistenceMetaDa
      * Serialize field mapping content; this will be called before
      * {@link #serializeValueMappingContent}. Does nothing by default.
      */
-    protected void serializeFieldMappingContent(FieldMetaData fmd,
-        PersistenceStrategy strategy, AnnotationBuilder ab) {
+    protected void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy,
AnnotationBuilder ab) {
     }
 
     /**

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java?rev=1759355&r1=1759354&r2=1759355&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
Mon Sep  5 20:35:11 2016
@@ -40,6 +40,7 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.CFMetaDataSerializer;
 import org.apache.openjpa.lib.meta.SourceTracker;
+import org.apache.openjpa.lib.util.ClassUtil;
 import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
@@ -694,7 +695,7 @@ public class XMLPersistenceMetaDataSeria
             getName()));
 
         if (isMetaDataMode()
-            && !meta.getTypeAlias().equals(Strings.getClassName(meta.
+            && !meta.getTypeAlias().equals(ClassUtil.getClassName(meta.
             getDescribedType())))
             addAttribute("name", meta.getTypeAlias());
 




Mime
View raw message