private boolean checkIfPathMatchesForEncoding(List<ElementsPath> theElements, boolean theCheckingForEncodeElements) { myEncodeContext.pushPath(myDef.getElementName(), false);
protected void encodeResourceToWriter(IBaseResource theResource, Writer theWriter, EncodeContext theEncodeContext) throws IOException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theWriter, "theWriter can not be null"); Validate.notNull(theEncodeContext, "theEncodeContext can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } String resourceName = myContext.getResourceDefinition(theResource).getName(); theEncodeContext.pushPath(resourceName, true); doEncodeResourceToWriter(theResource, theWriter, theEncodeContext); theEncodeContext.popPath(); }
@Override public void encodeResourceToJsonLikeWriter(IBaseResource theResource, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } EncodeContext encodeContext = new EncodeContext(); String resourceName = myContext.getResourceDefinition(theResource).getName(); encodeContext.pushPath(resourceName, true); doEncodeResourceToJsonLikeWriter(theResource, theJsonLikeWriter, encodeContext); }
theEncodeContext.pushPath(childName, false);
RuntimeResourceDefinition def = myContext.getResourceDefinition(resource); theEncodeContext.pushPath(def.getName(), true); encodeResourceToJsonStreamWriter(def, resource, theEventWriter, theChildName, false, theEncodeContext); theEncodeContext.popPath();
private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase theElement, String childName, BaseRuntimeElementDefinition<?> childDef, String theExtensionUrl, boolean theIncludedResource, CompositeChildElement theParent, EncodeContext theEncodeContext) throws XMLStreamException, DataFormatException { theEncodeContext.pushPath(childName, false); try { IBaseResource resource = (IBaseResource) theElement; String resourceName = myContext.getResourceDefinition(resource).getName(); theEncodeContext.pushPath(resourceName, true); encodeResourceToXmlStreamWriter(resource, theEventWriter, false, theEncodeContext); theEncodeContext.popPath();
for (BaseCodingDt securityLabel : securityLabels) { theEventWriter.beginObject(); theEncodeContext.pushPath("security", false); encodeCompositeElementChildrenToStreamWriter(resDef, resource, securityLabel, theEventWriter, theContainedResource, null, theEncodeContext); theEncodeContext.popPath();