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


Java Binary類代碼示例

本文整理匯總了Java中org.hl7.fhir.instance.model.Binary的典型用法代碼示例。如果您正苦於以下問題:Java Binary類的具體用法?Java Binary怎麽用?Java Binary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Binary類屬於org.hl7.fhir.instance.model包,在下文中一共展示了Binary類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testReadWithExplicitTypeXml

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testReadWithExplicitTypeXml() throws Exception {
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary/foo?_format=xml");
	HttpResponse status = ourClient.execute(httpGet);
	String responseContent = IOUtils.toString(status.getEntity().getContent(), "UTF-8");
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info(responseContent);
	
	assertEquals(200, status.getStatusLine().getStatusCode());
	assertThat(status.getFirstHeader("content-type").getValue(), startsWith(Constants.CT_FHIR_XML + ";"));
	
	Binary bin = ourCtx.newXmlParser().parseResource(Binary.class, responseContent);
	assertEquals("foo", bin.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:17,代碼來源:BinaryHl7OrgDstu2Test.java

示例2: testReadWithExplicitTypeJson

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testReadWithExplicitTypeJson() throws Exception {
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary/foo?_format=json");
	HttpResponse status = ourClient.execute(httpGet);
	String responseContent = IOUtils.toString(status.getEntity().getContent(), "UTF-8");
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info(responseContent);
	
	assertEquals(200, status.getStatusLine().getStatusCode());
	assertThat(status.getFirstHeader("content-type").getValue(), startsWith(Constants.CT_FHIR_JSON + ";"));
	
	Binary bin = ourCtx.newJsonParser().parseResource(Binary.class, responseContent);
	assertEquals("foo", bin.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:17,代碼來源:BinaryHl7OrgDstu2Test.java

示例3: 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

示例4: testSearchJson

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testSearchJson() throws Exception {
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true&_format=json");
	HttpResponse status = ourClient.execute(httpGet);
	String responseContent = IOUtils.toString(status.getEntity().getContent());
	IOUtils.closeQuietly(status.getEntity().getContent());
	assertEquals(200, status.getStatusLine().getStatusCode());
	assertEquals(Constants.CT_FHIR_JSON + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));

	ourLog.info(responseContent);

	org.hl7.fhir.instance.model.Bundle bundle = ourCtx.newJsonParser().parseResource(org.hl7.fhir.instance.model.Bundle.class, responseContent);
	Binary bin = (Binary) bundle.getEntry().get(0).getResource();

	assertEquals("text/plain", bin.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:18,代碼來源:BinaryHl7OrgDstu2Test.java

示例5: testSearchXml

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testSearchXml() throws Exception {
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true");
	HttpResponse status = ourClient.execute(httpGet);
	String responseContent = IOUtils.toString(status.getEntity().getContent());
	IOUtils.closeQuietly(status.getEntity().getContent());
	assertEquals(200, status.getStatusLine().getStatusCode());
	assertEquals(Constants.CT_FHIR_XML + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));

	ourLog.info(responseContent);

	org.hl7.fhir.instance.model.Bundle bundle = ourCtx.newXmlParser().parseResource(org.hl7.fhir.instance.model.Bundle.class, responseContent);
	Binary bin = (Binary) bundle.getEntry().get(0).getResource();

	assertEquals("text/plain", bin.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
}
 
開發者ID:jamesagnew,項目名稱:hapi-fhir,代碼行數:18,代碼來源:BinaryHl7OrgDstu2Test.java

示例6: 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

示例7: testParseContainedBinaryResource

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
/**
	 * Thanks to Alexander Kley!
	 */
	@Test
	public void testParseContainedBinaryResource() {
		byte[] bin = new byte[] {0,1,2,3,4};
	    final Binary binary = new Binary();
	    binary.setContentType("PatientConsent").setContent( bin);
//	    binary.setId(UUID.randomUUID().toString());
	    
	    DocumentManifest manifest = new DocumentManifest();
//	    manifest.setId(UUID.randomUUID().toString());
	    CodeableConcept cc = new CodeableConcept();
	    cc.addCoding().setSystem("mySystem").setCode( "PatientDocument");
		manifest.setType(cc);
	    manifest.setMasterIdentifier(new Identifier().setSystem("mySystem").setValue( UUID.randomUUID().toString()));
	    manifest.addContent().setResource(binary);
	    manifest.setStatus(DocumentReferenceStatus.CURRENT);
	    
	    String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(manifest);
	    ourLog.info(encoded);
	    assertThat(encoded, StringContainsInOrder.stringContainsInOrder(Arrays.asList("contained>","<Binary", "</contained>")));
	    
	    DocumentManifest actual = ourCtx.newXmlParser().parseResource(DocumentManifest.class, encoded);
	    assertEquals(1, actual.getContained().size());
	    assertEquals(1, actual.getContent().size());
	    assertNotNull(actual.getContent().get(0).getResource());
	    
	}
 
開發者ID:gajen0981,項目名稱:FHIR-Server,代碼行數:30,代碼來源:XmlParserTest.java

示例8: 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

示例9: testParseBinaryResource

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testParseBinaryResource() {

	Binary val = ourCtx.newXmlParser().parseResource(Binary.class, "<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>");
	assertEquals("foo", val.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, val.getContent());

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

示例10: 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

示例11: testParseBinaryResource

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
@Test
public void testParseBinaryResource() {

	Binary val = ourCtx.newJsonParser().parseResource(Binary.class, "{\"resourceType\":\"Binary\",\"contentType\":\"foo\",\"content\":\"AQIDBA==\"}");
	assertEquals("foo", val.getContentType());
	assertArrayEquals(new byte[] { 1, 2, 3, 4 }, val.getContent());

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

示例12: 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

示例13: 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

示例14: composeBinary

import org.hl7.fhir.instance.model.Binary; //導入依賴的package包/類
protected void composeBinary(String name, Binary element) throws Exception {
	if (element != null) {
		composeElementAttributes(element);
		xml.attribute("contentType", element.getContentType());
		xml.open(FHIR_NS, name);
		xml.text(toString(element.getContent()));
		xml.close(FHIR_NS, name);
	}    
}
 
開發者ID:cqframework,項目名稱:ProfileGenerator,代碼行數:10,代碼來源:XmlComposerBase.java

示例15: 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


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