当前位置: 首页>>代码示例>>Java>>正文


Java Partial类代码示例

本文整理汇总了Java中org.joda.time.Partial的典型用法代码示例。如果您正苦于以下问题:Java Partial类的具体用法?Java Partial怎么用?Java Partial使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Partial类属于org.joda.time包,在下文中一共展示了Partial类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: minValue

import org.joda.time.Partial; //导入依赖的package包/类
public static Object minValue(Type type) {
    if (type == Integer.class) {
        return Integer.MIN_VALUE;
    }
    else if (type == BigDecimal.class) {
        return new BigDecimal("-9999999999999999999999999999.99999999");
    }
    else if (type == Quantity.class) {
        return new Quantity().withValue((BigDecimal)minValue(BigDecimal.class));
    }
    else if (type == DateTime.class) {
        return new DateTime(new Partial(DateTime.fields, new int[] {0001, 1, 1, 0, 0, 0, 0}));
    }
    else if (type == Time.class) {
        return new Time(new Partial(Time.fields, new int[] {0, 0, 0, 0}));
    }

    throw new NotImplementedException(String.format("MinValue is not implemented for type %s.", type.getTypeName()));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:20,代码来源:Value.java

示例2: evaluate

import org.joda.time.Partial; //导入依赖的package包/类
@Override
public Object evaluate(Context context) {

    if (this.getHour() == null) {
        return null;
    }

    Integer hour = (Integer)this.getHour().evaluate(context);
    Integer minute = (this.getMinute() == null) ? null : (Integer)this.getMinute().evaluate(context);
    Integer second = (this.getSecond() == null) ? null : (Integer)this.getSecond().evaluate(context);
    Integer millis = (this.getMillisecond() == null) ? null : (Integer)this.getMillisecond().evaluate(context);

    DateTimeZone timeZone =
            BaseTemporal.resolveDateTimeZone(
                    this.getTimezoneOffset() != null
                            ? (BigDecimal) this.getTimezoneOffset().evaluate(context)
                            : null);

    if (BaseTemporal.formatCheck(new ArrayList<>(Arrays.asList(hour, minute, second, millis)))) {
        int [] values = DateTime.getValues(hour, minute, second, millis);
        return new Time(new Partial(Time.getFields(values.length), values), timeZone);
    }

    throw new IllegalArgumentException("Time format is invalid");
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:26,代码来源:TimeEvaluator.java

示例3: toTime

import org.joda.time.Partial; //导入依赖的package包/类
public static Object toTime(Object operand) {
    if (operand == null) {
        return null;
    }

    String[] timeAndTimezone = operand.toString().replace('T', ' ').replace('Z', ' ').trim().split("[\\+-]");
    String[] time = timeAndTimezone[0].split("\\W");
    int[] values = new int[time.length];
    for (int i = 0; i < values.length; ++i) {
        values[i] = Integer.parseInt(time[i]);
    }

    return new Time(
            new Partial(Time.getFields(values.length), values),
            BaseTemporal.resolveDateTimeZone(getTimezone(operand.toString()))
    );
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:18,代码来源:ToTimeEvaluator.java

示例4: testMaximum

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.Max#evaluate(Context)}
 */
@Test
public void testMaximum() throws JAXBException {
    Context context = new Context(library);
    Object result = context.resolveExpressionRef("IntegerMaxValue").getExpression().evaluate(context);
    assertThat(result, is(Integer.MAX_VALUE));

    result = context.resolveExpressionRef("DecimalMaxValue").getExpression().evaluate(context);
    Assert.assertTrue(((BigDecimal) result).compareTo((BigDecimal) Value.maxValue(BigDecimal.class)) == 0);

    // TODO: QuantityMaxValue

    result = context.resolveExpressionRef("DateTimeMaxValue").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {9999, 12, 31, 23, 59, 59, 999})));

    result = context.resolveExpressionRef("TimeMaxValue").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {23, 59, 59, 999})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:21,代码来源:CqlArithmeticFunctionsTest.java

示例5: testMinimum

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.Min#evaluate(Context)}
 */
@Test
public void testMinimum() throws JAXBException {
    Context context = new Context(library);
    Object result = context.resolveExpressionRef("IntegerMinValue").getExpression().evaluate(context);
    assertThat(result, is(Integer.MIN_VALUE));

    result = context.resolveExpressionRef("DecimalMinValue").getExpression().evaluate(context);
    Assert.assertTrue(((BigDecimal) result).compareTo((BigDecimal) Value.minValue(BigDecimal.class)) == 0);

    // TODO: QuantityMinValue

    result = context.resolveExpressionRef("DateTimeMinValue").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {0001, 1, 1, 0, 0, 0, 0})));

    result = context.resolveExpressionRef("TimeMinValue").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {0, 0, 0, 0})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:21,代码来源:CqlArithmeticFunctionsTest.java

示例6: testExcept

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.ExceptEvaluator#evaluate(Context)}
 */
@Test
public void testExcept() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("ExceptEmptyListAndEmptyList").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("Except1234And23").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 4)));

    result = context.resolveExpressionRef("Except23And1234").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("ExceptDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((List)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((List)result).size(), is(1));

    result = context.resolveExpressionRef("ExceptTime").getExpression().evaluate(context);
    assertThat(((Time)((List)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((List)result).size(), is(1));

    result = context.resolveExpressionRef("ExceptNullRight").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 4)));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:28,代码来源:CqlListOperatorsTest.java

示例7: testFlatten

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.FlattenEvaluator#evaluate(Context)}
 */
@Test
public void testFlatten() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("FlattenEmpty").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("FlattenListNullAndNull").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(null, null)));

    result = context.resolveExpressionRef("FlattenList12And34").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 2, 3, 4)));

    result = context.resolveExpressionRef("FlattenDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((List)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((DateTime)((List)result).get(1)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));
    assertThat(((List)result).size(), is(2));

    result = context.resolveExpressionRef("FlattenTime").getExpression().evaluate(context);
    assertThat(((Time)((List)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((Time)((List)result).get(1)).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
    assertThat(((List)result).size(), is(2));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:27,代码来源:CqlListOperatorsTest.java

示例8: testFirst

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.FirstEvaluator#evaluate(Context)}
 */
@Test
public void testFirst() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("FirstEmpty").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("FirstNull1").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("First1Null").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("First12").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("FirstDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));

    result = context.resolveExpressionRef("FirstTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:26,代码来源:CqlListOperatorsTest.java

示例9: testIntersect

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.IntersectEvaluator#evaluate(Context)}
 */
@Test
public void testIntersect() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IntersectEmptyListAndEmptyList").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("Intersect1234And23").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(2, 3)));

    result = context.resolveExpressionRef("Intersect23And1234").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(2, 3)));

    result = context.resolveExpressionRef("IntersectDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((ArrayList)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((DateTime)((ArrayList)result).get(1)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));
    assertThat(((ArrayList)result).size(), is(2));

    result = context.resolveExpressionRef("IntersectTime").getExpression().evaluate(context);
    assertThat(((Time)((ArrayList)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((Time)((ArrayList)result).get(1)).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
    assertThat(((ArrayList)result).size(), is(2));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:27,代码来源:CqlListOperatorsTest.java

示例10: testLast

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.LastEvaluator#evaluate(Context)}
 */
@Test
public void testLast() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("LastEmpty").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("LastNull1").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("Last1Null").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("Last12").getExpression().evaluate(context);
    assertThat(result, is(2));

    result = context.resolveExpressionRef("LastDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));

    result = context.resolveExpressionRef("LastTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:26,代码来源:CqlListOperatorsTest.java

示例11: testDateTime

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.DateTimeEvaluator#evaluate(Context)}
 */
@Test
public void testDateTime() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("DateTimeYear").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(1), new int[] {2003})));

    result = context.resolveExpressionRef("DateTimeMonth").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(2), new int[] {2003, 10})));

    result = context.resolveExpressionRef("DateTimeDay").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2003, 10, 29})));

    result = context.resolveExpressionRef("DateTimeHour").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(4), new int[] {2003, 10, 29, 20})));

    result = context.resolveExpressionRef("DateTimeMinute").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(5), new int[] {2003, 10, 29, 20, 50})));

    result = context.resolveExpressionRef("DateTimeSecond").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(6), new int[] {2003, 10, 29, 20, 50, 33})));

    result = context.resolveExpressionRef("DateTimeMillisecond").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {2003, 10, 29, 20, 50, 33, 955})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:29,代码来源:CqlDateTimeOperatorsTest.java

示例12: testToday

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.TodayEvaluator#evaluate(Context)}
 */
@Test
public void testToday() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayTrue1").getExpression().evaluate(context);
    assertThat(result, is(true));

    result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayTrue2").getExpression().evaluate(context);
    assertThat(result, is(true));

    result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayFalse").getExpression().evaluate(context);
    assertThat(result, is(false));

    result = context.resolveExpressionRef("DateTimeAddTodayTrue").getExpression().evaluate(context);
    assertThat(result, is(true));

    context = new Context(library, new DateTime(new Partial(DateTime.getFields(7), new int[] {2016, 6, 10, 5, 5, 4, 999}), DateTimeZone.forOffsetHours(-7)));
    result = context.resolveExpressionRef("Issue34B").getExpression().evaluate(context);
    assertThat(((DateTime) result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2016, 6, 10})));
    assertThat(((DateTime) result).getTimezoneOffset(), is(new BigDecimal("-7.00")));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:25,代码来源:CqlDateTimeOperatorsTest.java

示例13: TestStart

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.StartEvaluator#evaluate(Context)}
 */
@Test
public void TestStart() {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IntegerIntervalStart").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("DecimalIntervalStart").getExpression().evaluate(context);
    assertThat(result, is(new BigDecimal("1.0")));

    result = context.resolveExpressionRef("QuantityIntervalStart").getExpression().evaluate(context);
    Assert.assertTrue(((Quantity) result).equal(new Quantity().withValue(new BigDecimal("1.0")).withUnit("g")));

    result = context.resolveExpressionRef("DateTimeIntervalStart").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {2016, 5, 1, 0, 0, 0, 0})));

    result = context.resolveExpressionRef("TimeIntervalStart").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {0, 0, 0, 0})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:23,代码来源:CqlIntervalOperatorsTest.java

示例14: maxValue

import org.joda.time.Partial; //导入依赖的package包/类
public static Object maxValue(Type type) {
    if (type == Integer.class) {
        return Integer.MAX_VALUE;
    }
    else if (type == BigDecimal.class) {
        return new BigDecimal("9999999999999999999999999999.99999999");
    }
    else if (type == Quantity.class) {
        return new Quantity().withValue((BigDecimal)maxValue(BigDecimal.class));
    }
    else if (type == DateTime.class) {
        return new DateTime(new Partial(DateTime.fields, new int[] {9999, 12, 31, 23, 59, 59, 999}));
    }
    else if (type == Time.class) {
        return new Time(new Partial(Time.fields, new int[] {23, 59, 59, 999}));
    }

    throw new NotImplementedException(String.format("MaxValue is not implemented for type %s.", type.getTypeName()));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:20,代码来源:Value.java

示例15: testIndexer

import org.joda.time.Partial; //导入依赖的package包/类
/**
 * {@link org.opencds.cqf.cql.elm.execution.IndexerEvaluator#evaluate(Context)}
 */
@Test
public void testIndexer() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IndexerNull1").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("Indexer0Of12").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("Indexer1Of12").getExpression().evaluate(context);
    assertThat(result, is(2));

    result = context.resolveExpressionRef("Indexer2Of12").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("IndexerNeg1Of12").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("IndexerDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));

    result = context.resolveExpressionRef("IndexerTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:29,代码来源:CqlListOperatorsTest.java


注:本文中的org.joda.time.Partial类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。