Code example for TreeSet

Methods: add, clear, contains

0
    public synchronized String getString(final String key) {
        final String retval = (String) this.cache.get(key);
        if (retval != null) {
            return retval;
        } 
        this.lookupPath.clear();
        return internalGetString(key);
    } 
 
    /** 
     * Performs the lookup for the given key. If the key points to a link the link is 
     * resolved and that key is looked up instead. 
     * 
     * @param key the key for the string 
     * @return the string for the given key 
     */ 
    protected String internalGetString(final String key) {
        if (this.lookupPath.contains(key)) {
            throw new MissingResourceException
                ("InfiniteLoop in resource lookup", 
                    getResourceBase(), this.lookupPath.toString());
        } 
        final String fromResBundle = this.resources.getString(key);
        if (fromResBundle.startsWith("@@")) {
            // global forward ... 
            final int idx = fromResBundle.indexOf('@', 2);
            if (idx == -1) {
                throw new MissingResourceException
                    ("Invalid format for global lookup key.", getResourceBase(), key);
            } 
            try { 
                final ResourceBundle res = ResourceBundle.getBundle
                    (fromResBundle.substring(2, idx));
                return res.getString(fromResBundle.substring(idx + 1));
            } 
            catch (Exception e) {
                Log.error("Error during global lookup", e);
                throw new MissingResourceException
                    ("Error during global lookup", getResourceBase(), key);
            } 
        } 
        else if (fromResBundle.startsWith("@")) {
            // local forward ... 
            final String newKey = fromResBundle.substring(1);
            this.lookupPath.add(key);
            final String retval = internalGetString(newKey);
 
            this.cache.put(key, retval);
            return retval;
        }