Package nom.tam.fits
Class FitsUtil
- java.lang.Object
-
- nom.tam.fits.FitsUtil
-
public final class FitsUtil extends java.lang.ObjectThis class comprises static utility functions used throughout the FITS classes.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBYTE_REPRESENTING_BLANKprivate static intBYTE_REPRESENTING_MAX_ASCII_VALUEprivate static java.util.logging.LoggerLOGthe logger to log to.private static booleanwroteCheckingError
-
Constructor Summary
Constructors Modifier Constructor Description privateFitsUtil()Utility class, do not instantiate it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intaddPadding(int size)static longaddPadding(long size)(package private) static byte[]booleanToByte(boolean[] bool)static java.lang.String[]byteArrayToStrings(byte[] bytes, int maxLen)(package private) static boolean[]byteToBoolean(byte[] bytes)static longfindOffset(java.io.Closeable o)static java.io.InputStreamgetURLStream(java.net.URL url, int level)static intmaxLength(java.lang.String[] strings)static voidpad(ArrayDataOutput stream, long size)Add padding to an output stream.static voidpad(ArrayDataOutput stream, long size, byte fill)Add padding to an output stream.static intpadding(int size)static intpadding(long size)static voidreposition(java.io.Closeable o, long offset)Reposition a random access stream to a requested offset.static byte[]stringsToByteArray(java.lang.String[] stringArray, int maxLen)Convert an array of Strings to bytes.
-
-
-
Field Detail
-
BYTE_REPRESENTING_BLANK
private static final int BYTE_REPRESENTING_BLANK
- See Also:
- Constant Field Values
-
BYTE_REPRESENTING_MAX_ASCII_VALUE
private static final int BYTE_REPRESENTING_MAX_ASCII_VALUE
- See Also:
- Constant Field Values
-
LOG
private static final java.util.logging.Logger LOG
the logger to log to.
-
wroteCheckingError
private static boolean wroteCheckingError
-
-
Method Detail
-
addPadding
public static int addPadding(int size)
- Parameters:
size- the current size.- Returns:
- Total size of blocked FITS element, using e.v. padding to fits block size.
-
addPadding
public static long addPadding(long size)
- Parameters:
size- the current size.- Returns:
- Total size of blocked FITS element, using e.v. padding to fits block size.
-
booleanToByte
static byte[] booleanToByte(boolean[] bool)
- Parameters:
bool- array of booleans- Returns:
- Convert an array of booleans to bytes.
-
byteArrayToStrings
public static java.lang.String[] byteArrayToStrings(byte[] bytes, int maxLen)- Parameters:
bytes- byte array to convertmaxLen- the max string length- Returns:
- Convert bytes to Strings.
-
byteToBoolean
static boolean[] byteToBoolean(byte[] bytes)
- Parameters:
bytes- the array of bytes to get the booleans from.- Returns:
- Convert an array of bytes to booleans.
-
findOffset
public static long findOffset(java.io.Closeable o)
- Parameters:
o- the stream to get the position- Returns:
- Find out where we are in a random access file .
-
getURLStream
public static java.io.InputStream getURLStream(java.net.URL url, int level) throws java.io.IOException- Parameters:
url- the url to get the stream fromlevel- max levels of redirection- Returns:
- Get a stream to a URL accommodating possible redirections. Note that if a redirection request points to a different protocol than the original request, then the redirection is not handled automatically.
- Throws:
java.io.IOException- if the operation failed
-
maxLength
public static int maxLength(java.lang.String[] strings) throws FitsException- Parameters:
strings- array of strings to check- Returns:
- Get the maximum length of a String in a String array.
- Throws:
FitsException- if the operation failed
-
pad
public static void pad(ArrayDataOutput stream, long size) throws FitsException
Add padding to an output stream.- Parameters:
stream- stream to padsize- the current size- Throws:
FitsException- if the operation failed
-
pad
public static void pad(ArrayDataOutput stream, long size, byte fill) throws FitsException
Add padding to an output stream.- Parameters:
stream- stream to padsize- the current sizefill- the fill byte to use- Throws:
FitsException- if the operation failed
-
padding
public static int padding(int size)
- Parameters:
size- the size without padding- Returns:
- How many bytes are needed to fill a 2880 block?
-
padding
public static int padding(long size)
-
reposition
public static void reposition(java.io.Closeable o, long offset) throws FitsExceptionReposition a random access stream to a requested offset.- Parameters:
o- the closable to repositionoffset- the offset to position it to.- Throws:
FitsException- if the operation was failed or not possible
-
stringsToByteArray
public static byte[] stringsToByteArray(java.lang.String[] stringArray, int maxLen)Convert an array of Strings to bytes.- Parameters:
stringArray- the array with StringsmaxLen- the max length (in bytes) of every String- Returns:
- the resulting bytes
-
-