public final class SaneWord
extends java.lang.Object
SIZE_IN_BYTES bytes.
See the SANE specification for a thorough discussion about the SANE word type.
| Modifier and Type | Field and Description |
|---|---|
static int |
SIZE_IN_BYTES
The number of bytes used to represent a SANE word.
|
static com.google.common.base.Function<SaneWord,java.lang.Double> |
TO_FIXED_FUNCTION
A function that, when applied to a
SaneWord instance, returns the SANE fixed precision
value of that SANE word. |
static com.google.common.base.Function<SaneWord,java.lang.Integer> |
TO_INTEGER_FUNCTION
A function that, when applied to a
SaneWord instance, returns the integer value of that
SANE word. |
| Modifier and Type | Method and Description |
|---|---|
double |
fixedPrecisionValue()
Returns the value of this
SaneWord treated as a SANE fixed precision value. |
static SaneWord |
forFixedPrecision(double value)
Creates a new
SaneWord from the given double. |
static SaneWord |
forInt(int value)
Returns a new
SaneWord representing the given integer value. |
static SaneWord |
forSaneVersion(int major,
int minor,
int build)
Returns a new
SaneWord representing the given SANE version. |
static SaneWord |
fromBytes(byte[] byteValue)
Creates a new
SaneWord from a copy of the given byte array. |
static SaneWord |
fromBytes(byte[] byteValue,
int offset)
Creates a new
SaneWord from a copy of the given bytes within the array. |
static SaneWord |
fromStream(java.io.InputStream input)
|
byte[] |
getValue()
Returns a copy of the underlying byte array representing this
SaneWord. |
int |
integerValue()
Treats this
SaneWord as an integer and returns the represented value. |
java.lang.String |
toString() |
public static final int SIZE_IN_BYTES
public static final com.google.common.base.Function<SaneWord,java.lang.Integer> TO_INTEGER_FUNCTION
SaneWord instance, returns the integer value of that
SANE word.integerValue()public static final com.google.common.base.Function<SaneWord,java.lang.Double> TO_FIXED_FUNCTION
SaneWord instance, returns the SANE fixed precision
value of that SANE word.fixedPrecisionValue()public static SaneWord fromStream(java.io.InputStream input) throws java.io.IOException
java.io.IOExceptionpublic static SaneWord forInt(int value)
SaneWord representing the given integer value.public static SaneWord forSaneVersion(int major, int minor, int build)
SaneWord representing the given SANE version.major - the SANE major versionminor - the SANE minor versionbuild - the SANE build identifierpublic byte[] getValue()
SaneWord. The length of
the array is SIZE_IN_BYTES bytes.public int integerValue()
SaneWord as an integer and returns the represented value.public double fixedPrecisionValue()
SaneWord treated as a SANE fixed precision value.public static SaneWord fromBytes(byte[] byteValue)
SaneWord from a copy of the given byte array. The array must be of length
SIZE_IN_BYTES, anything else will cause a runtime exception to be thrown.public static SaneWord fromBytes(byte[] byteValue, int offset)
SaneWord from a copy of the given bytes within the array.
offset + SIZE_IN_BYTES must be a valid index (i.e. there must be enough bytes in the
array at the given offset), otherwise a runtime exception is thrown.public java.lang.String toString()
toString in class java.lang.Object