rewrote comment to reflect that this key is not

only used for virtual and groupby nodes, but
also for nodes accessed via a property name
This commit is contained in:
hns 2001-08-05 19:23:22 +00:00
parent 889ab2dfcb
commit 8471241a88

View file

@ -6,16 +6,15 @@ package helma.objectmodel;
import java.io.Serializable; import java.io.Serializable;
/** /**
* This is the internal key for an object that is not stored in a db, but generated * This is the internal key for an object that is not - or not directly - fetched from a db,
* on the fly. Currently there are two kinds of such objects: virtual nodes, which are used * but derived from another object. This is useful for all kinds of object accessed via a
* as utility containers for objects in the database, and groupby nodes, which are used * symbolic name from another object, like objects mounted via a property name column,
* to group a certain kind of relational objects according to some property. * virtual nodes and groupby nodes.
*/ */
public final class SyntheticKey implements Key, Serializable { public final class SyntheticKey implements Key, Serializable {
private final Key parentKey; private final Key parentKey;
private final String name; private final String name;
// private final int hash;
/** /**
@ -24,23 +23,22 @@ public final class SyntheticKey implements Key, Serializable {
public SyntheticKey (Key key, String name) { public SyntheticKey (Key key, String name) {
this.parentKey = key; this.parentKey = key;
this.name = name; this.name = name;
// hash = name.hashCode () + key.hashCode ();
} }
public boolean equals (Object what) { public boolean equals (Object what) {
if (what == this)
return true;
try { try {
SyntheticKey k = (SyntheticKey) what; SyntheticKey k = (SyntheticKey) what;
return parentKey.equals (k.parentKey) && return parentKey.equals (k.parentKey) &&
(name == k.name || name.equals (k.name)); (name == k.name || name.equals (k.name));
} catch (Exception x) { } catch (Exception x) {
System.err.println ("SYNTHETIC NOT EQUAL: "+what+" - "+this);
return false; return false;
} }
} }
public int hashCode () { public int hashCode () {
// return hash;
return name.hashCode () + parentKey.hashCode (); return name.hashCode () + parentKey.hashCode ();
} }