| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.opends.messages.Message; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Integer decode(AttributeValue value) throws DirectoryException |
| | | { |
| | | ByteString nvalue = value.getNormalizedValue(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getSyntaxName() |
| | | { |
| | | return SYNTAX_INTEGER_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_INTEGER_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_INTEGER_DESCRIPTION; |
| | |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public EqualityMatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public OrderingMatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public SubstringMatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public ApproximateMatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | { |
| | |
| | | case '9': |
| | | return true; |
| | | case '-': |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get( |
| | | valueString)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE |
| | | .get(valueString)); |
| | | return false; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | valueString, |
| | | valueString.charAt(0), 0)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(0), 0)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | switch (valueString.charAt(0)) |
| | | { |
| | | case '0': |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get( |
| | | valueString)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO |
| | | .get(valueString)); |
| | | return false; |
| | | case '1': |
| | | case '2': |
| | |
| | | negative = true; |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | valueString, |
| | | valueString.charAt(0), 0)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(0), 0)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | // This is fine as long as the value isn't negative. |
| | | if (negative) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get( |
| | | valueString)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO |
| | | .get(valueString)); |
| | | return false; |
| | | } |
| | | break; |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | valueString, |
| | | valueString.charAt(0), 0)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(1), 1)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | valueString, |
| | | valueString.charAt(0), 0)); |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(i), i)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isBinary() |
| | | { |
| | | return false; |