nom.tam.fits
Class FitsUtil

java.lang.Object
  extended by nom.tam.fits.FitsUtil

public class FitsUtil
extends java.lang.Object

This class comprises static utility functions used throughout the FITS classes.


Constructor Summary
FitsUtil()
           
 
Method Summary
static int addPadding(int size)
          Total size of blocked FITS element
static long addPadding(long size)
           
static java.lang.String[] byteArrayToStrings(byte[] o, int maxLen)
          Convert bytes to Strings
static long findOffset(java.lang.Object o)
          Find out where we are in a random access file
static java.io.InputStream getURLStream(java.net.URL url, int level)
          Get a stream to a URL accommodating possible redirections.
static boolean isCompressed(java.io.File test)
          Is a file compressed?
static boolean isCompressed(java.lang.String filename)
          Check if a file seems to be compressed.
static int maxLength(java.lang.String[] o)
          Get the maximum length of a String in a String array.
static void pad(ArrayDataOutput stream, long size)
          Add padding to an output stream.
static void pad(ArrayDataOutput stream, long size, byte fill)
          Add padding to an output stream.
static int padding(int size)
          How many bytes are needed to fill the last 2880 block?
static int padding(long size)
           
static void reposition(java.lang.Object o, long offset)
          Reposition a random access stream to a requested offset
static byte[] stringsToByteArray(java.lang.String[] o, int maxLen)
          Copy an array of Strings to bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FitsUtil

public FitsUtil()
Method Detail

reposition

public static void reposition(java.lang.Object o,
                              long offset)
                       throws FitsException
Reposition a random access stream to a requested offset

Throws:
FitsException

findOffset

public static long findOffset(java.lang.Object o)
Find out where we are in a random access file


padding

public static int padding(int size)
How many bytes are needed to fill the last 2880 block?


padding

public static int padding(long size)

addPadding

public static int addPadding(int size)
Total size of blocked FITS element


addPadding

public static long addPadding(long size)

isCompressed

public static boolean isCompressed(java.io.File test)
Is a file compressed?


isCompressed

public static boolean isCompressed(java.lang.String filename)
Check if a file seems to be compressed.


maxLength

public static int maxLength(java.lang.String[] o)
                     throws FitsException
Get the maximum length of a String in a String array.

Throws:
FitsException

stringsToByteArray

public static byte[] stringsToByteArray(java.lang.String[] o,
                                        int maxLen)
Copy an array of Strings to bytes.


byteArrayToStrings

public static java.lang.String[] byteArrayToStrings(byte[] o,
                                                    int maxLen)
Convert bytes to Strings


getURLStream

public static java.io.InputStream getURLStream(java.net.URL url,
                                               int level)
                                        throws java.io.IOException
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

pad

public static void pad(ArrayDataOutput stream,
                       long size)
                throws FitsException
Add padding to an output stream.

Throws:
FitsException

pad

public static void pad(ArrayDataOutput stream,
                       long size,
                       byte fill)
                throws FitsException
Add padding to an output stream.

Throws:
FitsException