gov.nist.microanalysis.EPQTools
Class RippleFile

java.lang.Object
  extended by gov.nist.microanalysis.EPQTools.RippleFile

public class RippleFile
extends java.lang.Object

A class for reading and writing LISPIX-style Ripple files (rpl/raw)


Field Summary
static java.lang.String BIG_ENDIAN
           
static java.lang.String DONT_CARE_ENDIAN
           
static java.lang.String DONT_CARE_ORDER
           
static java.lang.String FLOAT
           
static java.lang.String IMAGE_ORDER
           
static java.lang.String LITTLE_ENDIAN
           
static java.lang.String SIGNED
           
static java.lang.String UNSIGNED
           
static java.lang.String VECTOR_ORDER
           
 
Constructor Summary
RippleFile(int width, int height, int depth, java.lang.String dataType, int byteDepth, java.lang.String order, java.lang.String rplFile, java.lang.String rawFile)
          Constructs a new RippleFile with the specified properties.
RippleFile(java.lang.String rplFile, boolean readOnly)
          Constructs a RippleFile from the name of the header file.
RippleFile(java.lang.String rplFile, java.lang.String rawFile, boolean readOnly)
          Constructs a RippleFile given explicit paths to the Ripple and raw files.
 
Method Summary
 void close()
          close - Closes the associated disk files.
 int fileSize()
          fileSize - Returns the size of the full raw file in bytes.
 int getCurrentCol()
          getCurrentCol - Returns the column on which the next read/write will happen
 int getCurrentItem()
          getCurrentItem - Returns the item index on which the next read/write will happen
 int getCurrentRow()
          getCurrentRow - Returns the row on which the next read/write will happen
 java.lang.String getDataType()
          getDataType - Returns the type of data item
 int getDatumSize()
          getDatumSize - Returns the size in bytes of the underlying data objects
 int getDepth()
          getDepth - Returns the depth of the underlying data matrix
 int getHeight()
          getHeight - Returns the height of the underlying data matrix
 int getWidth()
          getWidth - Returns the width of the underlying data matrix
 boolean isEof()
          isEof - Does the current position represent the end-of-file (end of data)
 double readDouble()
          readDouble - Read a single datum and return the value as a double.
 double[] readDouble(int len)
          readDouble - read len count data objects and return them as an array of doubles.
 double[] readDoubleItem()
          readDoubleItem - read depth (getDepth()) count of data objects and return them as an array of doubles.
 int readInt()
          readInt - Read a single integer
 int[] readInt(int len)
          readInt - read len count of integers
 int[] readIntItem()
          readIntItem - read depth (getDepth()) count of integer
 long readUnsigned()
          readUnsigned - Read a single unsigned integer
 void seek(int row, int col)
          seek - Moves the read/write pointer to the start of the specified item at [row,col]
 void seek(int row, int col, int item)
          seek - Moves the read/write pointer to the start of the specified datum at [row,col,item]
 void write(double val)
          write - Write a single double
 void write(double[] vals)
          write - Write an array of doubles
 void write(int val)
          write - Write a single integer
 void write(int[] vals)
          write - Write an array of integers (converts to float if necessary to be compatible with the underlying file.)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIG_ENDIAN

public static final java.lang.String BIG_ENDIAN
See Also:
Constant Field Values

LITTLE_ENDIAN

public static final java.lang.String LITTLE_ENDIAN
See Also:
Constant Field Values

DONT_CARE_ENDIAN

public static final java.lang.String DONT_CARE_ENDIAN
See Also:
Constant Field Values

IMAGE_ORDER

public static final java.lang.String IMAGE_ORDER
See Also:
Constant Field Values

VECTOR_ORDER

public static final java.lang.String VECTOR_ORDER
See Also:
Constant Field Values

DONT_CARE_ORDER

public static final java.lang.String DONT_CARE_ORDER
See Also:
Constant Field Values

SIGNED

public static final java.lang.String SIGNED
See Also:
Constant Field Values

UNSIGNED

public static final java.lang.String UNSIGNED
See Also:
Constant Field Values

FLOAT

public static final java.lang.String FLOAT
See Also:
Constant Field Values
Constructor Detail

RippleFile

public RippleFile(int width,
                  int height,
                  int depth,
                  java.lang.String dataType,
                  int byteDepth,
                  java.lang.String order,
                  java.lang.String rplFile,
                  java.lang.String rawFile)
           throws java.io.IOException
Constructs a new RippleFile with the specified properties.

Parameters:
width - - The width of each row (# of columns) within the Ripple file
height - - The number of rows
depth - - The number of data items at each [row,col] position
dataType - - One of RippleFile.SIGNED, RippleFile.UNSIGNED or RippleFile.FLOAT
byteDepth - - 1, 2, 4 for SIGNED or UNSIGNED, 4 or 8 for FLOAT
order - - BIG_ENDIAN, LITTLE_ENDIAN or DONT_CARE_ENDIAN
rplFile - - File name (usually *.rpl)
rawFile - - File name (usually *.raw)
Throws:
java.io.IOException

RippleFile

public RippleFile(java.lang.String rplFile,
                  boolean readOnly)
           throws java.lang.Exception,
                  java.io.IOException,
                  java.io.FileNotFoundException
Constructs a RippleFile from the name of the header file. The name of the raw file is inferred from the name of the header as first "header.rpl" then "header.". If neither is found then a FileNotFoundException is thrown.

Parameters:
rplFile - The name of the Ripple header file
readOnly - Should the file be opened as read-only?
Throws:
java.lang.Exception
java.io.IOException
java.io.FileNotFoundException

RippleFile

public RippleFile(java.lang.String rplFile,
                  java.lang.String rawFile,
                  boolean readOnly)
           throws java.lang.Exception,
                  java.io.IOException,
                  java.io.FileNotFoundException
Constructs a RippleFile given explicit paths to the Ripple and raw files.

Parameters:
rplFile - The name of the Ripple header file
rawFile - The name of the raw file
readOnly - Should the file be opened as read-only?
Throws:
java.lang.Exception
java.io.IOException
java.io.FileNotFoundException
Method Detail

fileSize

public int fileSize()
fileSize - Returns the size of the full raw file in bytes.

Returns:
int

close

public void close()
           throws java.io.IOException
close - Closes the associated disk files. Don't try to read, write or seek after performing this operation.

Throws:
java.io.IOException

seek

public void seek(int row,
                 int col)
          throws java.io.IOException
seek - Moves the read/write pointer to the start of the specified item at [row,col]

Parameters:
row -
col -
Throws:
java.io.IOException

seek

public void seek(int row,
                 int col,
                 int item)
          throws java.io.IOException
seek - Moves the read/write pointer to the start of the specified datum at [row,col,item]

Parameters:
row -
col -
item -
Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException
readDouble - Read a single datum and return the value as a double. (Converts ints into doubles if necessary)

Returns:
double
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
readInt - Read a single integer

Returns:
int
Throws:
java.io.IOException

readUnsigned

public long readUnsigned()
                  throws java.io.IOException
readUnsigned - Read a single unsigned integer

Returns:
long
Throws:
java.io.IOException

readInt

public int[] readInt(int len)
              throws java.io.IOException
readInt - read len count of integers

Parameters:
len -
Returns:
int[]
Throws:
java.io.IOException

readDouble

public double[] readDouble(int len)
                    throws java.io.IOException
readDouble - read len count data objects and return them as an array of doubles. (Will convert integers to doubles as necessary)

Parameters:
len -
Returns:
double[]
Throws:
java.io.IOException

readDoubleItem

public double[] readDoubleItem()
                        throws java.io.IOException
readDoubleItem - read depth (getDepth()) count of data objects and return them as an array of doubles. (Will convert integers into doubles as necessary)

Returns:
double[]
Throws:
java.io.IOException

readIntItem

public int[] readIntItem()
                  throws java.io.IOException
readIntItem - read depth (getDepth()) count of integer

Returns:
int[]
Throws:
java.io.IOException

write

public void write(int val)
           throws java.io.IOException
write - Write a single integer

Parameters:
val -
Throws:
java.io.IOException

write

public void write(double val)
           throws java.io.IOException
write - Write a single double

Parameters:
val -
Throws:
java.io.IOException

write

public void write(int[] vals)
           throws java.io.IOException
write - Write an array of integers (converts to float if necessary to be compatible with the underlying file.)

Parameters:
vals -
Throws:
java.io.IOException

write

public void write(double[] vals)
           throws java.io.IOException
write - Write an array of doubles

Parameters:
vals -
Throws:
java.io.IOException

getWidth

public int getWidth()
getWidth - Returns the width of the underlying data matrix

Returns:
int

getHeight

public int getHeight()
getHeight - Returns the height of the underlying data matrix

Returns:
int

getDepth

public int getDepth()
getDepth - Returns the depth of the underlying data matrix

Returns:
int

getDatumSize

public int getDatumSize()
getDatumSize - Returns the size in bytes of the underlying data objects

Returns:
1,2,4 or 8 bytes

getDataType

public java.lang.String getDataType()
getDataType - Returns the type of data item

Returns:
Returns RippleFile.SIGNED, RippleFile.UNSIGNED or RippleFile.FLOAT

getCurrentRow

public int getCurrentRow()
getCurrentRow - Returns the row on which the next read/write will happen

Returns:
int

getCurrentCol

public int getCurrentCol()
getCurrentCol - Returns the column on which the next read/write will happen

Returns:
int

getCurrentItem

public int getCurrentItem()
getCurrentItem - Returns the item index on which the next read/write will happen

Returns:
int

isEof

public boolean isEof()
isEof - Does the current position represent the end-of-file (end of data)

Returns:
true or false