Code example for HashSet

Methods: add, clear, contains

0
    final String retval = 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 (key == null)
    { 
      throw new NullPointerException();
    } 
 
    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.length() > 0 && fromResBundle.charAt(0) == '@')
    { 
      if (fromResBundle.length() > 1 && fromResBundle.charAt(1) == '@')
      { 
        // 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), locale, sourceClassLoader);
          return res.getString(fromResBundle.substring(idx + 1));
        } 
        catch (Exception e)
        { 
          logger.error("Error during global lookup", e);
          throw new MissingResourceException("Error during global lookup", getResourceBase(), key);
        } 
      } 
      else 
      { 
        // local forward ... 
        final String newKey = fromResBundle.substring(1);
        this.lookupPath.add(key);
        final String retval = internalGetString(newKey);
 
        this.cache.put(key, retval);
        return retval;
      }