diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/lookup/EntityPath.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (diff) | |
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better
Rewrote RemoteMap to use TreeMap instead of the internal array for
order. It now sorts its keys by number if they parse, else as strings.
Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/lookup/EntityPath.java')
| -rw-r--r-- | source/com/c2kernel/lookup/EntityPath.java | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/source/com/c2kernel/lookup/EntityPath.java b/source/com/c2kernel/lookup/EntityPath.java index 3a24228..4f9b771 100644 --- a/source/com/c2kernel/lookup/EntityPath.java +++ b/source/com/c2kernel/lookup/EntityPath.java @@ -39,12 +39,12 @@ public class EntityPath extends Path * Note no EntityPath constructors allow setting of CONTEXT or ENTITY:
* The object decides that for itself from the number of components
*/
-
+
public EntityPath(int syskey) throws InvalidEntityPathException {
super();
setSysKey(syskey);
}
-
+
/*
*/
public EntityPath()
@@ -55,15 +55,15 @@ public class EntityPath extends Path /*
*/
- public EntityPath(String[] path) throws InvalidEntityPathException
+ public EntityPath(String[] path) throws InvalidEntityPathException
{
- super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
+ super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
checkSysPath();
}
/*
*/
- public EntityPath(String path) throws InvalidEntityPathException
+ public EntityPath(String path) throws InvalidEntityPathException
{
super(path, Path.CONTEXT);
checkSysPath();
@@ -75,33 +75,35 @@ public class EntityPath extends Path super(parent, child);
checkSysPath();
}
-
+
// EntityPaths root in /entity
- public String getRoot() {
+ @Override
+ public String getRoot() {
return "entity";
}
-
- public EntityPath getEntity() throws ObjectNotFoundException {
+
+ @Override
+ public EntityPath getEntity() throws ObjectNotFoundException {
return this;
}
-
+
public byte[] getOID() {
if (mSysKey == Path.INVALID) return null;
return String.valueOf(mSysKey).getBytes();
}
/*************************************************************************/
-
+
/** Returns int form of syskey (if possible)
*/
- public int getSysKey() {
- if (mSysKey == Path.INVALID && mType == Path.ENTITY)
+ @Override
+ public int getSysKey() {
+ if (mSysKey == Path.INVALID && mType == Path.ENTITY)
try {
if (mPath.length != elementNo)
throw new InvalidEntityPathException("Incorrect number of components for a system key");
mSysKey = 0;
- for (int i=0; i<mPath.length;i++) {
- String keypart = mPath[i];
+ for (String keypart : mPath) {
if (keypart.length()!=elementLen+1)
throw new InvalidEntityPathException("Component '"+keypart+"' is not the correct size for a system key");
for(int j=1; j<elementLen+1; j++) // skip the 'd' prefix
@@ -119,12 +121,12 @@ public class EntityPath extends Path }
return mSysKey;
}
-
+
/** Sets path from int syskey
*/
public void setSysKey(int sysKey) throws InvalidEntityPathException
{
- if (sysKey < 0 || sysKey > maxSysKey)
+ if (sysKey < 0 || sysKey > maxSysKey)
throw new InvalidEntityPathException("System key "+sysKey+" out of range");
String stringPath = Integer.toString(sysKey);
ArrayList<String> newKey = new ArrayList<String>();
@@ -142,31 +144,32 @@ public class EntityPath extends Path newKey.add(0, nextComponent.toString());
}
- mPath = (String[])(newKey.toArray(mPath));
+ mPath = (newKey.toArray(mPath));
mSysKey = sysKey;
mStringPath = null;
- mDN = null;
+ mDN = null;
mType = Path.ENTITY;
checkSysPath();
- }
+ }
public void checkSysPath() throws InvalidEntityPathException {
if (mPath.length > elementNo)
throw new InvalidEntityPathException("EntityPath cannot have more than "+elementNo+" components: "+toString());
- if (mPath.length == elementNo)
+ if (mPath.length == elementNo)
mType = Path.ENTITY;
else
mType = Path.CONTEXT;
}
- public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated {
- LDAPAttributeSet attrs = new LDAPAttributeSet();
+ @Override
+ public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated {
+ LDAPAttributeSet attrs = new LDAPAttributeSet();
attrs.add(new LDAPAttribute("objectclass","cristalentity"));
attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey)));
attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1]));
if (mIOR != null)
attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR)));
return attrs;
- }
+ }
}
|
