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 HashSetDbImpl extends CollectableDbImpl implements HashSet {
027: private java.util.HashSet m_hashSet;
028:
029: public HashSetDbImpl() {
030: m_hashSet = new java.util.HashSet();
031: }
032:
033: public void fixUpReference(long fixUpTime) {
034: if (referenceHasBeenFixedUp(fixUpTime) == true) {
035: return;
036: }
037:
038: super .fixUpReference(fixUpTime);
039:
040: synchronized (m_hashSet) {
041: CollectableDbImpl.fixUpReference(m_hashSet, fixUpTime);
042: }
043: }
044:
045: public boolean add(Object o) {
046: boolean retval = false;
047:
048: synchronized (m_hashSet) {
049: retval = m_hashSet.add(o);
050: }
051:
052: return retval;
053: }
054:
055: public boolean addAll(java.util.Collection c) {
056: boolean retval = false;
057:
058: synchronized (m_hashSet) {
059: retval = m_hashSet.addAll(c);
060: }
061:
062: return retval;
063: }
064:
065: public boolean contains(Object o) {
066: boolean retval = false;
067:
068: synchronized (m_hashSet) {
069: retval = m_hashSet.contains(o);
070: }
071:
072: return retval;
073: }
074:
075: public boolean remove(Object o) {
076: boolean retval = false;
077:
078: synchronized (m_hashSet) {
079: retval = m_hashSet.remove(o);
080: }
081:
082: return retval;
083: }
084:
085: public boolean removeAll(java.util.Collection c) {
086: boolean retval = false;
087:
088: synchronized (m_hashSet) {
089: retval = m_hashSet.removeAll(c);
090: }
091:
092: return retval;
093: }
094:
095: public void clear() {
096: synchronized (m_hashSet) {
097: m_hashSet.clear();
098: }
099: }
100:
101: public int size() {
102: int retval = -1;
103:
104: synchronized (m_hashSet) {
105: retval = m_hashSet.size();
106: }
107:
108: return retval;
109: }
110:
111: public String toString() {
112: String retval = null;
113:
114: synchronized (m_hashSet) {
115: retval = m_hashSet.toString();
116: }
117:
118: return retval;
119: }
120:
121: public boolean equals(Object obj) {
122: boolean retval = false;
123:
124: synchronized (m_hashSet) {
125: retval = m_hashSet.equals(obj);
126: }
127:
128: return retval;
129: }
130:
131: public java.util.HashSet collection() {
132: return m_hashSet;
133: }
134:
135: public java.util.ArrayList toArrayList() {
136: java.util.ArrayList retval = null;
137:
138: synchronized (m_hashSet) {
139: retval = new java.util.ArrayList(m_hashSet);
140: }
141:
142: return retval;
143: }
144:
145: public Iterator iterator() {
146: return (Iterator) getDatabase().createObject(
147: IteratorDbImpl.class.getName(), "java.util.Collection",
148: new Object[] { m_hashSet });
149: }
150: }
|