/** * Matches and forgets optional spaces. * * @param name the name * @param pos the pos * @throws LdapInvalidDnException If some invalid chars are found */ private static void matchSpaces( char[] name, Position pos ) throws LdapInvalidDnException { while ( hasMoreChars( pos ) ) { char c = nextChar( name, pos, true ); if ( c != ' ' ) { pos.start--; break; } } }
/** * Parses a Dn from a String * * @param name The Dn to parse * @return A valid Dn * @throws org.apache.directory.api.ldap.model.exception.LdapException If the Dn was invalid */ /* No protection*/static Dn parse( String name ) throws LdapException { Dn dn = new Dn(); parseDn( null, name, dn ); return dn; }
matchSpaces( chars, pos ); String type = matchAttributeType( chars, pos ); matchSpaces( chars, pos ); matchEquals( chars, pos ); matchSpaces( chars, pos ); String upValue = matchValue( chars, pos ); matchSpaces( chars, pos );
parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); rdns.add( rdn ); if ( !hasMoreChars( pos ) ) char c = nextChar( chars, pos, true );
char c = nextChar( name, pos, false ); case 'z': return matchAttributeTypeDescr( name, pos ); case '9': return matchAttributeTypeNumericOid( name, pos );
/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }
/** * Gets the next character. * * @param name the name * @param pos the pos * @param increment true to increment the position * * @return the character * @throws LdapInvalidDnException If no more characters are available */ private static char nextChar( char[] name, Position pos, boolean increment ) throws LdapInvalidDnException { if ( !hasMoreChars( pos ) ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13610_NO_MORE_CHAR_AVAILABLE, pos.start ) ); } char c = name[pos.start]; if ( increment ) { pos.start++; } return c; }
/** * Parse a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param schemaManager The SchemaManager * @param dn The String to parse * @param rdn The Rdn to fill. Beware that if the Rdn is not empty, the new * AttributeTypeAndValue will be added. * @throws LdapInvalidDnException If the NameComponent is invalid */ private static void parse( SchemaManager schemaManager, String dn, Rdn rdn ) throws LdapInvalidDnException { try { FastDnParser.parseRdn( schemaManager, dn, rdn ); } catch ( TooComplexDnException e ) { rdn.clear(); new ComplexDnParser().parseRdn( schemaManager, dn, rdn ); } }
matchSpaces( chars, pos ); String type = matchAttributeType( chars, pos ); matchSpaces( chars, pos ); matchEquals( chars, pos ); matchSpaces( chars, pos ); String upValue = matchValue( chars, pos ); matchSpaces( chars, pos );
parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); rdns.add( rdn ); if ( !hasMoreChars( pos ) ) char c = nextChar( chars, pos, true );
char c = nextChar( name, pos, false ); case 'z': return matchAttributeTypeDescr( name, pos ); case '9': return matchAttributeTypeNumericOid( name, pos );
/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }
/** * Gets the next character. * * @param name the name * @param pos the pos * @param increment true to increment the position * * @return the character * @throws LdapInvalidDnException If no more characters are available */ private static char nextChar( char[] name, Position pos, boolean increment ) throws LdapInvalidDnException { if ( !hasMoreChars( pos ) ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13610_NO_MORE_CHAR_AVAILABLE, pos.start ) ); } char c = name[pos.start]; if ( increment ) { pos.start++; } return c; }
/** * Parse a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param schemaManager The SchemaManager * @param dn The String to parse * @param rdn The Rdn to fill. Beware that if the Rdn is not empty, the new * AttributeTypeAndValue will be added. * @throws LdapInvalidDnException If the NameComponent is invalid */ private static void parse( SchemaManager schemaManager, String dn, Rdn rdn ) throws LdapInvalidDnException { try { FastDnParser.parseRdn( schemaManager, dn, rdn ); } catch ( TooComplexDnException e ) { rdn.clear(); new ComplexDnParser().parseRdn( schemaManager, dn, rdn ); } }
matchSpaces( chars, pos ); String type = matchAttributeType( chars, pos ); matchSpaces( chars, pos ); matchEquals( chars, pos ); matchSpaces( chars, pos ); String upValue = matchValue( chars, pos ); matchSpaces( chars, pos );
/** * Matches and forgets optional spaces. * * @param name the name * @param pos the pos * @throws LdapInvalidDnException If some invalid chars are found */ private static void matchSpaces( char[] name, Position pos ) throws LdapInvalidDnException { while ( hasMoreChars( pos ) ) { char c = nextChar( name, pos, true ); if ( c != ' ' ) { pos.start--; break; } } }
parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); rdns.add( rdn ); if ( !hasMoreChars( pos ) ) char c = nextChar( chars, pos, true );
char c = nextChar( name, pos, false ); case 'z': return matchAttributeTypeDescr( name, pos ); case '9': return matchAttributeTypeNumericOid( name, pos );
/** * Parses a Dn from a String * * @param name The Dn to parse * @return A valid Dn * @throws org.apache.directory.api.ldap.model.exception.LdapException If the Dn was invalid */ /* No protection*/static Dn parse( String name ) throws LdapException { Dn dn = new Dn(); parseDn( null, name, dn ); return dn; }
/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }