public static Long extractToLong ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Long argout = null ; if ( value instanceof Short ) { argout = Long . valueOf ( ( ( Short ) value ) . longValue ( ) ) ; } else if ( value instanceof String ) { try { argout = Long . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToLong(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = Long . valueOf ( ( ( Integer ) value ) . longValue ( ) ) ; } else if ( value instanceof Long ) { argout = Long . valueOf ( ( ( Long ) value ) . longValue ( ) ) ; } else if ( value instanceof Float ) { argout = Long . valueOf ( ( ( Float ) value ) . longValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Long . valueOf ( 1 ) ; } else { argout = Long . valueOf ( 0 ) ; } } else if ( value instanceof Double ) { argout = Long . valueOf ( ( ( Double ) value ) . longValue ( ) ) ; } else if ( value instanceof DevState ) { argout = Long . valueOf ( Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) . longValue ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToLong(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a Long