| | |
| | | * single quoted string, or an open parenthesis followed by a |
| | | * space-delimited set of quoted strings or unquoted words followed by |
| | | * a close parenthesis. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The "extra" parameter value that was read. |
| | |
| | | values.add(readQuotedString(reader)); |
| | | reader.skipWhitespaces(); |
| | | reader.mark(); |
| | | } |
| | | while (reader.read() != ')'); |
| | | } while (reader.read() != ')'); |
| | | } |
| | | } |
| | | else |
| | |
| | | do |
| | | { |
| | | length++; |
| | | } |
| | | while (reader.read() != ' '); |
| | | } while (reader.read() != ' '); |
| | | |
| | | reader.reset(); |
| | | values = Collections.singletonList(reader.read(length)); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | values.add(readQuotedDescriptor(reader)); |
| | | reader.skipWhitespaces(); |
| | | reader.mark(); |
| | | } |
| | | while (reader.read() != ')'); |
| | | } while (reader.read() != ')'); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Reads the next OID from the definition, skipping over any leading |
| | | * spaces. |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The OID read from the definition. |
| | | * @throws DecodeException |
| | | * If a problem is encountered while reading the token name. |
| | | */ |
| | | static String readNumericOID(SubstringReader reader) |
| | | throws DecodeException |
| | | { |
| | | // This must be a numeric OID. In that case, we will accept |
| | | // only digits and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | int length = 0; |
| | | |
| | | // Skip over any spaces at the beginning of the value. |
| | | reader.skipWhitespaces(); |
| | | reader.mark(); |
| | | |
| | | try |
| | | { |
| | | char c; |
| | | while ((c = reader.read()) != ' ' && c != '\'') |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (!isDigit(c)) |
| | | { |
| | | // Technically, this must be an illegal character. However, it |
| | | // is possible that someone just got sloppy and did not |
| | | // include a space between the name/OID and a closing |
| | | // parenthesis. In that case, we'll assume it's the end of the |
| | | // value. |
| | | if (c == ')') |
| | | { |
| | | break; |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = false; |
| | | } |
| | | length++; |
| | | } |
| | | |
| | | if (length == 0) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | reader.reset(); |
| | | |
| | | return reader.read(length); |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Reads the attribute description or numeric OID, skipping over any |
| | | * leading or trailing spaces. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The attribute description or numeric OID read from the |
| | |
| | | */ |
| | | static String readOID(SubstringReader reader) throws DecodeException |
| | | { |
| | | int length = 1; |
| | | int length = 0; |
| | | boolean enclosingQuote = false; |
| | | String oid; |
| | | |
| | | // Skip over any spaces at the beginning of the value. |
| | | reader.skipWhitespaces(); |
| | | reader.mark(); |
| | | |
| | | try |
| | | if (reader.remaining() > 0) |
| | | { |
| | | // The next character must be either numeric (for an OID) or |
| | | // alphabetic (for an attribute description). |
| | | char c = reader.read(); |
| | | if (c == '\'') |
| | | if (reader.read() == '\'') |
| | | { |
| | | enclosingQuote = true; |
| | | reader.mark(); |
| | | c = reader.read(); |
| | | } |
| | | if (isDigit(c)) |
| | | else |
| | | { |
| | | reader.reset(); |
| | | oid = readNumericOID(reader); |
| | | } |
| | | } |
| | | |
| | | if (reader.remaining() > 0) |
| | | { |
| | | char c = reader.read(); |
| | | length++; |
| | | |
| | | if (isDigit(c)) |
| | | { |
| | | // This must be a numeric OID. In that case, we will accept |
| | | // only digits and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | |
| | | while (reader.remaining() > 0 && (c = reader.read()) != ' ' |
| | | && c != ')' && !(c == '\'' && enclosingQuote)) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (!isDigit(c)) |
| | | { |
| | | // This must be an illegal character. |
| | | // This must have been an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = false; |
| | | } |
| | | |
| | | length++; |
| | | } |
| | | |
| | | if (lastWasPeriod) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_ENDS_WITH_PERIOD |
| | | .get(reader.getString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | | else if (isAlpha(c)) |
| | | { |
| | | // This must be an attribute description. In this case, we will |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | && c != '_') |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | length++; |
| | | } |
| | | |
| | | reader.reset(); |
| | | |
| | | // Return the position of the first non-space character after |
| | | // the token. |
| | | oid = reader.read(length); |
| | | } |
| | | else |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (enclosingQuote) |
| | | if (enclosingQuote && c != '\'') |
| | | { |
| | | reader.read(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS |
| | | .get(reader.pos() - 1, String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | | } |
| | | return oid; |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | |
| | | if (length == 0) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | reader.reset(); |
| | | String oid = reader.read(length); |
| | | if (enclosingQuote) |
| | | { |
| | | reader.read(); |
| | | } |
| | | |
| | | return oid; |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Reads the next OID from the definition, skipping over any leading |
| | | * spaces. The OID may be followed by a integer length in brackets. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The OID read from the definition. |
| | |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | |
| | | |
| | | if (length == 0) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | && c != '_') |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | { |
| | | if (!isDigit(c)) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | |
| | | // Skip over any trailing spaces; |
| | | reader.skipWhitespaces(); |
| | | } |
| | | while (reader.read() != ')'); |
| | | } while (reader.read() != ')'); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Reads the value of a string enclosed in single quotes, skipping |
| | | * over the quotes and any leading spaces. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The string value read from the definition. |
| | |
| | | * If a problem is encountered while reading the quoted |
| | | * string. |
| | | */ |
| | | static String readQuotedDescriptor(SubstringReader reader) |
| | | private static String readQuotedDescriptor(SubstringReader reader) |
| | | throws DecodeException |
| | | { |
| | | int length = 0; |
| | |
| | | char c = reader.read(); |
| | | if (c != '\'') |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS.get(reader.pos() - 1, |
| | | String.valueOf(c)); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS |
| | | .get(reader.pos() - 1, String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | && c != '.') |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | | .get(String.valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Reads the value of a string enclosed in single quotes, skipping |
| | | * over the quotes and any leading spaces. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The string value read from the definition. |
| | |
| | | final char c = reader.read(); |
| | | if (c != '\'') |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS.get(reader.pos() - 1, |
| | | String.valueOf(c)); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS |
| | | .get(reader.pos() - 1, String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Reads the next ruleid from the definition, skipping over any |
| | | * leading spaces. |
| | | * |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The ruleid read from the definition. |
| | |
| | | |
| | | if (length == 0) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_RULE_ID_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_RULE_ID_NO_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final NumberFormatException e) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_RULE_ID_INVALID.get(ruleID); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_RULE_ID_INVALID |
| | | .get(ruleID); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | |
| | | // Skip over any trailing spaces; |
| | | reader.skipWhitespaces(); |
| | | } |
| | | while (reader.read() != ')'); |
| | | } while (reader.read() != ')'); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Reads the next token name from the definition, skipping over any |
| | | * leading or trailing spaces or <code>null</code> if there are no |
| | | * moretokens to read. |
| | | * |
| | | * more tokens to read. |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @return The token name read from the definition or |
| | |
| | | if (token == null && reader.remaining() > 0) |
| | | { |
| | | reader.reset(); |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNEXPECTED_CLOSE_PARENTHESIS.get(length); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_UNEXPECTED_CLOSE_PARENTHESIS |
| | | .get(length); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |