public Object normalizeByName( String name, String val ) throws LdapException { return normalizer.normalize( val ); }
public Object normalizeByOid( String oid, String val ) throws LdapException { return normalizer.normalize( val ); }
/** * Normalize the value. For a client String value, applies the given normalizer. * * It supposes that the client has access to the schema in order to select the * appropriate normalizer. * * @param Normalizer The normalizer to apply to the value * @exception LdapException If the value cannot be normalized */ public final void normalize( Normalizer normalizer ) throws LdapException { if ( normalizer != null ) { normalizedValue = (String)normalizer.normalize( wrappedValue ); normalized = true; } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } //Value<?> result = ( Value<?> ) cache.get( value ); //if ( result != null ) //{ // return result; //} Value<?> normalized = normalizer.normalize( value ); //cache.put( value, normalized ); return normalized; }
/** * {@inheritDoc} */ public String normalize( String value ) throws LdapException { if ( value == null ) { return null; } //String normalized = ( String ) cache.get( value ); //if ( normalized != null ) //{ // return normalized; //} String normalized = normalizer.normalize( value ); //cache.put( value, normalized ); return normalized; }
public Object normalizeByOid( String oid, byte[] val ) throws LdapException { return normalizer.normalize( new BinaryValue( val ) ); }
/** * Returns the normalized suffix of the {@link Partition}. */ public Name getNormalizedSuffix( Normalizer normalizer ) throws NamingException { return new LdapDN( normalizer.normalize( suffix ).toString() ); }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, String value ) throws NamingException { return lookup( name ).normalize( value ); }
/** * @see NameComponentNormalizer#normalizeByOid(String, String) */ public Object normalizeByOid( String oid, byte[] value ) throws NamingException { return lookup( oid ).normalize( value ); }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, byte[] value ) throws NamingException { return lookup( name ).normalize( value ); }
/** * @see NameComponentNormalizer#normalizeByOid(String, String) */ public Object normalizeByOid( String oid, String value ) throws NamingException { return lookup( oid ).normalize( value ); }
/** * @see NameComponentNormalizer#normalizeByOid(String, String) */ public Object normalizeByOid( String oid, String value ) throws LdapException { return lookup( oid ).normalize( value ); }
public Object normalizeByName( String name, byte[] val ) throws LdapException { return normalizer.normalize( new BinaryValue( val ) ); }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") public K getNormalized( K attrVal ) throws Exception { if ( attrVal instanceof Long ) { return attrVal; } if ( attrVal instanceof String ) { return ( K ) normalizer.normalize( ( String ) attrVal ); } else { return ( K ) normalizer.normalize( new BinaryValue( ( byte[] ) attrVal ) ).get(); } }
/** * Compute the normalized (canonical) representation for the wrapped string. * If the wrapped String is null, the normalized form will be null too. * * @throws LdapException if the value cannot be properly normalized */ public void normalize() throws LdapException { // If the value is already normalized, get out. if ( normalized ) { return; } if ( attributeType != null ) { Normalizer normalizer = getNormalizer(); if ( normalizer == null ) { normalizedValue = wrappedValue; } else { normalizedValue = ( String ) normalizer.normalize( wrappedValue ); } normalized = true; } }
normalizedValue = normalizer.normalize( this ).getBytes(); normalized = true; same = Arrays.equals( wrappedValue, normalizedValue );
/** * @see NameComponentNormalizer#normalizeByOid(String, String) */ public Object normalizeByOid( String oid, byte[] value ) throws LdapException { return lookup( oid ).normalize( new BinaryValue( value ) ); }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, byte[] value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( !attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( new BinaryValue( value ) ); } else { try { String valStr = new String( value, "UTF-8" ); return lookup( name ).normalize( valStr ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04223 ); LOG.error( message ); throw new LdapException( message ); } } }
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( value ); } else { try { String unescaped = unescape( value ); byte[] valBytes = unescaped.getBytes( "UTF-8" ); return lookup( name ).normalize( new BinaryValue( valBytes ) ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04222 ); LOG.error( message ); throw new LdapException( message ); } } }
/** * 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; } }