@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { if (combinations.isEmpty()) { return new ParameterSet(null, null); } // first check for exact parameter combination for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet; } } // second check for parameter combination with promotion for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet; } } return null; }
@Override public EdmType getReturnType() { int parameterCount = combinations.size(); if (parameterCount == 0) { return null; } if (parameterCount == 1) { return combinations.get(0).getReturnType(); } // There are more than 1 possible return type, check if they are equal, if not return null. EdmType returnType = combinations.get(0).getReturnType(); for (int i = 1; i < parameterCount; i++) { if (returnType != combinations.get(i)) { return null; } } return returnType; }
@Override public EdmType validateParameterSet(final List<ParameterSet> allowedParameterTypes, final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { // first check for exact parameter combination for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet.getReturnType(); } } // first check for parameter combination with promotion for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet.getReturnType(); } } return null; } }
combination.add(new ParameterSet(sbyte, sbyte, sbyte)); combination.add(new ParameterSet(byte_, byte_, byte_)); combination.add(new ParameterSet(int16, int16, int16)); combination.add(new ParameterSet(int32, int32, int32)); combination.add(new ParameterSet(int64, int64, int64)); combination.add(new ParameterSet(single, single, single)); combination.add(new ParameterSet(double_, double_, double_)); combination.add(new ParameterSet(decimal, decimal, decimal)); combination.add(new ParameterSet(sbyte, sbyte, null_)); combination.add(new ParameterSet(sbyte, null_, sbyte)); combination.add(new ParameterSet(byte_, byte_, null_)); combination.add(new ParameterSet(byte_, null_, byte_)); combination.add(new ParameterSet(int16, int16, null_)); combination.add(new ParameterSet(int16, null_, int16)); combination.add(new ParameterSet(int32, int32, null_)); combination.add(new ParameterSet(int32, null_, int32)); combination.add(new ParameterSet(int64, int64, null_)); combination.add(new ParameterSet(int64, null_, int64)); combination.add(new ParameterSet(single, single, null_)); combination.add(new ParameterSet(single, null_, single)); combination.add(new ParameterSet(double_, double_, null_)); combination.add(new ParameterSet(double_, null_, double_)); combination.add(new ParameterSet(decimal, decimal, null_)); combination.add(new ParameterSet(decimal, null_, decimal)); combination.add(new ParameterSet(sbyte, sbyte, sbyte));
@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { EdmType xxx = actualParameterTypes.get(actualParameterTypes.size() - 1); return new ParameterSet(xxx, null); }
@Override public EdmType validateParameterSet(final List<ParameterSet> allowedParameterTypes, final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { // first check for exact parameter combination for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet.getReturnType(); } } // first check for parameter combination with promotion for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet.getReturnType(); } } return null; } }
combination.add(new ParameterSet(sbyte, sbyte, sbyte)); combination.add(new ParameterSet(byte_, byte_, byte_)); combination.add(new ParameterSet(int16, int16, int16)); combination.add(new ParameterSet(int32, int32, int32)); combination.add(new ParameterSet(int64, int64, int64)); combination.add(new ParameterSet(single, single, single)); combination.add(new ParameterSet(double_, double_, double_)); combination.add(new ParameterSet(decimal, decimal, decimal)); combination.add(new ParameterSet(sbyte, sbyte, null_)); combination.add(new ParameterSet(sbyte, null_, sbyte)); combination.add(new ParameterSet(byte_, byte_, null_)); combination.add(new ParameterSet(byte_, null_, byte_)); combination.add(new ParameterSet(int16, int16, null_)); combination.add(new ParameterSet(int16, null_, int16)); combination.add(new ParameterSet(int32, int32, null_)); combination.add(new ParameterSet(int32, null_, int32)); combination.add(new ParameterSet(int64, int64, null_)); combination.add(new ParameterSet(int64, null_, int64)); combination.add(new ParameterSet(single, single, null_)); combination.add(new ParameterSet(single, null_, single)); combination.add(new ParameterSet(double_, double_, null_)); combination.add(new ParameterSet(double_, null_, double_)); combination.add(new ParameterSet(decimal, decimal, null_)); combination.add(new ParameterSet(decimal, null_, decimal)); combination.add(new ParameterSet(sbyte, sbyte, sbyte));
@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { EdmType xxx = actualParameterTypes.get(actualParameterTypes.size() - 1); return new ParameterSet(xxx, null); }
@Override public EdmType getReturnType() { int parameterCount = combinations.size(); if (parameterCount == 0) { return null; } if (parameterCount == 1) { return combinations.get(0).getReturnType(); } // There are more than 1 possible return type, check if they are equal, if not return null. EdmType returnType = combinations.get(0).getReturnType(); for (int i = 1; i < parameterCount; i++) { if (returnType != combinations.get(i)) { return null; } } return returnType; }
@Override public EdmType validateParameterSet(final List<ParameterSet> allowedParameterTypes, final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { // first check for exact parameter combination for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet.getReturnType(); } } // first check for parameter combination with promotion for (ParameterSet parameterSet : allowedParameterTypes) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet.getReturnType(); } } return null; } }
@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { if (combinations.isEmpty()) { return new ParameterSet(null, null); } // first check for exact parameter combination for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet; } } // second check for parameter combination with promotion for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet; } } return null; }
combination.add(new ParameterSet(sbyte, sbyte, sbyte)); combination.add(new ParameterSet(byte_, byte_, byte_)); combination.add(new ParameterSet(int16, int16, int16)); combination.add(new ParameterSet(int32, int32, int32)); combination.add(new ParameterSet(int64, int64, int64)); combination.add(new ParameterSet(single, single, single)); combination.add(new ParameterSet(double_, double_, double_)); combination.add(new ParameterSet(decimal, decimal, decimal)); combination.add(new ParameterSet(sbyte, sbyte, sbyte)); combination.add(new ParameterSet(byte_, byte_, byte_)); combination.add(new ParameterSet(int16, int16, int16)); combination.add(new ParameterSet(int32, int32, int32)); combination.add(new ParameterSet(int64, int64, int64)); combination.add(new ParameterSet(single, single, single)); combination.add(new ParameterSet(double_, double_, double_)); combination.add(new ParameterSet(decimal, decimal, decimal)); combination.add(new ParameterSet(boolean_, string, string)); combination.add(new ParameterSet(boolean_, time, time)); combination.add(new ParameterSet(boolean_, datetime, datetime)); combination.add(new ParameterSet(boolean_, datetimeoffset, datetimeoffset)); combination.add(new ParameterSet(boolean_, guid, guid)); combination.add(new ParameterSet(boolean_, sbyte, sbyte)); combination.add(new ParameterSet(boolean_, byte_, byte_)); combination.add(new ParameterSet(boolean_, int16, int16)); combination.add(new ParameterSet(boolean_, int32, int32)); combination.add(new ParameterSet(boolean_, int64, int64));
@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { EdmType xxx = actualParameterTypes.get(actualParameterTypes.size() - 1); return new ParameterSet(xxx, null); // return actualParameterTypes.get(actualParameterTypes.size() - 1); }
@Override public EdmType getReturnType() { int parameterCount = combinations.size(); if (parameterCount == 0) { return null; } if (parameterCount == 1) { return combinations.get(0).getReturnType(); } // There are more than 1 possible return type, check if they are equal, if not return null. EdmType returnType = combinations.get(0).getReturnType(); for (int i = 1; i < parameterCount; i++) { if (returnType != combinations.get(i)) { return null; } } return returnType; }
@Override public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError { if (combinations.size() == 0) { return new ParameterSet(null, null); } // first check for exact parameter combination for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, false); if (s) { return parameterSet; } } // first check for parameter combination with promotion for (ParameterSet parameterSet : combinations) { boolean s = parameterSet.equals(actualParameterTypes, true); if (s) { return parameterSet; } } return null; }
protected void validateUnaryOperatorTypes(final UnaryExpression unaryExpression) throws ExpressionParserInternalError { InfoUnaryOperator unOpt = availableUnaryOperators.get(unaryExpression.getOperator().toUriLiteral()); EdmType operandType = unaryExpression.getOperand().getEdmType(); if ((operandType == null) && (resourceEntityType == null)) { return; } List<EdmType> actualParameterTypes = new ArrayList<EdmType>(); actualParameterTypes.add(operandType); ParameterSet parameterSet = unOpt.validateParameterSet(actualParameterTypes); if (parameterSet != null) { unaryExpression.setEdmType(parameterSet.getReturnType()); } }
protected void validateUnaryOperatorTypes(final UnaryExpression unaryExpression) throws ExpressionParserInternalError { InfoUnaryOperator unOpt = availableUnaryOperators.get(unaryExpression.getOperator().toUriLiteral()); EdmType operandType = unaryExpression.getOperand().getEdmType(); if ((operandType == null) && (resourceEntityType == null)) { return; } List<EdmType> actualParameterTypes = new ArrayList<EdmType>(); actualParameterTypes.add(operandType); ParameterSet parameterSet = unOpt.validateParameterSet(actualParameterTypes); if (parameterSet != null) { unaryExpression.setEdmType(parameterSet.getReturnType()); } }
protected void validateUnaryOperatorTypes(final UnaryExpression unaryExpression) throws ExpressionParserInternalError { InfoUnaryOperator unOpt = availableUnaryOperators.get(unaryExpression.getOperator().toUriLiteral()); EdmType operandType = unaryExpression.getOperand().getEdmType(); if ((operandType == null) && (resourceEntityType == null)) { return; } List<EdmType> actualParameterTypes = new ArrayList<EdmType>(); actualParameterTypes.add(operandType); ParameterSet parameterSet = unOpt.validateParameterSet(actualParameterTypes); if (parameterSet != null) { unaryExpression.setEdmType(parameterSet.getReturnType()); } }
protected void validateMethodTypes(final MethodExpression methodExpression, final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError { InfoMethod methOpt = availableMethods.get(methodExpression.getUriLiteral()); List<EdmType> actualParameterTypes = new ArrayList<EdmType>(); // If there are no parameter then don't perform a type check if (methodExpression.getParameters().isEmpty()) { return; } for (CommonExpression parameter : methodExpression.getParameters()) { // If there is not at parsing time its not possible to determine the type of eg myPropertyName. // Since this should not cause validation errors null type node arguments are leading to bypass // the validation if (parameter.getEdmType() == null && resourceEntityType == null) { return; } actualParameterTypes.add(parameter.getEdmType()); } ParameterSet parameterSet = methOpt.validateParameterSet(actualParameterTypes); // If there is not returntype then the input parameter if (parameterSet == null) { // Tested with TestParserExceptions.testPMvalidateMethodTypes CASE 1 throw FilterParserExceptionImpl.createMETHOD_WRONG_INPUT_TYPE((MethodExpressionImpl) methodExpression, methodToken, curExpression); } methodExpression.setEdmType(parameterSet.getReturnType()); }
protected void validateMethodTypes(final MethodExpression methodExpression, final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError { InfoMethod methOpt = availableMethods.get(methodExpression.getUriLiteral()); List<EdmType> actualParameterTypes = new ArrayList<EdmType>(); // If there are no parameter then don't perform a type check if (methodExpression.getParameters().isEmpty()) { return; } for (CommonExpression parameter : methodExpression.getParameters()) { // If there is not at parsing time its not possible to determine the type of eg myPropertyName. // Since this should not cause validation errors null type node arguments are leading to bypass // the validation if (parameter.getEdmType() == null && resourceEntityType == null) { return; } actualParameterTypes.add(parameter.getEdmType()); } ParameterSet parameterSet = methOpt.validateParameterSet(actualParameterTypes); // If there is not returntype then the input parameter if (parameterSet == null) { // Tested with TestParserExceptions.testPMvalidateMethodTypes CASE 1 throw FilterParserExceptionImpl.createMETHOD_WRONG_INPUT_TYPE((MethodExpressionImpl) methodExpression, methodToken, curExpression); } methodExpression.setEdmType(parameterSet.getReturnType()); }