Example usage for com.fasterxml.jackson.databind JsonNode textValue

List of usage examples for com.fasterxml.jackson.databind JsonNode textValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonNode textValue.

Prototype

public String textValue() 

Source Link

Usage

From source file:com.rusticisoftware.tincan.Activity.java

public Activity(JsonNode jsonNode) throws URISyntaxException {
    this();//from w  ww  .j  av  a  2  s.  c om

    JsonNode idNode = jsonNode.path("id");
    if (!idNode.isMissingNode()) {
        this.setId(new URI(idNode.textValue()));
    }

    JsonNode definitionNode = jsonNode.path("definition");
    if (!definitionNode.isMissingNode()) {
        this.setDefinition(new ActivityDefinition(definitionNode));
    }
}

From source file:org.eel.kitchen.jsonschema.ref.IdFragment.java

@Override
public JsonNode resolve(final JsonNode node) {
    /*/*from  w ww  . j a v a2 s.c  o m*/
     * Non object instances are not worth being considered
     */
    if (!node.isObject())
        return MissingNode.getInstance();

    /*
     * If an id node exists and is a text node, see if that node's value
     * (minus the initial #) matches our id, if yes we have a match
     */
    final JsonNode idNode = node.path("id");

    if (idNode.isTextual()) {
        final String s = idNode.textValue();
        if (asString.equals(s))
            return node;
    }

    /*
     * Otherwise, go on with children. As this is an object,
     * JsonNode will cycle through the values, which is what we want.
     */

    JsonNode ret;
    for (final JsonNode subNode : node) {
        ret = resolve(subNode);
        if (!ret.isMissingNode())
            return ret;
    }

    return MissingNode.getInstance();
}

From source file:com.rusticisoftware.tincan.StatementsResult.java

public StatementsResult(JsonNode jsonNode) throws URISyntaxException, MalformedURLException {
    this();/*  w w  w.j  av a 2  s.co m*/

    JsonNode statementsNode = jsonNode.path("statements");
    if (!statementsNode.isMissingNode()) {
        for (JsonNode element : ((ArrayNode) statementsNode)) {
            this.statements.add(new Statement(element));
        }
    }

    JsonNode moreURLNode = jsonNode.path("more");
    if (!moreURLNode.isMissingNode()) {
        this.setMoreURL(moreURLNode.textValue());
    }
}

From source file:com.rusticisoftware.tincan.Verb.java

public Verb(JsonNode jsonNode) throws URISyntaxException {
    this();/*  w  ww . j a va 2s. c  o  m*/

    JsonNode idNode = jsonNode.path("id");
    if (!idNode.isMissingNode()) {
        this.setId(new URI(idNode.textValue()));
    }

    JsonNode displayNode = jsonNode.path("display");
    if (!displayNode.isMissingNode()) {
        this.setDisplay(new LanguageMap(displayNode));
    }
}

From source file:com.github.restdriver.matchers.WithValueAt.java

@Override
public boolean matchesSafely(JsonNode node) {

    if (!node.isArray()) {
        return false;
    }/*from   w w w.j  a  v  a2s.  c o  m*/

    Iterator<JsonNode> nodeIterator = node.elements();
    int nodeCount = 0;

    while (nodeIterator.hasNext()) {

        JsonNode currentNode = nodeIterator.next();

        if (nodeCount == position) {
            return matcher.matches(currentNode.textValue());
        }

        nodeCount++;

    }

    return false;
}

From source file:org.eel.kitchen.jsonschema.keyword.AbstractTypeKeywordValidator.java

protected AbstractTypeKeywordValidator(final String keyword, final JsonNode schema) {
    super(keyword, NodeType.values());
    final JsonNode node = schema.get(keyword);

    if (node.isTextual()) {
        addSimpleType(node.textValue());
        schemas = Collections.emptyList();
        return;/*from   w w  w.j  av a 2s .co m*/
    }

    final ImmutableList.Builder<JsonNode> builder = new ImmutableList.Builder<JsonNode>();

    for (final JsonNode element : node)
        if (element.isTextual())
            addSimpleType(element.textValue());
        else
            builder.add(element);

    schemas = builder.build();
}

From source file:org.activiti.rest.service.api.legacy.deployment.DeploymentsDeleteResource.java

@Post
public ObjectNode deleteDeployments(Representation entity) {
    try {//from w  w w.j  ava 2  s  .  co m
        if (authenticate(SecuredResource.ADMIN) == false)
            return null;
        Boolean cascade = RequestUtil.getBoolean(getQuery(), "cascade", false);
        String startParams = entity.getText();
        JsonNode idJSON = new ObjectMapper().readTree(startParams);
        ArrayNode idArray = (ArrayNode) idJSON.get("deploymentIds");
        for (JsonNode deploymentId : idArray) {
            if (cascade) {
                ActivitiUtil.getRepositoryService().deleteDeployment(deploymentId.textValue(), true);
            } else {
                ActivitiUtil.getRepositoryService().deleteDeployment(deploymentId.textValue());
            }
        }
        ObjectNode successNode = new ObjectMapper().createObjectNode();
        successNode.put("success", true);
        return successNode;
    } catch (Exception e) {
        if (e instanceof ActivitiException) {
            throw (ActivitiException) e;
        }
        throw new ActivitiException("Failed to delete deployments", e);
    }
}

From source file:com.github.fge.jsonschema.keyword.validator.common.DependenciesValidator.java

public DependenciesValidator(final JsonNode digest) {
    super("dependencies");

    /*//from  ww  w. ja v a 2s .co  m
     * Property dependencies
     */
    final ImmutableMultimap.Builder<String, String> mapBuilder = ImmutableMultimap.builder();
    final Map<String, JsonNode> map = JacksonUtils.asMap(digest.get("propertyDeps"));

    String key;
    for (final Map.Entry<String, JsonNode> entry : map.entrySet()) {
        key = entry.getKey();
        for (final JsonNode element : entry.getValue())
            mapBuilder.put(key, element.textValue());
    }

    propertyDeps = mapBuilder.build();

    /*
     * Schema dependencies
     */
    final ImmutableSet.Builder<String> setBuilder = ImmutableSet.builder();

    for (final JsonNode node : digest.get("schemaDeps"))
        setBuilder.add(node.textValue());

    schemaDeps = setBuilder.build();
}

From source file:com.github.fge.jsonschema.syntax.checkers.draftv4.DraftV4TypeSyntaxChecker.java

@Override
protected void checkValue(final Collection<JsonPointer> pointers, final ProcessingReport report,
        final SchemaTree tree) throws ProcessingException {
    final JsonNode node = getNode(tree);

    if (node.isTextual()) {
        final String s = node.textValue();
        if (NodeType.fromName(s) == null)
            report.error(newMsg(tree, "incorrectPrimitiveType").put("valid", ALL_TYPES).put("found", s));
        return;/*from  w w w  .  j  a va 2s. c  o  m*/
    }

    final int size = node.size();

    if (size == 0) {
        report.error(newMsg(tree, "emptyArray"));
        return;
    }

    final Set<Equivalence.Wrapper<JsonNode>> set = Sets.newHashSet();

    JsonNode element;
    NodeType type;
    boolean uniqueElements = true;

    for (int index = 0; index < size; index++) {
        element = node.get(index);
        type = NodeType.getNodeType(element);
        uniqueElements = set.add(EQUIVALENCE.wrap(element));
        if (type != NodeType.STRING) {
            report.error(newMsg(tree, "incorrectElementType").put("index", index)
                    .put("expected", NodeType.STRING).put("found", type));
            continue;
        }
        if (NodeType.fromName(element.textValue()) == null)
            report.error(newMsg(tree, "incorrectPrimitiveType").put("index", index).put("valid", ALL_TYPES)
                    .put("found", element));
    }

    if (!uniqueElements)
        report.error(newMsg(tree, "elementsNotUnique"));
}

From source file:com.ga2sa.utils.ArrayToStringDeserializer.java

@Override
public String deserialize(JsonParser jsonParser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    List<String> array = new ArrayList<String>();
    JsonNode tree = jsonParser.readValueAsTree();
    if (tree.isArray()) {
        tree.forEach(obj -> array.add(obj.textValue()));
    } else {/*w w w .j a  va 2  s  .  c o m*/
        array.add(tree.textValue());
    }

    return StringUtils.join(array, ",");
}