class ArraysConvert {

  public static Array<?> convertToArray(ucar.ma2.Array from) {
    if (from.isVlen()) {
      return convertVlen(from);
    }
    DataType dtype = from.getDataType();
    if (dtype == DataType.OPAQUE) {
      return convertOpaque(from);
    } else if (dtype == DataType.STRING) {
      String[] sarray = new String[(int) from.getSize()];
      for (int idx = 0; idx < sarray.length; idx++) {
        sarray[idx] = (String) from.getObject(idx);
      }
      return Arrays.factory(dtype, from.getShape(), sarray);
    } else if (dtype == DataType.STRUCTURE) {
      return convertArrayStructure(from);
    } else {
      return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype));
    }
  }

}