protected Object readAtomicScalar ( VarNotes vi , TypeNotes ti ) throws DapException { DapVariable atomvar = ( DapVariable ) getTemplate ( ) ; // Get into memory Nc4prototypes nc4 = ( ( Nc4DSP ) this . dsp ) . getJNI ( ) ; int ret ; DapType basetype = ti . getType ( ) ; Object result = null ; if ( basetype . isFixedSize ( ) ) { long memsize = ( ( DapType ) ti . get ( ) ) . getSize ( ) ; Nc4Pointer mem = Nc4Pointer . allocate ( memsize ) ; readcheck ( nc4 , ret = nc4 . nc_get_var ( vi . gid , vi . id , mem . p ) ) ; setMemory ( mem ) ; result = getatomicdata ( ti . getType ( ) , 1 , mem . size , mem ) ; } else if ( basetype . isStringType ( ) ) { String [ ] s = new String [ 1 ] ; readcheck ( nc4 , ret = nc4 . nc_get_var_string ( vi . gid , vi . id , s ) ) ; result = s ; } else if ( basetype . isOpaqueType ( ) ) { Nc4Pointer mem = Nc4Pointer . allocate ( ti . getSize ( ) ) ; readcheck ( nc4 , ret = nc4 . nc_get_var ( vi . gid , vi . id , mem . p ) ) ; setMemory ( mem ) ; ByteBuffer [ ] buf = new ByteBuffer [ 1 ] ; buf [ 0 ] = mem . p . getByteBuffer ( 0 , ti . getSize ( ) ) ; result = buf ; } else throw new DapException ( "Unexpected atomic type: " + basetype ) ; return result ; }
Read a top - level scalar atomic variable