public Slice finish ( ) throws DapException { // Attempt to repair undefined values if ( this . first == UNDEFINED ) this . first = 0 ; // default if ( this . stride == UNDEFINED ) this . stride = 1 ; // default if ( this . stop == UNDEFINED && this . maxsize != UNDEFINED ) this . stop = this . maxsize ; if ( this . stop == UNDEFINED && this . maxsize == UNDEFINED ) this . stop = this . first + 1 ; if ( this . maxsize == UNDEFINED && this . stop != UNDEFINED ) this . maxsize = this . stop ; // else (this.stop != UNDEFINED && this.maxsize != UNDEFINED) assert ( this . first != UNDEFINED ) ; assert ( this . stride != UNDEFINED ) ; assert ( this . stop != UNDEFINED ) ; // sanity checks if ( this . first > this . maxsize ) throw new DapException ( "Slice: first index > max size" ) ; if ( this . stop > ( this . maxsize + 1 ) ) throw new DapException ( "Slice: stop > max size" ) ; if ( this . first < 0 ) throw new DapException ( "Slice: first index < 0" ) ; if ( this . stop < 0 ) throw new DapException ( "Slice: stop index < 0" ) ; if ( this . stride <= 0 ) throw new DapException ( "Slice: stride index <= 0" ) ; if ( this . first > this . stop ) throw new DapException ( "Slice: first index > last" ) ; return this ; // fluent interface }
Perform sanity checks on a slice and repair where possible .