Example usage for com.fasterxml.jackson.core JsonPointer toString

List of usage examples for com.fasterxml.jackson.core JsonPointer toString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonPointer toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.reprezen.swagedit.schema.TypeDefinition.java

protected static String getProperty(JsonPointer pointer) {
    String s = pointer.toString();
    return s.substring(s.lastIndexOf("/") + 1).replaceAll("~1", "/");
}

From source file:org.forgerock.openig.migrate.action.traverse.path.PathVisitor.java

@Override
public void visitNode(final JsonNode node, final JsonPointer pointer) {
    if (pattern.matcher(pointer.toString()).matches()) {
        matches.add(new Match(node, pointer));
    }// ww w .  j a  va 2  s  . c o m
}

From source file:com.reprezen.swagedit.editor.hyperlinks.JsonReferenceHyperlinkDetector.java

@Override
protected boolean canDetect(JsonPointer pointer) {
    return pointer != null && pointer.toString().endsWith("$ref");
}

From source file:com.reprezen.swagedit.editor.hyperlinks.DefinitionHyperlinkDetector.java

@Override
protected boolean canDetect(JsonPointer pointer) {
    return pointer != null
            && (pointer.toString().matches(REQUIRED_PATTERN) || pointer.toString().matches(TAGS_PATTERN));
}

From source file:com.reprezen.swagedit.editor.hyperlinks.DefinitionHyperlinkDetector.java

@Override
protected IHyperlink[] doDetect(SwaggerDocument doc, ITextViewer viewer, HyperlinkInfo info,
        JsonPointer pointer) {
    JsonPointer targetPath;/*  w  w  w  .  j a  v  a 2  s.c o m*/
    if (pointer.toString().matches(REQUIRED_PATTERN)) {
        targetPath = getRequiredPropertyPath(doc, info, pointer);
    } else {
        targetPath = getTagDefinitionPath(doc, info, pointer);
    }

    if (targetPath == null) {
        return null;
    }

    IRegion target = doc.getRegion(targetPath);
    if (target == null) {
        return null;
    }

    return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
}

From source file:com.reprezen.swagedit.editor.hyperlinks.PathParamHyperlinkDetector.java

@Override
protected boolean canDetect(JsonPointer pointer) {
    return pointer != null && pointer.toString().startsWith("/paths");
}

From source file:com.reprezen.swagedit.editor.hyperlinks.DefinitionHyperlinkDetector.java

protected JsonPointer getRequiredPropertyPath(SwaggerDocument doc, HyperlinkInfo info, JsonPointer pointer) {
    Matcher matcher = Pattern.compile(REQUIRED_PATTERN).matcher(pointer.toString());
    String containerPath = null;/*from   w  ww . j  a va  2  s.c  om*/
    if (matcher.find()) {
        containerPath = matcher.group(1);
    }

    if (emptyToNull(containerPath) == null) {
        return null;
    }

    AbstractNode container = doc.getModel().find(JsonPointer.compile(containerPath));
    if (container.get("properties") != null && container.get("properties").get(info.text) != null) {
        return container.get("properties").get(info.text).getPointer();
    } else {
        return null;
    }
}

From source file:org.forgerock.openig.migrate.action.InlineDeclarationsAction.java

private String lastSegmentOf(final JsonPointer pointer) {
    String ser = pointer.toString();
    int i = ser.lastIndexOf('/');
    return ser.substring(i + 1);
}

From source file:org.forgerock.openig.migrate.action.InlineDeclarationsAction.java

private JsonPointer parentOf(final JsonPointer pointer) {
    String ser = pointer.toString();
    int i = ser.lastIndexOf('/');
    return JsonPointer.compile(ser.substring(0, i));
}

From source file:org.forgerock.openig.migrate.action.traverse.NodeTraversal.java

private void traverse(JsonNode node, JsonPointer pointer, NodeVisitor visitor) {
    if (node.isArray()) {
        int index = 0;
        for (JsonNode child : node) {
            traverse(child, compile(format("%s/%d", pointer.toString(), index++)), visitor);
        }/* ww  w  .j  a  v  a 2 s.co m*/
    } else if (node.isObject()) {
        Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();
        while (iterator.hasNext()) {
            Map.Entry<String, JsonNode> entry = iterator.next();
            traverse(entry.getValue(), compile(format("%s/%s", pointer.toString(), entry.getKey())), visitor);

        }
    }
    visitor.visitNode(node, pointer);
}