public void testASCIIAttribute() {
   final MetadataAttribute attribute1 = new MetadataAttribute("name", ProductData.TYPE_ASCII, 1);
   attribute1.getData().setElems("new data");
   // attribute should be of type ASCII and not INT8
   assertEquals(attribute1.getDataType(), ProductData.TYPE_ASCII);
   final MetadataAttribute attribute2 =
       new MetadataAttribute("name", new ProductData.ASCII("my string"), false);
   // attribute should be of type ASCII and not INT8
   assertEquals(attribute2.getDataType(), ProductData.TYPE_ASCII);
 }
Exemplo n.º 2
0
  private void writeMetadataAttribute(int locationID, MetadataAttribute attribute)
      throws IOException {
    int productDataType = attribute.getDataType();
    if (attribute.getData() instanceof ProductData.ASCII
        || attribute.getData() instanceof ProductData.UTC) {
      createScalarAttribute(locationID, attribute.getName(), attribute.getData().getElemString());
    } else if (attribute.getData().isScalar()) {
      createScalarAttribute(
          locationID,
          attribute.getName(),
          getH5DataType(productDataType),
          attribute.getData().getElems());
    } else {
      createArrayAttribute(
          locationID,
          attribute.getName(),
          getH5DataType(productDataType),
          attribute.getData().getNumElems(),
          attribute.getData().getElems());
    }
    if (_metadataAnnotated) {
      if (attribute.getUnit() != null) {
        createScalarAttribute(locationID, attribute.getName() + ".unit", attribute.getUnit());
      }

      if (attribute.getDescription() != null) {
        createScalarAttribute(
            locationID, attribute.getName() + ".descr", attribute.getDescription());
      }
    }
  }