當前位置: 首頁>>代碼示例>>Java>>正文


Java Binary.setContent方法代碼示例

本文整理匯總了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());

}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:17,代碼來源:BinaryHl7OrgDstu2Test.java

示例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);
}
 
開發者ID:gajen0981,項目名稱:FHIR-Server,代碼行數:11,代碼來源:XmlParserTest.java

示例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);

}
 
開發者ID:gajen0981,項目名稱:FHIR-Server,代碼行數:12,代碼來源:XmlParserTest.java

示例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);

}
 
開發者ID:gajen0981,項目名稱:FHIR-Server,代碼行數:12,代碼來源:JsonParserTest.java

示例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;
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:9,代碼來源:BinaryHl7OrgDstu2Test.java

示例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);
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:9,代碼來源:BinaryHl7OrgDstu2Test.java

示例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;
}
 
開發者ID:cqframework,項目名稱:ProfileGenerator,代碼行數:15,代碼來源:XmlParserBase.java

示例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;
}
 
開發者ID:cqframework,項目名稱:ProfileGenerator,代碼行數:8,代碼來源:JsonParserBase.java


注:本文中的org.hl7.fhir.instance.model.Binary.setContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。