Class DataDTOToMVELTranslator
java.lang.Object
org.broadleafcommerce.openadmin.web.rulebuilder.DataDTOToMVELTranslator
Utility class to convert a DataDTO/ExpressionDTO into an MVEL string
- Author:
- Elbert Bautista (elbertbautista)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildCollectionExpression(StringBuffer sb, String entityKey, String field, Object[] value, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, String operator, boolean includeParenthesis, boolean isFieldComparison, boolean ignoreCase, boolean isNegation, boolean ignoreQuotes) protected voidbuildExpression(StringBuffer sb, String entityKey, String field, Object[] value, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, String operator, boolean includeParenthesis, boolean isFieldComparison, boolean ignoreCase, boolean isNegation, boolean ignoreQuotes) protected voidbuildExpression(ExpressionDTO expressionDTO, StringBuffer sb, String entityKey, BLCOperator operator, RuleBuilderFieldService fieldService) protected StringbuildFieldName(String entityKey, String fieldName) protected voidbuildMVEL(DataDTO dataDTO, StringBuffer sb, String entityKey, String groupOperator, RuleBuilderFieldService fieldService) createMVEL(String entityKey, DataDTO dataDTO, RuleBuilderFieldService fieldService) protected StringescapeInternalMiltyQuotes(String processedValue) protected StringescapeInternalQuotes(String processedValue) protected StringescapeStringLiteralValue(String value) Escapes a single value so that it can be placed between the double quotes of an MVEL string literal.protected Object[]extractBasicValues(Object value) protected StringformatField(String entityKey, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, String field, boolean ignoreCase) protected StringformatValue(String fieldName, String entityKey, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, Object[] value, boolean isFieldComparison, boolean ignoreCase, boolean ignoreQuotes) booleanisProjection(Object value) protected booleanisStringLiteralType(org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType)
-
Field Details
-
CONTAINS_OPERATOR
- See Also:
-
STARTS_WITH_OPERATOR
- See Also:
-
ENDS_WITH_OPERATOR
- See Also:
-
EQUALS_OPERATOR
- See Also:
-
NOT_EQUALS_OPERATOR
- See Also:
-
GREATER_THAN_EQUALS_OPERATOR
- See Also:
-
LESS_THAN_EQUALS_OPERATOR
- See Also:
-
GREATER_THAN_OPERATOR
- See Also:
-
LESS_THAN_OPERATOR
- See Also:
-
COLLECTION_OPERATOR
- See Also:
-
SIZE_GREATER_THAN_OPERATOR
- See Also:
-
SIZE_GREATER_THAN_EQUALS_OPERATOR
- See Also:
-
SIZE_LESS_THAN_OPERATOR
- See Also:
-
SIZE_LESS_THAN_EQUALS_OPERATOR
- See Also:
-
SIZE_EQUALS_OPERATOR
- See Also:
-
ZERO_OPERATOR
- See Also:
-
OLD_CONTAINS_OPERATOR
- See Also:
-
OLD_STARTS_WITH_OPERATOR
- See Also:
-
OLD_ENDS_WITH_OPERATOR
- See Also:
-
-
Constructor Details
-
DataDTOToMVELTranslator
public DataDTOToMVELTranslator()
-
-
Method Details
-
createMVEL
public String createMVEL(String entityKey, DataDTO dataDTO, RuleBuilderFieldService fieldService) throws MVELTranslationException - Throws:
MVELTranslationException
-
buildMVEL
protected void buildMVEL(DataDTO dataDTO, StringBuffer sb, String entityKey, String groupOperator, RuleBuilderFieldService fieldService) throws MVELTranslationException - Throws:
MVELTranslationException
-
buildExpression
protected void buildExpression(ExpressionDTO expressionDTO, StringBuffer sb, String entityKey, BLCOperator operator, RuleBuilderFieldService fieldService) throws MVELTranslationException - Throws:
MVELTranslationException
-
extractBasicValues
-
escapeStringLiteralValue
Escapes a single value so that it can be placed between the double quotes of an MVEL string literal. Backslashes are escaped first, so that an escaped quote cannot be turned back into a closing quote. Since every double quote is escaped, the result never starts with a double quote, soformatValue(java.lang.String, java.lang.String, org.broadleafcommerce.common.presentation.client.SupportedFieldType, org.broadleafcommerce.common.presentation.client.SupportedFieldType, java.lang.Object[], boolean, boolean, boolean)always adds the quotes itself.- Parameters:
value- the value as entered in the rule builder- Returns:
- the escaped value, without surrounding quotes
-
isStringLiteralType
protected boolean isStringLiteralType(org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType) - Returns:
- true if
formatValue(java.lang.String, java.lang.String, org.broadleafcommerce.common.presentation.client.SupportedFieldType, org.broadleafcommerce.common.presentation.client.SupportedFieldType, java.lang.Object[], boolean, boolean, boolean)writes values of the given type as quoted string literals
-
escapeInternalQuotes
-
escapeInternalMiltyQuotes
-
isProjection
-
buildCollectionExpression
protected void buildCollectionExpression(StringBuffer sb, String entityKey, String field, Object[] value, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, String operator, boolean includeParenthesis, boolean isFieldComparison, boolean ignoreCase, boolean isNegation, boolean ignoreQuotes) throws MVELTranslationException - Throws:
MVELTranslationException
-
buildExpression
protected void buildExpression(StringBuffer sb, String entityKey, String field, Object[] value, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, String operator, boolean includeParenthesis, boolean isFieldComparison, boolean ignoreCase, boolean isNegation, boolean ignoreQuotes) throws MVELTranslationException - Throws:
MVELTranslationException
-
buildFieldName
-
formatField
-
formatValue
protected String formatValue(String fieldName, String entityKey, org.broadleafcommerce.common.presentation.client.SupportedFieldType type, org.broadleafcommerce.common.presentation.client.SupportedFieldType secondaryType, Object[] value, boolean isFieldComparison, boolean ignoreCase, boolean ignoreQuotes) throws MVELTranslationException - Throws:
MVELTranslationException
-