use of org.apache.directory.api.ldap.model.schema.LdapSyntax in project directory-ldap-api by apache.
the class DefaultSchemaManager method addSyntaxes.
/**
* Add all the Schema's Syntaxes
*/
private void addSyntaxes(Schema schema, Registries registries) throws LdapException, IOException {
if (schema.getSchemaLoader() == null) {
return;
}
for (Entry entry : schema.getSchemaLoader().loadSyntaxes(schema)) {
LdapSyntax syntax = factory.getSyntax(this, entry, registries, schema.getSchemaName());
addSchemaObject(registries, syntax, schema);
}
}
use of org.apache.directory.api.ldap.model.schema.LdapSyntax in project directory-ldap-api by apache.
the class EntryUtils method getCaseIgnoringAttributeNoNumbersType.
/* no protection*/
static AttributeType getCaseIgnoringAttributeNoNumbersType() {
MutableAttributeType attributeType = new MutableAttributeType("1.1.3.1");
LdapSyntax syntax = new LdapSyntax("1.1.1.1", "", true);
syntax.setSyntaxChecker(new SyntaxChecker("1.1.2.1") {
public static final long serialVersionUID = 1L;
public boolean isValidSyntax(Object value) {
if (value == null) {
return true;
}
if (!(value instanceof String)) {
return false;
}
String strval = (String) value;
for (char c : strval.toCharArray()) {
if (Character.isDigit(c)) {
return false;
}
}
return true;
}
});
MutableMatchingRule matchingRule = new MutableMatchingRule("1.1.2.1");
matchingRule.setSyntax(syntax);
matchingRule.setLdapComparator(new LdapComparator<String>(matchingRule.getOid()) {
public static final long serialVersionUID = 1L;
public int compare(String o1, String o2) {
return (o1 == null ? (o2 == null ? 0 : -1) : (o2 == null ? 1 : o1.compareTo(o2)));
}
});
Normalizer normalizer = new Normalizer("1.1.1") {
public static final long serialVersionUID = 1L;
public String normalize(String value) throws LdapException {
return normalize(value, PrepareString.AssertionType.ATTRIBUTE_VALUE);
}
public String normalize(String value, PrepareString.AssertionType assertionType) throws LdapException {
return Strings.toLowerCaseAscii(value);
}
};
matchingRule.setNormalizer(normalizer);
attributeType.setEquality(matchingRule);
attributeType.setSyntax(syntax);
return attributeType;
}
use of org.apache.directory.api.ldap.model.schema.LdapSyntax in project directory-ldap-api by apache.
the class EntryUtils method syntaxFactory.
/**
* A local Syntax class used for the tests
*/
public static LdapSyntax syntaxFactory(String oid, boolean humanReadable) {
LdapSyntax ldapSyntax = new LdapSyntax(oid);
ldapSyntax.setHumanReadable(humanReadable);
return ldapSyntax;
}
use of org.apache.directory.api.ldap.model.schema.LdapSyntax in project directory-ldap-api by apache.
the class EntryUtils method getBytesAttributeType.
/* No protection */
static AttributeType getBytesAttributeType() {
MutableAttributeType attributeType = new MutableAttributeType("1.2");
LdapSyntax syntax = new LdapSyntax("1.2.1", "", false);
syntax.setSyntaxChecker(new SyntaxChecker("1.2.1") {
public static final long serialVersionUID = 1L;
public boolean isValidSyntax(Object value) {
return (value == null) || (((byte[]) value).length < 5);
}
});
MutableMatchingRule matchingRule = new MutableMatchingRule("1.2.2");
matchingRule.setSyntax(syntax);
matchingRule.setLdapComparator(new ByteArrayComparator("1.2.2"));
matchingRule.setNormalizer(new NoOpNormalizer("1.1.1"));
attributeType.setEquality(matchingRule);
attributeType.setSyntax(syntax);
return attributeType;
}
Aggregations