예제 #1
0
파일: DBAbstract.java 프로젝트: joval/JDBM3
  public synchronized <K> NavigableSet<K> getTreeSet(String name) {
    Object o = getCollectionInstance(name);
    if (o != null) return (NavigableSet<K>) o;

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

      BTree t = BTree.<K, Object>load(this, recid);
      if (t.hasValues()) throw new ClassCastException("TreeMap is not TreeSet");
      BTreeSet<K> ret = new BTreeSet<K>(new BTreeMap(t, false));
      collections.put(name, new WeakReference<Object>(ret));
      return ret;

    } catch (IOException e) {
      throw new IOError(e);
    }
  }
예제 #2
0
파일: DBAbstract.java 프로젝트: joval/JDBM3
  public synchronized <K, V> ConcurrentNavigableMap<K, V> getTreeMap(String name) {
    Object o = getCollectionInstance(name);
    if (o != null) return (ConcurrentNavigableMap<K, V>) o;

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

      BTree t = BTree.<K, V>load(this, recid);
      if (!t.hasValues()) throw new ClassCastException("TreeSet is not TreeMap");
      ConcurrentNavigableMap<K, V> ret =
          new BTreeMap<K, V>(t, false); // TODO put readonly flag here
      collections.put(name, new WeakReference<Object>(ret));
      return ret;
    } catch (IOException e) {
      throw new IOError(e);
    }
  }