/** * Looks up the Normalizer to use for a name component using the attributeId * for the name component. First the attribute is resolved, then its * equality matching rule is looked up. The normalizer of that matching * rule is returned. * * @param id the name or oid of the attribute in the name component to * normalize the value of * @return the Normalizer to use for normalizing the value of the attribute * @throws NamingException if there are failures resolving the Normalizer */ private Normalizer lookup( String id ) throws NamingException { AttributeType type = attributeRegistry.lookup( id ); MatchingRule mrule = type.getEquality(); if ( mrule == null ) { return NoOpNormalizer.INSTANCE; } return type.getEquality().getNormalizer(); }
public MatchingRule getEquality() throws NamingException { if ( equalityId != null ) { return this.matchingRuleRegistry.lookup( equalityId ); } if ( superiorId != null ) { return getSuperior().getEquality(); } return null; }
public Map getNormalizerMapping() throws NamingException { if ( mapping == null ) { Map bootstrapMapping = bootstrap.getNormalizerMapping(); mapping = new HashMap( ( byOid.size() << 1 ) + bootstrapMapping.size() ); mapping.putAll( bootstrapMapping ); for ( Iterator ii = byOid.values().iterator(); ii.hasNext(); /**/ ) { AttributeType type = ( AttributeType ) ii.next(); OidNormalizer oidNormalizer = new OidNormalizer( type.getOid(), type.getEquality().getNormalizer() ); mapping.put( type.getOid(), oidNormalizer ); String[] aliases = type.getNames(); for ( int jj = 0; jj < aliases.length; jj++ ) { mapping.put( aliases[jj], oidNormalizer ); mapping.put( aliases[jj].toLowerCase(), oidNormalizer ); } } } return Collections.unmodifiableMap( mapping ); }
/** * @return The MatchingRule associated with the AttributeType */ public MatchingRule getEquality() throws NamingException { if ( equalityMR == null ) { if ( equalityId != null ) { equalityMR = this.matchingRuleRegistry.lookup( equalityId ); } else if ( superiorId != null ) { equalityMR = getSuperior().getEquality(); } } return equalityMR; }
MatchingRule mr = attributeType.getEquality();
MatchingRule matchingRule = type.getEquality(); OidNormalizer oidNormalizer = null;
/** * Looks up the Normalizer to use for a name component using the attributeId * for the name component. First the attribute is resolved, then its * equality matching rule is looked up. The normalizer of that matching * rule is returned. * * @param id the name or oid of the attribute in the name component to * normalize the value of * @return the Normalizer to use for normalizing the value of the attribute * @throws LdapException if there are failures resolving the Normalizer */ private Normalizer lookup( String id ) throws LdapException { AttributeType type = schemaManager.lookupAttributeTypeRegistry( id ); MatchingRule mrule = type.getEquality(); if ( mrule == null ) { return new NoOpNormalizer( id ); } return mrule.getNormalizer(); }
private void setupUserIndices() throws Exception { if ( userIndices != null && userIndices.size() > 0 ) { Map<String, AvlIndex<? extends Object, E>> tmp = new HashMap<String, AvlIndex<? extends Object, E>>(); for ( AvlIndex<? extends Object, E> index : userIndices.values() ) { String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() ); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid ); // Check that the attributeType has an EQUALITY matchingRule MatchingRule mr = attributeType.getEquality(); if ( mr != null ) { index.initialize( schemaManager.lookupAttributeTypeRegistry( oid ) ); tmp.put( oid, index ); } else { LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) ); } } userIndices = tmp; } else { userIndices = new HashMap<String, AvlIndex<? extends Object, E>>(); } }
mrule = type.getEquality(); break; case ( SUBSTRING_MATCH ):
mrule = type.getEquality(); break; case ( SUBSTRING_MATCH ):
if ( ( superior != null ) && ( superior.getEquality() != null ) ) this.equality = superior.getEquality(); this.equalityOid = this.equality.getOid();
/** * {@inheritDoc} */ public void addMappingFor( AttributeType attributeType ) throws LdapException { MatchingRule equality = attributeType.getEquality(); OidNormalizer oidNormalizer; String oid = attributeType.getOid(); if ( equality == null ) { LOG.debug( "Attribute {} does not have an EQUALITY MatchingRule : using NoopNormalizer", attributeType .getName() ); oidNormalizer = new OidNormalizer( oid, new NoOpNormalizer( attributeType.getOid() ) ); } else { oidNormalizer = new OidNormalizer( oid, equality.getNormalizer() ); } oidNormalizerMap.put( oid, oidNormalizer ); // Also inject the attributeType's short names in the map for ( String name : attributeType.getNames() ) { oidNormalizerMap.put( name.toLowerCase(), oidNormalizer ); } }
Normalizer normalizer = attributeType.getEquality().getNormalizer(); OidNormalizer oidNormalizer = new OidNormalizer( attributeType.getOid(), normalizer ); mapping.put( attributeType.getOid(), oidNormalizer );
/** * TODO I don't think the keyCache is required anymore since the normalizer * will cache values for us. */ public Object getNormalized( Object attrVal ) throws NamingException { Object normalized = keyCache.get( attrVal ); if ( null == normalized ) { normalized = attribute.getEquality().getNormalizer().normalize( attrVal ); // Double map it so if we use an already normalized // value we can get back the same normalized value. // and not have to regenerate a second time. keyCache.put( attrVal, normalized ); keyCache.put( normalized, normalized ); } return normalized; } }
isSuccess &= resolve( at.getEquality(), errors ); if ( at.getEquality() != null )
Normalizer normalizer = attrType.getEquality().getNormalizer(); Object reqVal = normalizer.normalize( value );
if ( attributeType.getEquality() != null ) delReference( attributeType, attributeType.getEquality() );
MatchingRule mr = attributeType.getEquality();
/** * Initializes the forward and reverse tables used by this Index. * * @throws NamingException if we cannot initialize the forward and reverse * tables */ private void initTables() throws NamingException { SerializableComparator comp; comp = new SerializableComparator( attribute.getEquality().getOid() ); /* * The forward key/value map stores attribute values to master table * primary keys. A value for an attribute can occur several times in * different entries so the forward map can have more than one value. */ forward = new JdbmTable( attribute.getName() + FORWARD_BTREE, true, numDupLimit, recMan, new IndexComparator( comp, true ) ); /* * Now the reverse map stores the primary key into the master table as * the key and the values of attributes as the value. If an attribute * is single valued according to its specification based on a schema * then duplicate keys should not be allowed within the reverse table. */ reverse = new JdbmTable( attribute.getName() + REVERSE_BTREE, !attribute.isSingleValue(), numDupLimit, recMan, new IndexComparator( comp, false ) ); }
Normalizer normalizer = attributeType.getEquality().getNormalizer(); return comparator.compare( normalizer.normalize( get() ), normalizer.normalize( other.get() ) ) == 0;