本文整理汇总了Java中org.hl7.fhir.instance.model.IntegerType类的典型用法代码示例。如果您正苦于以下问题:Java IntegerType类的具体用法?Java IntegerType怎么用?Java IntegerType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntegerType类属于org.hl7.fhir.instance.model包,在下文中一共展示了IntegerType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processConstant
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private Base processConstant(ExecutionContext context, String constant) throws PathEngineException {
if (constant.equals("true")) {
return new BooleanType(true);
} else if (constant.equals("false")) {
return new BooleanType(false);
} else if (constant.equals("{}")) {
return null;
} else if (Utilities.isInteger(constant)) {
return new IntegerType(constant);
} else if (Utilities.isDecimal(constant)) {
return new DecimalType(constant);
} else if (constant.startsWith("\'")) {
return new StringType(processConstantString(constant));
} else if (constant.startsWith("%")) {
return resolveConstant(context, constant);
} else if (constant.startsWith("@")) {
return processDateConstant(context.appInfo, constant.substring(1));
} else {
return new StringType(constant);
}
}
示例2: opTimes
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> opTimes(List<Base> left, List<Base> right) throws PathEngineException {
if (left.size() == 0)
throw new PathEngineException("Error performing *: left operand has no value");
if (left.size() > 1)
throw new PathEngineException("Error performing *: left operand has more than one value");
if (!left.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing +: left operand has the wrong type (%s)", left.get(0).fhirType()));
if (right.size() == 0)
throw new PathEngineException("Error performing *: right operand has no value");
if (right.size() > 1)
throw new PathEngineException("Error performing *: right operand has more than one value");
if (!right.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing *: right operand has the wrong type (%s)", right.get(0).fhirType()));
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("integer") && r.hasType("integer"))
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) * Integer.parseInt(r.primitiveValue())));
else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer"))
result.add(new DecimalType(new BigDecimal(l.primitiveValue()).multiply(new BigDecimal(r.primitiveValue()))));
else
throw new PathEngineException(String.format("Error performing *: left and right operand have incompatible or illegal types (%s, %s)", left.get(0).fhirType(), right.get(0).fhirType()));
return result;
}
示例3: opMinus
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> opMinus(List<Base> left, List<Base> right) throws PathEngineException {
if (left.size() == 0)
throw new PathEngineException("Error performing -: left operand has no value");
if (left.size() > 1)
throw new PathEngineException("Error performing -: left operand has more than one value");
if (!left.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing -: left operand has the wrong type (%s)", left.get(0).fhirType()));
if (right.size() == 0)
throw new PathEngineException("Error performing -: right operand has no value");
if (right.size() > 1)
throw new PathEngineException("Error performing -: right operand has more than one value");
if (!right.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing -: right operand has the wrong type (%s)", right.get(0).fhirType()));
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("integer") && r.hasType("integer"))
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) - Integer.parseInt(r.primitiveValue())));
else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer"))
result.add(new DecimalType(new BigDecimal(l.primitiveValue()).subtract(new BigDecimal(r.primitiveValue()))));
else
throw new PathEngineException(String.format("Error performing -: left and right operand have incompatible or illegal types (%s, %s)", left.get(0).fhirType(), right.get(0).fhirType()));
return result;
}
示例4: addIntegerExtension
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
public static void addIntegerExtension(DomainResource dr, String url, int value) {
Extension ex = getExtension(dr, url);
if (ex != null)
ex.setValue(new IntegerType(value));
else
dr.getExtension().add(Factory.newExtension(url, new IntegerType(value), true));
}
示例5: describeCardinality
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private String describeCardinality(ElementDefinition definition, ElementDefinition fallback, UnusedTracker tracker) {
IntegerType min = definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
StringType max = definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
if (min.isEmpty() && fallback != null)
min = fallback.getMinElement();
if (max.isEmpty() && fallback != null)
max = fallback.getMaxElement();
tracker.used = !max.isEmpty() && !max.getValue().equals("0");
if (min.isEmpty() && max.isEmpty())
return null;
else
return (!min.hasValue() ? "" : Integer.toString(min.getValue())) + ".." + (!max.hasValue() ? "" : max.getValue());
}
示例6: opPlus
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> opPlus(List<Base> left, List<Base> right) throws PathEngineException {
if (left.size() == 0)
throw new PathEngineException("Error performing +: left operand has no value");
if (left.size() > 1)
throw new PathEngineException("Error performing +: left operand has more than one value");
if (!left.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing +: left operand has the wrong type (%s)", left.get(0).fhirType()));
if (right.size() == 0)
throw new PathEngineException("Error performing +: right operand has no value");
if (right.size() > 1)
throw new PathEngineException("Error performing +: right operand has more than one value");
if (!right.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing +: right operand has the wrong type (%s)", right.get(0).fhirType()));
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("string", "id", "code", "uri") && r.hasType("string", "id", "code", "uri"))
result.add(new StringType(l.primitiveValue() + r.primitiveValue()));
else if (l.hasType("integer") && r.hasType("integer"))
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) + Integer.parseInt(r.primitiveValue())));
else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer"))
result.add(new DecimalType(new BigDecimal(l.primitiveValue()).add(new BigDecimal(r.primitiveValue()))));
else
throw new PathEngineException(String.format("Error performing +: left and right operand have incompatible or illegal types (%s, %s)", left.get(0).fhirType(), right.get(0).fhirType()));
return result;
}
示例7: opDiv
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> opDiv(List<Base> left, List<Base> right) throws PathEngineException {
if (left.size() == 0)
throw new PathEngineException("Error performing div: left operand has no value");
if (left.size() > 1)
throw new PathEngineException("Error performing div: left operand has more than one value");
if (!left.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing div: left operand has the wrong type (%s)", left.get(0).fhirType()));
if (right.size() == 0)
throw new PathEngineException("Error performing div: right operand has no value");
if (right.size() > 1)
throw new PathEngineException("Error performing div: right operand has more than one value");
if (!right.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing div: right operand has the wrong type (%s)", right.get(0).fhirType()));
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("integer") && r.hasType("integer"))
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) / Integer.parseInt(r.primitiveValue())));
else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
Decimal d1;
try {
d1 = new Decimal(l.primitiveValue());
Decimal d2 = new Decimal(r.primitiveValue());
result.add(new IntegerType(d1.divInt(d2).asDecimal()));
} catch (UcumException e) {
throw new PathEngineException(e);
}
}
else
throw new PathEngineException(String.format("Error performing div: left and right operand have incompatible or illegal types (%s, %s)", left.get(0).fhirType(), right.get(0).fhirType()));
return result;
}
示例8: opMod
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> opMod(List<Base> left, List<Base> right) throws PathEngineException {
if (left.size() == 0)
throw new PathEngineException("Error performing mod: left operand has no value");
if (left.size() > 1)
throw new PathEngineException("Error performing mod: left operand has more than one value");
if (!left.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing mod: left operand has the wrong type (%s)", left.get(0).fhirType()));
if (right.size() == 0)
throw new PathEngineException("Error performing mod: right operand has no value");
if (right.size() > 1)
throw new PathEngineException("Error performing mod: right operand has more than one value");
if (!right.get(0).isPrimitive())
throw new PathEngineException(String.format("Error performing mod: right operand has the wrong type (%s)", right.get(0).fhirType()));
List<Base> result = new ArrayList<Base>();
Base l = left.get(0);
Base r = right.get(0);
if (l.hasType("integer") && r.hasType("integer"))
result.add(new IntegerType(Integer.parseInt(l.primitiveValue()) % Integer.parseInt(r.primitiveValue())));
else if (l.hasType("decimal", "integer") && r.hasType("decimal", "integer")) {
Decimal d1;
try {
d1 = new Decimal(l.primitiveValue());
Decimal d2 = new Decimal(r.primitiveValue());
result.add(new DecimalType(d1.modulo(d2).asDecimal()));
} catch (UcumException e) {
throw new PathEngineException(e);
}
}
else
throw new PathEngineException(String.format("Error performing mod: left and right operand have incompatible or illegal types (%s, %s)", left.get(0).fhirType(), right.get(0).fhirType()));
return result;
}
示例9: funcLength
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> funcLength(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
List<Base> result = new ArrayList<Base>();
if (focus.size() == 1) {
String s = convertToString(focus.get(0));
result.add(new IntegerType(s.length()));
}
return result;
}
示例10: funcToInteger
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private List<Base> funcToInteger(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
String s = convertToString(focus);
List<Base> result = new ArrayList<Base>();
if (Utilities.isInteger(s))
result.add(new IntegerType(s));
return result;
}
示例11: composeIntegerCore
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private void composeIntegerCore(String name, IntegerType value, boolean inArray) throws Exception {
if (value != null) {
prop(name, java.lang.Integer.valueOf(value.getValue()));
}
else if (inArray)
writeNull(name);
}
示例12: composeIntegerExtras
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private void composeIntegerExtras(String name, IntegerType value, boolean inArray) throws Exception {
if (value != null && (!Utilities.noString(value.getXmlId()) || value.hasExtensions())) {
open(inArray ? null : "_"+name);
composeElement(value);
close();
}
else if (inArray)
writeNull(name);
}
示例13: composeInteger
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private void composeInteger(String name, IntegerType value) throws Exception {
if (value != null) {
composeElementAttributes(value);
xml.attribute("value", toString(value.getValue()));
xml.open(FHIR_NS, name);
composeElementElements(value);
xml.close(FHIR_NS, name);
}
}
示例14: parseInteger
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
private IntegerType parseInteger(XmlPullParser xpp) throws Exception {
IntegerType res = new IntegerType();
parseElementAttributes(xpp, res);
res.setValue(parseIntegerPrimitive(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;
}
示例15: testIntegerType
import org.hl7.fhir.instance.model.IntegerType; //导入依赖的package包/类
@Test
public void testIntegerType() {
assertTrue(IBaseIntegerDatatype.class.isAssignableFrom(IntegerType.class));
}