From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: 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 --- source/com/c2kernel/lookup/Path.java | 58 +++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'source/com/c2kernel/lookup/Path.java') 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 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