Package javax.json

Examples of javax.json.JsonArray


  }

  private void parseChildren(ParserState<?> theState, String theName, JsonValue theJsonVal, JsonValue theAlternateVal) {
    switch (theJsonVal.getValueType()) {
    case ARRAY: {
      JsonArray nextArray = (JsonArray) theJsonVal;
      JsonArray nextAlternateArray = (JsonArray) theAlternateVal;
      for (int i = 0; i < nextArray.size(); i++) {
        JsonValue nextObject = nextArray.get(i);
        JsonValue nextAlternate = null;
        if (nextAlternateArray != null) {
          nextAlternate = nextAlternateArray.get(i);
        }
        parseChildren(theState, theName, nextObject, nextAlternate);
      }
      break;
    }
View Full Code Here


      for (Iterator<String> iter = nextExtObj.keySet().iterator(); iter.hasNext();) {
        String next = iter.next();
        if ("url".equals(next)) {
          continue;
        } else if ("extension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          parseExtension(theState, jsonVal, false);
        } else if ("modifierExtension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          parseExtension(theState, jsonVal, true);
        } else {
          JsonValue jsonVal = nextExtObj.get(next);
          parseChildren(theState, next, jsonVal, null);
        }
View Full Code Here

        continue;
      } else if ("id".equals(nextName)) {
        elementId = theObject.getString(nextName);
        continue;
      } else if ("extension".equals(nextName)) {
        JsonArray array = theObject.getJsonArray(nextName);
        parseExtension(theState, array, false);
        continue;
      } else if ("modifierExtension".equals(nextName)) {
        JsonArray array = theObject.getJsonArray(nextName);
        parseExtension(theState, array, true);
        continue;
      } else if (nextName.charAt(0) == '_') {
        continue;
      }
View Full Code Here

  private void parseBundleChildren(JsonObject theObject, ParserState<?> theState) {
    for (String nextName : theObject.keySet()) {
      if ("resourceType".equals(nextName)) {
        continue;
      } else if ("link".equals(nextName)) {
        JsonArray entries = theObject.getJsonArray(nextName);
        for (JsonValue jsonValue : entries) {
          theState.enteringNewElement(null, "link");
          JsonObject linkObj = (JsonObject) jsonValue;
          String rel = linkObj.getString("rel", null);
          String href = linkObj.getString("href", null);
          theState.attributeValue("rel", rel);
          theState.attributeValue("href", href);
          theState.endingElement();
        }
        continue;
      } else if ("entry".equals(nextName)) {
        JsonArray entries = theObject.getJsonArray(nextName);
        for (JsonValue jsonValue : entries) {
          theState.enteringNewElement(null, "entry");
          parseBundleChildren((JsonObject) jsonValue, theState);
          theState.endingElement();
        }
View Full Code Here

  }

  private void parseChildren(ParserState<?> theState, String theName, JsonValue theJsonVal, JsonValue theAlternateVal) {
    switch (theJsonVal.getValueType()) {
    case ARRAY: {
      JsonArray nextArray = (JsonArray) theJsonVal;
      JsonArray nextAlternateArray = (JsonArray) theAlternateVal;
      for (int i = 0; i < nextArray.size(); i++) {
        JsonValue nextObject = nextArray.get(i);
        JsonValue nextAlternate = null;
        if (nextAlternateArray != null) {
          nextAlternate = nextAlternateArray.get(i);
        }
        parseChildren(theState, theName, nextObject, nextAlternate);
      }
      break;
    }
View Full Code Here

    for (Entry<String, JsonValue> nextEntry : alternate.entrySet()) {
      String nextKey = nextEntry.getKey();
      JsonValue nextVal = nextEntry.getValue();
      if ("extension".equals(nextKey)) {
        boolean isModifier = false;
        JsonArray array = (JsonArray) nextEntry.getValue();
        parseExtension(theState, array, isModifier);
      } else if ("modifierExtension".equals(nextKey)) {
        boolean isModifier = true;
        JsonArray array = (JsonArray) nextEntry.getValue();
        parseExtension(theState, array, isModifier);
      } else if ("id".equals(nextKey)) {
        switch (nextVal.getValueType()) {
        case STRING:
          theState.attributeValue("id", ((JsonString) nextVal).getString());
View Full Code Here

      for (Iterator<String> iter = nextExtObj.keySet().iterator(); iter.hasNext();) {
        String next = iter.next();
        if ("url".equals(next)) {
          continue;
        } else if ("extension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          parseExtension(theState, jsonVal, false);
        } else if ("modifierExtension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          parseExtension(theState, jsonVal, true);
        } else {
          JsonValue jsonVal = nextExtObj.get(next);
          parseChildren(theState, next, jsonVal, null);
        }
View Full Code Here

            SAXUnmarshallerHandler rootContentHandler = null;
            if (getContentHandler() instanceof SAXUnmarshallerHandler) {
                rootContentHandler = (SAXUnmarshallerHandler) getContentHandler();
            }
            JsonArray jsonArray = (JsonArray) jsonValue;
            int size = jsonArray.size();

            List list = new ArrayList(size);
            for (int x = 0; x < size; x++) {
                parseRoot(jsonArray.get(x));
                if (getContentHandler() instanceof SAXUnmarshallerHandler) {
                    SAXUnmarshallerHandler saxUnmarshallerHandler = (SAXUnmarshallerHandler) contentHandler;
                    list.add(saxUnmarshallerHandler.getObject());
                    saxUnmarshallerHandler.setObject(null);
                } else if (getContentHandler() instanceof UnmarshalRecord) {
View Full Code Here

            while (iter.hasNext()) {
                Entry<String, JsonValue> nextEntry = iter.next();
                parsePair(nextEntry.getKey(), nextEntry.getValue());
            }
        } else if(valueType == ValueType.ARRAY) {
            JsonArray childArray = (JsonArray)jsonValue;
            int size = childArray.size();
              
            List list = new ArrayList(size);           
            for(int x=0; x<size; x++) {
                JsonValue nextArrayValue = childArray.get(x);
                parseValue(nextArrayValue);
            }
        }
  }
View Full Code Here

            return;
        }
        ValueType valueType = jsonValue.getValueType();

        if (valueType == ValueType.ARRAY) {
            JsonArray jsonArray = (JsonArray) jsonValue;
            String parentLocalName = name;

            if (attributePrefix != null && parentLocalName.startsWith(attributePrefix)) {
                // do nothing;
                return;
            }
            String uri = Constants.EMPTY_STRING;
            if (namespaceAware && namespaces != null) {
                if (parentLocalName.length() > 2) {
                    int nsIndex = parentLocalName.indexOf(namespaceSeparator, 1);
                    if (nsIndex > -1) {
                        String prefix = parentLocalName.substring(0, nsIndex);
                        uri = namespaces.resolveNamespacePrefix(prefix);
                    }
                    if (uri == null) {
                        uri = namespaces.getDefaultNamespaceURI();
                    } else {
                        parentLocalName = parentLocalName.substring(nsIndex + 1);
                    }
                } else {
                    uri = namespaces.getDefaultNamespaceURI();
                }
            }

            boolean isTextValue = false;
            int arraySize = jsonArray.size();
            if (arraySize == 0) {
                if (contentHandler instanceof UnmarshalRecord) {
                    isTextValue = isTextValue(parentLocalName);
                    UnmarshalRecord ur = (UnmarshalRecord) contentHandler;
                    XPathNode node = ur.getNonAttributeXPathNode(uri, parentLocalName, parentLocalName, null);
                    if (node != null) {
                        NodeValue nv = node.getNodeValue();
                        if (nv == null && node.getTextNode() != null) {
                            nv = node.getTextNode().getUnmarshalNodeValue();
                        }
                        if (nv != null && nv.isContainerValue()) {
                            ur.getContainerInstance(((ContainerValue) nv));
                        }
                    }
                }
            }
            startCollection();

            XPathFragment groupingXPathFragment = null;
            XPathFragment itemXPathFragment = null;
            if (contentHandler instanceof UnmarshalRecord) {
                isTextValue = isTextValue(parentLocalName);
                UnmarshalRecord unmarshalRecord = (UnmarshalRecord) contentHandler;
                if (unmarshalRecord.getUnmarshaller().isWrapperAsCollectionName()) {
                    XPathNode unmarshalRecordXPathNode = unmarshalRecord.getXPathNode();
                    if (null != unmarshalRecordXPathNode) {
                        XPathFragment currentFragment = new XPathFragment();
                        currentFragment.setLocalName(parentLocalName);
                        currentFragment.setNamespaceURI(uri);
                        currentFragment.setNamespaceAware(namespaceAware);
                        XPathNode groupingXPathNode = unmarshalRecordXPathNode.getNonAttributeChildrenMap().get(currentFragment);
                        if (groupingXPathNode != null) {
                            if (groupingXPathNode.getUnmarshalNodeValue() instanceof CollectionGroupingElementNodeValue) {
                                groupingXPathFragment = groupingXPathNode.getXPathFragment();
                                contentHandler.startElement(uri, parentLocalName, parentLocalName, new AttributesImpl());
                                XPathNode itemXPathNode = groupingXPathNode.getNonAttributeChildren().get(0);
                                itemXPathFragment = itemXPathNode.getXPathFragment();
                            } else if (groupingXPathNode.getUnmarshalNodeValue() == null) {
                                XPathNode itemXPathNode = groupingXPathNode.getNonAttributeChildren().get(0);
                                if (itemXPathNode != null) {
                                    if (((MappingNodeValue) itemXPathNode.getUnmarshalNodeValue()).isContainerValue()) {
                                        groupingXPathFragment = groupingXPathNode.getXPathFragment();
                                        contentHandler.startElement(uri, parentLocalName, parentLocalName, new AttributesImpl());
                                        itemXPathFragment = itemXPathNode.getXPathFragment();
                                    }
                                }
                            }
                        }
                    }
                }

                for (int i = 0; i < arraySize; i++) {
                    JsonValue nextArrayValue = jsonArray.get(i);
                    if (nextArrayValue.getValueType() == ValueType.NULL) {
                        ((UnmarshalRecord) contentHandler).setNil(true);
                    }

                    if (!isTextValue) {
View Full Code Here

TOP

Related Classes of javax.json.JsonArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.