Class HashSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet
-
- com.sun.jdo.spi.persistence.support.sqlstore.sco.HashSet
-
- All Implemented Interfaces:
SCO
,SCOCollection
,Serializable
,Cloneable
,Iterable
,Collection
,Set
public class HashSet extends HashSet implements SCOCollection
A mutable 2nd class object date.- Version:
- 1.0
- Author:
- Marina Vatkina
- See Also:
HashSet
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HashSet(Object owner, String fieldName, Class elementType, boolean allowNulls)
Creates a new emptyHashSet
object.HashSet(Object owner, String fieldName, Class elementType, boolean allowNulls, int initialCapacity)
Creates a new emptyHashSet
object that has the specified initial capacity.Assigns owning object and field name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Object o)
Adds the specified element to this set if it is not already present.boolean
addAll(Collection c)
Adds all of the elements in the specified collection to this collectionvoid
addAllInternal(Collection c)
Adds a Collection to the list without recording changes if the HashSet is not deferred.void
addInternal(Object o)
Adds an object to the list without recording changes if the HashSet is not deferred.void
addToBaseCollection(Object o)
Adds an object to the list without recording changes.void
applyDeferredUpdates(Collection c)
If the HashSet is deferred, we first initialize the internal collection with c and they apply any deferred updates specified by the added and removed lists.void
applyUpdates(StateManager sm, boolean modified)
Apply changes (can be a no-op)void
clear()
Removes all of the elements from this set.void
clearInternal()
Clears Collection without notifing the ownerObject
clone()
Creates and returns a copy of this object.Object
cloneInternal()
Creates and returns a copy of this object without resetting the owner and field value.Collection
getAdded()
Returns added collectionString
getFieldName()
Returns the field nameObject
getOwner()
Returns the owner object of the SCO instanceCollection
getRemoved()
Returns removed collectionboolean
isDeferred()
Return true is this HashSet is deferred, false otherwise.Iterator
iterator()
Returns an iterator over the elements in this set.StateManager
makeDirty()
Marks object dirtyvoid
markDeferred()
Mark this HashSet as deferred.boolean
remove(Object o)
Removes the given element from this set if it is present.boolean
removeAll(Collection c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).void
removeAllInternal(Collection c)
Removes objects of the given Collection from this Collection without recording the event.void
removeInternal(Object o)
Removes an element without notifing the ownervoid
reset()
Cleans removed and added listsboolean
retainAll(Collection c)
Retains only the elements in this collection that are contained in the specified collection (optional operation).void
setOwner(Object owner, String fieldName, Class elementType)
Set the owner if this instance is not owned.void
unsetOwner()
Nullifies references to the owner Object and Field-
Methods inherited from class java.util.HashSet
contains, isEmpty, size, spliterator
-
Methods inherited from class java.util.AbstractSet
equals, hashCode
-
Methods inherited from class java.util.AbstractCollection
containsAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Constructor Detail
-
HashSet
public HashSet(Object owner, String fieldName, Class elementType, boolean allowNulls)
Creates a new emptyHashSet
object. Assigns owning object and field name.- Parameters:
owner
- the owning objectfieldName
- the owning field nameelementType
- the element types allowedallowNulls
- true if nulls are allowed
-
HashSet
public HashSet(Object owner, String fieldName, Class elementType, boolean allowNulls, int initialCapacity)
Creates a new emptyHashSet
object that has the specified initial capacity.Assigns owning object and field name.- Parameters:
owner
- the owning objectfieldName
- the owning field nameelementType
- the element types allowedallowNulls
- true if nulls are allowedinitialCapacity
- the initial capacity of the hash map.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero.- See Also:
HashSet
-
-
Method Detail
-
add
public boolean add(Object o)
Adds the specified element to this set if it is not already present.
-
addAll
public boolean addAll(Collection c)
Adds all of the elements in the specified collection to this collection- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceSet
- Overrides:
addAll
in classAbstractCollection
- Parameters:
c
- collection whose elements are to be added to this collection.- Returns:
- true if this collection changed as a result of the call.
- Throws:
UnsupportedOperationException
- if the addAll method is not supported by this collection.- See Also:
AbstractCollection
,HashSet
-
remove
public boolean remove(Object o)
Removes the given element from this set if it is present.
-
removeAll
public boolean removeAll(Collection c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceSet
- Overrides:
removeAll
in classAbstractSet
- Parameters:
c
- elements to be removed from this collection.- Returns:
- true if this collection changed as a result of the call.
- Throws:
UnsupportedOperationException
- removeAll is not supported by this collection.- See Also:
HashSet
,AbstractCollection
-
retainAll
public boolean retainAll(Collection c)
Retains only the elements in this collection that are contained in the specified collection (optional operation).- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceSet
- Overrides:
retainAll
in classAbstractCollection
- Returns:
- true if this collection changed as a result of the call.
- Throws:
UnsupportedOperationException
- if the retainAll method is not supported by this collection.- See Also:
HashSet
,AbstractCollection
-
clear
public void clear()
Removes all of the elements from this set.
-
clone
public Object clone()
Creates and returns a copy of this object.Mutable Second Class Objects are required to provide a public clone method in order to allow for copying PersistenceCapable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.
-
iterator
public Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Specified by:
iterator
in interfaceSet
- Overrides:
iterator
in classHashSet
- Returns:
- an Iterator over the elements in this set.
- See Also:
ConcurrentModificationException
-
cloneInternal
public Object cloneInternal()
Creates and returns a copy of this object without resetting the owner and field value.- Specified by:
cloneInternal
in interfaceSCO
-
reset
public void reset()
Cleans removed and added lists- Specified by:
reset
in interfaceSCOCollection
-
markDeferred
public void markDeferred()
Mark this HashSet as deferred.- Specified by:
markDeferred
in interfaceSCOCollection
-
isDeferred
public boolean isDeferred()
Return true is this HashSet is deferred, false otherwise.- Specified by:
isDeferred
in interfaceSCOCollection
-
applyDeferredUpdates
public void applyDeferredUpdates(Collection c)
If the HashSet is deferred, we first initialize the internal collection with c and they apply any deferred updates specified by the added and removed lists.- Specified by:
applyDeferredUpdates
in interfaceSCOCollection
-
addInternal
public void addInternal(Object o)
Adds an object to the list without recording changes if the HashSet is not deferred. Otherwise, add o to the added list.- Specified by:
addInternal
in interfaceSCOCollection
-
addAllInternal
public void addAllInternal(Collection c)
Adds a Collection to the list without recording changes if the HashSet is not deferred. Otherwise, add o to the removed list.- Specified by:
addAllInternal
in interfaceSCOCollection
-
addToBaseCollection
public void addToBaseCollection(Object o)
Description copied from interface:SCOCollection
Adds an object to the list without recording changes.- Specified by:
addToBaseCollection
in interfaceSCOCollection
-
removeAllInternal
public void removeAllInternal(Collection c)
Description copied from interface:SCOCollection
Removes objects of the given Collection from this Collection without recording the event. Used internaly to remove a collection of elements from this collection.- Specified by:
removeAllInternal
in interfaceSCOCollection
-
getAdded
public Collection getAdded()
Returns added collection- Specified by:
getAdded
in interfaceSCOCollection
- Returns:
- added collection of added elements
-
getRemoved
public Collection getRemoved()
Returns removed collection- Specified by:
getRemoved
in interfaceSCOCollection
- Returns:
- removed collection of removed elements
-
clearInternal
public void clearInternal()
Clears Collection without notifing the owner- Specified by:
clearInternal
in interfaceSCOCollection
-
removeInternal
public void removeInternal(Object o)
Removes an element without notifing the owner- Specified by:
removeInternal
in interfaceSCOCollection
-
unsetOwner
public void unsetOwner()
Nullifies references to the owner Object and Field- Specified by:
unsetOwner
in interfaceSCO
-
getOwner
public Object getOwner()
Returns the owner object of the SCO instance
-
getFieldName
public String getFieldName()
Returns the field name- Specified by:
getFieldName
in interfaceSCO
- Returns:
- field name as java.lang.String
-
makeDirty
public StateManager makeDirty()
Marks object dirty
-
applyUpdates
public void applyUpdates(StateManager sm, boolean modified)
Apply changes (can be a no-op)- Specified by:
applyUpdates
in interfaceSCO
-
setOwner
public void setOwner(Object owner, String fieldName, Class elementType)
Set the owner if this instance is not owned.- Specified by:
setOwner
in interfaceSCOCollection
- Parameters:
owner
- the new owner.fieldName
- the new field name.elementType
- the new element type as Class, or null if type is not checked or not supported.- See Also:
SCOCollection.setOwner(java.lang.Object, java.lang.String, java.lang.Class)
-
-