@Override protected void describe(StringBuilder buf) { super.describe(buf); buf.append(format("property %s %s\n", getPropertyName(), getPropertyValue())); }
private String injectOverridenProperties(String aggregatedScript, List<String> scriptProperties) throws Exception, ScriptParseException { ScriptParserImpl parser = new ScriptParserImpl(); for (String propertyToInject : scriptProperties) { String propertyName = parser.parseWithStrategy(propertyToInject, PROPERTY_NODE).getPropertyName(); StringBuilder replacementScript = new StringBuilder(); Pattern pattern = Pattern.compile("property\\s+" + propertyName + "\\s+.+"); boolean matchFound = false; for (String scriptLine : aggregatedScript.split("\\r?\\n")) { if (pattern.matcher(scriptLine).matches()) { matchFound = true; replacementScript.append(propertyToInject + "\n"); } else { replacementScript.append(scriptLine + "\n"); } } if (!matchFound) { String errorMsg = "Received " + propertyToInject + " in PREPARE but found no where to substitute it"; LOGGER.error(errorMsg); throw new Exception(errorMsg); } aggregatedScript = replacementScript.toString(); } return aggregatedScript; }
@Override public Configuration visit(AstPropertyNode propertyNode, State state) { String propertyName = propertyNode.getPropertyName(); Object value = propertyNode.resolve(); if (value instanceof AutoCloseable) { state.configuration.getResources().add((AutoCloseable) value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", propertyName, formatValue)); } return state.configuration; }