Exemple #1
0
  /**
   * ************************************************************************* See description of
   * superclass/interface.
   *
   * @see ch.skyguide.message.structure.AbstractGenericDataBlock#encode()
   */
  @Override
  public ByteBuffer encode() {
    ByteBuffer dataBlockBuffer = ByteBuffer.allocate(getFieldLengthIndicator());

    dataBlockBuffer.put((byte) getDataCategory());
    dataBlockBuffer.putShort((short) getFieldLengthIndicator());

    for (GenericRecord currentRecord : m_records) {
      dataBlockBuffer.put(currentRecord.encode());
    }

    dataBlockBuffer.flip();

    return dataBlockBuffer.asReadOnlyBuffer();
  }
 /**
  * ************************************************************************* extracts a DataField
  * from a GenericRecord, checks it's not null, renders it as String
  *
  * @param r the GenericRecord to extract data from
  * @param frn the Field Reference Number of the data field to extract
  * @return the string representation for the matching field
  */
 private String extractField(GenericRecord r, int frn) {
   final DataField f = r.getDataField(frn);
   Assert.assertNotNull(f);
   return f.toString();
 }