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); }
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; }
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); }
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; }