| | |
| | | |
| | | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | import static com.sun.opends.sdk.util.StaticUtils.*; |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | import static com.sun.opends.sdk.util.StaticUtils.toLowerCase; |
| | | import static org.opends.sdk.schema.SchemaConstants.EMR_OCTET_STRING_OID; |
| | | import static org.opends.sdk.schema.SchemaConstants.OMR_OCTET_STRING_OID; |
| | | import static org.opends.sdk.schema.SchemaConstants.SYNTAX_ENHANCED_GUIDE_NAME; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | |
| | | |
| | | |
| | | /** |
| | | * This class implements the enhanced guide attribute syntax, which may |
| | | * be used to provide criteria for generating search filters for entries |
| | | * of a given objectclass. |
| | | * This class implements the enhanced guide attribute syntax, which may be used |
| | | * to provide criteria for generating search filters for entries of a given |
| | | * objectclass. |
| | | */ |
| | | final class EnhancedGuideSyntaxImpl extends AbstractSyntaxImpl |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an |
| | | * attribute with this syntax. If it is not, then the reason may be |
| | | * appended to the provided buffer. |
| | | * |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param schema |
| | | * The schema in which this syntax is defined. |
| | | * @param value |
| | | * The value for which to make the determination. |
| | | * @param invalidReason |
| | | * The buffer to which the invalid reason should be appended. |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | public boolean valueIsAcceptable(final Schema schema, |
| | | final ByteSequence value, final LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string version of the provided value. |
| | | final String valueStr = toLowerCase(value.toString()); |
| | |
| | | if (sharpPos < 0) |
| | | { |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SHARP |
| | | .get(valueStr)); |
| | | invalidReason |
| | | .append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SHARP.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (ocLength == 0) |
| | | { |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_OC |
| | | .get(valueStr)); |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_OC.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | try |
| | | { |
| | | SchemaUtils.readOID(new SubstringReader(ocName |
| | | .substring(ocLength))); |
| | | SchemaUtils.readOID(new SubstringReader(ocName.substring(ocLength))); |
| | | } |
| | | catch (final DecodeException de) |
| | | { |
| | |
| | | else |
| | | { |
| | | |
| | | invalidReason |
| | | .append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get( |
| | | valueStr, scopeStr)); |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get( |
| | | valueStr, scopeStr)); |
| | | } |
| | | |
| | | return false; |
| | |
| | | |
| | | // Everything between the two octothorpes must be the criteria. Make |
| | | // sure it is valid. |
| | | final String criteria = |
| | | valueStr.substring(sharpPos + 1, lastSharpPos).trim(); |
| | | final String criteria = valueStr.substring(sharpPos + 1, lastSharpPos) |
| | | .trim(); |
| | | final int criteriaLength = criteria.length(); |
| | | if (criteriaLength == 0) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | return GuideSyntaxImpl.criteriaIsValid(criteria, valueStr, |
| | | invalidReason); |
| | | return GuideSyntaxImpl.criteriaIsValid(criteria, valueStr, invalidReason); |
| | | } |
| | | } |