Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 57566 invoked from network); 12 Dec 2001 12:30:30 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Dec 2001 12:30:30 -0000 Received: (qmail 10134 invoked by uid 97); 12 Dec 2001 12:30:28 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 10118 invoked by uid 97); 12 Dec 2001 12:30:28 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 10107 invoked by uid 97); 12 Dec 2001 12:30:27 -0000 Date: 12 Dec 2001 12:30:27 -0000 Message-ID: <20011212123027.37671.qmail@icarus.apache.org> From: colus@apache.org To: jakarta-avalon-excalibur-cvs@apache.org Subject: cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/i18n ResourceManager.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N colus 01/12/12 04:30:27 Modified: src/java/org/apache/avalon/excalibur/i18n ResourceManager.java Log: Refactor for prepare to use with Locale. Fixed javadoc. Revision Changes Path 1.10 +39 -14 jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/i18n/ResourceManager.java Index: ResourceManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/i18n/ResourceManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ResourceManager.java 2001/12/11 09:53:28 1.9 +++ ResourceManager.java 2001/12/12 12:30:26 1.10 @@ -40,7 +40,7 @@ /** * Retrieve resource for specified name. - * The baseName is determined by name postfixed with ".Resources". + * The basename is determined by name postfixed with ".Resources". * * @param clazz the Class * @return the Resources @@ -52,7 +52,7 @@ /** * Retrieve resource for specified Classes package. - * The baseName is determined by name of classes package + * The basename is determined by name of classes package * postfixed with ".Resources". * * @param clazz the Class @@ -60,41 +60,66 @@ */ public final static Resources getPackageResources( final Class clazz ) { + return getBaseResources( getPackageResourcesBaseName( clazz ) ); + } + + /** + * Retrieve resource for specified Class. + * The basename is determined by name of Class + * postfixed with "Resources". + * + * @param clazz the Class + * @return the Resources + */ + public final static Resources getClassResources( final Class clazz ) + { + return getBaseResources( getClassResourcesBaseName( clazz ) ); + } + + /** + * Retrieve resource basename for specified Classes package. + * The basename is determined by name of classes package + * postfixed with ".Resources". + * + * @param clazz the Class + * @return the resource basename + */ + public final static String getPackageResourcesBaseName( final Class clazz ) + { final Package pkg = clazz.getPackage(); - String resource; + String baseName; if ( null == pkg ) { final String name = clazz.getName(); if ( -1 == name.lastIndexOf( "." ) ) { - resource = "Resources"; + baseName = "Resources"; } else { - resource = name.substring( 0, name.lastIndexOf( "." ) ) + ".Resources"; + baseName = name.substring( 0, name.lastIndexOf( "." ) ) + ".Resources"; } } else { - resource = pkg.getName() + ".Resources"; + baseName = pkg.getName() + ".Resources"; } - return getBaseResources( resource ); + return baseName; } /** - * Retrieve resource for specified Class. - * The baseName is determined by name of Class - * postfixed with ".Resources". + * Retrieve resource basename for specified Class. + * The basename is determined by name of Class + * postfixed with "Resources". * * @param clazz the Class - * @return the Resources + * @return the resource basename */ - public final static Resources getClassResources( final Class clazz ) + public final static String getClassResourcesBaseName( final Class clazz ) { - final String resource = clazz.getName() + "Resources"; - return getBaseResources( resource ); + return clazz.getName() + "Resources"; } /** -- To unsubscribe, e-mail: For additional commands, e-mail: