Beispiel #1
0
 /**
  * Returns an array of {@link FieldMetaType}s in the order of field occurrence.
  *
  * @return
  */
 private FieldMetaType[] getFieldTypes() {
   return header.getFieldTypes().toArray(new FieldMetaType[header.getFieldTypes().size()]);
 }
Beispiel #2
0
  /**
   * Sets up a mapping which describes the order of occurrence of comma separated fields - mapping
   * their ordinal position to the {@link Encoder} which services the encoding of the field
   * occurring in that position. This sequence of types is contained by an instance of {@link
   * Header} which makes available an array of {@link FieldMetaType}s.
   */
  private void makeIndexEncoderMap() {
    indexToEncoderMap = new TIntObjectHashMap<Encoder<?>>();

    for (int i = 0, size = header.getFieldNames().size(); i < size; i++) {
      switch (header.getFieldTypes().get(i)) {
        case DATETIME:
          Optional<DateEncoder> de = getDateEncoder(encoder);
          if (de.isPresent()) {
            indexToEncoderMap.put(i, de.get());
          } else {
            throw new IllegalArgumentException(
                "DateEncoder never initialized: " + header.getFieldNames().get(i));
          }
          break;
        case BOOLEAN:
        case FLOAT:
        case INTEGER:
          Optional<Encoder<?>> ne = getNumberEncoder(encoder);
          if (ne.isPresent()) {
            indexToEncoderMap.put(i, ne.get());
          } else {
            throw new IllegalArgumentException(
                "Number (or Boolean) encoder never initialized: " + header.getFieldNames().get(i));
          }
          break;
        case LIST:
        case STRING:
          Optional<Encoder<?>> ce = getCategoryEncoder(encoder);
          if (ce.isPresent()) {
            indexToEncoderMap.put(i, ce.get());
          } else {
            throw new IllegalArgumentException(
                "Category encoder never initialized: " + header.getFieldNames().get(i));
          }
          break;
        case COORD:
        case GEO:
          Optional<Encoder<?>> ge = getCoordinateEncoder(encoder);
          if (ge.isPresent()) {
            indexToEncoderMap.put(i, ge.get());
          } else {
            throw new IllegalArgumentException(
                "Coordinate encoder never initialized: " + header.getFieldNames().get(i));
          }
          break;
        case SARR:
        case DARR:
          Optional<SDRPassThroughEncoder> spte = getSDRPassThroughEncoder(encoder);
          if (spte.isPresent()) {
            indexToEncoderMap.put(i, spte.get());
          } else {
            throw new IllegalArgumentException(
                "SDRPassThroughEncoder encoder never initialized: "
                    + header.getFieldNames().get(i));
          }
          break;
        default:
          break;
      }
    }
  }