[Arakhnę-Dev] [331] * Fixing the Locale API according the the bug fixes in the Caller API . |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 331
Author: galland
Date: 2012-02-07 11:48:54 +0100 (Tue, 07 Feb 2012)
Log Message:
-----------
* Fixing the Locale API according the the bug fixes in the Caller API.
Modified Paths:
--------------
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/AndroidResourceWrapper.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ResourceWrapper.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/Resources.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/StandardJREResourceWrapper.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/locale/Locale.java
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/AndroidResourceWrapper.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/AndroidResourceWrapper.java 2012-02-07 10:48:17 UTC (rev 330)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/AndroidResourceWrapper.java 2012-02-07 10:48:54 UTC (rev 331)
@@ -88,4 +88,12 @@
return classLoader.getResourceAsStream(resourceName);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String translateResourceName(String resourceName) {
+ return resourceName.replaceAll("[.]", "/"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
}
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ResourceWrapper.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ResourceWrapper.java 2012-02-07 10:48:17 UTC (rev 330)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ResourceWrapper.java 2012-02-07 10:48:54 UTC (rev 331)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2004-2012 Stephane GALLAND
+ * Copyright (C) 2012 Stephane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -77,5 +77,21 @@
* not found in class paths.
*/
public InputStream getResourceAsStream(ClassLoader classLoader, String path);
-
+
+ /** Translate the given resource name according to the current JVM standard.
+ * <p>
+ * The <code>resourceName</code> argument should be a fully
+ * qualified class name. However, for compatibility with earlier
+ * versions, Sun's Java SE Runtime Environments do not verify this,
+ * and so it is possible to access <code>PropertyResourceBundle</code>s
+ * by specifying a path name (using "/") instead of a fully
+ * qualified class name (using ".").
+ * In several VM, such as Dalvik, the translation from "." to "/" is not
+ * automatically done by the VM to retreive the file.
+ *
+ * @param resourceName
+ * @return the translated resource name.
+ */
+ public String translateResourceName(String resourceName);
+
}
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/Resources.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/Resources.java 2012-02-07 10:48:17 UTC (rev 330)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/Resources.java 2012-02-07 10:48:54 UTC (rev 331)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2004-2012 Stephane GALLAND.
+ * Copyright (C) 2008-2012 Stephane GALLAND.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -348,4 +348,23 @@
return getResource(classLoader, classname.getPackage(), name.toString());
}
+ /** Translate the given resource name according to the current JVM standard.
+ * <p>
+ * The <code>resourceName</code> argument should be a fully
+ * qualified class name. However, for compatibility with earlier
+ * versions, Sun's Java SE Runtime Environments do not verify this,
+ * and so it is possible to access <code>PropertyResourceBundle</code>s
+ * by specifying a path name (using "/") instead of a fully
+ * qualified class name (using ".").
+ * In several VM, such as Dalvik, the translation from "." to "/" is not
+ * automatically done by the VM to retreive the file.
+ *
+ * @param resourceName
+ * @return the translated resource name.
+ * @since 7.0
+ */
+ public static String translateResourceName(String resourceName) {
+ return currentResourceInstance.translateResourceName(resourceName);
+ }
+
}
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/StandardJREResourceWrapper.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/StandardJREResourceWrapper.java 2012-02-07 10:48:17 UTC (rev 330)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/StandardJREResourceWrapper.java 2012-02-07 10:48:54 UTC (rev 331)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2004-2012 Stephane GALLAND.
+ * Copyright (C) 2008-2012 Stephane GALLAND.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -106,5 +106,13 @@
}
return is;
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String translateResourceName(String resourceName) {
+ return resourceName;
+ }
+
}
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/locale/Locale.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/locale/Locale.java 2012-02-07 10:48:17 UTC (rev 330)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/locale/Locale.java 2012-02-07 10:48:54 UTC (rev 331)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2005-10, Multiagent Team,
+ * Copyright (c) 2008-10, Multiagent Team,
* Laboratoire Systemes et Transports,
* Universite de Technologie de Belfort-Montbeliard.
* All rights reserved.
@@ -71,9 +71,10 @@
private static Class<?> detectResourceClass(Class<?> resource) {
if (resource==null) {
// Parameter value:
- // 0: is always Locale.class (ie. the caller of this PRIVATE function)
- // 1: is the third top of the trace stack ie, the first caller outside Locale.class
- return Caller.getCallerClass(1);
+ // 0: is always Locale.class (ie. this PRIVATE function)
+ // 1: is always Locale.class (ie. the caller of this PRIVATE function)
+ // 2: is the third top of the trace stack ie, the first caller outside Locale.class
+ return Caller.getCallerClass(2);
}
return resource;
}
@@ -128,9 +129,9 @@
// Get the resource file
ResourceBundle resource = null;
try {
- resource = ResourceBundle.getBundle(resourcePath,
- java.util.Locale.getDefault(),
- classLoader);
+ resource = ResourceBundle.getBundle(resourcePath,
+ java.util.Locale.getDefault(),
+ classLoader);
}
catch (MissingResourceException exep) {
return defaultValue;