String interfaceClass = attribs.getValue(ATTRIB_INTERFACE);
if (interfaceClass == null || interfaceClass.length() == 0) {
throw new SAXException("Missing required " + ATTRIB_INTERFACE + " attribute");
}
Builder builder = new Builder().setNamespace(Namespaces.NS_SERVICE);
String filter;
String target = attribs.getValue(ATTRIB_TARGET);
if (target != null)
filter = String.format("(&(%s=%s)%s)", Constants.OBJECTCLASS, interfaceClass, target);
else
filter = String.format("(%s=%s)", Constants.OBJECTCLASS, interfaceClass);
builder.addDirective(Namespaces.DIRECTIVE_FILTER, filter);
String cardinality = attribs.getValue(ATTRIB_CARDINALITY);
if (cardinality != null) {
cardinality = cardinality.trim().toLowerCase();
if (cardinality.length() > 0) {
if ('0' == cardinality.charAt(0))
builder.addDirective(Namespaces.DIRECTIVE_RESOLUTION, Namespaces.RESOLUTION_OPTIONAL);
if ('n' == cardinality.charAt(cardinality.length() - 1))
builder.addDirective(Namespaces.DIRECTIVE_CARDINALITY, Namespaces.CARDINALITY_MULTIPLE);
}
}
builder.addDirective(Namespaces.DIRECTIVE_EFFECTIVE, Namespaces.EFFECTIVE_ACTIVE);
return builder.buildRequirement();
}