Changeset 9279


Ignore:
Timestamp:
2005-03-04T15:22:41+13:00 (19 years ago)
Author:
kjdon
Message:

changed again how you get text strings. have gone back to using the class name if no dictionary name is specified, but will now look up the super class list until a string is found. can still specify a dictionary in the getTextString call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r9265 r9279  
    8787    protected HashMap format_info_map = null;
    8888
    89     /** the name of the Dictionary to be used. The classname will be used if null */
    90     protected String dictionary_name = null;
    91 
    9289    /** sets the cluster name */
    9390    public void setClusterName(String cluster_name) {
     
    119116    this.short_service_info = this.doc.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
    120117    this.format_info_map = new HashMap();
    121     // the default value for the dictionary is the classname
    122     String class_name = this.getClass().getName();
    123     class_name = class_name.substring(class_name.lastIndexOf('.')+1);
    124     this.dictionary_name = class_name;
    125 
    126118    }
    127119   
     
    335327    /** overloaded version for no args case */
    336328    protected String getTextString(String key, String lang) {
    337     return getTextString(key, lang, this.dictionary_name, null);
     329    return getTextString(key, lang, null, null);
    338330    }
    339331
     
    342334    }
    343335    protected String getTextString(String key, String lang, String [] args) {
    344     return getTextString(key, lang, this.dictionary_name, args);
     336    return getTextString(key, lang, null, args);
    345337    }
    346338   
     
    352344    //String class_name = this.getClass().getName();
    353345    //class_name = class_name.substring(class_name.lastIndexOf('.')+1);
    354    
    355     Dictionary dict = new Dictionary(dictionary, lang);
     346    if (dictionary != null) {
     347        // just try the one specified dictionary
     348        Dictionary dict = new Dictionary(dictionary, lang);
     349        String result = dict.get(key, args);
     350        if (result == null) { // not found
     351        return "_"+key+"_";
     352        }
     353        return result;
     354    }
     355
     356    // else we try class names for dictionary names
     357    String class_name = this.getClass().getName();
     358    class_name = class_name.substring(class_name.lastIndexOf('.')+1);
     359    Dictionary dict = new Dictionary(class_name, lang);
    356360    String result = dict.get(key, args);
    357     if (result == null) { // not found
     361    if (result != null) {
     362        return result;
     363    }
     364
     365    // we have to try super classes
     366    Class c = this.getClass().getSuperclass();
     367    while (result == null && c != null) {
     368        class_name = c.getName();
     369        class_name = class_name.substring(class_name.lastIndexOf('.')+1);
     370        if (class_name.equals("ServiceRack")) {
     371        // this is as far as we go
     372        break;
     373        }
     374        dict = new Dictionary(class_name, lang);
     375        result = dict.get(key, args);
     376        c = c.getSuperclass();
     377    }
     378    if (result == null) {
    358379        return "_"+key+"_";
    359380    }
    360381    return result;
     382   
    361383    }
    362384
Note: See TracChangeset for help on using the changeset viewer.