@Test public void testEscapeValueNumeric() { String res = Rdn.escapeValue( new byte[] { '-', 0x00, '-', 0x1F, '-', 0x7F, '-' } ); assertEquals( "-\\00-\\1F-\\7F-", res ); }
public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( chars[i] ) { case ' ': if ( ( i > 0 ) && ( i < chars.length - 1 ) ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '#': if ( i != 0 ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '"': case '+': case ',': case ';': case '=': case '<': case '>': case '\\': newChars[pos++] = '\\'; newChars[pos++] = chars[i]; break; case 0x7F: newChars[pos++] = '\\'; newChars[pos++] = '7'; newChars[pos++] = 'F'; break; case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: newChars[pos++] = '\\'; newChars[pos++] = '0'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: newChars[pos++] = '\\'; newChars[pos++] = '1'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; default: newChars[pos++] = chars[i]; break; } } return new String( newChars, 0, pos ); }
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( chars[i] ) { case ' ': if ( ( i > 0 ) && ( i < chars.length - 1 ) ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '#': if ( i != 0 ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '"': case '+': case ',': case ';': case '=': case '<': case '>': case '\\': newChars[pos++] = '\\'; newChars[pos++] = chars[i]; break; case 0x7F: newChars[pos++] = '\\'; newChars[pos++] = '7'; newChars[pos++] = 'F'; break; case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: newChars[pos++] = '\\'; newChars[pos++] = '0'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: newChars[pos++] = '\\'; newChars[pos++] = '1'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; default: newChars[pos++] = chars[i]; break; } } return new String( newChars, 0, pos ); } }
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( chars[i] ) { case ' ': if ( ( i > 0 ) && ( i < chars.length - 1 ) ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '#': if ( i != 0 ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '"': case '+': case ',': case ';': case '=': case '<': case '>': case '\\': newChars[pos++] = '\\'; newChars[pos++] = chars[i]; break; case 0x7F: newChars[pos++] = '\\'; newChars[pos++] = '7'; newChars[pos++] = 'F'; break; case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: newChars[pos++] = '\\'; newChars[pos++] = '0'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: newChars[pos++] = '\\'; newChars[pos++] = '1'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; default: newChars[pos++] = chars[i]; break; } } return new String( newChars, 0, pos ); } Rdn();  Rdn( SchemaManager schemaManager );  Rdn( SchemaManager schemaManager, String rdn );  Rdn( String rdn );  Rdn( SchemaManager schemaManager, String upType, String upValue );  Rdn( String upType, String upValue );  Rdn( SchemaManager schemaManager, Ava... avas );  Rdn( Ava... avas );  Rdn( Rdn rdn );  Rdn( SchemaManager schemaManager, Rdn rdn ); }
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( chars[i] ) { case ' ': if ( ( i > 0 ) && ( i < chars.length - 1 ) ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '#': if ( i != 0 ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '"': case '+': case ',': case ';': case '=': case '<': case '>': case '\\': newChars[pos++] = '\\'; newChars[pos++] = chars[i]; break; case 0x7F: newChars[pos++] = '\\'; newChars[pos++] = '7'; newChars[pos++] = 'F'; break; case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: newChars[pos++] = '\\'; newChars[pos++] = '0'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: newChars[pos++] = '\\'; newChars[pos++] = '1'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; default: newChars[pos++] = chars[i]; break; } } return new String( newChars, 0, pos ); } Rdn();  Rdn( SchemaManager schemaManager );  Rdn( SchemaManager schemaManager, String rdn );  Rdn( String rdn );  Rdn( SchemaManager schemaManager, String upType, String upValue );  Rdn( String upType, String upValue );  Rdn( SchemaManager schemaManager, Ava... avas );  Rdn( Ava... avas );  Rdn( Rdn rdn );  Rdn( SchemaManager schemaManager, Rdn rdn ); Object getValue( String type ); Ava getAva( String type ); @Override Iterator<Ava> iterator(); @Override Rdn clone(); String getName(); String getNormName(); Ava getAva(); Ava getAva( int pos ); String getType(); String getNormType(); String getValue(); @Override boolean equals( Object that ); int size(); static Object unescapeValue( String value ); static String escapeValue( String value ); String getEscaped(); static String escapeValue( byte[] attrValue ); boolean isSchemaAware(); static boolean isValid( String dn ); static boolean isValid( SchemaManager schemaManager, String dn ); @Override int hashCode(); int serialize( byte[] buffer, int pos ); int deserialize( byte[] buffer, int pos ); @Override void writeExternal( ObjectOutput out ); @Override void readExternal( ObjectInput in ); @Override int compareTo( Rdn otherRdn ); @Override String toString(); }
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( chars[i] ) { case ' ': if ( ( i > 0 ) && ( i < chars.length - 1 ) ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '#': if ( i != 0 ) { newChars[pos++] = chars[i]; } else { newChars[pos++] = '\\'; newChars[pos++] = chars[i]; } break; case '"': case '+': case ',': case ';': case '=': case '<': case '>': case '\\': newChars[pos++] = '\\'; newChars[pos++] = chars[i]; break; case 0x7F: newChars[pos++] = '\\'; newChars[pos++] = '7'; newChars[pos++] = 'F'; break; case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: newChars[pos++] = '\\'; newChars[pos++] = '0'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: newChars[pos++] = '\\'; newChars[pos++] = '1'; newChars[pos++] = Strings.dumpHex( ( byte ) ( chars[i] & 0x0F ) ); break; default: newChars[pos++] = chars[i]; break; } } return new String( newChars, 0, pos ); } Rdn();  Rdn( SchemaManager schemaManager );  Rdn( SchemaManager schemaManager, String rdn );  Rdn( String rdn );  Rdn( SchemaManager schemaManager, String upType, String upValue );  Rdn( String upType, String upValue );  Rdn( SchemaManager schemaManager, Ava... avas );  Rdn( Ava... avas );  Rdn( Rdn rdn );  Rdn( SchemaManager schemaManager, Rdn rdn ); Object getValue( String type ); Ava getAva( String type ); @Override Iterator<Ava> iterator(); @Override Rdn clone(); String getName(); String getNormName(); Ava getAva(); Ava getAva( int pos ); String getType(); String getNormType(); String getValue(); @Override boolean equals( Object that ); int size(); static Object unescapeValue( String value ); static String escapeValue( String value ); String getEscaped(); static String escapeValue( byte[] attrValue ); boolean isSchemaAware(); static boolean isValid( String dn ); static boolean isValid( SchemaManager schemaManager, String dn ); @Override int hashCode(); int serialize( byte[] buffer, int pos ); int deserialize( byte[] buffer, int pos ); @Override void writeExternal( ObjectOutput out ); @Override void readExternal( ObjectInput in ); @Override int compareTo( Rdn otherRdn ); @Override String toString(); static final Rdn EMPTY_RDN; static final int UNDEFINED; static final int SUPERIOR; static final int INFERIOR; static final int EQUAL; }