You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by ne...@apache.org on 2001/11/02 20:41:48 UTC

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n BundleInfo.java

neeme       01/11/02 11:41:48

  Modified:    src/scratchpad/org/apache/avalon/excalibur/i18n
                        BundleInfo.java
  Log:
  support for new matcher system, added the matches(BundleInfo) method for comparing two bundleinfo instances
  
  Revision  Changes    Path
  1.2       +23 -1     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/BundleInfo.java
  
  Index: BundleInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/BundleInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BundleInfo.java	2001/10/30 21:38:56	1.1
  +++ BundleInfo.java	2001/11/02 19:41:48	1.2
  @@ -13,7 +13,7 @@
    * Used to map locale information to URI space, to find the relevant bundle.
    *
    * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/10/30 21:38:56 $ $Author: neeme $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/11/02 19:41:48 $ $Author: neeme $
    */
   public class BundleInfo {
   
  @@ -78,6 +78,28 @@
               newloc = new Locale(this.locale.getLanguage(), this.locale.getCountry(), "");
   
           return newloc;
  +    }
  +
  +    public boolean matches(BundleInfo info) {
  +        return
  +            match(this.name, info.getName()) &&
  +            match(this.locale, info.getLocale()) &&
  +            match(this.ext, info.getExtensionParameter());
  +    }
  +
  +    protected boolean match(String str, String reference) {
  +        if (str == null) return true;
  +        if (reference == null) return false;
  +        return str.equals(reference);
  +    }
  +
  +    protected boolean match(Locale locale, Locale reference) {
  +        if (locale == null) return true;
  +        if (reference == null) return false;
  +        return
  +            match(locale.getLanguage(), reference.getLanguage()) &&
  +            match(locale.getCountry(), reference.getCountry()) &&
  +            match(locale.getVariant(), reference.getVariant());
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>