public String findMostSpecific ( String attributeType ) { // Initialize internal state. pos = 0 ; beg = 0 ; end = 0 ; cur = 0 ; chars = dn . toCharArray ( ) ; String attType = nextAT ( ) ; if ( attType == null ) { return null ; } while ( true ) { String attValue = "" ; if ( pos == length ) { return null ; } switch ( chars [ pos ] ) { case ' ' : attValue = quotedAV ( ) ; break ; case ' ' : attValue = hexAV ( ) ; break ; case ' ' : case ' ' : case ' ' : // compatibility with RFC 1779: semicolon can separate RDNs //empty attribute value break ; default : attValue = escapedAV ( ) ; } // Values are ordered from most specific to least specific // due to the RFC2253 formatting. So take the first match // we see. if ( attributeType . equalsIgnoreCase ( attType ) ) { return attValue ; } if ( pos >= length ) { return null ; } if ( chars [ pos ] == ' ' || chars [ pos ] == ' ' ) { } else if ( chars [ pos ] != ' ' ) { throw new IllegalStateException ( "Malformed DN: " + dn ) ; } pos ++ ; attType = nextAT ( ) ; if ( attType == null ) { throw new IllegalStateException ( "Malformed DN: " + dn ) ; } } }
Parses the DN and returns the most significant attribute value for an attribute type or null if none found .