public int getIntegerValue ( ) throws IOException , SaneException { // check for type agreement Preconditions . checkState ( getValueType ( ) == OptionValueType . INT , "option is not an integer" ) ; Preconditions . checkState ( getValueCount ( ) == 1 , "option is an integer array, not integer" ) ; // Send RCP corresponding to: // // SANE_Status sane_control_option (SANE_Handle h, SANE_Int n, // SANE_Action a, void *v, // SANE_Int * i); ControlOptionResult result = readOption ( ) ; Preconditions . checkState ( result . getType ( ) == OptionValueType . INT ) ; Preconditions . checkState ( result . getValueSize ( ) == SaneWord . SIZE_IN_BYTES , "unexpected value size " + result . getValueSize ( ) + ", expecting " + SaneWord . SIZE_IN_BYTES ) ; // TODO: handle resource authorisation // TODO: check status -- may have to reload options!! return SaneWord . fromBytes ( result . getValue ( ) ) . integerValue ( ) ; // the // value }
Reads the current Integer value option . We do not cache value from previous get or set operations so each get involves a round trip to the server .