public abstract class StringElementSizer extends Object
This functionality is required when writing VOTable output; the FIELD headers need to have the common length of the strings, since VOTable output may contain variable-length arrays of fixed-length strings, but not fixed-length arrays of variable-length strings.
A number of implementations are provided. The basic approaches are to read all the elements and find the maximum string length, which in general requires an extra pass through the data, or just provide some sort of guess.
Modifier and Type | Field and Description |
---|---|
static StringElementSizer |
ASSERT_UNUSED
If called upon to provide length values, a false assertion is made.
|
static StringElementSizer |
ERROR_IF_USED
If called upon to provide length values, an error will be raised.
|
static StringElementSizer |
FIXED2
A fixed element length of 2 is used.
|
static StringElementSizer |
NOCALC
The existing string length values, which may not be legal, are copied.
|
static StringElementSizer |
READ
All elements are read and the maximum length used.
|
static StringElementSizer |
SAMPLE
The first few elements are read and the maximum length used.
|
Constructor and Description |
---|
StringElementSizer() |
Modifier and Type | Method and Description |
---|---|
abstract int[] |
calculateStringArrayElementSizes(StarTable table,
int[] icols)
Fills in element length values for string array-valued columns
in a supplied table.
|
static StringElementSizer |
createFixedSizer(int elSize)
Creates an instance that reports a fixed length for all strings.
|
static StringElementSizer |
createSampleReadSizer(int maxRow)
Creates an instance which reads some or all of the data to determine
the maximum string length.
|
public static final StringElementSizer NOCALC
public static final StringElementSizer READ
public static final StringElementSizer SAMPLE
public static final StringElementSizer FIXED2
public static final StringElementSizer ERROR_IF_USED
public static final StringElementSizer ASSERT_UNUSED
public abstract int[] calculateStringArrayElementSizes(StarTable table, int[] icols) throws IOException
The return value is an array the same size as the input
icols
array whose elements are the calculated
string lengths (ValueInfo.getElementSize()
)
for the corresponding column indices.
table
- input tableicols
- index array of String[]-valued columns whose
element lengths need to be determinedIOException
public static StringElementSizer createFixedSizer(int elSize)
elSize
- fixed string lengthpublic static StringElementSizer createSampleReadSizer(int maxRow)
maxRow
- maximum number of rows to read;
if not positive, all rows are readCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.