本文整理匯總了Java中org.hl7.fhir.instance.model.Binary.setContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Binary.setContent方法的具體用法?Java Binary.setContent怎麽用?Java Binary.setContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hl7.fhir.instance.model.Binary
的用法示例。
在下文中一共展示了Binary.setContent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCreateWrongType
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
public void testCreateWrongType() throws Exception {
Binary res = new Binary();
res.setContent(new byte[] { 1, 2, 3, 4 });
res.setContentType("text/plain");
String stringContent = ourCtx.newJsonParser().encodeResourceToString(res);
HttpPost http = new HttpPost("http://localhost:" + ourPort + "/Binary");
http.setEntity(new StringEntity(stringContent, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
HttpResponse status = ourClient.execute(http);
assertEquals(201, status.getStatusLine().getStatusCode());
assertEquals("text/plain", ourLast.getContentType());
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ourLast.getContent());
}
示例2: testEncodeBinaryWithNoContentType
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
@Test
public void testEncodeBinaryWithNoContentType() {
Binary b = new Binary();
b.setContent(new byte[] {1,2,3,4});
String output = ourCtx.newXmlParser().encodeResourceToString(b);
ourLog.info(output);
assertEquals("<Binary xmlns=\"http://hl7.org/fhir\">AQIDBA==</Binary>", output);
}
示例3: testEncodeBinaryResource
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
@Test
public void testEncodeBinaryResource() {
Binary patient = new Binary();
patient.setContentType("foo");
patient.setContent(new byte[] { 1, 2, 3, 4 });
String val = ourCtx.newXmlParser().encodeResourceToString(patient);
assertEquals("<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>", val);
}
示例4: testEncodeBinaryResource
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
@Test
public void testEncodeBinaryResource() {
Binary patient = new Binary();
patient.setContentType("foo");
patient.setContent(new byte[] { 1, 2, 3, 4 });
String val = ourCtx.newJsonParser().encodeResourceToString(patient);
assertEquals("{\"resourceType\":\"Binary\",\"contentType\":\"foo\",\"content\":\"AQIDBA==\"}", val);
}
示例5: read
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
@Read
public Binary read(@IdParam IdType theId) {
Binary retVal = new Binary();
retVal.setId("1");
retVal.setContent(new byte[] { 1, 2, 3, 4 });
retVal.setContentType(theId.getIdPart());
return retVal;
}
示例6: search
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
@Search
public List<Binary> search() {
Binary retVal = new Binary();
retVal.setId("1");
retVal.setContent(new byte[] { 1, 2, 3, 4 });
retVal.setContentType("text/plain");
return Collections.singletonList(retVal);
}
示例7: parseBinary
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
protected Resource parseBinary(XmlPullParser xpp) throws Exception {
Binary res = new Binary();
parseElementAttributes(xpp, res);
res.setContentType(xpp.getAttributeValue(null, "contentType"));
int eventType = next(xpp);
if (eventType == XmlPullParser.TEXT) {
res.setContent(Base64.decodeBase64(xpp.getText().getBytes()));
eventType = next(xpp);
}
if (eventType != XmlPullParser.END_TAG)
throw new Exception("Bad String Structure");
next(xpp);
return res;
}
示例8: parseBinary
import org.hl7.fhir.instance.model.Binary; //導入方法依賴的package包/類
protected Resource parseBinary(JsonObject json) throws Exception {
Binary res = new Binary();
parseResourceProperties(json, res);
res.setContentType(json.get("contentType").getAsString());
res.setContent(Base64.decodeBase64(json.get("content").getAsString().getBytes()));
return res;
}