copper-server-impl/src/main/java/com/pogeyan/cmis/impl/uri/expression/FilterParserImpl.java
/**
	 * Read the parameters of a method expression
	 * 
	 * @param methodInfo
	 *            Signature information about the method whose parameters should
	 *            be read
	 * @param methodExpression
	 *            Method expression to which the read parameters are added
	 * @return The method expression input parameter
	 * @throws ExpressionParserException
	 * @throws ExpressionParserInternalError
	 * @throws TokenizerExpectError
	 *             The next token did not match the expected token
	 */
Read the parameters of a method expression


Read the parameters of a method expression
protected MethodExpression readParameters(final InfoMethod methodInfo, final MethodExpressionImpl methodExpression,
			final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError {
		CommonExpression expression;
		boolean expectAnotherExpression = false;
		boolean readComma = true;
		Token openParenthesis = tokenList.expectToken(TokenKind.OPENPAREN, true); 
		Token token = tokenList.lookToken();
		if (token == null) {
			throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(openParenthesis, curExpression);
		}
		while (token.getKind() != TokenKind.CLOSEPAREN) {
			if (readComma == false) {
				throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PARENTHESIS_EXPECTED_AFTER_POS(
						tokenList.lookPrevToken(), curExpression);
			}
			expression = readElement(null);
			if (expression != null) {
				expression = readElements(expression, 0);
			}
			if ((expression == null) && (expectAnotherExpression == true)) {
				throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(token, curExpression);
			} else if (expression != null) {
				methodExpression.appendParameter(expression);
			}
			token = tokenList.lookToken();
			if (token == null) {
				throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PARENTHESIS_EXPECTED_AFTER_POS(
						tokenList.lookPrevToken(), curExpression);
			}
			if (token.getKind() == TokenKind.COMMA) {
				expectAnotherExpression = true;
				if (expression == null) {
					throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AT_POS(token, curExpression);
				}
				tokenList.expectToken(",", true);
				readComma = true;
			} else {
				readComma = false;
			}
		}
		tokenList.expectToken(TokenKind.CLOSEPAREN, true);
		int count = methodExpression.getParameters().size();
		if ((methodInfo.getMinParameter() > -1) && (count < methodInfo.getMinParameter())) {
			throw FilterParserExceptionImpl.createMETHOD_WRONG_ARG_COUNT(methodExpression, methodToken, curExpression);
		}
		if ((methodInfo.getMaxParameter() > -1) && (count > methodInfo.getMaxParameter())) {
			 CASE 15
			throw FilterParserExceptionImpl.createMETHOD_WRONG_ARG_COUNT(methodExpression, methodToken, curExpression);
		}
		return methodExpression;
	}
protected MethodExpression readParameters ( final InfoMethod methodInfo , final MethodExpressionImpl methodExpression , final Token methodToken ) throws ExpressionParserException , ExpressionParserInternalError { CommonExpression expression ; boolean expectAnotherExpression = false ; boolean readComma = true ; Token openParenthesis = tokenList . expectToken ( TokenKind . OPENPAREN , true ) ; Token token = tokenList . lookToken ( ) ; if ( token == null ) { throw FilterParserExceptionImpl . createEXPRESSION_EXPECTED_AFTER_POS ( openParenthesis , curExpression ) ; } while ( token . getKind ( ) != TokenKind . CLOSEPAREN ) { if ( readComma == false ) { throw FilterParserExceptionImpl . createCOMMA_OR_CLOSING_PARENTHESIS_EXPECTED_AFTER_POS ( tokenList . lookPrevToken ( ) , curExpression ) ; } expression = readElement ( null ) ; if ( expression != null ) { expression = readElements ( expression , 0 ) ; } if ( ( expression == null ) && ( expectAnotherExpression == true ) ) { throw FilterParserExceptionImpl . createEXPRESSION_EXPECTED_AFTER_POS ( token , curExpression ) ; } else if ( expression != null ) { methodExpression . appendParameter ( expression ) ; } token = tokenList . lookToken ( ) ; if ( token == null ) { throw FilterParserExceptionImpl . createCOMMA_OR_CLOSING_PARENTHESIS_EXPECTED_AFTER_POS ( tokenList . lookPrevToken ( ) , curExpression ) ; } if ( token . getKind ( ) == TokenKind . COMMA ) { expectAnotherExpression = true ; if ( expression == null ) { throw FilterParserExceptionImpl . createEXPRESSION_EXPECTED_AT_POS ( token , curExpression ) ; } tokenList . expectToken ( "," , true ) ; readComma = true ; } else { readComma = false ; } } tokenList . expectToken ( TokenKind . CLOSEPAREN , true ) ; int count = methodExpression . getParameters ( ) . size ( ) ; if ( ( methodInfo . getMinParameter ( ) > - 1 ) && ( count < methodInfo . getMinParameter ( ) ) ) { throw FilterParserExceptionImpl . createMETHOD_WRONG_ARG_COUNT ( methodExpression , methodToken , curExpression ) ; } if ( ( methodInfo . getMaxParameter ( ) > - 1 ) && ( count > methodInfo . getMaxParameter ( ) ) ) { throw FilterParserExceptionImpl . createMETHOD_WRONG_ARG_COUNT ( methodExpression , methodToken , curExpression ) ; } return methodExpression ; }
Read the parameters of a method expression
Read the parameters of a method expression
// The existing of a '(' is verified BEFORE this method is called --> so // it's a internal error // throws // FilterParserInternalError // Tested with TestParserExceptions.TestPMreadParameters CASE 1 e.g. // "$filter=concat(" // Tested with TestParserExceptions.TestPMreadParameters CASE 12 // e.g. "$filter=concat('a' 'b')" // Tested with TestParserExceptions.TestPMreadParameters CASE 4 // e.g. "$filter=concat(," // parameter list may be empty // Tested with TestParserExceptions.TestPMreadParameters CASE 2 // e.g. "$filter=concat(123" // Tested with TestParserExceptions.TestPMreadParameters // CASE 3 e.g. "$filter=concat(," // because the while loop above only exits if a ')' has been found it is // an // internal error if there is not ')' // ---check parameter count // Tested with TestParserExceptions.TestPMreadParameters CASE 12 // Tested with TestParserExceptions.TestPMreadParameters CASE 15