FreeHEP API
Version current

hep.io.xdr
Class XDRRandomAccessFile

java.lang.Object
  extended byjava.io.RandomAccessFile
      extended byhep.io.xdr.XDRRandomAccessFile
All Implemented Interfaces:
DataInput, DataOutput, XDRDataInput, XDRDataOutput

public class XDRRandomAccessFile
extends RandomAccessFile
implements XDRDataInput, XDRDataOutput

A random access file for use with XDR.

Version:
$Id: XDRRandomAccessFile.java,v 1.3 2003/09/16 23:11:55 tonyj Exp $
Author:
Tony Johnson (tonyj@slac.stanford.edu)
Source Code:
XDRRandomAccessFile.java

Constructor Summary
XDRRandomAccessFile(String name, String mode)
           
 
Method Summary
 void pad()
          Skips appropriate amount to bring stream to 4-byte boundary.
 double[] readDoubleArray(double[] buffer)
          Reads a double array.
 float[] readFloatArray(float[] buffer)
          Reads a float array.
 int[] readIntArray(int[] buffer)
          Reads an integer array.
 String readString()
          Read a String.
 String readString(int l)
          Reads a String of length l bytes, and skips appropriate amount to bring stream to 4-byte boundary.
 void writeDoubleArray(double[] array)
           
 void writeDoubleArray(double[] array, int start, int n)
           
 void writeFloatArray(float[] array)
           
 void writeFloatArray(float[] array, int start, int n)
           
 void writeIntArray(int[] array)
           
 void writeIntArray(int[] array, int start, int n)
           
 void writeString(String s)
          Write a string preceeded by its (int) length
 void writeStringChars(String s)
          Write a string (no length is written)
 
Methods inherited from class java.io.RandomAccessFile
close, getChannel, getFD, getFilePointer, length, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
 
Methods inherited from interface java.io.DataOutput
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 

Constructor Detail

XDRRandomAccessFile

public XDRRandomAccessFile(String name,
                           String mode)
                    throws IOException
Method Detail

pad

public void pad()
         throws IOException
Description copied from interface: XDRDataInput
Skips appropriate amount to bring stream to 4-byte boundary.

Specified by:
pad in interface XDRDataInput
Throws:
IOException

readDoubleArray

public double[] readDoubleArray(double[] buffer)
                         throws IOException
Description copied from interface: XDRDataInput
Reads a double array. Assumes int length proceeds array. Throws an exception if array length > 32767 to protect against bad data exhausting memory. If buffer is not null, and is large enough to hold array, it is filled and returned, otherwise a new array is allocated and returned.

Specified by:
readDoubleArray in interface XDRDataInput
Throws:
IOException

readFloatArray

public float[] readFloatArray(float[] buffer)
                       throws IOException
Description copied from interface: XDRDataInput
Reads a float array. Assumes int length proceeds array. Throws an exception if array length > 32767 to protect against bad data exhausting memory. If buffer is not null, and is large enough to hold array, it is filled and returned, otherwise a new array is allocated and returned.

Specified by:
readFloatArray in interface XDRDataInput
Throws:
IOException

readIntArray

public int[] readIntArray(int[] buffer)
                   throws IOException
Description copied from interface: XDRDataInput
Reads an integer array. Assumes int length proceeds array. Throws an exception if array length > 32767 to protect against bad data exhausting memory. If buffer is not null, and is large enough to hold array, it is filled and returned, otherwise a new array is allocated and returned.

Specified by:
readIntArray in interface XDRDataInput
Throws:
IOException

readString

public String readString(int l)
                  throws IOException
Description copied from interface: XDRDataInput
Reads a String of length l bytes, and skips appropriate amount to bring stream to 4-byte boundary.

Specified by:
readString in interface XDRDataInput
Throws:
IOException

readString

public String readString()
                  throws IOException
Description copied from interface: XDRDataInput
Read a String. Assumes int length proceeds String. Throws an exception if string length > 32767 to protect against bad data exhausting memory.

Specified by:
readString in interface XDRDataInput
Throws:
IOException

writeDoubleArray

public void writeDoubleArray(double[] array)
                      throws IOException
Specified by:
writeDoubleArray in interface XDRDataOutput
Throws:
IOException

writeDoubleArray

public void writeDoubleArray(double[] array,
                             int start,
                             int n)
                      throws IOException
Specified by:
writeDoubleArray in interface XDRDataOutput
Throws:
IOException

writeFloatArray

public void writeFloatArray(float[] array)
                     throws IOException
Specified by:
writeFloatArray in interface XDRDataOutput
Throws:
IOException

writeFloatArray

public void writeFloatArray(float[] array,
                            int start,
                            int n)
                     throws IOException
Specified by:
writeFloatArray in interface XDRDataOutput
Throws:
IOException

writeIntArray

public void writeIntArray(int[] array)
                   throws IOException
Specified by:
writeIntArray in interface XDRDataOutput
Throws:
IOException

writeIntArray

public void writeIntArray(int[] array,
                          int start,
                          int n)
                   throws IOException
Specified by:
writeIntArray in interface XDRDataOutput
Throws:
IOException

writeString

public void writeString(String s)
                 throws IOException
Description copied from interface: XDRDataOutput
Write a string preceeded by its (int) length

Specified by:
writeString in interface XDRDataOutput
Throws:
IOException

writeStringChars

public void writeStringChars(String s)
                      throws IOException
Description copied from interface: XDRDataOutput
Write a string (no length is written)

Specified by:
writeStringChars in interface XDRDataOutput
Throws:
IOException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.