src/share/classes/com/sun/jndi/ldap/LdapName.java

Print this page

        

*** 76,86 **** */ public final class LdapName implements Name { private transient String unparsed; // if non-null, the DN in unparsed form ! private transient Vector rdns; // parsed name components private transient boolean valuesCaseSensitive = false; /** * Constructs an LDAP name from the given DN. * --- 76,86 ---- */ public final class LdapName implements Name { private transient String unparsed; // if non-null, the DN in unparsed form ! private transient Vector<Rdn> rdns; // parsed name components private transient boolean valuesCaseSensitive = false; /** * Constructs an LDAP name from the given DN. *
*** 95,117 **** /* * Constructs an LDAP name given its parsed components and, optionally * (if "name" is not null), the unparsed DN. */ ! private LdapName(String name, Vector rdns) { unparsed = name; ! this.rdns = (Vector)rdns.clone(); } /* * Constructs an LDAP name given its parsed components (the elements * of "rdns" in the range [beg,end)) and, optionally * (if "name" is not null), the unparsed DN. */ ! private LdapName(String name, Vector rdns, int beg, int end) { unparsed = name; ! this.rdns = new Vector(); for (int i = beg; i < end; i++) { this.rdns.addElement(rdns.elementAt(i)); } } --- 95,118 ---- /* * Constructs an LDAP name given its parsed components and, optionally * (if "name" is not null), the unparsed DN. */ ! @SuppressWarnings("unchecked") ! private LdapName(String name, Vector<Rdn> rdns) { unparsed = name; ! this.rdns = (Vector<Rdn>)rdns.clone(); } /* * Constructs an LDAP name given its parsed components (the elements * of "rdns" in the range [beg,end)) and, optionally * (if "name" is not null), the unparsed DN. */ ! private LdapName(String name, Vector<Rdn> rdns, int beg, int end) { unparsed = name; ! this.rdns = new Vector<>(); for (int i = beg; i < end; i++) { this.rdns.addElement(rdns.elementAt(i)); } }
*** 128,138 **** StringBuffer buf = new StringBuffer(); for (int i = rdns.size() - 1; i >= 0; i--) { if (i < rdns.size() - 1) { buf.append(','); } ! Rdn rdn = (Rdn)rdns.elementAt(i); buf.append(rdn); } unparsed = new String(buf); return unparsed; --- 129,139 ---- StringBuffer buf = new StringBuffer(); for (int i = rdns.size() - 1; i >= 0; i--) { if (i < rdns.size() - 1) { buf.append(','); } ! Rdn rdn = rdns.elementAt(i); buf.append(rdn); } unparsed = new String(buf); return unparsed;
*** 153,164 **** // Compare RDNs one by one, lexicographically. int minSize = Math.min(rdns.size(), that.rdns.size()); for (int i = 0 ; i < minSize; i++) { // Compare a single pair of RDNs. ! Rdn rdn1 = (Rdn)rdns.elementAt(i); ! Rdn rdn2 = (Rdn)that.rdns.elementAt(i); int diff = rdn1.compareTo(rdn2); if (diff != 0) { return diff; } --- 154,165 ---- // Compare RDNs one by one, lexicographically. int minSize = Math.min(rdns.size(), that.rdns.size()); for (int i = 0 ; i < minSize; i++) { // Compare a single pair of RDNs. ! Rdn rdn1 = rdns.elementAt(i); ! Rdn rdn2 = that.rdns.elementAt(i); int diff = rdn1.compareTo(rdn2); if (diff != 0) { return diff; }
*** 170,180 **** // Sum up the hash codes of the components. int hash = 0; // For each RDN... for (int i = 0; i < rdns.size(); i++) { ! Rdn rdn = (Rdn)rdns.elementAt(i); hash += rdn.hashCode(); } return hash; } --- 171,181 ---- // Sum up the hash codes of the components. int hash = 0; // For each RDN... for (int i = 0; i < rdns.size(); i++) { ! Rdn rdn = rdns.elementAt(i); hash += rdn.hashCode(); } return hash; }
*** 184,201 **** public boolean isEmpty() { return rdns.isEmpty(); } ! public Enumeration getAll() { ! final Enumeration enum_ = rdns.elements(); ! return new Enumeration () { public boolean hasMoreElements() { return enum_.hasMoreElements(); } ! public Object nextElement() { return enum_.nextElement().toString(); } }; } --- 185,202 ---- public boolean isEmpty() { return rdns.isEmpty(); } ! public Enumeration<String> getAll() { ! final Enumeration<Rdn> enum_ = rdns.elements(); ! return new Enumeration<String>() { public boolean hasMoreElements() { return enum_.hasMoreElements(); } ! public String nextElement() { return enum_.nextElement().toString(); } }; }
*** 252,262 **** private boolean matches(int beg, int end, Name n) { for (int i = beg; i < end; i++) { Rdn rdn; if (n instanceof LdapName) { LdapName ln = (LdapName)n; ! rdn = (Rdn)ln.rdns.elementAt(i - beg); } else { String rdnString = n.get(i - beg); try { rdn = (new DnParser(rdnString, valuesCaseSensitive)).getRdn(); } catch (InvalidNameException e) { --- 253,263 ---- private boolean matches(int beg, int end, Name n) { for (int i = beg; i < end; i++) { Rdn rdn; if (n instanceof LdapName) { LdapName ln = (LdapName)n; ! rdn = ln.rdns.elementAt(i - beg); } else { String rdnString = n.get(i - beg); try { rdn = (new DnParser(rdnString, valuesCaseSensitive)).getRdn(); } catch (InvalidNameException e) {
*** 284,296 **** LdapName s = (LdapName)suffix; for (int i = 0; i < s.rdns.size(); i++) { rdns.insertElementAt(s.rdns.elementAt(i), pos++); } } else { ! Enumeration comps = suffix.getAll(); while (comps.hasMoreElements()) { ! DnParser p = new DnParser((String)comps.nextElement(), valuesCaseSensitive); rdns.insertElementAt(p.getRdn(), pos++); } } unparsed = null; // no longer valid --- 285,297 ---- LdapName s = (LdapName)suffix; for (int i = 0; i < s.rdns.size(); i++) { rdns.insertElementAt(s.rdns.elementAt(i), pos++); } } else { ! Enumeration<String> comps = suffix.getAll(); while (comps.hasMoreElements()) { ! DnParser p = new DnParser(comps.nextElement(), valuesCaseSensitive); rdns.insertElementAt(p.getRdn(), pos++); } } unparsed = null; // no longer valid
*** 404,416 **** } /* * Parses the DN, returning a Vector of its RDNs. */ ! Vector getDn() throws InvalidNameException { cur = 0; ! Vector rdns = new Vector(len / 3 + 10); // leave room for growth if (len == 0) { return rdns; } --- 405,417 ---- } /* * Parses the DN, returning a Vector of its RDNs. */ ! Vector<Rdn> getDn() throws InvalidNameException { cur = 0; ! Vector<Rdn> rdns = new Vector<>(len / 3 + 10); // leave room for growth if (len == 0) { return rdns; }
*** 593,603 **** /* * A vector of the TypeAndValue elements of this Rdn. * It is sorted to facilitate set operations. */ ! private final Vector tvs = new Vector(); void add(TypeAndValue tv) { // Set i to index of first element greater than tv, or to // tvs.size() if there is none. --- 594,604 ---- /* * A vector of the TypeAndValue elements of this Rdn. * It is sorted to facilitate set operations. */ ! private final Vector<TypeAndValue> tvs = new Vector<>(); void add(TypeAndValue tv) { // Set i to index of first element greater than tv, or to // tvs.size() if there is none.
*** 634,644 **** public int compareTo(Object obj) { Rdn that = (Rdn)obj; int minSize = Math.min(tvs.size(), that.tvs.size()); for (int i = 0; i < minSize; i++) { // Compare a single pair of type/value pairs. ! TypeAndValue tv = (TypeAndValue)tvs.elementAt(i); int diff = tv.compareTo(that.tvs.elementAt(i)); if (diff != 0) { return diff; } } --- 635,645 ---- public int compareTo(Object obj) { Rdn that = (Rdn)obj; int minSize = Math.min(tvs.size(), that.tvs.size()); for (int i = 0; i < minSize; i++) { // Compare a single pair of type/value pairs. ! TypeAndValue tv = tvs.elementAt(i); int diff = tv.compareTo(that.tvs.elementAt(i)); if (diff != 0) { return diff; } }
*** 660,670 **** Attributes attrs = new BasicAttributes(true); TypeAndValue tv; Attribute attr; for (int i = 0; i < tvs.size(); i++) { ! tv = (TypeAndValue) tvs.elementAt(i); if ((attr = attrs.get(tv.getType())) == null) { attrs.put(tv.getType(), tv.getUnescapedValue()); } else { attr.add(tv.getUnescapedValue()); } --- 661,671 ---- Attributes attrs = new BasicAttributes(true); TypeAndValue tv; Attribute attr; for (int i = 0; i < tvs.size(); i++) { ! tv = tvs.elementAt(i); if ((attr = attrs.get(tv.getType())) == null) { attrs.put(tv.getType(), tv.getUnescapedValue()); } else { attr.add(tv.getUnescapedValue()); }