Java Code Examples for com.fasterxml.jackson.databind.node.ValueNode#textValue()

The following examples show how to use com.fasterxml.jackson.databind.node.ValueNode#textValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlaceholderResolver.java    From styx with Apache License 2.0 6 votes vote down vote up
@Override
public void onValueNode(ValueNode node, Optional<ContainerNode<?>> parent, List<PathElement> path) {
    String value = node.isTextual() ? node.textValue() : node.toString();

    List<Placeholder> placeholders = extractPlaceholders(value);

    if (!placeholders.isEmpty()) {
        for (Placeholder placeholder : placeholders) {
            if (placeholder.hasDefaultValue()) {
                String valueWithReplacements = replacePlaceholder(value, placeholder.name(), placeholder.defaultValue());

                last(path).setChild(parent.get(), TextNode.valueOf(valueWithReplacements));

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("At {}, replaced {} with {}", new Object[]{path, value, valueWithReplacements});
                }
            }
        }
    }
}
 
Example 2
Source File: PlaceholderResolver.java    From styx with Apache License 2.0 5 votes vote down vote up
@Override
public void onValueNode(ValueNode node, Optional<ContainerNode<?>> parent, List<PathElement> pathAsList) {
    String path = new NodePath(pathAsList).toString();

    String value = node.isTextual() ? node.textValue() : node.toString();

    List<Placeholder> placeholders = extractPlaceholders(value);

    if (placeholders.isEmpty() && !resolved.containsKey(path)) {
        resolved.put(path, value);
        passAgain = true;
    } else {
        boolean changes = false;

        for (Placeholder placeholder : placeholders) {
            String replacement = resolved.get(placeholder.name());

            if (replacement != null) {
                String valueWithReplacements = replacePlaceholder(value, placeholder.name(), replacement);

                last(pathAsList).setChild(parent.get(), TextNode.valueOf(valueWithReplacements));

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("At {}, replaced {} with {}", new Object[]{pathAsList, value, valueWithReplacements});
                }

                value = valueWithReplacements;
                changes = true;
            }
        }
        passAgain |= changes;
    }
}
 
Example 3
Source File: PlaceholderResolver.java    From styx with Apache License 2.0 5 votes vote down vote up
@Override
public void onValueNode(ValueNode node, Optional<ContainerNode<?>> parent, List<PathElement> path) {
    String value = node.isTextual() ? node.textValue() : node.toString();

    List<String> placeholders = extractPlaceholderStrings(value);

    if (!placeholders.isEmpty()) {
        String pathString = new NodePath(path).toString();

        for (String placeholder : placeholders) {
            unresolvedPlaceholderDescriptions.add(new UnresolvedPlaceholder(pathString, value, placeholder));
        }
    }
}