예제 #1
0
파일: DBAbstract.java 프로젝트: joval/JDBM3
  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);
    }
  }
예제 #2
0
파일: DBAbstract.java 프로젝트: joval/JDBM3
  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);
    }
  }