/** * Replace all the ${} tokens with the specified String. * <p/> * For example, if the input string is "xxxx ${A} xxxxx ${B} ..." and the * replacement String "?", this method will return "xxxx ? xxxxx ? ...". * * @param string The String on which to perform the replacement. * @param replacement The replacement string. * @return The String with the tokens replaced. */ public static String replaceTokens(String string, String replacement) { List<String> tokens = getTokens(string); // Could obviously do this more efficiently by matching and finding // and using a StringBuilder, but this is fine for now :-) for (String token : tokens) { string = string.replace("${" + token + "}", replacement); } return string; } }
private SplitFilenameFilter(String filenamePattern) { // Convert the filename pattern to a regexp... String pattern = DollarBraceDecoder.replaceTokens(filenamePattern, ".*"); regexPattern = Pattern.compile(pattern); }
public StatementExec(String statementString) throws SmooksConfigurationException { AssertArgument.isNotNull(statementString, "statementString"); statement = XmlUtil.removeEntities(statementString).trim(); if (statement.toLowerCase().startsWith("select")) { statementType = StatementType.QUERY; } else { statementType = StatementType.UPDATE; updateStatementTemplate = new MVELTemplate(statement); } // The input payload can be a List<Map> (result set)and the statement can look // like "select * from ORDER_DETAIL_SOURCE where ORD_ID = ${ORD_ID} and ORD_CD = ${ORD_CD}", // where the ${} tokens denote one or more field/column names in the payload List<Map> rows. These // tokens will be used to extract values from the input rows (Map) to populate the PreparedStatment. List<String> statementExecFields = DollarBraceDecoder.getTokens(statement); intitialiseStatementExpressions(statementExecFields); statement = DollarBraceDecoder.replaceTokens(statement, "?"); isJoin = !statementExecFields.isEmpty(); }
public StatementExec(String statementString) throws SmooksConfigurationException { AssertArgument.isNotNull(statementString, "statementString"); statement = XmlUtil.removeEntities(statementString).trim(); if (statement.toLowerCase().startsWith("select")) { statementType = StatementType.QUERY; } else { statementType = StatementType.UPDATE; updateStatementTemplate = new MVELTemplate(statement); } // The input payload can be a List<Map> (result set)and the statement can look // like "select * from ORDER_DETAIL_SOURCE where ORD_ID = ${ORD_ID} and ORD_CD = ${ORD_CD}", // where the ${} tokens denote one or more field/column names in the payload List<Map> rows. These // tokens will be used to extract values from the input rows (Map) to populate the PreparedStatment. List<String> statementExecFields = DollarBraceDecoder.getTokens(statement); intitialiseStatementExpressions(statementExecFields); statement = DollarBraceDecoder.replaceTokens(statement, "?"); isJoin = !statementExecFields.isEmpty(); }
/** * Replace all the ${} tokens with the specified String. * <p/> * For example, if the input string is "xxxx ${A} xxxxx ${B} ..." and the * replacement String "?", this method will return "xxxx ? xxxxx ? ...". * * @param string The String on which to perform the replacement. * @param replacement The replacement string. * @return The String with the tokens replaced. */ public static String replaceTokens(String string, String replacement) { List<String> tokens = getTokens(string); // Could obviously do this more efficiently by matching and finding // and using a StringBuilder, but this is fine for now :-) for (String token : tokens) { string = string.replace("${" + token + "}", replacement); } return string; } }
private SplitFilenameFilter(String filenamePattern) { // Convert the filename pattern to a regexp... String pattern = DollarBraceDecoder.replaceTokens(filenamePattern, ".*"); regexPattern = Pattern.compile(pattern); }
/** * Replace all the ${} tokens with the specified String. * <p/> * For example, if the input string is "xxxx ${A} xxxxx ${B} ..." and the * replacement String "?", this method will return "xxxx ? xxxxx ? ...". * * @param string The String on which to perform the replacement. * @param replacement The replacement string. * @return The String with the tokens replaced. */ public static String replaceTokens(String string, String replacement) { List<String> tokens = getTokens(string); // Could obviously do this more efficiently by matching and finding // and using a StringBuilder, but this is fine for now :-) for (String token : tokens) { string = string.replace("${" + token + "}", replacement); } return string; } }
private void expandSelector(SmooksResourceConfiguration resourceConfiguration, boolean failOnMissingBean, SmooksResourceConfiguration context) { SelectorStep[] selectorSteps = resourceConfiguration.getSelectorSteps(); QName targetElement = selectorSteps[0].getTargetElement(); if(targetElement == null) { return; } String localPart = targetElement.getLocalPart(); if(localPart.equals("#") && context != null) { resourceConfiguration.setSelectorSteps(concat(context.getSelectorSteps(), selectorSteps)); return; } List<String> dollarBraceTokens = DollarBraceDecoder.getTokens(localPart); if(dollarBraceTokens.size() == 1) { String beanId = dollarBraceTokens.get(0); Bean bean = baseBeans.get(beanId); if(bean != null) { resourceConfiguration.setSelectorSteps(concat(bean.getConfig().getSelectorSteps(), selectorSteps)); } else if(failOnMissingBean) { throw new SmooksConfigurationException("Invalid selector '" + SelectorStepBuilder.toString(selectorSteps) + "'. Unknown beanId '" + beanId + "'."); } } }
private void expandSelector(SmooksResourceConfiguration resourceConfiguration, boolean failOnMissingBean, SmooksResourceConfiguration context) { SelectorStep[] selectorSteps = resourceConfiguration.getSelectorSteps(); QName targetElement = selectorSteps[0].getTargetElement(); if(targetElement == null) { return; } String localPart = targetElement.getLocalPart(); if(localPart.equals("#") && context != null) { resourceConfiguration.setSelectorSteps(concat(context.getSelectorSteps(), selectorSteps)); return; } List<String> dollarBraceTokens = DollarBraceDecoder.getTokens(localPart); if(dollarBraceTokens.size() == 1) { String beanId = dollarBraceTokens.get(0); Bean bean = baseBeans.get(beanId); if(bean != null) { resourceConfiguration.setSelectorSteps(concat(bean.getConfig().getSelectorSteps(), selectorSteps)); } else if(failOnMissingBean) { throw new SmooksConfigurationException("Invalid selector '" + SelectorStepBuilder.toString(selectorSteps) + "'. Unknown beanId '" + beanId + "'."); } } }
private void expandSelector(SmooksResourceConfiguration resourceConfiguration, boolean failOnMissingBean, SmooksResourceConfiguration context) { SelectorStep[] selectorSteps = resourceConfiguration.getSelectorSteps(); QName targetElement = selectorSteps[0].getTargetElement(); if(targetElement == null) { return; } String localPart = targetElement.getLocalPart(); if(localPart.equals("#") && context != null) { resourceConfiguration.setSelectorSteps(concat(context.getSelectorSteps(), selectorSteps)); return; } List<String> dollarBraceTokens = DollarBraceDecoder.getTokens(localPart); if(dollarBraceTokens.size() == 1) { String beanId = dollarBraceTokens.get(0); Bean bean = baseBeans.get(beanId); if(bean != null) { resourceConfiguration.setSelectorSteps(concat(bean.getConfig().getSelectorSteps(), selectorSteps)); } else if(failOnMissingBean) { throw new SmooksConfigurationException("Invalid selector '" + SelectorStepBuilder.toString(selectorSteps) + "'. Unknown beanId '" + beanId + "'."); } } }