static ParserState<TagList> getPreTagListInstance(IParser theParser, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) { ParserState<TagList> retVal = new ParserState<TagList>(theParser, theContext, theJsonMode, theErrorHandler); retVal.push(retVal.new PreTagListState()); return retVal; }
parserState.enteringNewElementExtension(elem, url, false, getServerBaseUrl()); } else if ("modifierExtension".equals(elem.getName().getLocalPart())) { Attribute urlAttr = elem.getAttributeByName(new QName("url")); parserState.enteringNewElementExtension(elem, url, true, getServerBaseUrl()); } else { String elementName = elem.getName().getLocalPart(); parserState.enteringNewElement(namespaceURI, elementName); parserState.commentPre(next); for (Iterator<Attribute> iter = attributes; iter.hasNext();) { Attribute next = iter.next(); parserState.attributeValue(next.getName().getLocalPart(), next.getValue()); if (!heldComments.isEmpty()) { for (String next : heldComments) { parserState.commentPost(next); parserState.endingElement(); parserState.string(nextEvent.asCharacters().getData()); break; parserState.xmlEvent(nextEvent); return parserState.getObject(); } catch (XMLStreamException e) { throw new DataFormatException(e);
if (!theInArray && theState.elementIsRepeating(theName)) { getErrorHandler().incorrectJsonType(null, theName, ValueType.ARRAY, null, ValueType.OBJECT, null); theState.enteringNewElement(null, theName); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); JsonLikeObject nextObject = theJsonVal.getAsObject(); boolean preResource = false; if (theState.isPreResource()) { JsonLikeValue resType = nextObject.get("resourceType"); if (resType == null || !resType.isString()) { throw new DataFormatException("Missing required element 'resourceType' from JSON resource object, unable to parse"); theState.enteringNewElement(null, resType.getAsString()); preResource = true; theState.endingElement(); theState.endingElement(); } else if (theJsonVal.isNull()) { theState.enteringNewElement(null, theName); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); theState.endingElement(); } else { theState.enteringNewElement(null, theName); theState.attributeValue("value", theJsonVal.getAsString()); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); theState.endingElement();
public <T extends IBaseResource> T doParseResource(Class<T> theResourceType, JsonLikeStructure theJsonStructure) { JsonLikeObject object = theJsonStructure.getRootObject(); JsonLikeValue resourceTypeObj = object.get("resourceType"); if (resourceTypeObj == null || !resourceTypeObj.isString() || isBlank(resourceTypeObj.getAsString())) { throw new DataFormatException("Invalid JSON content detected, missing required element: 'resourceType'"); } String resourceType = resourceTypeObj.getAsString(); ParserState<? extends IBaseResource> state = ParserState.getPreResourceInstance(this, theResourceType, myContext, true, getErrorHandler()); state.enteringNewElement(null, resourceType); parseChildren(object, state); state.endingElement(); state.endingElement(); @SuppressWarnings("unchecked") T retVal = (T) state.getObject(); return retVal; }
url = getExtensionUrl(jsonElement.getAsString()); theState.enteringNewElementExtension(null, url, theIsModifier, getServerBaseUrl()); for (String next : nextExtObj.keySet()) { if ("url".equals(next)) { String nextName = alternateName.substring(1); if (nextExtObj.get(nextName) == null) { theState.enteringNewElement(null, nextName); parseAlternates(nextValue, theState, alternateName, alternateName); theState.endingElement(); theState.endingElement();
String nextName = alternateName.substring(1); if (theObject.get(nextName) == null) { theState.enteringNewElement(null, nextName); parseAlternates(nextValue, theState, alternateName, alternateName); theState.endingElement();
private <T extends IBaseResource> T parseResource(Class<T> theResourceType, XMLEventReader theStreamReader) { ParserState<T> parserState = ParserState.getPreResourceInstance(this, theResourceType, myContext, false, getErrorHandler()); return doXmlLoop(theStreamReader, parserState); }
private void parseFhirComments(JsonLikeValue theObject, ParserState<?> theState) { if (theObject.isArray()) { JsonLikeArray comments = theObject.getAsArray(); for (int i = 0; i < comments.size(); i++) { JsonLikeValue nextComment = comments.get(i); if (nextComment.isString()) { String commentText = nextComment.getAsString(); if (commentText != null) { theState.commentPre(commentText); } } } } }
} else if ("id".equals(nextKey)) { if (nextVal.isString()) { theState.attributeValue("id", nextVal.getAsString()); } else { getErrorHandler().incorrectJsonType(null, "id", ValueType.SCALAR, ScalarType.STRING, nextVal.getJsonType(), nextVal.getDataType());
public <T extends IBaseResource> T doParseResource(Class<T> theResourceType, JsonLikeStructure theJsonStructure) { JsonLikeObject object = theJsonStructure.getRootObject(); JsonLikeValue resourceTypeObj = object.get("resourceType"); if (resourceTypeObj == null || !resourceTypeObj.isString() || isBlank(resourceTypeObj.getAsString())) { throw new DataFormatException("Invalid JSON content detected, missing required element: 'resourceType'"); } String resourceType = resourceTypeObj.getAsString(); ParserState<? extends IBaseResource> state = ParserState.getPreResourceInstance(this, theResourceType, myContext, true, getErrorHandler()); state.enteringNewElement(null, resourceType); parseChildren(object, state); state.endingElement(); state.endingElement(); @SuppressWarnings("unchecked") T retVal = (T) state.getObject(); return retVal; }
url = getExtensionUrl(jsonElement.getAsString()); theState.enteringNewElementExtension(null, url, theIsModifier, getServerBaseUrl()); for (String next : nextExtObj.keySet()) { if ("url".equals(next)) { String nextName = alternateName.substring(1); if (nextExtObj.get(nextName) == null) { theState.enteringNewElement(null, nextName); parseAlternates(nextValue, theState, alternateName, alternateName); theState.endingElement(); theState.endingElement();
String nextName = alternateName.substring(1); if (theObject.get(nextName) == null) { theState.enteringNewElement(null, nextName); parseAlternates(nextValue, theState, alternateName, alternateName); theState.endingElement();
private <T extends IBaseResource> T parseResource(Class<T> theResourceType, XMLEventReader theStreamReader) { ParserState<T> parserState = ParserState.getPreResourceInstance(this, theResourceType, myContext, false, getErrorHandler()); return doXmlLoop(theStreamReader, parserState); }
private void parseFhirComments(JsonLikeValue theObject, ParserState<?> theState) { if (theObject.isArray()) { JsonLikeArray comments = theObject.getAsArray(); for (int i = 0; i < comments.size(); i++) { JsonLikeValue nextComment = comments.get(i); if (nextComment.isString()) { String commentText = nextComment.getAsString(); if (commentText != null) { theState.commentPre(commentText); } } } } }
} else if ("id".equals(nextKey)) { if (nextVal.isString()) { theState.attributeValue("id", nextVal.getAsString()); } else { getErrorHandler().incorrectJsonType(null, "id", ValueType.SCALAR, ScalarType.STRING, nextVal.getJsonType(), nextVal.getDataType());
parserState.enteringNewElementExtension(elem, url, false, getServerBaseUrl()); } else if ("modifierExtension".equals(elem.getName().getLocalPart())) { Attribute urlAttr = elem.getAttributeByName(new QName("url")); parserState.enteringNewElementExtension(elem, url, true, getServerBaseUrl()); } else { String elementName = elem.getName().getLocalPart(); parserState.enteringNewElement(namespaceURI, elementName); parserState.commentPre(next); parserState.attributeValue(next.getName().getLocalPart(), next.getValue()); if (!heldComments.isEmpty()) { for (String next : heldComments) { parserState.commentPost(next); parserState.endingElement(); parserState.string(nextEvent.asCharacters().getData()); break; parserState.xmlEvent(nextEvent); return parserState.getObject(); } catch (XMLStreamException e) { throw new DataFormatException(e);
if (!theInArray && theState.elementIsRepeating(theName)) { getErrorHandler().incorrectJsonType(null, theName, ValueType.ARRAY, null, ValueType.OBJECT, null); theState.enteringNewElement(null, theName); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); JsonLikeObject nextObject = theJsonVal.getAsObject(); boolean preResource = false; if (theState.isPreResource()) { JsonLikeValue resType = nextObject.get("resourceType"); if (resType == null || !resType.isString()) { throw new DataFormatException("Missing required element 'resourceType' from JSON resource object, unable to parse"); theState.enteringNewElement(null, resType.getAsString()); preResource = true; theState.endingElement(); theState.endingElement(); } else if (theJsonVal.isNull()) { theState.enteringNewElement(null, theName); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); theState.endingElement(); } else { theState.enteringNewElement(null, theName); theState.attributeValue("value", theJsonVal.getAsString()); parseAlternates(theAlternateVal, theState, theAlternateName, theAlternateName); theState.endingElement();
/** * @param theResourceType * May be null */ static <T extends IBaseResource> ParserState<T> getPreResourceInstance(IParser theParser, Class<T> theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException { ParserState<T> retVal = new ParserState<T>(theParser, theContext, theJsonMode, theErrorHandler); if (theResourceType == null) { if (theContext.getVersion().getVersion().isRi()) { retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); } else { retVal.push(retVal.new PreResourceStateHapi(theResourceType)); } } else { if (IResource.class.isAssignableFrom(theResourceType)) { retVal.push(retVal.new PreResourceStateHapi(theResourceType)); } else { retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); } } return retVal; }
static ParserState<TagList> getPreTagListInstance(IParser theParser, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) { ParserState<TagList> retVal = new ParserState<TagList>(theParser, theContext, theJsonMode, theErrorHandler); retVal.push(retVal.new PreTagListState()); return retVal; }
/** * @param theResourceType * May be null */ static <T extends IBaseResource> ParserState<T> getPreResourceInstance(IParser theParser, Class<T> theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException { ParserState<T> retVal = new ParserState<T>(theParser, theContext, theJsonMode, theErrorHandler); if (theResourceType == null) { if (theContext.getVersion().getVersion().isRi()) { retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); } else { retVal.push(retVal.new PreResourceStateHapi(theResourceType)); } } else { if (IResource.class.isAssignableFrom(theResourceType)) { retVal.push(retVal.new PreResourceStateHapi(theResourceType)); } else { retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); } } return retVal; }