openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r423162 - in /incubator/openjpa/trunk: openjpa-kernel-5/ openjpa-kernel/ openjpa-kernel/src/main/resources/org/apache/openjpa/conf/ openjpa-lib/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/test/java/org/apache/ope...
Date Tue, 18 Jul 2006 18:11:00 GMT
Author: pcl
Date: Tue Jul 18 11:10:59 2006
New Revision: 423162

URL: http://svn.apache.org/viewvc?rev=423162&view=rev
Log:
basic logic for converting simple JavaNames to xml-names; added some localization information
about forgotten properties; removed spurious memory status printout from base test class;
added 'target' to the svn:ignore for all the top-level maven dirs

Added:
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java
  (with props)
Modified:
    incubator/openjpa/trunk/openjpa-kernel/   (props changed)
    incubator/openjpa/trunk/openjpa-kernel-5/   (props changed)
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties
    incubator/openjpa/trunk/openjpa-lib/   (props changed)
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
    incubator/openjpa/trunk/openjpa-persistence/   (props changed)
    incubator/openjpa/trunk/openjpa-xmlstore/   (props changed)

Propchange: incubator/openjpa/trunk/openjpa-kernel/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 18 11:10:59 2006
@@ -0,0 +1,2 @@
+
+target

Propchange: incubator/openjpa/trunk/openjpa-kernel-5/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 18 11:10:59 2006
@@ -0,0 +1,2 @@
+
+target

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties?rev=423162&r1=423161&r2=423162&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties
Tue Jul 18 11:10:59 2006
@@ -33,6 +33,14 @@
 DataCache-expert: true
 DataCache-interface: org.apache.openjpa.datacache.DataCache
 
+DataCacheManager-name: Data cache
+DataCacheManager-desc: Plugin used to manage configuration''s cache instances.
+DataCacheManager-type: General
+DataCacheManager-cat: Cache
+DataCacheManager-displayorder: 50
+DataCacheManager-expert: true
+DataCacheManager-interface: org.apache.openjpa.datacache.DataCacheManager
+
 DataCacheTimeout-name: Default data cache timeout
 DataCacheTimeout-desc: The number of milliseconds that data in the data cache \
 	is valid for. A value of 0 or less means that by default, cached data does \
@@ -235,6 +243,7 @@
 Connection2UserName-cat: Connecting.XA
 Connection2UserName-displayorder: 50
 Connection2UserName-expert: true
+
 
 Connection2Password-name: Unmanaged connection password
 Connection2Password-desc: The password for the user specified in \

Propchange: incubator/openjpa/trunk/openjpa-lib/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 18 11:10:59 2006
@@ -0,0 +1,2 @@
+
+target

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java?rev=423162&r1=423161&r2=423162&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java
Tue Jul 18 11:10:59 2006
@@ -67,6 +67,12 @@
     public static final String ATTRIBUTE_INTERFACE = "propertyInterface";
 
     /**
+     * Attribute of the returned {@link Value} property descriptors naming
+     * the property's name in XML format (i.e. two-words instead of TwoWords).
+     */
+    public static final String ATTRIBUTE_XML = "xmlName";
+    
+    /**
      * Return the product name. Defaults to <code>solarmetric</code>.
      */
     public String getProductName();

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?rev=423162&r1=423161&r2=423162&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
Tue Jul 18 11:10:59 2006
@@ -131,7 +131,7 @@
      */
     public ConfigurationImpl(boolean loadDefaults) {
         _prefixes.add("openjpa");
-        
+
         logFactoryPlugin = addPlugin("Log", true);
         String[] aliases = new String[]{
             "true", "org.apache.openjpa.lib.log.LogFactoryImpl",
@@ -456,6 +456,8 @@
         String cat = findLocalized(prop + "-cat", false, val.getScope());
         if (cat != null)
             pd.setValue(ATTRIBUTE_CATEGORY, cat);
+        
+        pd.setValue(ATTRIBUTE_XML, toXMLName(prop));
 
         String order = findLocalized(prop + "-displayorder", false,
             val.getScope());
@@ -762,6 +764,44 @@
         return toProperties(false).hashCode();
     }
 
+    /**
+     * Convert <code>propName</code> to a lowercase-with-hyphens-style string.
+     * This algorithm is only designed for mixes of uppercase and lowercase 
+     * letters and lone digits. A more sophisticated conversion should probably 
+     * be handled by a proper parser generator or regular expressions.
+     */
+    static String toXMLName(String propName) {
+        if (propName == null)
+            return null;
+        StringBuffer buf = new StringBuffer();
+        char c;
+        for (int i = 0; i < propName.length(); i++) {
+            c = propName.charAt(i);
+
+            // convert sequences of all-caps to downcase with dashes around 
+            // them. put a trailing cap that is followed by downcase into the
+            // downcase word.
+            if (i != 0 && Character.isUpperCase(c) 
+                && (Character.isLowerCase(propName.charAt(i-1))
+                    || (i > 1 && i < propName.length() - 1
+                        && Character.isUpperCase(propName.charAt(i-1)) 
+                        && Character.isLowerCase(propName.charAt(i+1)))))
+                buf.append('-');
+            
+            // surround sequences of digits with dashes.
+            if (i != 0
+                && ((!Character.isLetter(c) && Character.isLetter(propName
+                    .charAt(i - 1))) 
+                    || 
+                    (Character.isLetter(c) && !Character.isLetter(propName
+                        .charAt(i - 1)))))
+                buf.append('-');
+            
+            buf.append(Character.toLowerCase(c));
+        }
+        return buf.toString();
+    }
+    
     /**
      * Implementation of the {@link Externalizable} interface to read from
      * the properties written by {@link #writeExternal}.

Added: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java?rev=423162&view=auto
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java
(added)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java
Tue Jul 18 11:10:59 2006
@@ -0,0 +1,45 @@
+package org.apache.openjpa.lib.conf;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+
+public class TestXMLCaseConversions extends TestCase {
+
+    public void testToXMLName() {
+        assertEquals("easy-xml-conversion", 
+            ConfigurationImpl.toXMLName("easyXmlConversion"));
+        assertEquals("initial-caps", 
+            ConfigurationImpl.toXMLName("InitialCaps"));
+        assertEquals("nodash", 
+            ConfigurationImpl.toXMLName("nodash"));
+        assertEquals("anothernodash", 
+            ConfigurationImpl.toXMLName("Anothernodash"));
+        assertEquals("multiple-caps", 
+            ConfigurationImpl.toXMLName("MUltipleCaps"));
+        assertEquals("trailing-multi-caps", 
+            ConfigurationImpl.toXMLName("TrailingMultiCAPS"));
+        assertEquals("two-i-nner-caps", 
+            ConfigurationImpl.toXMLName("TwoINnerCaps"));
+        assertEquals("four-inn-er-caps", 
+            ConfigurationImpl.toXMLName("FourINNErCaps"));
+        assertEquals("inner-3-number", 
+            ConfigurationImpl.toXMLName("Inner3Number"));
+        assertEquals("inner-03-number", 
+            ConfigurationImpl.toXMLName("Inner03Number"));
+    }
+    
+    public static void main(String[] args) throws IOException {
+        BufferedReader r = new BufferedReader (new FileReader(new File(args[0])));
+        while (true) {
+            String s = r.readLine();
+            if (s == null)
+                break;
+            System.out.println(s + ": " + ConfigurationImpl.toXMLName(s));
+        }
+    }
+}

Propchange: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestXMLCaseConversions.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java?rev=423162&r1=423161&r2=423162&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
Tue Jul 18 11:10:59 2006
@@ -218,7 +218,7 @@
     }
 
     public void tearDown() throws Exception {
-        if ("true".equals(System.getProperty("meminfo", "true")))
+        if ("true".equals(System.getProperty("meminfo")))
             printMemoryInfo();
 
         super.tearDown();

Propchange: incubator/openjpa/trunk/openjpa-persistence/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 18 11:10:59 2006
@@ -0,0 +1,2 @@
+
+target

Propchange: incubator/openjpa/trunk/openjpa-xmlstore/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 18 11:10:59 2006
@@ -0,0 +1,2 @@
+
+target



Mime
View raw message