예제 #1
0
파일: DataType.java 프로젝트: inexas/oak
  /**
   * Convert a value to an Oak markup representation.
   *
   * @param value The value to represent.
   * @param tb The buffer in which to write the markup.
   */
  public void toMarkup(Object value, Text t) {
    if (value == null) {
      t.append("null");
    } else {
      switch (this) {
        case z:
        case Z:
        case f:
        case F:
        case bool:
          t.append(value.toString());
          break;

        case cardinality:
          ((Cardinality) value).toString(t);
          break;

        case text:
          escapeForOak((String) value, true, t);
          break;

        case identifier:
          t.append(value.toString());
          break;

        case path:
          ((Path) value).toString(t);
          break;

        case datetime:
          t.append('@');
          t.append(DateU.formatStandardDatetime((LocalDateTime) value));
          break;

        case date:
          t.append('@');
          t.append(DateU.formatStandardDate((LocalDate) value));
          break;

        case time:
          t.append('@');
          t.append(DateU.formatStandardTime((LocalTime) value));
          break;

        case any:
        default:
          throw new UnexpectedException("asString: " + this);
      }
    }
  }