cdm/src/main/java/ucar/ma2/ArraySequence.java
private Array extractMemberArrayFromIteration(StructureMembers.Member proxym, int[] rshape) throws IOException {
    DataType dataType = proxym.getDataType();
    Object dataArray = null;
    int count = 0;
    int initial = 1000;

    try (StructureDataIterator sdataIter = getStructureDataIterator()) {
      switch (dataType) {
        case DOUBLE: {
          ArrayList<Double> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            double[] data = sdata.getJavaArrayDouble(realm);
            for (double aData : data) result.add(aData);
            count++;
          }
          double[] da = new double[result.size()];
          int i = 0;
          for (Double d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case FLOAT: {
          ArrayList<Float> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            float[] data = sdata.getJavaArrayFloat(realm);
            for (float aData : data) result.add(aData);
            count++;
          }
          float[] da = new float[result.size()];
          int i = 0;
          for (Float d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case UBYTE:
        case BYTE:
        case ENUM1:
        {
          ArrayList<Byte> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            byte[] data = sdata.getJavaArrayByte(realm);
            for (byte aData : data) result.add(aData);
            count++;
          }
          byte[] da = new byte[result.size()];
          int i = 0;
          for (Byte d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case USHORT:
        case SHORT:
        case ENUM2:
        {
          ArrayList<Short> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            short[] data = sdata.getJavaArrayShort(realm);
            for (short aData : data) result.add(aData);
            count++;
          }
          short[] da = new short[result.size()];
          int i = 0;
          for (Short d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case UINT:
        case INT:
        case ENUM4:
        {
          ArrayList<Integer> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            int[] data = sdata.getJavaArrayInt(realm);
            for (int aData : data) result.add(aData);
            count++;
          }
          int[] da = new int[result.size()];
          int i = 0;
          for (Integer d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case ULONG:
        case LONG: {
          ArrayList<Long> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            long[] data = sdata.getJavaArrayLong(realm);
            for (long aData : data) result.add(aData);
            count++;
          }
          long[] da = new long[result.size()];
          int i = 0;
          for (Long d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case CHAR: {
          ArrayList<Character> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            char[] data = sdata.getJavaArrayChar(realm);
            for (char aData : data) result.add(aData);
            count++;
          }
          char[] da = new char[result.size()];
          int i = 0;
          for (Character d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case STRING: {
          ArrayList<String> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            String[] data = sdata.getJavaArrayString(realm);
            result.addAll(Arrays.asList(data));
            count++;
          }
          String[] da = new String[result.size()];
          int i = 0;
          for (String d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case STRUCTURE: {
          ArrayList<StructureData> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            ArrayStructure as = sdata.getArrayStructure(realm);
            StructureDataIterator innerIter = as.getStructureDataIterator();
            while (innerIter.hasNext())
              result.add(innerIter.next());
            count++;
          }

          rshape[0] = count;
          StructureMembers membersw = new StructureMembers(proxym.getStructureMembers()); // no data arrays get propagated
          return new ArrayStructureW(membersw, rshape, result.toArray(new StructureData[0]));
        }
      }
    }

    // create an array to hold the result
    rshape[0] = count;
    return Array.factory(dataType, rshape, dataArray);
  }
private Array extractMemberArrayFromIteration(StructureMembers.Member proxym, int[] rshape) throws IOException {
    DataType dataType = proxym.getDataType();
    Object dataArray = null;
    int count = 0;
    int initial = 1000;

    try (StructureDataIterator sdataIter = getStructureDataIterator()) {
      switch (dataType) {
        case DOUBLE: {
          ArrayList<Double> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            double[] data = sdata.getJavaArrayDouble(realm);
            for (double aData : data) result.add(aData);
            count++;
          }
          double[] da = new double[result.size()];
          int i = 0;
          for (Double d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case FLOAT: {
          ArrayList<Float> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            float[] data = sdata.getJavaArrayFloat(realm);
            for (float aData : data) result.add(aData);
            count++;
          }
          float[] da = new float[result.size()];
          int i = 0;
          for (Float d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case UBYTE:
        case BYTE:
        case ENUM1:
        {
          ArrayList<Byte> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            byte[] data = sdata.getJavaArrayByte(realm);
            for (byte aData : data) result.add(aData);
            count++;
          }
          byte[] da = new byte[result.size()];
          int i = 0;
          for (Byte d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case USHORT:
        case SHORT:
        case ENUM2:
        {
          ArrayList<Short> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            short[] data = sdata.getJavaArrayShort(realm);
            for (short aData : data) result.add(aData);
            count++;
          }
          short[] da = new short[result.size()];
          int i = 0;
          for (Short d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case UINT:
        case INT:
        case ENUM4:
        {
          ArrayList<Integer> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            int[] data = sdata.getJavaArrayInt(realm);
            for (int aData : data) result.add(aData);
            count++;
          }
          int[] da = new int[result.size()];
          int i = 0;
          for (Integer d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case ULONG:
        case LONG: {
          ArrayList<Long> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            long[] data = sdata.getJavaArrayLong(realm);
            for (long aData : data) result.add(aData);
            count++;
          }
          long[] da = new long[result.size()];
          int i = 0;
          for (Long d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case CHAR: {
          ArrayList<Character> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            char[] data = sdata.getJavaArrayChar(realm);
            for (char aData : data) result.add(aData);
            count++;
          }
          char[] da = new char[result.size()];
          int i = 0;
          for (Character d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case STRING: {
          ArrayList<String> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            String[] data = sdata.getJavaArrayString(realm);
            result.addAll(Arrays.asList(data));
            count++;
          }
          String[] da = new String[result.size()];
          int i = 0;
          for (String d : result) da[i++] = d;
          dataArray = da;
          break;
        }

        case STRUCTURE: {
          ArrayList<StructureData> result = new ArrayList<>(initial);
          while (sdataIter.hasNext()) {
            StructureData sdata = sdataIter.next();
            StructureMembers.Member realm = sdata.getStructureMembers().findMember(proxym.getName());
            ArrayStructure as = sdata.getArrayStructure(realm);
            StructureDataIterator innerIter = as.getStructureDataIterator();
            while (innerIter.hasNext())
              result.add(innerIter.next());
            count++;
          }

          rshape[0] = count;
          StructureMembers membersw = new StructureMembers(proxym.getStructureMembers()); // no data arrays get propagated
          return new ArrayStructureW(membersw, rshape, result.toArray(new StructureData[0]));
        }
      }
    }

    // create an array to hold the result
    rshape[0] = count;
    return Array.factory(dataType, rshape, dataArray);
  }
when we dont know how many in the iteration