Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.fudaa.dodico.fortran
Class FortranBinaryInputStream  view FortranBinaryInputStream download FortranBinaryInputStream.java

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byjava.io.DataInputStream
              extended byorg.fudaa.dodico.fortran.NativeBinaryInputStream
                  extended byorg.fudaa.dodico.fortran.FortranBinaryInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class FortranBinaryInputStream
extends NativeBinaryInputStream

Une classe facilitant la lecture de fichiers binaires écrits par Fortran L'équivalence d'intructions entre Java et Fortran se fera de la manière suivante :

 (en considérant i=integer/int, f=real/float, d=double precision/double et
 s=character*()/String)
 1) Pour un fichier à acces séquentiel :
 Fortran
 open  (unit=10,file='fichier.bin',access='sequentiel',form='unformatted')
 read  (unit=10) ,,, 
 ...
 close (unit=10)
 Java
 FortranBinaryInputStream in=
 new FortranBinaryInputStream(new FileInputStream("fichier.bin"),true);
 in.readRecord();
 i=in.readInteger();
 f=in.readReal();
 d=in.readDoublePrecision();
 s=in.readCharacter(s.length());
 ...
 in.close();
 2) Pour un fichier à acces direct :
 Fortran
 open  (unit=10,file='fichier.bin',access='direct',recl=30,form='unformatted')
 read  (unit=10,rec=1) ,,,
 ...
 close (unit=10)
 Java
 FortranBinaryInputStream in=
 new FortranBinaryInputStream(new FileInputStream("fichier.bin"),false);
 in.setRecordLength(30);
 in.readRecord();
 i=in.readInteger();
 f=in.readReal();
 d=in.readDoublePrecision();
 s=in.readCharacter(s.length());
 ...
 in.close();
 

Version:
$Revision: 1.9 $ $Date: 2002/11/25 09:59:25 $ by $Author: deniger $

Field Summary
private  long currentPos_
           
private  long nextPos_
           
private  int recordLength_
           
private  boolean sequential_
           
 
Fields inherited from class org.fudaa.dodico.fortran.NativeBinaryInputStream
buf, i1, i2, i3, i4, l1, l2, l3, l4, l5, l6, l7, l8, s1, s2, SPARC, SPARC_NAME, X86, X86_NAME
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
FortranBinaryInputStream(java.io.InputStream _in, boolean _sequential)
          Création en précisant si le fichier binaire est à access séquentiel ou non.
FortranBinaryInputStream(java.io.InputStream _in, boolean _sequential, java.lang.String _architectureID)
          Il est possible de definir l'architecture intel ( little indian) ou sparc (big indian).
 
Method Summary
 int getRecordLength()
          Retourne la longueur des enregistrements (pour les fichiers à accès Direct
 int getSequentialRecordLength()
          ATTENTION Different du cas acces direct.
 long positionCourante()
          Renvoie en nb d'octets la position courante.
 java.lang.String readCharacter(int _lgString)
          Lecture d'un champ chaine de caractères "character" Fortran
 double readDoublePrecision()
          Lecture d'un champ réel en double précision "double precision" Fortran
 float readFloat_32()
           
 double readFloat_64()
           
 short readInt_16()
          Redefinition de la methode (changement: la position courante est geree).
 int readInt_32()
          Redefinition de la methode (changement: la position courante est geree).
 long readInt_64()
           
 byte readInt_8()
          Redefinition de la methode (changement: la position courante est geree).
 int readInteger()
          Lecture d'un champ entier "integer" Fortran
 float readReal()
          Lecture d'un champ réel "real" Fortran
 void readRecord()
          Lecture des champs de l'enregistrement.
 int readUInt_16()
          Redefinition de la methode (changement: la position courante est geree).
 long readUInt_32()
          Redefinition de la methode (changement: la position courante est geree).
 short readUInt_8()
          Redefinition de la methode (changement: la position courante est geree).
 void setRecordLength(int _length)
          Affectation de la longueur des enregistrements (pour les fichiers à accès Direct
 
Methods inherited from class org.fudaa.dodico.fortran.NativeBinaryInputStream
getMachineId, isFinFichier, isMachineKnown, isSparc, isX86, setMachineType
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequential_

private boolean sequential_

recordLength_

private int recordLength_

currentPos_

private long currentPos_

nextPos_

private long nextPos_
Constructor Detail

FortranBinaryInputStream

public FortranBinaryInputStream(java.io.InputStream _in,
                                boolean _sequential)
                         throws java.io.IOException
Création en précisant si le fichier binaire est à access séquentiel ou non. Si sequentiel, alors certaines donnees ( generees par la meme instruction write de fortran) sont entourees par 4 octets qui correspondent a la longueur de l'enregistrement. La variable systeme ("os.arch") permet de déterminer l'architecture a utiliser.


FortranBinaryInputStream

public FortranBinaryInputStream(java.io.InputStream _in,
                                boolean _sequential,
                                java.lang.String _architectureID)
                         throws java.io.IOException
Il est possible de definir l'architecture intel ( little indian) ou sparc (big indian).

Method Detail

getSequentialRecordLength

public int getSequentialRecordLength()
ATTENTION Different du cas acces direct. Renvoie la taille de l'enregistrement lu par le flux.


setRecordLength

public void setRecordLength(int _length)
Affectation de la longueur des enregistrements (pour les fichiers à accès Direct


getRecordLength

public int getRecordLength()
Retourne la longueur des enregistrements (pour les fichiers à accès Direct


readCharacter

public java.lang.String readCharacter(int _lgString)
                               throws java.io.IOException
Lecture d'un champ chaine de caractères "character" Fortran


readInteger

public int readInteger()
                throws java.io.IOException
Lecture d'un champ entier "integer" Fortran


readReal

public float readReal()
               throws java.io.IOException
Lecture d'un champ réel "real" Fortran


readDoublePrecision

public double readDoublePrecision()
                           throws java.io.IOException
Lecture d'un champ réel en double précision "double precision" Fortran


readInt_8

public byte readInt_8()
               throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readInt_8 in class NativeBinaryInputStream

readUInt_8

public short readUInt_8()
                 throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readUInt_8 in class NativeBinaryInputStream

readInt_16

public short readInt_16()
                 throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readInt_16 in class NativeBinaryInputStream

readUInt_16

public int readUInt_16()
                throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readUInt_16 in class NativeBinaryInputStream

readInt_32

public int readInt_32()
               throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readInt_32 in class NativeBinaryInputStream

readUInt_32

public long readUInt_32()
                 throws java.io.IOException
Redefinition de la methode (changement: la position courante est geree).

Overrides:
readUInt_32 in class NativeBinaryInputStream

readInt_64

public long readInt_64()
                throws java.io.IOException
Overrides:
readInt_64 in class NativeBinaryInputStream

readFloat_32

public float readFloat_32()
                   throws java.io.IOException
Overrides:
readFloat_32 in class NativeBinaryInputStream

readFloat_64

public double readFloat_64()
                    throws java.io.IOException
Overrides:
readFloat_64 in class NativeBinaryInputStream

positionCourante

public long positionCourante()
Renvoie en nb d'octets la position courante.


readRecord

public void readRecord()
                throws java.io.IOException
Lecture des champs de l'enregistrement. L'enregistrement doit etre lu avant la lecture des champs. Un enregistrement correspond à une instruction READ du Fortran