Java 类java.time.calendrical.DateTimeAccessor.Query 实例源码

项目:java8-backports    文件:DateTimePrintContext.java   
/**
 * Gets a value using a query.
 * 
 * @param query the query to use, not null
 * @return the result, null if not found and optional is true
 * @throws DateTimeException if the type is not available and the section is not optional
 */
<R> R getValue(Query<R> query) {

  R result = this.dateTime.query(query);
  if (result == null && this.optional == 0) {
    throw new DateTimeException("Unable to extract value: " + this.dateTime.getClass());
  }
  return result;
}
项目:java8-backports    文件:DateTimeFormatterBuilder.java   
@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {

  ZoneId zone = context.getValue(Query.ZONE_ID);
  if (zone == null) {
    return false;
  }
  // TODO: fix getText(textStyle, context.getLocale())
  buf.append(zone.getId()); // TODO: Use symbols
  return true;
}
项目:java8-backports    文件:DateTimeFormatterBuilder.java   
@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {

  ZoneId zone = context.getValue(Query.ZONE_ID);
  if (zone == null || (this.regionOnly && zone instanceof ZoneOffset)) {
    return false;
  }
  buf.append(zone.getId());
  return true;
}
项目:java8-backports    文件:DateTimeFormatterBuilder.java   
@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {

  Chrono<?> chrono = context.getValue(Query.CHRONO);
  if (chrono == null) {
    return false;
  }
  if (this.textStyle == null) {
    buf.append(chrono.getId());
  } else {
    buf.append(chrono.getId()); // TODO: Use symbols
  }
  return true;
}
项目:java8-backports    文件:AbstractDateTimeTest.java   
@Test(groups = { "tck" })
public void basicTest_query() {

  for (DateTimeAccessor sample : samples()) {
    assertEquals(sample.query(new Query<String>() {

      @Override
      public String doQuery(DateTimeAccessor dateTime) {

        return "foo";
      }
    }), "foo");
  }
}
项目:java8-backports    文件:TCKZonedDateTime.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_DATE_TIME.query(Query.CHRONO), ISOChrono.INSTANCE);
}
项目:java8-backports    文件:TCKZonedDateTime.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_DATE_TIME.query(Query.ZONE_ID), this.TEST_DATE_TIME.getZone());
}
项目:java8-backports    文件:TCKZonedDateTime.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_DATE_TIME.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKZonedDateTime.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_DATE_TIME.query(Query.OFFSET), OFFSET_0100);
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_2008_6_30_11_30_59_000000500.query(Query.CHRONO), ISOChrono.INSTANCE);
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_2008_6_30_11_30_59_000000500.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_2008_6_30_11_30_59_000000500.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_2008_6_30_11_30_59_000000500.query(Query.OFFSET), OFFSET_PONE);
}
项目:java8-backports    文件:TCKDayOfWeek.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(DayOfWeek.FRIDAY.query(Query.CHRONO), null);
}
项目:java8-backports    文件:TCKDayOfWeek.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(DayOfWeek.FRIDAY.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKDayOfWeek.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(DayOfWeek.FRIDAY.query(Query.TIME_PRECISION), null);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_2007_07_15_12_30_40_987654321.query(Query.CHRONO), ISOChrono.INSTANCE);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_2007_07_15_12_30_40_987654321.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_2007_07_15_12_30_40_987654321.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_2007_07_15_12_30_40_987654321.query(Query.OFFSET), null);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_2007_07_15.query(Query.CHRONO), ISOChrono.INSTANCE);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_2007_07_15.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_2007_07_15.query(Query.TIME_PRECISION), null);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_2007_07_15.query(Query.OFFSET), null);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_12_30_40_987654321.query(Query.CHRONO), null);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_12_30_40_987654321.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_12_30_40_987654321.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_12_30_40_987654321.query(Query.OFFSET), null);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_2007_07_15_PONE.query(Query.CHRONO), ISOChrono.INSTANCE);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_2007_07_15_PONE.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_2007_07_15_PONE.query(Query.TIME_PRECISION), null);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_2007_07_15_PONE.query(Query.OFFSET), OFFSET_PONE);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(this.TEST_11_30_59_500_PONE.query(Query.CHRONO), null);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(this.TEST_11_30_59_500_PONE.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(this.TEST_11_30_59_500_PONE.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_query_offset() {

  assertEquals(this.TEST_11_30_59_500_PONE.query(Query.OFFSET), OFFSET_PONE);
}
项目:java8-backports    文件:TestInstant.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(Instant.EPOCH.query(Query.CHRONO), null);
}
项目:java8-backports    文件:TestInstant.java   
@Test(groups = { "tck" })
public void test_query_zone() {

  assertEquals(Instant.EPOCH.query(Query.ZONE_ID), null);
}
项目:java8-backports    文件:TestInstant.java   
@Test(groups = { "tck" })
public void test_query_timePrecision() {

  assertEquals(Instant.EPOCH.query(Query.TIME_PRECISION), NANOS);
}
项目:java8-backports    文件:TCKMonth.java   
@Test(groups = { "tck" })
public void test_query_chrono() {

  assertEquals(Month.JUNE.query(Query.CHRONO), ISOChrono.INSTANCE);
}