Package ucar.nc2.iosp
Class IospArrayHelper
- java.lang.Object
-
- ucar.nc2.iosp.IospArrayHelper
-
public class IospArrayHelper extends Object
Helper methods for IOSP's for reading data.
-
-
Constructor Summary
Constructors Constructor Description IospArrayHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
makePrimitiveArray(int size, ArrayType arrayType)
Create 1D primitive array of the given size and typestatic Object
makePrimitiveArray(int size, ArrayType arrayType, Object fillValue)
Create 1D primitive array of the given size and type, fill it with the given valuestatic Object
readData(LayoutBB layout, ArrayType arrayType, Object arr)
Read data subset from ByteBuffer, place in given primitive array.static Object
readData(PositioningDataInputStream raf, Layout index, ArrayType arrayType, Object arr)
Read data subset from PositioningDataInputStream, place in given primitive array.static Object
readData(RandomAccessFile raf, Layout layout, ArrayType arrayType, Object arr, ByteOrder byteOrder)
Read data subset from RandomAccessFile, place in given primitive array.static Object
readDataFill(LayoutBB layout, ArrayType arrayType, Object fillValue)
Read data subset from ByteBuffer, create primitive array of size Layout.getTotalNelems.static Object
readDataFill(PositioningDataInputStream is, Layout index, ArrayType ArrayType, Object fillValue)
Read data subset from PositioningDataInputStream, create primitive array of size Layout.getTotalNelems.static Object
readDataFill(RandomAccessFile raf, Layout index, ArrayType arrayType, Object fillValue, ByteOrder byteOrder)
Read data subset from RandomAccessFile, create primitive array of size Layout.getTotalNelems.
-
-
-
Method Detail
-
readDataFill
public static Object readDataFill(RandomAccessFile raf, Layout index, ArrayType arrayType, Object fillValue, ByteOrder byteOrder) throws IOException
Read data subset from RandomAccessFile, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.- Parameters:
raf
- read from here.index
- handles skipping around in the file.arrayType
- ArrayType of the variablefillValue
- must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for nonebyteOrder
- if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before reading- Returns:
- primitive array with data read in
- Throws:
IOException
- on read error
-
readData
public static Object readData(RandomAccessFile raf, Layout layout, ArrayType arrayType, Object arr, ByteOrder byteOrder) throws IOException
Read data subset from RandomAccessFile, place in given primitive array. Reading is controlled by the Layout object.- Parameters:
raf
- read from here.layout
- handles skipping around in the file.arrayType
- ArrayType of the variablearr
- primitive array to read data intobyteOrder
- if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before reading- Returns:
- primitive array with data read in
- Throws:
IOException
- on read error
-
readDataFill
public static Object readDataFill(PositioningDataInputStream is, Layout index, ArrayType ArrayType, Object fillValue) throws IOException
Read data subset from PositioningDataInputStream, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.- Parameters:
is
- read from here.index
- handles skipping around in the file.ArrayType
- ArrayType of the variablefillValue
- must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none- Returns:
- primitive array with data read in
- Throws:
IOException
- on read error
-
readData
public static Object readData(PositioningDataInputStream raf, Layout index, ArrayType arrayType, Object arr) throws IOException
Read data subset from PositioningDataInputStream, place in given primitive array. Reading is controlled by the Layout object.- Parameters:
raf
- read from here.index
- handles skipping around in the file.arrayType
- ArrayType of the variablearr
- primitive array to read data into- Returns:
- primitive array with data read in
- Throws:
IOException
- on read error
-
readDataFill
public static Object readDataFill(LayoutBB layout, ArrayType arrayType, Object fillValue)
Read data subset from ByteBuffer, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.- Parameters:
layout
- handles skipping around in the file, provide ByteBuffer to read fromarrayType
- ArrayType of the variablefillValue
- must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none- Returns:
- primitive array with data read in
-
readData
public static Object readData(LayoutBB layout, ArrayType arrayType, Object arr)
Read data subset from ByteBuffer, place in given primitive array. Reading is controlled by the LayoutBB object.- Parameters:
layout
- handles skipping around in the file, privide ByteBuffer to read fromarrayType
- ArrayType of the variablearr
- primitive array to read data into- Returns:
- the primitive array with data read in
-
makePrimitiveArray
public static Object makePrimitiveArray(int size, ArrayType arrayType)
Create 1D primitive array of the given size and type- Parameters:
size
- the size of the array to createarrayType
- ArrayType of the variable- Returns:
- primitive array with all zeroes
-
makePrimitiveArray
public static Object makePrimitiveArray(int size, ArrayType arrayType, Object fillValue)
Create 1D primitive array of the given size and type, fill it with the given value- Parameters:
size
- the size of the array to createarrayType
- ArrayType of the variablefillValue
- must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none- Returns:
- primitive array with data read in
-
-