KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > myoodb > collectable > HashSetDbImpl


1 ///////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
4
//
5
// All Rights Reserved
6
//
7
// This program is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License and GNU Library
9
// General Public License as published by the Free Software Foundation;
10
// either version 2, or (at your option) any later version.
11
//
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License and GNU Library General Public License
16
// for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// and GNU Library General Public License along with this program; if
20
// not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21
// MA 02139, USA.
22
//
23
///////////////////////////////////////////////////////////////////////////////
24
package org.myoodb.collectable;
25
26 public class HashSetDbImpl extends CollectableDbImpl implements HashSet
27 {
28     private java.util.HashSet JavaDoc m_hashSet;
29
30     public HashSetDbImpl()
31     {
32         m_hashSet = new java.util.HashSet JavaDoc();
33     }
34
35     public void fixUpReference(long fixUpTime)
36     {
37         if (referenceHasBeenFixedUp(fixUpTime) == true)
38         {
39             return;
40         }
41
42         super.fixUpReference(fixUpTime);
43
44         synchronized(m_hashSet)
45         {
46             CollectableDbImpl.fixUpReference(m_hashSet, fixUpTime);
47         }
48     }
49
50     public boolean add(Object JavaDoc o)
51     {
52         boolean retval = false;
53
54         synchronized(m_hashSet)
55         {
56             retval = m_hashSet.add(o);
57         }
58
59         return retval;
60     }
61
62     public boolean addAll(java.util.Collection JavaDoc c)
63     {
64         boolean retval = false;
65
66         synchronized(m_hashSet)
67         {
68             retval = m_hashSet.addAll(c);
69         }
70
71         return retval;
72     }
73
74     public boolean contains(Object JavaDoc o)
75     {
76         boolean retval = false;
77
78         synchronized(m_hashSet)
79         {
80             retval = m_hashSet.contains(o);
81         }
82
83         return retval;
84     }
85
86     public boolean remove(Object JavaDoc o)
87     {
88         boolean retval = false;
89
90         synchronized(m_hashSet)
91         {
92             retval = m_hashSet.remove(o);
93         }
94
95         return retval;
96     }
97
98     public boolean removeAll(java.util.Collection JavaDoc c)
99     {
100         boolean retval = false;
101
102         synchronized(m_hashSet)
103         {
104             retval = m_hashSet.removeAll(c);
105         }
106
107         return retval;
108     }
109
110     public void clear()
111     {
112         synchronized(m_hashSet)
113         {
114             m_hashSet.clear();
115         }
116     }
117     public int size()
118     {
119         int retval = -1;
120
121         synchronized(m_hashSet)
122         {
123             retval = m_hashSet.size();
124         }
125
126         return retval;
127     }
128
129     public String JavaDoc toString()
130     {
131         String JavaDoc retval = null;
132
133         synchronized(m_hashSet)
134         {
135             retval = m_hashSet.toString();
136         }
137
138         return retval;
139     }
140
141     public boolean equals(Object JavaDoc obj)
142     {
143         boolean retval = false;
144
145         synchronized(m_hashSet)
146         {
147             retval = m_hashSet.equals(obj);
148         }
149
150         return retval;
151     }
152
153     public java.util.HashSet JavaDoc collection()
154     {
155         return m_hashSet;
156     }
157
158     public java.util.ArrayList JavaDoc toArrayList()
159     {
160         java.util.ArrayList JavaDoc retval = null;
161
162         synchronized(m_hashSet)
163         {
164             retval = new java.util.ArrayList JavaDoc(m_hashSet);
165         }
166
167         return retval;
168     }
169
170     public Iterator iterator()
171     {
172         return (Iterator) getDatabase().createObject(IteratorDbImpl.class.getName(), "java.util.Collection", new Object JavaDoc[] {m_hashSet});
173     }
174 }
175
Free Books   Free Magazines  
Popular Tags