* @throws org.apache.directory.api.ldap.model.exception.LdapException if there is a database access failure
*/
@SuppressWarnings("unchecked")
private boolean evalEquality( EqualityNode<?> node, Entry entry ) throws LdapException
{
Normalizer normalizer = getNormalizer( node.getAttributeType() );
Comparator comparator = getComparator( node.getAttributeType() );
// get the attribute associated with the node
Attribute attr = entry.get( node.getAttribute() );
// If we do not have the attribute just return false
if ( null == attr )
{
return false;
}
// check if Ava value exists in attribute
AttributeType attributeType = node.getAttributeType();
Value<?> value = null;
if ( attributeType.getSyntax().isHumanReadable() )
{
if ( node.getValue().isHumanReadable() )
{
value = node.getValue();
}
else
{
value = new org.apache.directory.api.ldap.model.entry.StringValue( node.getValue().getString() );
}
}
else
{
value = node.getValue();
}
if ( attr.contains( value ) )
{
return true;
}
// get the normalized Ava filter value
Value<?> filterValue = normalizer.normalize( value );
// check if the normalized value is present
if ( attr.contains( filterValue ) )
{
return true;
}
/*
* We need to now iterate through all values because we could not get
* a lookup to work. For each value we normalize and use the comparator
* to determine if a match exists.
*/
for ( Value<?> val : attr )
{
Value<?> normValue = normalizer.normalize( val );
if ( 0 == comparator.compare( normValue.getValue(), filterValue.getValue() ) )
{
return true;
}