Example usage for javax.json JsonValue getClass

List of usage examples for javax.json JsonValue getClass

Introduction

In this page you can find the example usage for javax.json JsonValue getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:nl.nn.adapterframework.align.Json2Xml.java

@Override
public Map<String, String> getAttributes(XSElementDeclaration elementDeclaration, JsonValue node)
        throws SAXException {
    if (!readAttributes) {
        return null;
    }/*  w ww . j a  v a 2s.  c  o m*/
    if (!(node instanceof JsonObject)) {
        if (DEBUG)
            log.debug("getAttributes() parent node is not a JsonObject, but a [" + node.getClass().getName()
                    + "] isParentOfSingleMultipleOccurringChildElement ["
                    + isParentOfSingleMultipleOccurringChildElement() + "]  value [" + node
                    + "], returning null");
        return null;
    }
    JsonObject o = (JsonObject) node;
    if (o.isEmpty()) {
        if (DEBUG)
            log.debug("getAttributes() no children");
        return null;
    }
    try {
        Map<String, String> result = new HashMap<String, String>();
        for (String key : o.keySet()) {
            if (key.startsWith(attributePrefix)) {
                String attributeName = key.substring(attributePrefix.length());
                String value = getText(elementDeclaration, o.get(key));
                if (DEBUG)
                    log.debug("getAttributes() attribute [" + attributeName + "] = [" + value + "]");
                result.put(attributeName, value);
            }
        }
        return result;
    } catch (JsonException e) {
        throw new SAXException(e);
    }
}

From source file:nl.nn.adapterframework.align.Json2Xml.java

@Override
public Set<String> getAllNodeChildNames(XSElementDeclaration elementDeclaration, JsonValue node)
        throws SAXException {
    if (DEBUG)/*from ww  w  .j a  v a 2  s .c o m*/
        log.debug("getAllChildNames() node isParentOfSingleMultipleOccurringChildElement ["
                + isParentOfSingleMultipleOccurringChildElement() + "] [" + node.getClass().getName() + "]["
                + node + "]");
    try {
        if (isParentOfSingleMultipleOccurringChildElement()) {
            if ((insertElementContainerElements || !strictSyntax) && node instanceof JsonArray) {
                if (DEBUG)
                    log.debug(
                            "getAllChildNames() parentOfSingleMultipleOccurringChildElement,JsonArray,(insertElementContainerElements || !strictSyntax)");
                Set<String> result = new HashSet<String>();
                result.addAll(getMultipleOccurringChildElements());
                if (DEBUG)
                    log.debug("getAllChildNames() isParentOfSingleMultipleOccurringChildElement, result ["
                            + result + "]");
                return result;
            }
            if ((insertElementContainerElements && strictSyntax) && !(node instanceof JsonArray)) {
                throw new SAXException(MSG_FULL_INPUT_IN_STRICT_COMPACTING_MODE);
            }
        }
        if (!(node instanceof JsonObject)) {
            if (DEBUG)
                log.debug("getAllChildNames() parent node is not a JsonObject, but a ["
                        + node.getClass().getName() + "] isParentOfSingleMultipleOccurringChildElement ["
                        + isParentOfSingleMultipleOccurringChildElement() + "]  value [" + node
                        + "], returning null");
            return null;
        }
        JsonObject o = (JsonObject) node;
        if (o.isEmpty()) {
            if (DEBUG)
                log.debug("getAllChildNames() no children");
            return new HashSet<String>();
        }
        Set<String> result = new HashSet<String>();
        for (String key : o.keySet()) {
            if (!readAttributes || !key.startsWith(attributePrefix)) {
                result.add(key);
                if (DEBUG)
                    log.debug("getAllChildNames() key [" + key + "] added to set");
            }
        }
        return result;
    } catch (JsonException e) {
        throw new SAXException(e);
    }
}

From source file:nl.nn.adapterframework.align.Json2Xml.java

@Override
public Iterable<JsonValue> getNodeChildrenByName(JsonValue node, XSElementDeclaration childElementDeclaration)
        throws SAXException {
    String name = childElementDeclaration.getName();
    if (DEBUG)//from w  ww.  j a  va  2s  .com
        log.debug("getChildrenByName() childname [" + name + "] isParentOfSingleMultipleOccurringChildElement ["
                + isParentOfSingleMultipleOccurringChildElement() + "] isMultipleOccuringChildElement ["
                + isMultipleOccurringChildElement(name) + "] node [" + node + "]");
    try {
        if (!(node instanceof JsonObject)) {
            if (DEBUG)
                log.debug("getChildrenByName() parent node is not a JsonObject, but a ["
                        + node.getClass().getName() + "]");
            return null;
        }
        JsonObject o = (JsonObject) node;
        if (!o.containsKey(name)) {
            if (DEBUG)
                log.debug("getChildrenByName() no children named [" + name + "] node [" + node + "]");
            return null;
        }
        JsonValue child = o.get(name);
        List<JsonValue> result = new LinkedList<JsonValue>();
        if (child instanceof JsonArray) {
            if (DEBUG)
                log.debug("getChildrenByName() child named [" + name
                        + "] is a JsonArray, current node insertElementContainerElements ["
                        + insertElementContainerElements + "]");
            // if it could be necessary to insert elementContainers, we cannot return them as a list of individual elements now, because then the containing element would be duplicated
            // we also cannot use the isSingleMultipleOccurringChildElement, because it is not valid yet
            if (!isMultipleOccurringChildElement(name)) {
                if (insertElementContainerElements || !strictSyntax) {
                    result.add(child);
                    if (DEBUG)
                        log.debug("getChildrenByName() singleMultipleOccurringChildElement [" + name
                                + "] returning array node (insertElementContainerElements=true)");
                } else {
                    throw new SAXException(MSG_EXPECTED_SINGLE_ELEMENT + " [" + name + "]");
                }
            } else {
                if (DEBUG)
                    log.debug("getChildrenByName() childname [" + name
                            + "] returning elements of array node (insertElementContainerElements=false or not singleMultipleOccurringChildElement)");
                result.addAll((JsonArray) child);
            }
            return result;
        }
        result.add(child);
        if (DEBUG)
            log.debug("getChildrenByName() name [" + name + "] returning [" + child + "]");
        return result;
    } catch (JsonException e) {
        throw new SAXException(e);
    }
}