Package ucar.nc2.iosp
Class IospHelper
java.lang.Object
ucar.nc2.iosp.IospHelper
Helper methods for IOSP's for reading data.
- Since:
- Jan 3, 2008
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]convertByteToBoolean(byte[] from) static char[]convertByteToChar(byte[] byteArray) static char[]convertByteToCharUTF(byte[] byteArray) static byte[]convertCharToByte(char[] from) static byte[]convertCharToByteUTF(char[] from) static ArrayStructureBBcopyToArrayBB(StructureData sdata) Deprecated.use StructureDataDeep.copyToArrayBBstatic longcopyToByteChannel(Array data, WritableByteChannel channel) Copy data to a channel.static longcopyToOutputStream(Array data, OutputStream out) Copy data to a OutputStream.static ArrayStructureBBDeprecated.use StructureDataDeep.copyToArrayBBstatic ObjectmakePrimitiveArray(int size, DataType dataType) Create 1D primitive array of the given size and typestatic ObjectmakePrimitiveArray(int size, DataType dataType, Object fillValue) Create 1D primitive array of the given size and type, fill it with the given valuestatic ObjectRead data subset from ByteBuffer, place in given primitive array.static ObjectreadData(PositioningDataInputStream raf, Layout index, DataType dataType, Object arr) Read data subset from PositioningDataInputStream, place in given primitive array.static ObjectreadData(RandomAccessFile raf, Layout layout, DataType dataType, Object arr, int byteOrder, boolean convertChar) Read data subset from RandomAccessFile, place in given primitive array.static ObjectreadDataFill(LayoutBB layout, DataType dataType, Object fillValue) Read data subset from ByteBuffer, create primitive array of size Layout.getTotalNelems.static ObjectreadDataFill(PositioningDataInputStream is, Layout index, DataType dataType, Object fillValue) Read data subset from PositioningDataInputStream, create primitive array of size Layout.getTotalNelems.static ObjectreadDataFill(RandomAccessFile raf, Layout index, DataType dataType, Object fillValue, int byteOrder) Read data subset from RandomAccessFile, create primitive array of size Layout.getTotalNelems.static ObjectreadDataFill(RandomAccessFile raf, Layout index, DataType dataType, Object fillValue, int byteOrder, boolean convertChar) static Arraystatic longtransferData(Array result, WritableByteChannel channel)
-
Constructor Details
-
IospHelper
public IospHelper()
-
-
Method Details
-
readDataFill
public static Object readDataFill(RandomAccessFile raf, Layout index, DataType dataType, Object fillValue, int 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.dataType- dataType of the variablefillValue- must be Number if dataType.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
-
readDataFill
public static Object readDataFill(RandomAccessFile raf, Layout index, DataType dataType, Object fillValue, int byteOrder, boolean convertChar) throws IOException - Throws:
IOException
-
readData
public static Object readData(RandomAccessFile raf, Layout layout, DataType dataType, Object arr, int byteOrder, boolean convertChar) 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.dataType- dataType of the variablearr- primitive array to read data intobyteOrder- if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before readingconvertChar- true if bytes should be converted to char for dataType CHAR- Returns:
- primitive array with data read in
- Throws:
IOException- on read error
-
readDataFill
public static Object readDataFill(PositioningDataInputStream is, Layout index, DataType dataType, 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.dataType- dataType of the variablefillValue- must be Number if dataType.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, DataType dataType, 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.dataType- dataType of the variablearr- primitive array to read data into- Returns:
- primitive array with data read in
- Throws:
IOException- on read error
-
readDataFill
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 fromdataType- dataType of the variablefillValue- must be Number if dataType.isNumeric(), or String for STRING, byte[] for Structure, or null for none- Returns:
- primitive array with data read in
-
readData
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 fromdataType- dataType of the variablearr- primitive array to read data into- Returns:
- the primitive array with data read in
-
copyToByteChannel
Copy data to a channel. Used by ncstream. Not doing Structures correctly yet.- Parameters:
data- copy from herechannel- copy to here- Returns:
- number of bytes copied
- Throws:
IOException- on write error
-
copyToOutputStream
Copy data to a OutputStream. Used by ncstream. Not doing Structures correctly yet.- Parameters:
data- copy from hereout- copy to here- Returns:
- number of bytes copied
- Throws:
IOException- on write error
-
makeArrayBB
Deprecated.use StructureDataDeep.copyToArrayBB- Throws:
IOException
-
copyToArrayBB
Deprecated.use StructureDataDeep.copyToArrayBB -
makePrimitiveArray
Create 1D primitive array of the given size and type- Parameters:
size- the size of the array to createdataType- dataType of the variable- Returns:
- primitive array with data read in
-
makePrimitiveArray
Create 1D primitive array of the given size and type, fill it with the given value- Parameters:
size- the size of the array to createdataType- dataType of the variablefillValue- must be Number if dataType.isNumeric(), or String for STRING, byte[] for Structure, or null for none- Returns:
- primitive array with data read in
-
convertByteToCharUTF
public static char[] convertByteToCharUTF(byte[] byteArray) -
convertCharToByteUTF
public static byte[] convertCharToByteUTF(char[] from) -
convertByteToChar
public static char[] convertByteToChar(byte[] byteArray) -
convertCharToByte
public static byte[] convertCharToByte(char[] from) -
convertByteToBoolean
public static boolean[] convertByteToBoolean(byte[] from) -
transferData
- Throws:
IOException
-
readSection
- Throws:
IOExceptionInvalidRangeException
-