static public ArrayStructureBB copyToArrayBB ( ArrayStructure as , ByteOrder bo , boolean canonical ) throws IOException { if ( ! canonical && as . getClass ( ) . equals ( ArrayStructureBB . class ) ) { // no subclasses, LOOK detect already canonical later ArrayStructureBB abb = ( ArrayStructureBB ) as ; ByteBuffer bb = abb . getByteBuffer ( ) ; if ( bo == null || bo . equals ( bb . order ( ) ) ) return abb ; } StructureMembers smo = as . getStructureMembers ( ) ; StructureMembers sm = new StructureMembers ( smo ) ; ArrayStructureBB abb = new ArrayStructureBB ( sm , as . getShape ( ) ) ; ArrayStructureBB . setOffsets ( sm ) ; // this makes the packing canonical if ( bo != null ) { ByteBuffer bb = abb . getByteBuffer ( ) ; bb . order ( bo ) ; } try ( StructureDataIterator iter = as . getStructureDataIterator ( ) ) { while ( iter . hasNext ( ) ) copyToArrayBB ( iter . next ( ) , abb ) ; } return abb ; }
Make deep copy from an ArrayStructure to a ArrayStructureBB whose data is contained in a ByteBuffer