/** * Returns the individual components of a relative distinguished name * (RDN), normalized. * * @param rdn The relative distinguished name, or in other words, * the left-most component of a distinguished name. *<br><br> * @param noTypes If true, returns only the values of the * components, and not the names of the component, for * example "Babs Jensen" instead of "cn=Babs Jensen". * * @return An array of strings representing the individual components * of an RDN, or null if the RDN is not a valid RDN. */ public static String[] explodeRDN(String rdn, boolean noTypes) { RDN rdnToExplode = new RDN(rdn); return rdnToExplode.explodeRDN(noTypes); }
/** * Compares this DN to the specified DN to determine if they are equal. * * @param toDN the DN to compare to * @return <code>true</code> if the DNs are equal; otherwise * <code>false</code> */ public boolean equals( DN toDN ){ int length = toDN.rdnList.size(); if( this.rdnList.size() != length) return false; for(int i=0; i<length; i++){ if (!((RDN)rdnList.get(i)).equals( (RDN)toDN.rdnList.get(i) )) return false; } return true; }
/** * Creates a string that represents this RDN, according to RFC 2253 * * @return An RDN string */ public String toString(){ return toString(false); }
String rawValue = ""; int hexDigitCount = 0; RDN currRDN = new RDN(); dnString.substring(valueStart, currIndex-trailingSpaceCount); currRDN.add(attrType, attrValue, rawValue); if (currChar != '+'){ rdnList.add(currRDN); currRDN = new RDN(); currRDN.add(attrType, attrValue, rawValue); if (currChar != '+'){ rdnList.add(currRDN); currRDN = new RDN(); currRDN.add(attrType, attrValue, rawValue); if (currChar != '+'){ rdnList.add(currRDN); currRDN = new RDN(); rawValue = dnString.substring(valueStart, currIndex - trailingSpaceCount); currRDN.add(attrType,attrValue,rawValue); rdnList.add(currRDN); currRDN.add(attrType, attrValue, rawValue); rdnList.add(currRDN);
Identifier id = new Identifier(); try { id.setType(this.getIdentifierType(((RDN)dn.getRDNs().get(0)).getType())); } catch (IllegalArgumentException e1) { throw new LDAPException("Could not determine type",53, e1.toString(), e1);
/** * Compares the RDN to the rdn passed. Note: If an there exist any * mulivalues in one RDN they must all be present in the other. * * @param rdn the RDN to compare to * * @throws IllegalArgumentException if the application compares a name * with an OID. */ public boolean equals(RDN rdn){ if (this.values.size() != rdn.values.size()){ return false; } int j,i; for (i=0; i<this.values.size(); i++){ //verify that the current value and type exists in the other list j=0; //May need a more intellegent compare while ( j<values.size() && ( !((String)this.values.get(i)).equalsIgnoreCase( (String) rdn.values.get(j)) || !equalAttrType((String)this.types.get(i), (String) rdn.types.get(j)))){ j++; } if (j >= rdn.values.size()) //couldn't find first value return false; } return true; }
/** * return a string array of the individual RDNs contained in the DN * * @param noTypes If true, returns only the values of the * components, and not the names, e.g. "Babs * Jensen", "Accounting", "Acme", "us" - instead of * "cn=Babs Jensen", "ou=Accounting", "o=Acme", and * "c=us". * @return <code>String[]</code> containing the rdns in the DN with * the leftmost rdn in the first element of the array * */ public String[] explodeDN(boolean noTypes) { int length = rdnList.size(); String[] rdns = new String[length]; for(int i=0; i<length; i++) rdns[i]=((RDN)rdnList.get(i)).toString(noTypes); return rdns; }