Exemplo n.º 1
0
  public synchronized <K, V> ConcurrentMap<K, V> getHashMap(String name) {
    Object o = getCollectionInstance(name);
    if (o != null) return (ConcurrentMap<K, V>) o;

    try {
      long recid = getNamedObject(name);
      if (recid == 0) return null;

      HTree tree = fetch(recid);
      tree.setPersistenceContext(this);
      if (!tree.hasValues()) {
        throw new ClassCastException("HashSet is not HashMap");
      }
      collections.put(name, new WeakReference<Object>(tree));
      return tree;
    } catch (IOException e) {
      throw new IOError(e);
    }
  }
Exemplo n.º 2
0
  public synchronized <K> Set<K> getHashSet(String name) {
    Object o = getCollectionInstance(name);
    if (o != null) return (Set<K>) o;

    try {
      long recid = getNamedObject(name);
      if (recid == 0) return null;

      HTree tree = fetch(recid);
      tree.setPersistenceContext(this);
      if (tree.hasValues()) {
        throw new ClassCastException("HashMap is not HashSet");
      }
      Set<K> ret = new HTreeSet(tree);
      collections.put(name, new WeakReference<Object>(ret));
      return ret;
    } catch (IOException e) {
      throw new IOError(e);
    }
  }