本文整理汇总了Java中org.hl7.fhir.instance.model.StringType.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java StringType.setValue方法的具体用法?Java StringType.setValue怎么用?Java StringType.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hl7.fhir.instance.model.StringType
的用法示例。
在下文中一共展示了StringType.setValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateParametersParameterComponent
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testCreateParametersParameterComponent() {
String[] names = { "type", "resourceUrl", "name", "_lastUpdated" };
String[] values = { "master", "http://fhirserver.net", "Mike", "ge2016-02-16" };
for (int i = 0; i < names.length; i++) {
String name = names[i];
String value = values[i];
ParametersParameterComponent expected = new ParametersParameterComponent();
expected.setName(name);
StringType strTypeVal = new StringType();
strTypeVal.setValue(value);
expected.setValue(strTypeVal);
ParametersParameterComponent actual = ParametersUtil.createParameter(name,
value);
assertNotNull(actual);
assertEquals("name", actual.getName(), expected.getName());
assertEquals("value", actual.getValue().toString(),
expected.getValue().toString());
}
}
示例2: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
family.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<name><family value=\"Shmoe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension></family></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>)ext.getValue()).getValue());
}
示例3: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("Hello"));
family.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString(
"<name><family value=\"Shmoe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension></family></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>) ext.getValue()).getValue());
}
示例4: createParameter
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
public static ParametersParameterComponent createParameter(String name, String value) {
final ParametersParameterComponent p = new ParametersParameterComponent();
p.setName(name);
StringType strTypeVal = new StringType();
strTypeVal.setValue(value);
p.setValue(strTypeVal);
return p;
}
示例5: testHasValue
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testHasValue() {
StringType type = new StringType();
assertFalse(type.hasValue());
type.addExtension().setUrl("http://foo").setValue(new DecimalType(123));
assertFalse(type.hasValue());
type.setValue("Hello");
assertTrue(type.hasValue());
}
示例6: parseString
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
private StringType parseString(XmlPullParser xpp) throws Exception {
StringType res = new StringType();
parseElementAttributes(xpp, res);
res.setValue(parseStringPrimitive(xpp.getAttributeValue(null, "value")));
next(xpp);
int eventType = nextNoWhitespace(xpp);
while (eventType != XmlPullParser.END_TAG) {
if (!parseElementContent(eventType, xpp, res))
unknownContent(xpp);
eventType = nextNoWhitespace(xpp);
}
next(xpp);
return res;
}
示例7: testMoreExtensions
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testMoreExtensions() throws Exception {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));
// Add the extension to the resource
patient.getExtension().add(ext);
// END SNIPPET: resourceExtension
// START SNIPPET: resourceStringExtension
HumanName name = patient.addName();
name.addFamily("Shmoe");
StringType given = name.addGivenElement();
given.setValue("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("given"));
given.getExtension().add(ext2);
StringType given2 = name.addGivenElement();
given2.setValue("Shmoe");
Extension given2ext = new Extension().setUrl("http://examples.com#givenext_parent");
given2.getExtension().add(given2ext);
given2ext.addExtension().setUrl("http://examples.com#givenext_child").setValue(new StringType("CHILD"));
// END SNIPPET: resourceStringExtension
// START SNIPPET: subExtension
Extension parent = new Extension().setUrl("http://example.com#parent");
patient.getExtension().add(parent);
Extension child1 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child1);
Extension child2 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child2);
// END SNIPPET: subExtension
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<Patient xmlns=\"http://hl7.org/fhir\"><extension><url value=\"http://example.com/extensions#someext\"/><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
assertThat(
enc,
containsString("<extension><extension><url value=\"http://example.com#child\"/><valueString value=\"value1\"/></extension><extension><url value=\"http://example.com#child\"/><valueString value=\"value1\"/></extension><url value=\"http://example.com#parent\"/></extension>"));
assertThat(enc, containsString("<given value=\"Joe\"><extension><url value=\"http://examples.com#givenext\"/><valueString value=\"given\"/></extension></given>"));
assertThat(enc, containsString("<given value=\"Shmoe\"><extension><extension><url value=\"http://examples.com#givenext\"/><valueString value=\"given\"/></extension><url value=\"http://examples.com#givenext_child\"/></extension></given>"));
}
示例8: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
family.addExtension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
//@formatter:off
assertThat(enc, containsString(("{\n" +
" \"resourceType\":\"Patient\",\n" +
" \"name\":[\n" +
" {\n" +
" \"family\":[\n" +
" \"Shmoe\"\n" +
" ],\n" +
" \"_family\":[\n" +
" {\n" +
" \"extension\":[\n" +
" {\n" +
" \"url\":\"http://examples.com#givenext\",\n" +
" \"valueString\":\"Hello\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
"}").replace("\n", "").replaceAll(" +", "")));
//@formatter:on
Patient parsed = new FhirContext().newJsonParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>)ext.getValue()).getValue());
}
示例9: testMoreExtensions
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
@Test
public void testMoreExtensions() throws Exception {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));
// Add the extension to the resource
patient.getExtension().add(ext);
// END SNIPPET: resourceExtension
// START SNIPPET: resourceStringExtension
HumanName name = patient.addName();
name.addFamily("Shmoe");
StringType given = name.addGivenElement();
given.setValue("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("given"));
given.getExtension().add(ext2);
StringType given2 = name.addGivenElement();
given2.setValue("Shmoe");
Extension given2ext = new Extension().setUrl("http://examples.com#givenext_parent");
given2.getExtension().add(given2ext);
given2ext.addExtension().setUrl("http://examples.com#givenext_child").setValue(new StringType("CHILD"));
// END SNIPPET: resourceStringExtension
// START SNIPPET: subExtension
Extension parent = new Extension().setUrl("http://example.com#parent");
patient.getExtension().add(parent);
Extension child1 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child1);
Extension child2 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child2);
// END SNIPPET: subExtension
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString(
"<Patient xmlns=\"http://hl7.org/fhir\"><extension url=\"http://example.com/extensions#someext\"><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
assertThat(enc, containsString(
"<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension></extension>"));
assertThat(enc, containsString(
"<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>"));
assertThat(enc, containsString(
"<given value=\"Shmoe\"><extension url=\"http://examples.com#givenext_parent\"><extension url=\"http://examples.com#givenext_child\"><valueString value=\"CHILD\"/></extension></extension></given>"));
}
示例10: parseString
import org.hl7.fhir.instance.model.StringType; //导入方法依赖的package包/类
private StringType parseString(String v) throws Exception {
StringType res = new StringType();
if (v != null)
res.setValue(parseStringPrimitive(v));
return res;
}