summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lookup/Path.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/lookup/Path.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (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/Path.java')
-rw-r--r--source/com/c2kernel/lookup/Path.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/source/com/c2kernel/lookup/Path.java b/source/com/c2kernel/lookup/Path.java
index b713493..4966d1e 100644
--- a/source/com/c2kernel/lookup/Path.java
+++ b/source/com/c2kernel/lookup/Path.java
@@ -32,10 +32,10 @@ public abstract class Path implements Serializable
public static final String delim = "/";
// types
- public static final short UNKNOWN = 0;
+ public static final short UNKNOWN = 0;
public static final short CONTEXT = 1;
public static final short ENTITY = 2;
-
+
// invalid int key
public static final int INVALID = -1;
@@ -54,11 +54,11 @@ public abstract class Path implements Serializable
protected org.omg.CORBA.Object mIOR = null;
//
// needed for unusual subclass constructors
-
+
protected static String mGlobalPath; //cern.ch
protected static String mRootPath; //cristal2
protected static String mLocalPath; //lab27
-
+
public Path() {
}
@@ -115,7 +115,7 @@ public abstract class Path implements Serializable
{
mStringPath = null;
mDN = null;
- mPath = (String[])path.clone();
+ mPath = path.clone();
mSysKey = INVALID;
}
@@ -134,7 +134,7 @@ public abstract class Path implements Serializable
newPath.add(tok.nextToken());
}
- mPath = (String[])(newPath.toArray(mPath));
+ mPath = (newPath.toArray(mPath));
mStringPath = null;
mDN = null;
mSysKey = INVALID;
@@ -153,7 +153,7 @@ public abstract class Path implements Serializable
{
mStringPath = null;
mDN = null;
- mPath = (String[])(path.getPath().clone());
+ mPath = (path.getPath().clone());
mSysKey = INVALID;
}
@@ -167,7 +167,7 @@ public abstract class Path implements Serializable
String root = "cn="+getRoot()+",";
if (dn.endsWith(mLocalPath))
dn = dn.substring(0, dn.lastIndexOf(mLocalPath));
-
+
if (dn.endsWith(root))
dn = dn.substring(0, dn.lastIndexOf(root));
@@ -180,7 +180,7 @@ public abstract class Path implements Serializable
else
break;
}
- mPath = (String[])(newPath.toArray(mPath));
+ mPath = (newPath.toArray(mPath));
mSysKey = INVALID;
mStringPath = null;
mDN = dn+root;
@@ -204,8 +204,8 @@ public abstract class Path implements Serializable
{
if (mStringPath == null) {
StringBuffer stringPathBuffer = new StringBuffer("/").append(getRoot());
- for (int i=0; i<mPath.length; i++)
- stringPathBuffer.append(delim).append(mPath[i]);
+ for (String element : mPath)
+ stringPathBuffer.append(delim).append(element);
mStringPath = stringPathBuffer.toString();
}
return mStringPath;
@@ -221,15 +221,15 @@ public abstract class Path implements Serializable
}
return mDN;
}
-
+
public String getFullDN() {
return getDN()+mLocalPath;
}
-
+
public boolean exists() {
return Gateway.getLDAPLookup().exists(this);
}
-
+
/** Queries the lookup for the IOR
*/
@@ -240,14 +240,14 @@ public abstract class Path implements Serializable
try {
newIOR = myLookup.getIOR(this);
} catch (ObjectNotFoundException ex) {
- newIOR = null;
}
setIOR(newIOR);
}
return mIOR;
}
- public String toString() {
+ @Override
+ public String toString() {
return getString();
}
@@ -258,17 +258,17 @@ public abstract class Path implements Serializable
public int getSysKey() {
return mSysKey;
}
-
- public Enumeration getChildren() {
+
+ public Enumeration<?> getChildren() {
String filter = "objectclass=*";
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(10);
searchCons.setDereference(LDAPSearchConstraints.DEREF_FINDING );
return Gateway.getLDAPLookup().search(getFullDN(), LDAPConnection.SCOPE_ONE,filter,searchCons);
}
-
+
public Path find(String name) throws ObjectNotFoundException {
- Enumeration e = Gateway.getLDAPLookup().search(this, name);
+ Enumeration<?> e = Gateway.getLDAPLookup().search(this, name);
if (e.hasMoreElements()) {
Path thisPath =(Path)e.nextElement();
if (e.hasMoreElements())
@@ -277,24 +277,26 @@ public abstract class Path implements Serializable
}
throw new ObjectNotFoundException("No match for "+name, "");
}
-
+
public abstract EntityPath getEntity() throws ObjectNotFoundException;
public abstract LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated;
-
- public boolean equals( Object path )
- {
+
+ @Override
+ public boolean equals( Object path )
+ {
return toString().equals(path.toString());
}
-
- public int hashCode() {
+
+ @Override
+ public int hashCode() {
return toString().hashCode();
}
public String dump() {
StringBuffer comp = new StringBuffer("Components: { ");
- for (int i=0; i<mPath.length; i++)
- comp.append("'").append(mPath[i]).append("' ");
+ for (String element : mPath)
+ comp.append("'").append(element).append("' ");
return "Path - dump(): "+comp.toString()+"}\n dn="+getDN()+"\n string="+toString()+"\n int="+getSysKey()+"\n type="+mType;
}
}