Package eu.europa.ted.efx.xpath
Class XPathScriptGenerator
- java.lang.Object
-
- eu.europa.ted.efx.xpath.XPathScriptGenerator
-
- All Implemented Interfaces:
ScriptGenerator
public class XPathScriptGenerator extends Object implements ScriptGenerator
-
-
Constructor Summary
Constructors Constructor Description XPathScriptGenerator()
-
Method Summary
-
-
-
Method Detail
-
composeNodeReferenceWithPredicate
public <T extends Expression> T composeNodeReferenceWithPredicate(Expression.PathExpression nodeReference, Expression.BooleanExpression predicate, Class<T> type)
Description copied from interface:ScriptGeneratorGiven a PathExpression and a predicate, this method should return the target language script for matching the subset of nodes in the PathExpression that match the predicate. Similar toScriptGenerator.composeFieldReferenceWithPredicate(eu.europa.ted.efx.model.Expression.PathExpression, eu.europa.ted.efx.model.Expression.BooleanExpression, java.lang.Class<T>)but for nodes. Quick reminder: the difference between fields and nodes is that fields contain values, while nodes contain other nodes and/or fields.- Specified by:
composeNodeReferenceWithPredicatein interfaceScriptGenerator
-
composeFieldReferenceWithPredicate
public <T extends Expression> T composeFieldReferenceWithPredicate(Expression.PathExpression fieldReference, Expression.BooleanExpression predicate, Class<T> type)
Description copied from interface:ScriptGeneratorGiven a PathExpression and a predicate, this method should return the target language script for matching the subset of nodes in the PathExpression that match the predicate. Similar toScriptGenerator.composeNodeReferenceWithPredicate(eu.europa.ted.efx.model.Expression.PathExpression, eu.europa.ted.efx.model.Expression.BooleanExpression, java.lang.Class<T>)but for fields. Quick reminder: the difference between fields and nodes is that fields contain values, while nodes contain other nodes and/or fields.- Specified by:
composeFieldReferenceWithPredicatein interfaceScriptGenerator
-
composeFieldReferenceWithAxis
public <T extends Expression> T composeFieldReferenceWithAxis(Expression.PathExpression fieldReference, String axis, Class<T> type)
- Specified by:
composeFieldReferenceWithAxisin interfaceScriptGenerator
-
composeFieldValueReference
public <T extends Expression> T composeFieldValueReference(Expression.PathExpression fieldReference, Class<T> type)
Description copied from interface:ScriptGeneratorGiven a PathExpression, this method should return the target language script for retrieving the value of the field.- Specified by:
composeFieldValueReferencein interfaceScriptGenerator
-
composeFieldAttributeReference
public <T extends Expression> T composeFieldAttributeReference(Expression.PathExpression fieldReference, String attribute, Class<T> type)
Description copied from interface:ScriptGeneratorGiven a PathExpression and an attribute name, this method should return the target language script for retrieving the value of the attribute.- Specified by:
composeFieldAttributeReferencein interfaceScriptGenerator
-
composeVariableReference
public <T extends Expression> T composeVariableReference(String variableName, Class<T> type)
Description copied from interface:ScriptGeneratorGiven a variable name this method should return script to dereference the variable. The returned Expression should be of the indicated type.- Specified by:
composeVariableReferencein interfaceScriptGenerator
-
composeVariableDeclaration
public <T extends Expression> T composeVariableDeclaration(String variableName, Class<T> type)
- Specified by:
composeVariableDeclarationin interfaceScriptGenerator
-
composeParameterDeclaration
public <T extends Expression> T composeParameterDeclaration(String parameterName, Class<T> type)
- Specified by:
composeParameterDeclarationin interfaceScriptGenerator
-
composeList
public <T extends Expression,L extends Expression.ListExpression<T>> L composeList(List<T> list, Class<L> type)
Description copied from interface:ScriptGeneratorTakes a list of string expressions and returns the target language script that corresponds to a list of string expressions.- Specified by:
composeListin interfaceScriptGenerator
-
getNumericLiteralEquivalent
public Expression.NumericExpression getNumericLiteralEquivalent(String literal)
Description copied from interface:ScriptGeneratorReturns the numeric literal passed in target language script. The passed literal is in EFX.- Specified by:
getNumericLiteralEquivalentin interfaceScriptGenerator
-
getStringLiteralEquivalent
public Expression.StringExpression getStringLiteralEquivalent(String literal)
Description copied from interface:ScriptGeneratorReturns the string literal in the target language. Note that the string literal passed as a parameter is already between quotes in EFX.- Specified by:
getStringLiteralEquivalentin interfaceScriptGenerator
-
getBooleanEquivalent
public Expression.BooleanExpression getBooleanEquivalent(boolean value)
Description copied from interface:ScriptGeneratorTakes a Java Boolean value and returns the corresponding target language script.- Specified by:
getBooleanEquivalentin interfaceScriptGenerator
-
getDateLiteralEquivalent
public Expression.DateExpression getDateLiteralEquivalent(String literal)
- Specified by:
getDateLiteralEquivalentin interfaceScriptGenerator
-
getTimeLiteralEquivalent
public Expression.TimeExpression getTimeLiteralEquivalent(String literal)
- Specified by:
getTimeLiteralEquivalentin interfaceScriptGenerator
-
getDurationLiteralEquivalent
public Expression.DurationExpression getDurationLiteralEquivalent(String literal)
- Specified by:
getDurationLiteralEquivalentin interfaceScriptGenerator
-
composeContainsCondition
public <T extends Expression,L extends Expression.ListExpression<T>> Expression.BooleanExpression composeContainsCondition(T needle, L haystack)
Description copied from interface:ScriptGeneratorReturns the target language script that checks whether a given list of values (haystack) contains a given value (needle).- Specified by:
composeContainsConditionin interfaceScriptGenerator
-
composePatternMatchCondition
public Expression.BooleanExpression composePatternMatchCondition(Expression.StringExpression expression, String pattern)
Description copied from interface:ScriptGeneratorReturns the target language script that checks whether a given string matches the given RegEx pattern.- Specified by:
composePatternMatchConditionin interfaceScriptGenerator
-
composeAllSatisfy
public <T extends Expression> Expression.BooleanExpression composeAllSatisfy(Expression.ListExpression<T> list, String variableName, Expression.BooleanExpression booleanExpression)
- Specified by:
composeAllSatisfyin interfaceScriptGenerator
-
composeAllSatisfy
public <T extends Expression> Expression.BooleanExpression composeAllSatisfy(Expression.IteratorListExpression iterators, Expression.BooleanExpression booleanExpression)
- Specified by:
composeAllSatisfyin interfaceScriptGenerator
-
composeAnySatisfies
public <T extends Expression> Expression.BooleanExpression composeAnySatisfies(Expression.ListExpression<T> list, String variableName, Expression.BooleanExpression booleanExpression)
- Specified by:
composeAnySatisfiesin interfaceScriptGenerator
-
composeAnySatisfies
public <T extends Expression> Expression.BooleanExpression composeAnySatisfies(Expression.IteratorListExpression iterators, Expression.BooleanExpression booleanExpression)
- Specified by:
composeAnySatisfiesin interfaceScriptGenerator
-
composeConditionalExpression
public <T extends Expression> T composeConditionalExpression(Expression.BooleanExpression condition, T whenTrue, T whenFalse, Class<T> type)
- Specified by:
composeConditionalExpressionin interfaceScriptGenerator
-
composeForExpression
public <T1 extends Expression,L1 extends Expression.ListExpression<T1>,T2 extends Expression,L2 extends Expression.ListExpression<T2>> L2 composeForExpression(String variableName, L1 sourceList, T2 expression, Class<L2> targetListType)
- Specified by:
composeForExpressionin interfaceScriptGenerator
-
composeForExpression
public <T2 extends Expression,L2 extends Expression.ListExpression<T2>> L2 composeForExpression(Expression.IteratorListExpression iterators, T2 expression, Class<L2> targetListType)
- Specified by:
composeForExpressionin interfaceScriptGenerator
-
composeIteratorExpression
public <T extends Expression,L extends Expression.ListExpression<T>> Expression.IteratorExpression composeIteratorExpression(String variableName, L sourceList)
- Specified by:
composeIteratorExpressionin interfaceScriptGenerator
-
composeIteratorExpression
public Expression.IteratorExpression composeIteratorExpression(String variableName, Expression.PathExpression pathExpression)
- Specified by:
composeIteratorExpressionin interfaceScriptGenerator
-
composeIteratorList
public Expression.IteratorListExpression composeIteratorList(List<Expression.IteratorExpression> iterators)
- Specified by:
composeIteratorListin interfaceScriptGenerator
-
composeParenthesizedExpression
public <T extends Expression> T composeParenthesizedExpression(T expression, Class<T> type)
Description copied from interface:ScriptGeneratorReturns the given expression parenthesized in the target language.- Specified by:
composeParenthesizedExpressionin interfaceScriptGenerator
-
composeExternalReference
public Expression.PathExpression composeExternalReference(Expression.StringExpression externalReference)
Description copied from interface:ScriptGeneratorWhen we need data from an external source, we need some script that gets that data. Getting the data is a two-step process: a) we need to access the data source, b) we need to get the actual data from the data source. This method should return the target language script that connects to the data source and permits us to subsequently get the data by using a PathExpression.- Specified by:
composeExternalReferencein interfaceScriptGenerator
-
composeFieldInExternalReference
public Expression.PathExpression composeFieldInExternalReference(Expression.PathExpression externalReference, Expression.PathExpression fieldReference)
Description copied from interface:ScriptGeneratorSeeScriptGenerator.composeExternalReference(eu.europa.ted.efx.model.Expression.StringExpression)for more details.- Specified by:
composeFieldInExternalReferencein interfaceScriptGenerator
-
joinPaths
public Expression.PathExpression joinPaths(Expression.PathExpression first, Expression.PathExpression second)
Description copied from interface:ScriptGeneratorJoins two given path expressions into one by placing the second after the first and using the proper delimiter.- Specified by:
joinPathsin interfaceScriptGenerator- Parameters:
first- The part of the path that goes before the delimiter.second- The part of the path that goes after the delimiter.- Returns:
-
composeLogicalAnd
public Expression.BooleanExpression composeLogicalAnd(Expression.BooleanExpression leftOperand, Expression.BooleanExpression rightOperand)
BooleanExpressions- Specified by:
composeLogicalAndin interfaceScriptGenerator
-
composeLogicalOr
public Expression.BooleanExpression composeLogicalOr(Expression.BooleanExpression leftOperand, Expression.BooleanExpression rightOperand)
Description copied from interface:ScriptGeneratorReturns the target language script for performing a logical OR operation on the two given operands.- Specified by:
composeLogicalOrin interfaceScriptGenerator
-
composeLogicalNot
public Expression.BooleanExpression composeLogicalNot(Expression.BooleanExpression condition)
Description copied from interface:ScriptGeneratorReturns the target language script for performing a logical NOT operation on the given boolean expression.- Specified by:
composeLogicalNotin interfaceScriptGenerator
-
composeExistsCondition
public Expression.BooleanExpression composeExistsCondition(Expression.PathExpression reference)
- Specified by:
composeExistsConditionin interfaceScriptGenerator
-
composeUniqueValueCondition
public Expression.BooleanExpression composeUniqueValueCondition(Expression.PathExpression needle, Expression.PathExpression haystack)
- Specified by:
composeUniqueValueConditionin interfaceScriptGenerator
-
composeContainsCondition
public Expression.BooleanExpression composeContainsCondition(Expression.StringExpression haystack, Expression.StringExpression needle)
Boolean functions- Specified by:
composeContainsConditionin interfaceScriptGenerator
-
composeStartsWithCondition
public Expression.BooleanExpression composeStartsWithCondition(Expression.StringExpression text, Expression.StringExpression startsWith)
- Specified by:
composeStartsWithConditionin interfaceScriptGenerator
-
composeEndsWithCondition
public Expression.BooleanExpression composeEndsWithCondition(Expression.StringExpression text, Expression.StringExpression endsWith)
- Specified by:
composeEndsWithConditionin interfaceScriptGenerator
-
composeComparisonOperation
public Expression.BooleanExpression composeComparisonOperation(Expression leftOperand, String operator, Expression rightOperand)
Description copied from interface:ScriptGeneratorReturns the target language script that compares the two operands (for equality etc.).- Specified by:
composeComparisonOperationin interfaceScriptGeneratoroperator- The EFX operator that is used to compare the two operands. Do not forget to translate the operator to the target language equivalent.
-
composeSequenceEqualFunction
public Expression.BooleanExpression composeSequenceEqualFunction(Expression.ListExpressionBase one, Expression.ListExpressionBase two)
- Specified by:
composeSequenceEqualFunctionin interfaceScriptGenerator
-
composeCountOperation
public Expression.NumericExpression composeCountOperation(Expression.PathExpression nodeSet)
Numeric functions- Specified by:
composeCountOperationin interfaceScriptGenerator
-
composeCountOperation
public Expression.NumericExpression composeCountOperation(Expression.ListExpressionBase list)
- Specified by:
composeCountOperationin interfaceScriptGenerator
-
composeToNumberConversion
public Expression.NumericExpression composeToNumberConversion(Expression.StringExpression text)
- Specified by:
composeToNumberConversionin interfaceScriptGenerator
-
composeSumOperation
public Expression.NumericExpression composeSumOperation(Expression.PathExpression nodeSet)
- Specified by:
composeSumOperationin interfaceScriptGenerator
-
composeSumOperation
public Expression.NumericExpression composeSumOperation(Expression.NumericListExpression nodeSet)
- Specified by:
composeSumOperationin interfaceScriptGenerator
-
composeStringLengthCalculation
public Expression.NumericExpression composeStringLengthCalculation(Expression.StringExpression text)
- Specified by:
composeStringLengthCalculationin interfaceScriptGenerator
-
composeNumericOperation
public Expression.NumericExpression composeNumericOperation(Expression.NumericExpression leftOperand, String operator, Expression.NumericExpression rightOperand)
Description copied from interface:ScriptGeneratorGiven a numeric operation, this method should return the target language script that performs the operation.- Specified by:
composeNumericOperationin interfaceScriptGeneratoroperator- The EFX intended operator. Do not forget to translate the operator to the target language equivalent.
-
composeSubstringExtraction
public Expression.StringExpression composeSubstringExtraction(Expression.StringExpression text, Expression.NumericExpression start, Expression.NumericExpression length)
String functions- Specified by:
composeSubstringExtractionin interfaceScriptGenerator
-
composeSubstringExtraction
public Expression.StringExpression composeSubstringExtraction(Expression.StringExpression text, Expression.NumericExpression start)
- Specified by:
composeSubstringExtractionin interfaceScriptGenerator
-
composeToStringConversion
public Expression.StringExpression composeToStringConversion(Expression.NumericExpression number)
- Specified by:
composeToStringConversionin interfaceScriptGenerator
-
composeStringConcatenation
public Expression.StringExpression composeStringConcatenation(List<Expression.StringExpression> list)
- Specified by:
composeStringConcatenationin interfaceScriptGenerator
-
composeNumberFormatting
public Expression.StringExpression composeNumberFormatting(Expression.NumericExpression number, Expression.StringExpression format)
- Specified by:
composeNumberFormattingin interfaceScriptGenerator
-
getStringLiteralFromUnquotedString
public Expression.StringExpression getStringLiteralFromUnquotedString(String value)
Description copied from interface:ScriptGeneratorGets a piece of text and returns it inside quotes as expected by the target language.- Specified by:
getStringLiteralFromUnquotedStringin interfaceScriptGenerator- Returns:
-
composeToDateConversion
public Expression.DateExpression composeToDateConversion(Expression.StringExpression date)
Date functions- Specified by:
composeToDateConversionin interfaceScriptGenerator
-
composeAddition
public Expression.DateExpression composeAddition(Expression.DateExpression date, Expression.DurationExpression duration)
- Specified by:
composeAdditionin interfaceScriptGenerator
-
composeSubtraction
public Expression.DateExpression composeSubtraction(Expression.DateExpression date, Expression.DurationExpression duration)
- Specified by:
composeSubtractionin interfaceScriptGenerator
-
composeToTimeConversion
public Expression.TimeExpression composeToTimeConversion(Expression.StringExpression time)
Time functions- Specified by:
composeToTimeConversionin interfaceScriptGenerator
-
composeToDayTimeDurationConversion
public Expression.DurationExpression composeToDayTimeDurationConversion(Expression.StringExpression text)
Duration functions- Specified by:
composeToDayTimeDurationConversionin interfaceScriptGenerator
-
composeToYearMonthDurationConversion
public Expression.DurationExpression composeToYearMonthDurationConversion(Expression.StringExpression text)
- Specified by:
composeToYearMonthDurationConversionin interfaceScriptGenerator
-
composeSubtraction
public Expression.DurationExpression composeSubtraction(Expression.DateExpression startDate, Expression.DateExpression endDate)
- Specified by:
composeSubtractionin interfaceScriptGenerator
-
composeMultiplication
public Expression.DurationExpression composeMultiplication(Expression.NumericExpression number, Expression.DurationExpression duration)
- Specified by:
composeMultiplicationin interfaceScriptGenerator
-
composeAddition
public Expression.DurationExpression composeAddition(Expression.DurationExpression left, Expression.DurationExpression right)
- Specified by:
composeAdditionin interfaceScriptGenerator
-
composeSubtraction
public Expression.DurationExpression composeSubtraction(Expression.DurationExpression left, Expression.DurationExpression right)
- Specified by:
composeSubtractionin interfaceScriptGenerator
-
composeDistinctValuesFunction
public <T extends Expression,L extends Expression.ListExpression<T>> L composeDistinctValuesFunction(L list, Class<L> listType)
- Specified by:
composeDistinctValuesFunctionin interfaceScriptGenerator
-
composeUnionFunction
public <T extends Expression,L extends Expression.ListExpression<T>> L composeUnionFunction(L listOne, L listTwo, Class<L> listType)
- Specified by:
composeUnionFunctionin interfaceScriptGenerator
-
composeIntersectFunction
public <T extends Expression,L extends Expression.ListExpression<T>> L composeIntersectFunction(L listOne, L listTwo, Class<L> listType)
- Specified by:
composeIntersectFunctionin interfaceScriptGenerator
-
composeExceptFunction
public <T extends Expression,L extends Expression.ListExpression<T>> L composeExceptFunction(L listOne, L listTwo, Class<L> listType)
- Specified by:
composeExceptFunctionin interfaceScriptGenerator
-
-