public static int productFromUri ( URI uri ) throws DataSourceResourceException { try { return Integer . parseInt ( uri . getPath ( ) . substring ( 1 ) , 16 ) ; } catch ( NumberFormatException e ) { throw new DataSourceResourceException ( "USB device must be of the format " + DEFAULT_USB_DEVICE_URI + " -- the given " + uri + " has a bad product ID" ) ; } catch ( StringIndexOutOfBoundsException e ) { throw new DataSourceResourceException ( "USB device must be of the format " + DEFAULT_USB_DEVICE_URI + " -- the given " + uri + " has a bad product ID" ) ; } }
Return an integer product ID from a URI specifying a USB device .