|
|||||||||
| Home >> All >> Util >> [ Collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
Util.Collections
Class AbstrRelation

java.lang.ObjectUtil.Collections.AbstrRelation
- All Implemented Interfaces:
- java.lang.Cloneable, Relation, java.io.Serializable
- Direct Known Subclasses:
- AbstrRelationMapBased
- public abstract class AbstrRelation
- extends java.lang.Object
- implements Relation, java.lang.Cloneable, java.io.Serializable
- extends java.lang.Object
AbstrRelation
- Version:
- $Id: AbstrRelation.java,v 1.2 2003/05/12 10:05:21 joewhaley Exp $
| Nested Class Summary |
| Nested classes inherited from class Util.Collections.Relation |
Relation.EntryVisitor |
| Field Summary | |
protected int |
hashCode
|
static boolean |
OPTIMIZE_HASH_CODE
Optimizes the .hashCode() method by caching the hash code. |
| Constructor Summary | |
AbstrRelation()
|
|
| Method Summary | |
boolean |
add(java.lang.Object key,
java.lang.Object value)
Adds the pair <key, value> to the relation. |
boolean |
addAll(java.lang.Object key,
java.util.Collection values)
Adds a relation from key to each element of the set
values. |
java.lang.Object |
clone()
Clones this relation. |
boolean |
contains(java.lang.Object key,
java.lang.Object value)
Checks the existence of the relation <key,value>. |
boolean |
containsKey(java.lang.Object key)
Checks the existence of the key key in this relation. |
private boolean |
equal_sets(java.util.Collection c1,
java.util.Collection c2)
|
boolean |
equals(java.lang.Object o)
Checks the equality of two relations |
void |
forAllEntries(Relation.EntryVisitor visitor)
Visits all the entries <key,value> of
this relation and calls visitor.visit
on each of them. |
protected Relation |
getEmptyRelation()
|
java.util.Set |
getValues(java.lang.Object key)
Returns the image of key through this relation. |
protected java.util.Set |
getValues2(java.lang.Object key)
|
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
boolean |
isEmpty()
Tests if this relation is empty or not. |
java.util.Set |
keys()
Returns all the keys appearing in this relation. |
void |
remove(java.lang.Object key,
java.lang.Object value)
Removes the relation between key and
value. |
void |
removeAll(java.lang.Object key,
java.util.Collection values)
Removes the relation between key and
any element from values. |
void |
removeKey(java.lang.Object key)
Removes all the relations attached to key. |
void |
removeKeys(PredicateWrapper predicate)
Removes all the keys that satisfy predicate.check(). |
void |
removeObjects(PredicateWrapper predicate)
Removes all the relations involving at least one object that satisfy predicate.check(). |
void |
removeValues(PredicateWrapper predicate)
Removes all the values that satisfy predicate.check(). |
Relation |
select(java.util.Collection selected_keys)
Returns the subrelation of this relation that contains only the keys that appear in selected_keys. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
void |
union(Relation rel)
Combines this relation with a new one. |
java.util.Set |
values()
Returns all the values appearing in this relation. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
OPTIMIZE_HASH_CODE
public static final boolean OPTIMIZE_HASH_CODE
- Optimizes the .hashCode() method by caching the hash code.
The cached value is invalidated after each update.
- See Also:
- Constant Field Values
hashCode
protected int hashCode
| Constructor Detail |
AbstrRelation
public AbstrRelation()
| Method Detail |
getEmptyRelation
protected Relation getEmptyRelation()
add
public boolean add(java.lang.Object key, java.lang.Object value)
- Description copied from interface:
Relation - Adds the pair
<key, value>to the relation. Returnstrueif the new relation is bigger.
addAll
public boolean addAll(java.lang.Object key, java.util.Collection values)
- Description copied from interface:
Relation - Adds a relation from
keyto each element of the setvalues.valuesshould not contain duplicated elements. Returnstrueif the new relation is bigger.
remove
public void remove(java.lang.Object key, java.lang.Object value)
- Description copied from interface:
Relation - Removes the relation between
keyandvalue.
getValues2
protected java.util.Set getValues2(java.lang.Object key)
removeAll
public void removeAll(java.lang.Object key, java.util.Collection values)
- Description copied from interface:
Relation - Removes the relation between
keyand any element fromvalues.
removeKey
public void removeKey(java.lang.Object key)
- Description copied from interface:
Relation - Removes all the relations attached to
key.
removeKeys
public void removeKeys(PredicateWrapper predicate)
- Description copied from interface:
Relation - Removes all the keys that satisfy
predicate.check().- Specified by:
removeKeysin interfaceRelation
removeValues
public void removeValues(PredicateWrapper predicate)
- Description copied from interface:
Relation - Removes all the values that satisfy
predicate.check().- Specified by:
removeValuesin interfaceRelation
removeObjects
public void removeObjects(PredicateWrapper predicate)
- Description copied from interface:
Relation - Removes all the relations involving at least one object that
satisfy
predicate.check().- Specified by:
removeObjectsin interfaceRelation
contains
public boolean contains(java.lang.Object key, java.lang.Object value)
- Description copied from interface:
Relation - Checks the existence of the relation
<key,value>.
containsKey
public boolean containsKey(java.lang.Object key)
- Description copied from interface:
Relation - Checks the existence of the
keykey in this relation.- Specified by:
containsKeyin interfaceRelation
isEmpty
public boolean isEmpty()
- Description copied from interface:
Relation - Tests if this relation is empty or not.
getValues
public java.util.Set getValues(java.lang.Object key)
- Description copied from interface:
Relation - Returns the image of
keythrough this relation. The returned collection is guarranted not to contain duplicates. Can returnnullif no value is attached to key. If the result is non-null, additions and removals on the returned collection take effect on the relation.
keys
public java.util.Set keys()
- Description copied from interface:
Relation - Returns all the keys appearing in this relation. The result is
guaranted not to contain duplicates.
values
public java.util.Set values()
- Description copied from interface:
Relation - Returns all the values appearing in this relation.
union
public void union(Relation rel)
- Description copied from interface:
Relation - Combines
thisrelation with a new one. Anullparameter is considered to be an empty relation.
equals
public boolean equals(java.lang.Object o)
- Description copied from interface:
Relation - Checks the equality of two relations
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
equal_sets
private boolean equal_sets(java.util.Collection c1, java.util.Collection c2)
select
public Relation select(java.util.Collection selected_keys)
- Description copied from interface:
Relation - Returns the subrelation of this relation that contains
only the keys that appear in
selected_keys.
forAllEntries
public void forAllEntries(Relation.EntryVisitor visitor)
- Description copied from interface:
Relation - Visits all the entries
<key,value>ofthisrelation and callsvisitor.visiton each of them.- Specified by:
forAllEntriesin interfaceRelation
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
clone
public java.lang.Object clone()
- Description copied from interface:
Relation - Clones this relation.
|
|||||||||
| Home >> All >> Util >> [ Collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
Util.Collections.AbstrRelation