diff options
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/ItemPath.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/ItemPath.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/main/java/com/c2kernel/lookup/ItemPath.java b/src/main/java/com/c2kernel/lookup/ItemPath.java index 2219c8a..793a0ed 100644 --- a/src/main/java/com/c2kernel/lookup/ItemPath.java +++ b/src/main/java/com/c2kernel/lookup/ItemPath.java @@ -27,19 +27,15 @@ public class ItemPath extends Path {
public ItemPath() {
- this(UUID.randomUUID());
+ setSysKey(UUID.randomUUID());
}
- public ItemPath(UUID uuid) {
+ protected ItemPath(UUID uuid) {
setSysKey(uuid);
- mPath = new String[1];
- mPath[0] = mUUID.toString();
}
public ItemPath(SystemKey syskey) {
setSysKey(syskey);
- mPath = new String[1];
- mPath[0] = mUUID.toString();
}
/*
@@ -82,13 +78,15 @@ public class ItemPath extends Path public byte[] getOID() {
if (mType == Path.CONTEXT) return null;
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
- bb.putLong(mUUID.getMostSignificantBits());
- bb.putLong(mUUID.getLeastSignificantBits());
+ bb.putLong(mSysKey.msb);
+ bb.putLong(mSysKey.lsb);
return bb.array();
}
protected void setSysKey(UUID uuid) {
mUUID = uuid;
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
mSysKey = new SystemKey(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
mType = Path.ENTITY;
}
@@ -96,7 +94,18 @@ public class ItemPath extends Path protected void setSysKey(SystemKey sysKey) {
mSysKey = sysKey;
mUUID = new UUID(sysKey.msb, sysKey.lsb);
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
mType = Path.ENTITY;
}
+
+ public static ItemPath fromUUIDString(String uuid) throws InvalidItemPathException {
+ if (uuid == null) throw new InvalidItemPathException("Null uuid");
+ try {
+ return new ItemPath(UUID.fromString(uuid));
+ } catch (IllegalArgumentException ex) {
+ throw new InvalidItemPathException("Illegal uuid: "+uuid);
+ }
+ }
}
|
