static public Index slicesToIndex ( List < Slice > slices ) throws DapException { long [ ] positions = new long [ slices . size ( ) ] ; long [ ] dimsizes = new long [ slices . size ( ) ] ; for ( int i = 0 ; i < positions . length ; i ++ ) { Slice s = slices . get ( i ) ; if ( s . getCount ( ) != 1 ) throw new DapException ( "Attempt to convert non-singleton sliceset to index" ) ; positions [ i ] = s . getFirst ( ) ; dimsizes [ i ] = s . getMax ( ) ; } return new Index ( positions , dimsizes ) ; }
If a set of slices refers to a single position then return the corresponding Index . Otherwise throw Exception .