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"));
}
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)));
}
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));
}
}
}
}
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);
}
}
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 "));
}
Aggregations