Package org.apache.sis.storage.geotiff
Enum Type
- All Implemented Interfaces:
Serializable
,Comparable<Type>
,java.lang.constant.Constable
The types of values in a TIFF header. Provides also some support for reading a value of a given type.
Note on naming convention: the values in this enumeration are not necessarily named as the TIFF type names. This enumeration rather match the Java primitive type names.
- Since:
- 0.8
- Version:
- 1.2
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescription8-bits byte that contains a 7-bit ASCII code.An 8-bits signed (twos-complement) integer.Double precision (8-bytes) IEEE format.Single precision (4-bytes) IEEE format.A 32-bits (4-bytes) signed (twos-complement) integer.A 64-bits (8-bytes) signed (twos-complement) integer.Two signed integers: the first represents the numerator of a fraction; the second, the denominator.A 16-bits (2-bytes) signed (twos-complement) integer.A 8-bits unsigned integer.32-bits (4-bytes) unsigned integer.A 64-bits (8-bytes) unsigned integer.An 8-bits byte that may contain anything, depending on the definition of the field.Two unsigned integers: the first represents the numerator of a fraction; the second, the denominator.A 16-bits (2-bytes) unsigned integer. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int
The TIFF numerical code for this type.private static final Type[]
All types known to this enumeration in an array where the index is the GeoTIFF numerical code.(package private) final boolean
Whether this type is an unsigned integer.(package private) final int
The size of this type, in number of bytes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Type
(int code, int size, boolean isUnsigned) Creates a new enumeration -
Method Summary
Modifier and TypeMethodDescription(package private) final String
canNotConvert
(String value) Formats an error message for a value that cannot be converted.(package private) static void
ensureSingleton
(double previous, double actual, long count) Same asensureSingleton(long, long, long)
but with floating-point values.(package private) static void
ensureSingleton
(long previous, long actual, long count) Invoked byread(…)
method implementations for verifying that thecount
argument value is 1.readArray
(ChannelDataInput input, int count) Reads an arbitrary number of values as a Java array.double
readDouble
(ChannelDataInput input, long count) Reads a single value and returns it as adouble
type, performing conversion if needed.final int
readInt
(ChannelDataInput input, long count) Reads a single value and returns it as a signedint
type, performing conversion if needed.long
readLong
(ChannelDataInput input, long count) Reads a single value and returns it as along
type, performing conversion if needed.readObject
(ChannelDataInput input, long count) final short
readShort
(ChannelDataInput input, long count) Reads a single value and returns it as a signedshort
type, performing conversion if needed.String[]
readString
(ChannelDataInput input, long length, Charset charset) Reads the value as strings.final long
readUnsignedLong
(ChannelDataInput input, long count) Reads a single value which is expected to be positive.final Vector
readVector
(ChannelDataInput input, long count) Reads an arbitrary number of values as a wrapper around a Java array of primitive type.(package private) static String
toString
(long numerator, long denominator) Formats a rational number.(package private) static Type
valueOf
(int code) Returns the type for the given GeoTIFF code, ornull
if the given type is unknown.static Type
Returns the enum constant of this type with the specified name.static Type[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
UNDEFINED
An 8-bits byte that may contain anything, depending on the definition of the field.- TIFF name:
UNDEFINED
- TIFF code: 7
- TIFF name:
-
BYTE
An 8-bits signed (twos-complement) integer.- TIFF name:
SBYTE
- TIFF code: 6
- TIFF name:
-
UBYTE
A 8-bits unsigned integer.- TIFF name:
BYTE
- TIFF code: 1
- TIFF name:
-
SHORT
A 16-bits (2-bytes) signed (twos-complement) integer.- TIFF name:
SSHORT
- TIFF code: 8
- TIFF name:
-
USHORT
A 16-bits (2-bytes) unsigned integer.- TIFF name:
SHORT
- TIFF code: 3
- TIFF name:
-
INT
A 32-bits (4-bytes) signed (twos-complement) integer.- TIFF name:
SLONG
- TIFF code: 9
- TIFF name:
-
UINT
32-bits (4-bytes) unsigned integer.- TIFF name:
LONG
- TIFF code: 4
- TIFF name:
-
LONG
A 64-bits (8-bytes) signed (twos-complement) integer.- TIFF code: 17
-
ULONG
A 64-bits (8-bytes) unsigned integer.- TIFF code: 16
-
FLOAT
Single precision (4-bytes) IEEE format.- TIFF name:
FLOAT
- TIFF code: 11
- TIFF name:
-
DOUBLE
Double precision (8-bytes) IEEE format.- TIFF name:
DOUBLE
- TIFF code: 12
- TIFF name:
-
RATIONAL
Two signed integers: the first represents the numerator of a fraction; the second, the denominator.- TIFF name:
SRATIONAL
- TIFF code: 10
- TIFF name:
-
URATIONAL
Two unsigned integers: the first represents the numerator of a fraction; the second, the denominator.- TIFF name:
RATIONAL
- TIFF code: 5
- TIFF name:
-
ASCII
8-bits byte that contains a 7-bit ASCII code. In a string of ASCII characters, the last byte must be NUL (binary zero). The string length (including the NUL byte) is thecount
field before the string. NUL bytes may also appear in the middle of the string for separating its content into multi-strings.- TIFF name:
ASCII
- TIFF code: 2
- TIFF name:
-
-
Field Details
-
code
final int codeThe TIFF numerical code for this type. -
size
final int sizeThe size of this type, in number of bytes. -
isUnsigned
final boolean isUnsignedWhether this type is an unsigned integer. -
FROM_CODES
All types known to this enumeration in an array where the index is the GeoTIFF numerical code.
-
-
Constructor Details
-
Type
private Type(int code, int size, boolean isUnsigned) Creates a new enumeration
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
valueOf
Returns the type for the given GeoTIFF code, ornull
if the given type is unknown.- Parameters:
code
- the GeoTIFF numerical code.- Returns:
- the enumeration value that represent the given type, or
null
if unknown.
-
toString
-
ensureSingleton
static void ensureSingleton(long previous, long actual, long count) Invoked byread(…)
method implementations for verifying that thecount
argument value is 1. All read methods other thanreadArray(…)
expect exactly one value, except methods inASCII
enumeration value which are treated differently.While exactly one value is expected, we are tolerant to longer arrays provided that all values are the same. This is seen in practice where a value expected to apply to the image is repeated for each band.
- Parameters:
previous
- the previous value.actual
- the actual value.count
- the number of values to read.- Throws:
IllegalArgumentException
- ifcount
does not have the expected value.
-
ensureSingleton
static void ensureSingleton(double previous, double actual, long count) Same asensureSingleton(long, long, long)
but with floating-point values. -
canNotConvert
Formats an error message for a value that cannot be converted. -
readShort
Reads a single value and returns it as a signedshort
type, performing conversion if needed. This method should be invoked when the caller expects a single value.- Parameters:
input
- the input from where to read the value.count
- the amount of values (normally exactly 1).- Returns:
- the value as a
short
. - Throws:
IOException
- if an error occurred while reading the stream.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.ArithmeticException
- if the value cannot be represented in the Java signedshort
type.IllegalArgumentException
- if the value is not a singleton.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readInt
Reads a single value and returns it as a signedint
type, performing conversion if needed. This method should be invoked when the caller expects a single value.- Parameters:
input
- the input from where to read the value.count
- the amount of values (normally exactly 1).- Returns:
- the value as an
int
. - Throws:
IOException
- if an error occurred while reading the stream.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.ArithmeticException
- if the value cannot be represented in the Java signedint
type.IllegalArgumentException
- if the value is not a singleton.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readUnsignedLong
Reads a single value which is expected to be positive. A negative value may be an encoding error in the big TIFF file, or if it was really the intended value then something greater than what we can support.- Throws:
IOException
- if an error occurred while reading the stream.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.ArithmeticException
- if the value cannot be represented in the Java signedlong
type.IllegalArgumentException
- if the value is not a singleton.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readLong
Reads a single value and returns it as along
type, performing conversion if needed. This method should be invoked when the caller expect a single value.If the value is an ASCII type, then this method will parse the text as a number. This support of ASCII type is required for supporting the encoding used in the tags added by GDAL.
- Parameters:
input
- the input from where to read the value.count
- the amount of values (normally exactly 1).- Returns:
- the value as a
long
. - Throws:
IOException
- if an error occurred while reading the stream.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.ArithmeticException
- if the value cannot be represented in the Java signedlong
type.IllegalArgumentException
- if the value is not a singleton.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readDouble
Reads a single value and returns it as adouble
type, performing conversion if needed. This method should be invoked when the caller expect a single value.If the value is an ASCII type, then this method will parse the text as a number. This support of ASCII type is required for supporting the encoding used in the tags added by GDAL.
- Parameters:
input
- the input from where to read the value.count
- the amount of values (normally exactly 1).- Returns:
- the value as a
double
. - Throws:
IOException
- if an error occurred while reading the stream.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.IllegalArgumentException
- if the value is not a singleton.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readString
Reads the value as strings. There is usually exactly one string, but an arbitrary amount is allowed.- Parameters:
input
- the input from where to read the value.length
- the string length, including the final NUL byte.charset
- the character encoding (normally US ASCII).- Returns:
- the value as a string.
- Throws:
IOException
- if an error occurred while reading the stream.ArithmeticException
- if the given length is too large.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readObject
Returns the value as aVector
, aNumber
(only for fractions) or aString
instance. This method should be overridden by all enumeration values that do no overridereadArray(ChannelDataInput, int)
.- Parameters:
input
- the input from where to read the values.count
- the amount of values.- Returns:
- the value as a Java array or a
String
, ornull
if undefined. - Throws:
IOException
- if an error occurred while reading the stream.
-
readArray
Reads an arbitrary number of values as a Java array.- Parameters:
input
- the input from where to read the values.count
- the amount of values.- Returns:
- the value as a Java array. May be an empty array.
- Throws:
IOException
- if an error occurred while reading the stream.UnsupportedOperationException
- if this type isUNDEFINED
.
-
readVector
Reads an arbitrary number of values as a wrapper around a Java array of primitive type. This wrapper provide a more convenient way to access array elements than the object returned byreadArray(ChannelDataInput, int)
.- Parameters:
input
- the input from where to read the values.count
- the amount of values.- Returns:
- the value as a wrapper around a Java array of primitive type.
- Throws:
IOException
- if an error occurred while reading the stream.ArithmeticException
- if the given count is too large.NumberFormatException
- if the value was stored in ASCII and cannot be parsed.UnsupportedOperationException
- if this type isUNDEFINED
.
-