public int convertScalarInt ( int recnum , StructureMembers . Member m ) { if ( m . getDataType ( ) == DataType . INT || m . getDataType ( ) == DataType . UINT ) return getScalarInt ( recnum , m ) ; if ( m . getDataType ( ) == DataType . SHORT ) return ( int ) getScalarShort ( recnum , m ) ; if ( m . getDataType ( ) == DataType . USHORT ) return DataType . unsignedShortToInt ( getScalarShort ( recnum , m ) ) ; if ( m . getDataType ( ) == DataType . BYTE ) return ( int ) getScalarByte ( recnum , m ) ; if ( m . getDataType ( ) == DataType . UBYTE ) return ( int ) DataType . unsignedByteToShort ( getScalarByte ( recnum , m ) ) ; if ( m . getDataType ( ) == DataType . LONG || m . getDataType ( ) == DataType . ULONG ) return ( int ) getScalarLong ( recnum , m ) ; Object o = getScalarObject ( recnum , m ) ; if ( o instanceof Number ) return ( ( Number ) o ) . intValue ( ) ; throw new ForbiddenConversionException ( "Type is " + m . getDataType ( ) + ", not convertible to int" ) ; }
Get scalar value as an int with conversion as needed . Underlying type must be convertible to int .