arieh       01/03/16 15:43:56

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32 Context.java
  Log:
  Add support for 'docbase' localization lookup to the getRealPath() method.
  Preserve backwards compatibility on the getRealPath(path, loc, loc) call.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.100.2.5 +48 -3     jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.100.2.4
  retrieving revision 1.100.2.5
  diff -u -r1.100.2.4 -r1.100.2.5
  --- Context.java      2000/11/18 00:09:42     1.100.2.4
  +++ Context.java      2001/03/16 23:43:53     1.100.2.5
  @@ -807,7 +807,8 @@
       }
   
       /**  method to return the Localized version of the file whose
  -     *   name is passed as an argument.
  +     *   name is passed as an argument. This corresponds to "file" type
  +     *   localization resource lookup mechanism.
        *
        *  The method performs a resource lookup in a manner similar to the
        *  one specified by java.util.ResourceBundle.
  @@ -854,11 +855,55 @@
        */
       public String getRealPath (String path, Locale reqLocale, Locale fbLocale)
       {
  +     return getRealPath (path, reqLocale, fbLocale, "file");
  +    }
  +
  +    /**  method to return the Localized version of the file whose
  +     *   name is passed as an argument. The localization is done based
  +     *   on localization subdirectories under the docBase.
  +     *
  +     *  The method performs a resource lookup in a manner similar to the
  +     *  one used for JavaHelp resources.
  +     *
  +     *  Search for localized versions of the file are looked for:
  +     *
  +     *   <docBase> + "/" + language1 + "_" + country1 + "_" + variant1 + file
  +     *   <docBase> + "/" + language1 + "_" + country1 + file
  +     *   <docBase> + "/" + language1 + file
  +     *   <docBase> + "/" + language2 + "_" + country2 + "_" + variant1 + file
  +     *   <docBase> + "/" + language2 + "_" + country2 + file
  +     *   <docBase> + "/" + language2 + file
  +     *   <docBase> + file
  +     *
  +     *  Where language1, country1, variant1 are associated with the Locale
  +     *  passed as an argument and language2, country2, variant are associated
  +     *  with the fallback Locale passed as argument.
  +     *
  +     *
  +     *  @param path the pathname for the resource whose localized version
  +     *          we are seeking
  +     *  @param loc the Locale we are interested in.
  +     *  @param fbLoc the fallback Locale to use if unsuccessful
  +     *  @param locType the type of localization required "file", "docbase"
  +     *
  +     *  @return a String with the path of the "best localized match" for
  +     *          the file whose path has been passed as argument.
  +     */
  +    public String getRealPath (String path, Locale reqLocale, Locale fbLocale,
  +                            String locType)
  +    {
           String base = getAbsolutePath();
           if (path == null) path = "";
  +
  +        String realPath = null;
  +
  +     if ("file".equals (locType))
  +         realPath = FileUtil.getLocalizedFile (base, path,
  +                                               reqLocale, fbLocale);
  +     else if ("docbase".equals (locType))
  +         realPath = FileUtil.getDocBaseLocalizedFile (base, path,
  +                                               reqLocale, fbLocale);
   
  -        String realPath = FileUtil.getLocalizedFile (base, path,
  -                                                  reqLocale, fbLocale);
        if( debug>5) {
            log("Get real path " + path + " " + realPath + " " + base
                 + reqLocale.toString() + " " + fbLocale.toString() );
  
  
  

Reply via email to