| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.opends.messages.Message; |
| | |
| | | * the value. |
| | | */ |
| | | private static int readExtraParameterValues(String valueStr, |
| | | List<String> valueList, int startPos) |
| | | List<String> valueList, int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = valueStr.charAt(startPos++); |
| | | while ((startPos < length) && (c == ' ')) |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | c = valueStr.charAt(startPos++); |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | Message message = ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr); |
| | | Message message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | |
| | | { |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != '\'')) |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | startPos++; |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | | { |
| | | startPos++; |
| | | // We're expecting a list of values. Quoted, space separated. |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | |
| | | message); |
| | | } |
| | | |
| | | |
| | | if (c == ')') |
| | | { |
| | | // This is the end of the list. |
| | |
| | | { |
| | | // This is an illegal character. |
| | | Message message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get(valueStr, c, startPos); |
| | | ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get( |
| | | valueStr, c, startPos); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | else if (c == '\'') |
| | | { |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | startPos++; |
| | | } |
| | | else |
| | | { |
| | | // We'll recursively call this method to deal with this. |
| | | startPos = readExtraParameterValues(valueStr, valueList, startPos); |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | Message message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | { |
| | |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | Message message = ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr); |
| | | Message message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |