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 emptyHashSetobject.HashSet(Object owner, String fieldName, Class elementType, boolean allowNulls, int initialCapacity)Creates a new emptyHashSetobject 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 booleanadd(Object o)Adds the specified element to this set if it is not already present.booleanaddAll(Collection c)Adds all of the elements in the specified collection to this collectionvoidaddAllInternal(Collection c)Adds a Collection to the list without recording changes if the HashSet is not deferred.voidaddInternal(Object o)Adds an object to the list without recording changes if the HashSet is not deferred.voidaddToBaseCollection(Object o)Adds an object to the list without recording changes.voidapplyDeferredUpdates(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.voidapplyUpdates(StateManager sm, boolean modified)Apply changes (can be a no-op)voidclear()Removes all of the elements from this set.voidclearInternal()Clears Collection without notifing the ownerObjectclone()Creates and returns a copy of this object.ObjectcloneInternal()Creates and returns a copy of this object without resetting the owner and field value.CollectiongetAdded()Returns added collectionStringgetFieldName()Returns the field nameObjectgetOwner()Returns the owner object of the SCO instanceCollectiongetRemoved()Returns removed collectionbooleanisDeferred()Return true is this HashSet is deferred, false otherwise.Iteratoriterator()Returns an iterator over the elements in this set.StateManagermakeDirty()Marks object dirtyvoidmarkDeferred()Mark this HashSet as deferred.booleanremove(Object o)Removes the given element from this set if it is present.booleanremoveAll(Collection c)Removes from this collection all of its elements that are contained in the specified collection (optional operation).voidremoveAllInternal(Collection c)Removes objects of the given Collection from this Collection without recording the event.voidremoveInternal(Object o)Removes an element without notifing the ownervoidreset()Cleans removed and added listsbooleanretainAll(Collection c)Retains only the elements in this collection that are contained in the specified collection (optional operation).voidsetOwner(Object owner, String fieldName, Class elementType)Set the owner if this instance is not owned.voidunsetOwner()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 emptyHashSetobject. 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 emptyHashSetobject 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:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet- Overrides:
addAllin 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:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet- Overrides:
removeAllin 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:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet- Overrides:
retainAllin 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:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceSet- Overrides:
iteratorin 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:
cloneInternalin interfaceSCO
-
reset
public void reset()
Cleans removed and added lists- Specified by:
resetin interfaceSCOCollection
-
markDeferred
public void markDeferred()
Mark this HashSet as deferred.- Specified by:
markDeferredin interfaceSCOCollection
-
isDeferred
public boolean isDeferred()
Return true is this HashSet is deferred, false otherwise.- Specified by:
isDeferredin 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:
applyDeferredUpdatesin 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:
addInternalin 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:
addAllInternalin interfaceSCOCollection
-
addToBaseCollection
public void addToBaseCollection(Object o)
Description copied from interface:SCOCollectionAdds an object to the list without recording changes.- Specified by:
addToBaseCollectionin interfaceSCOCollection
-
removeAllInternal
public void removeAllInternal(Collection c)
Description copied from interface:SCOCollectionRemoves 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:
removeAllInternalin interfaceSCOCollection
-
getAdded
public Collection getAdded()
Returns added collection- Specified by:
getAddedin interfaceSCOCollection- Returns:
- added collection of added elements
-
getRemoved
public Collection getRemoved()
Returns removed collection- Specified by:
getRemovedin interfaceSCOCollection- Returns:
- removed collection of removed elements
-
clearInternal
public void clearInternal()
Clears Collection without notifing the owner- Specified by:
clearInternalin interfaceSCOCollection
-
removeInternal
public void removeInternal(Object o)
Removes an element without notifing the owner- Specified by:
removeInternalin interfaceSCOCollection
-
unsetOwner
public void unsetOwner()
Nullifies references to the owner Object and Field- Specified by:
unsetOwnerin interfaceSCO
-
getOwner
public Object getOwner()
Returns the owner object of the SCO instance
-
getFieldName
public String getFieldName()
Returns the field name- Specified by:
getFieldNamein 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:
applyUpdatesin interfaceSCO
-
setOwner
public void setOwner(Object owner, String fieldName, Class elementType)
Set the owner if this instance is not owned.- Specified by:
setOwnerin 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)
-
-