}
}
/* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType()
{
AttributeType attributeType = new AttributeType( "1.1.3.1" );
LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true );
syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
{
private static final long serialVersionUID = 0L;
public boolean isValidSyntax( Object value )
{
if ( !( value instanceof String ) )
{
return false;
}
String strval = ( String ) value;
for ( char c:strval.toCharArray() )
{
if ( Character.isDigit( c ) )
{
return false;
}
}
return true;
}
} );
MatchingRule matchingRule = new MatchingRule( "1.1.2.1" );
matchingRule.setSyntax( syntax );
matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
{
private static final long serialVersionUID = 0L;
public int compare( String o1, String o2 )
{
return ( o1 == null ?
( o2 == null ? 0 : -1 ) :
( o2 == null ? 1 : o1.compareTo( o2 ) ) );
}
int getValue( String val )
{
if ( val.equals( "LOW" ) )
{
return 0;
}
else if ( val.equals( "MEDIUM" ) )
{
return 1;
}
else if ( val.equals( "HIGH" ) )
{
return 2;
}
throw new IllegalArgumentException( I18n.err( I18n.ERR_472 ) );
}
} );
Normalizer normalizer = new Normalizer( "1.1.1" )
{
private static final long serialVersionUID = 0L;
public Value<?> normalize( Value<?> value ) throws NamingException
{
if ( !value.isBinary() )
{
return new ClientStringValue( value.getString().toLowerCase() );
}
throw new IllegalStateException( I18n.err( I18n.ERR_473 ) );
}
public String normalize( String value ) throws NamingException
{
return value.toLowerCase();
}
};
matchingRule.setNormalizer( normalizer );
attributeType.setEquality( matchingRule );
attributeType.setSyntax( syntax );
return attributeType;
}