Datastore identity type. Implementations may choose to use this type,
or choose to use their own datastore identity values.
| Constructor: |
public Id(String str) {
this(str, (ClassLoader) null);
}
Create an id from the result of a #toString call on another
instance. |
public Id(String str,
ClassLoader loader) {
if (loader == null)
loader = (ClassLoader) AccessController.doPrivileged(
J2DoPrivHelper.getContextClassLoaderAction());
if (str == null)
_id = 0L;
else {
int dash = str.indexOf('-");
try {
type = Class.forName(str.substring(0, dash), true, loader);
} catch (Throwable t) {
throw new UserException(_loc.get("string-id", str), t);
}
_id = Long.parseLong(str.substring(dash + 1));
}
}
Create an id from the result of an #toString call on another
instance. |
public Id(Class cls,
String key) {
super(cls);
if (key == null)
_id = 0L;
else {
// allow either stringified long or result of Id.toString
int dash = key.indexOf('-");
if (dash > 0) // don't check for -1; might be negative number
key = key.substring(dash + 1);
_id = Long.parseLong(key);
}
}
Construct from the result of a #toString call on another
instance. |
public Id(Class cls,
Long key) {
this(cls, (key == null) ? 0L : key.longValue());
}
Construct from key value. |
public Id(Class cls,
long key) {
super(cls);
_id = key;
}
Construct from key value. |
public Id(String str,
OpenJPAConfiguration conf,
ClassLoader brokerLoader) {
this(str, (conf == null) ? brokerLoader : conf.
getClassResolverInstance().getClassLoader(Id.class, brokerLoader));
}
Create an id from the result of an #toString call on another
instance. |
public Id(Class cls,
long key,
boolean subs) {
super(cls, subs);
_id = key;
}
Construct from key value. |
| Method from org.apache.openjpa.util.Id Detail: |
public long getId() {
return _id;
}
|
public Object getIdObject() {
return Numbers.valueOf(_id);
}
|
protected boolean idEquals(OpenJPAId other) {
return _id == ((Id) other)._id;
}
|
protected int idHash() {
return (int) (_id ^ (_id > > > 32));
}
|
public static Id newInstance(Class cls,
Object val) {
if (val instanceof Id)
return (Id) val;
if (val instanceof String)
return new Id(cls, (String) val);
if (val instanceof Number)
return new Id(cls, ((Number) val).longValue());
if (val == null)
return new Id(cls, 0L);
throw new UserException(_loc.get("unknown-oid", cls, val,
val.getClass()));
}
Create an id from the given type and value; the value might be an
id instnace, a stringified id, or a primary key value. |