Search in sources :

Example 41 with Normalizer

use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.

the class DeepTrimNormalizerTest method testNormalizeString.

@Test
public void testNormalizeString() throws Exception {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    assertEquals(" abcd ", normalizer.normalize("abcd"));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Example 42 with Normalizer

use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.

the class DeepTrimNormalizerTest method testNormalizeIgnore.

@Test
public void testNormalizeIgnore() throws Exception {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    char[] chars = new char[58];
    int pos = 0;
    for (char c = 0x0000; c < 0x0008; c++) {
        chars[pos++] = c;
    }
    for (char c = 0x000E; c < 0x001F; c++) {
        chars[pos++] = c;
    }
    for (char c = 0x007F; c < 0x0084; c++) {
        chars[pos++] = c;
    }
    for (char c = 0x0086; c < 0x009F; c++) {
        chars[pos++] = c;
    }
    chars[pos++] = 0x00AD;
    assertEquals("  ", normalizer.normalize(new String(chars)));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Example 43 with Normalizer

use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.

the class DefaultNormalizerRegistry method unregisterSchemaElements.

/**
 * {@inheritDoc}
 */
@Override
public void unregisterSchemaElements(String schemaName) throws LdapException {
    if (schemaName == null) {
        return;
    }
    // with the give schemaName
    for (Normalizer normalizer : this) {
        if (schemaName.equalsIgnoreCase(normalizer.getSchemaName())) {
            String oid = normalizer.getOid();
            SchemaObject removed = unregister(oid);
            if (DEBUG) {
                LOG.debug(I18n.msg(I18n.MSG_13702_REMOVED_FROM_REGISTRY, removed, oid));
            }
        }
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer)

Example 44 with Normalizer

use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.

the class ConcreteNameComponentNormalizer method normalizeByName.

/**
 * {@inheritDoc}
 */
@Override
public Object normalizeByName(String name, String value) throws LdapException {
    AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(name);
    Normalizer normalizer = lookup(name);
    if (attributeType.getSyntax().isHumanReadable()) {
        return normalizer.normalize(value);
    } else {
        String unescaped = unescape(value);
        return normalizer.normalize(unescaped);
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer)

Example 45 with Normalizer

use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.

the class DeepTrimToLowerNormalizerTest method testInsignifiantSpacesStringCharsSpaces.

@Test
public void testInsignifiantSpacesStringCharsSpaces() throws LdapException {
    Normalizer normalizer = new DeepTrimToLowerNormalizer("1.1.1");
    assertEquals(" a ", normalizer.normalize(" a"));
    assertEquals(" a ", normalizer.normalize("a "));
    assertEquals(" a ", normalizer.normalize(" a "));
    assertEquals(" a  a ", normalizer.normalize("a a"));
    assertEquals(" a  a ", normalizer.normalize(" a a"));
    assertEquals(" a  a ", normalizer.normalize("a a "));
    assertEquals(" a  a ", normalizer.normalize("a  a"));
    assertEquals(" a  a ", normalizer.normalize(" a   a "));
    assertEquals(" aaa  aaa  aaa ", normalizer.normalize("  aaa   aaa   aaa  "));
}
Also used : DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) Test(org.junit.Test)

Aggregations

Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)78 Test (org.junit.Test)59 DeepTrimToLowerNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer)20 DeepTrimNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer)15 TelephoneNumberNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.TelephoneNumberNormalizer)12 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)10 NumericNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer)9 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)7 NoOpNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer)7 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)7 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)6 PrepareString (org.apache.directory.api.ldap.model.schema.PrepareString)6 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)5 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)5 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)5 MutableMatchingRule (org.apache.directory.api.ldap.model.schema.MutableMatchingRule)4 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)4 ByteArrayComparator (org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator)4 BooleanNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer)4 LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)3