public synchronized boolean remove()

in auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java [162:221]


  public synchronized boolean remove(K key) throws IOException
  {
    if (log.isDebugEnabled())
    {
      log.debug("removing item for key: " + key);
    }

    boolean removed = false;

    // handle partial removal
    if (key instanceof String && ( (String) key)
        .endsWith(CacheConstants.NAME_COMPONENT_DELIMITER))
    {
      // remove all keys of the same name hierarchy.
      synchronized (map)
      {
        for (Iterator itr = map.entrySet().iterator(); itr.hasNext(); )
        {
          Map.Entry entry = (Map.Entry) itr.next();
          Object k = entry.getKey();

          if (k instanceof String
              && ( (String) k).startsWith(key.toString()))
          {
            itr.remove();

            removed = true;
          }
        }
      }
    }
    else if (key instanceof GroupId)
    {
      // remove all keys of the same name hierarchy.
      synchronized (map)
      {
        for (Iterator itr = map.entrySet().iterator(); itr.hasNext(); )
        {
          Map.Entry entry = (Map.Entry) itr.next();
          Object k = entry.getKey();

          if (k instanceof GroupAttrName
              && ( (GroupAttrName) k).groupId.equals(key))
          {
            itr.remove();

            removed = true;
          }
        }
      }
    }
    else
    {
      // remove single item.
      ICacheElement<K, V> ce = (ICacheElement) map.remove(key);
      removed = true;
    }

    return removed;
  }