/** * Gets the normalizer for equality matching. * * @param attrId the attribute identifier * @return the normalizer for equality matching * @throws javax.naming.NamingException if there is a failure */ private Normalizer getNormalizer( String attrId ) throws NamingException { MatchingRule mrule = getMatchingRule( attrId, EQUALITY_MATCH ); return mrule.getNormalizer(); }
/** * Gets the normalizer for equality matching. * * @param attrId the attribute identifier * @return the normalizer for equality matching * @throws NamingException if there is a failure */ private Normalizer getNormalizer( String attrId ) throws NamingException { MatchingRule mrule = getMatchingRule( attrId, EQUALITY_MATCH ); if ( mrule == null ) { return NoOpNormalizer.INSTANCE; } return mrule.getNormalizer(); }
/** * Gets a normalizer using getMatchingRule() to resolve the matchingRule * that the normalizer is extracted from. * * @return a normalizer associated with the attributeType or null if one cannot be found * @throws LdapException if resolution of schema entities fail */ protected Normalizer getNormalizer() throws LdapException { if ( attributeType != null ) { MatchingRule mr = getMatchingRule(); if ( mr == null ) { return null; } return mr.getNormalizer(); } else { return null; } }
/** * Returns the normalized suffix of the {@link Partition}. */ public Name getNormalizedSuffix( MatchingRuleRegistry matchingRuleRegistry ) throws NamingException { return getNormalizedSuffix( matchingRuleRegistry.lookup( "distinguishedNameMatch" ).getNormalizer() ); }
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 ); }
oidNormalizer = new OidNormalizer( type.getOid(), matchingRule.getNormalizer() );
/** * 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(); }
/** * 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(); }
/** * Delete the MR references (using and usedBy) : * MR -> C * MR -> N * MR -> S */ public void delCrossReferences( MatchingRule matchingRule ) { if ( matchingRule.getLdapComparator() != null ) { delReference( matchingRule, matchingRule.getLdapComparator() ); } if ( matchingRule.getNormalizer() != null ) { delReference( matchingRule, matchingRule.getNormalizer() ); } if ( matchingRule.getSyntax() != null ) { delReference( matchingRule, matchingRule.getSyntax() ); } }
String oid = oidRegistry.getOid( snode.getAttribute() ); AttributeType type = attributeTypeRegistry.lookup( oid ); Normalizer normalizer = type.getSubstr().getNormalizer();
/** * {@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; } }
if ( mr.getNormalizer() == null )
if ( mr.getNormalizer() == null )
Normalizer normalizer = matchingRule.getNormalizer();
Normalizer normalizer = attrType.getEquality().getNormalizer(); Object reqVal = normalizer.normalize( value );
normalizer = mr.getNormalizer();
Normalizer normalizer = attributeType.getEquality().getNormalizer(); return comparator.compare( normalizer.normalize( get() ), normalizer.normalize( other.get() ) ) == 0;
final SubstringNode snode = ( SubstringNode ) node; AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() ); Normalizer normalizer = type.getSubstr().getNormalizer();