001: ///////////////////////////////////////////////////////////////////////////////
002: //
003: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
004: //
005: // All Rights Reserved
006: //
007: // This program is free software; you can redistribute it and/or modify
008: // it under the terms of the GNU General Public License and GNU Library
009: // General Public License as published by the Free Software Foundation;
010: // either version 2, or (at your option) any later version.
011: //
012: // This program is distributed in the hope that it will be useful,
013: // but WITHOUT ANY WARRANTY; without even the implied warranty of
014: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: // GNU General Public License and GNU Library General Public License
016: // for more details.
017: //
018: // You should have received a copy of the GNU General Public License
019: // and GNU Library General Public License along with this program; if
020: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
021: // MA 02139, USA.
022: //
023: ///////////////////////////////////////////////////////////////////////////////
024: package org.myoodb.collectable;
025:
026: public class TreeSetDbImpl extends CollectableDbImpl implements TreeSet {
027: private java.util.TreeSet m_treeSet;
028:
029: public TreeSetDbImpl() {
030: m_treeSet = new java.util.TreeSet();
031: }
032:
033: public TreeSetDbImpl(java.util.Comparator cmp) {
034: m_treeSet = new java.util.TreeSet(cmp);
035: }
036:
037: public void fixUpReference(long fixUpTime) {
038: if (referenceHasBeenFixedUp(fixUpTime) == true) {
039: return;
040: }
041:
042: super .fixUpReference(fixUpTime);
043:
044: synchronized (m_treeSet) {
045: CollectableDbImpl.fixUpReference(m_treeSet, fixUpTime);
046: }
047: }
048:
049: public boolean add(Object o) {
050: boolean retval = false;
051:
052: synchronized (m_treeSet) {
053: retval = m_treeSet.add(o);
054: }
055:
056: return retval;
057: }
058:
059: public boolean addAll(java.util.Collection c) {
060: boolean retval = false;
061:
062: synchronized (m_treeSet) {
063: retval = m_treeSet.addAll(c);
064: }
065:
066: return retval;
067: }
068:
069: public boolean contains(Object o) {
070: boolean retval = false;
071:
072: synchronized (m_treeSet) {
073: retval = m_treeSet.contains(o);
074: }
075:
076: return retval;
077: }
078:
079: public boolean remove(Object o) {
080: boolean retval = false;
081:
082: synchronized (m_treeSet) {
083: retval = m_treeSet.remove(o);
084: }
085:
086: return retval;
087: }
088:
089: public boolean removeAll(java.util.Collection c) {
090: boolean retval = false;
091:
092: synchronized (m_treeSet) {
093: retval = m_treeSet.removeAll(c);
094: }
095:
096: return retval;
097: }
098:
099: public Object first() {
100: Object retval = null;
101:
102: synchronized (m_treeSet) {
103: retval = m_treeSet.first();
104: }
105:
106: return retval;
107: }
108:
109: public Object last() {
110: Object retval = null;
111:
112: synchronized (m_treeSet) {
113: retval = m_treeSet.last();
114: }
115:
116: return retval;
117: }
118:
119: public void clear() {
120: synchronized (m_treeSet) {
121: m_treeSet.clear();
122: }
123: }
124:
125: public int size() {
126: int retval = -1;
127:
128: synchronized (m_treeSet) {
129: retval = m_treeSet.size();
130: }
131:
132: return retval;
133: }
134:
135: public String toString() {
136: String retval = null;
137:
138: synchronized (m_treeSet) {
139: retval = m_treeSet.toString();
140: }
141:
142: return retval;
143: }
144:
145: public boolean equals(Object obj) {
146: boolean retval = false;
147:
148: synchronized (m_treeSet) {
149: retval = m_treeSet.equals(obj);
150: }
151:
152: return retval;
153: }
154:
155: public java.util.TreeSet collection() {
156: return m_treeSet;
157: }
158:
159: public java.util.ArrayList toArrayList() {
160: java.util.ArrayList retval = null;
161:
162: synchronized (m_treeSet) {
163: retval = new java.util.ArrayList(m_treeSet);
164: }
165:
166: return retval;
167: }
168:
169: public Iterator iterator() {
170: return (Iterator) getDatabase().createObject(
171: IteratorDbImpl.class.getName(), "java.util.Collection",
172: new Object[] { m_treeSet });
173: }
174:
175: public java.util.SortedSet headSet(Object toElement) {
176: synchronized (m_treeSet) {
177: return m_treeSet.headSet(toElement);
178: }
179: }
180:
181: public java.util.SortedSet subSet(Object fromElement,
182: Object toElement) {
183: synchronized (m_treeSet) {
184: return m_treeSet.subSet(fromElement, toElement);
185: }
186: }
187:
188: public java.util.SortedSet tailSet(Object fromElement) {
189: synchronized (m_treeSet) {
190: return m_treeSet.tailSet(fromElement);
191: }
192: }
193: }
|