|
From: <de...@us...> - 2003-09-02 08:43:02
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/fortran
In directory sc8-pr-cvs1:/tmp/cvs-serv9006/fortran
Modified Files:
FortranBinaryInputStream.java FortranWriter.java
NativeBinaryInputStream.java
Log Message:
Correction bug 797184
Amelioration lecture format reflux/telemac
Index: FortranBinaryInputStream.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/fortran/FortranBinaryInputStream.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** FortranBinaryInputStream.java 4 Jul 2003 12:47:12 -0000 1.5
--- FortranBinaryInputStream.java 2 Sep 2003 08:41:24 -0000 1.6
***************
*** 15,18 ****
--- 15,19 ----
/**
* Une classe facilitant la lecture de fichiers binaires écrits par Fortran
+ * Utilise la classe NativeBinaryInputStream qui est deja "bufferisee".
* L'équivalence d'intructions entre Java et Fortran se fera de la manière
* suivante :<BR>
***************
*** 63,69 ****
*
* Dans le cas acces sequentiel, un compteur permet de se positionner
! * dans le flux. Il faut faire attention lors de l'utilisation des methodes
! * mark et reset (par exemple) sur le inputstream donne en entree. le compteur
! * peut devenir faux.
*
*
--- 64,69 ----
*
* Dans le cas acces sequentiel, un compteur permet de se positionner
! * dans le flux.
! *
*
*
***************
*** 85,89 ****
* de l'enregistrement. La variable systeme ("os.arch") permet de déterminer
* l'architecture a utiliser.
! * @param _in InputStream
* @param _sequential <B>true</B> le fichier est binaire à accès
* <I>Sequential</I>. <B>false</B> le fichier est binaire à accès <I>Direct</I>
--- 85,89 ----
* de l'enregistrement. La variable systeme ("os.arch") permet de déterminer
* l'architecture a utiliser.
! * @param _in InputStream (inutile d'utiliser un buffer)
* @param _sequential <B>true</B> le fichier est binaire à accès
* <I>Sequential</I>. <B>false</B> le fichier est binaire à accès <I>Direct</I>
***************
*** 98,102 ****
* Il est possible de definir l'architecture intel ( little indian) ou sparc
* (big indian).
! * @param _in InputStream.
* @param _sequential <B>true</B> le fichier est binaire à accès
* <I>Sequential</I>. <B>false</B> le fichier est binaire à accès
--- 98,102 ----
* Il est possible de definir l'architecture intel ( little indian) ou sparc
* (big indian).
! * @param _in InputStream.(inutile d'utiliser un buffer)
* @param _sequential <B>true</B> le fichier est binaire à accès
* <I>Sequential</I>. <B>false</B> le fichier est binaire à accès
***************
*** 179,182 ****
--- 179,183 ----
/**
* Lecture d'un champ réel en double précision "<I>double precision</I>"
+ * soit 8 octets.
* Fortran
* @return double correspondant au double precision
***************
*** 284,288 ****
*/
public void readRecord() throws IOException {
! skip(nextPos_-currentPos_);
currentPos_=nextPos_;
--- 285,290 ----
*/
public void readRecord() throws IOException {
! long l=skip(nextPos_-currentPos_);
! if(l!=(nextPos_-currentPos_)) System.err.println("Probleme de lecture binaire");
currentPos_=nextPos_;
***************
*** 297,301 ****
/**
* Renvoie la position courante dans le flux.
- * @return long
*/
public int getCurrentPosition()
--- 299,302 ----
Index: FortranWriter.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/fortran/FortranWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FortranWriter.java 4 Jul 2003 12:47:13 -0000 1.4
--- FortranWriter.java 2 Sep 2003 08:41:24 -0000 1.5
***************
*** 13,19 ****
import java.io.PrintWriter;
import java.io.Writer;
! import java.util.Iterator;
! import java.util.Vector;
import org.fudaa.dodico.commun.DodicoLib;
--- 13,19 ----
import java.io.PrintWriter;
import java.io.Writer;
! import java.util.Collections;
+ import org.fudaa.dodico.commun.DodicoArrayList;
import org.fudaa.dodico.commun.DodicoLib;
***************
*** 28,76 ****
// extends PrintWriter
{
! protected Vector fields;
protected int number;
private Writer out_;
! private String line_separator_ = DodicoLib.LINE_SEP;
private StringBuffer buffer_;
! public FortranWriter(Writer _w)
! {
! out_=_w;
! fields=new Vector();
! number=-1;
}
!
! private void write(String _b) throws IOException
! {
out_.write(_b.toCharArray());
}
!
! private void write(StringBuffer _b) throws IOException
! {
! char[] c=new char[_b.length()];
_b.getChars(0, c.length, c, 0);
out_.write(c);
_b.setLength(0);
}
-
! public FortranWriter(PrintWriter _w)
! {
! out_ = _w;
! fields = new Vector();
! number = -1;
}
! public void close()
! throws IOException
! {
out_.close();
}
-
-
! public void flush()
! throws IOException
! {
out_.flush();
}
--- 28,70 ----
// extends PrintWriter
{
! protected DodicoArrayList fields;
! int nbMaxFields_;
! // protected Vector fields;
protected int number;
private Writer out_;
! private String line_separator_= DodicoLib.LINE_SEP;
private StringBuffer buffer_;
! public FortranWriter(Writer _w) {
! out_= _w;
! fields= new DodicoArrayList();
! // fields= new Vector();
! number= -1;
! nbMaxFields_= -1;
}
!
! private void write(String _b) throws IOException {
out_.write(_b.toCharArray());
}
!
! private void write(StringBuffer _b) throws IOException {
! char[] c= new char[_b.length()];
_b.getChars(0, c.length, c, 0);
out_.write(c);
_b.setLength(0);
}
! public FortranWriter(PrintWriter _w) {
! out_= _w;
! fields= new DodicoArrayList();
! // fields= new Vector();
! number= -1;
}
! public void close() throws IOException {
out_.close();
}
! public void flush() throws IOException {
out_.flush();
}
***************
*** 80,85 ****
* Incremente le num de ligne.
*/
! public void println(String _l) throws IOException
! {
write(_l + line_separator_);
//fields.clear();
--- 74,78 ----
* Incremente le num de ligne.
*/
! public void println(String _l) throws IOException {
write(_l + line_separator_);
//fields.clear();
***************
*** 87,90 ****
--- 80,89 ----
}
+ public void println() throws IOException {
+ write(line_separator_);
+ //fields.clear();
+ number++;
+ }
+
// public FortranWriter()
// {
***************
*** 100,126 ****
// }
! public int getLineNumber()
! {
return number;
}
! private boolean stringQuoted_ = true;
! public boolean isStringQuoted()
! {
return stringQuoted_;
}
! public void setStringQuoted(boolean _stringQuoted)
! {
! stringQuoted_ = _stringQuoted;
}
! public String getLineSeparator()
! {
return line_separator_;
}
! public void setLineSeparator(String _ls)
! {
! line_separator_ = _ls;
}
--- 99,120 ----
// }
! public int getLineNumber() {
return number;
}
! private boolean stringQuoted_= true;
! public boolean isStringQuoted() {
return stringQuoted_;
}
! public void setStringQuoted(boolean _stringQuoted) {
! stringQuoted_= _stringQuoted;
}
! public String getLineSeparator() {
return line_separator_;
}
! public void setLineSeparator(String _ls) {
! line_separator_= _ls;
}
***************
*** 129,161 ****
*/
! public void writeFields() throws IOException
! {
! String s;
! Object o;
! if(buffer_==null) buffer_=new StringBuffer(200);
! for (Iterator e = fields.iterator(); e.hasNext();)
! {
! o = e.next();
! if (o != null)
! {
! s = "";
!
! if (stringQuoted_ && (o instanceof String))
! {
! s = o.toString();
!
! if (s.indexOf('\'') >= 0)
! {
! for (int i = s.length() - 1; i >= 0; i--)
! if (s.charAt(i) == '\'')
! s = s.substring(0, i) + "''" + s.substring(i + 1);
! }
!
! s = "'" + s + "'";
! }
! else
! s = o.toString();
! buffer_.append(s + " ");
! //out_.write(s + " ");
}
}
--- 123,136 ----
*/
! public void writeFields() throws IOException {
! FormatField o;
! if (buffer_ == null)
! buffer_= new StringBuffer(200);
! // for (Iterator e= fields.iterator(); e.hasNext();) {
! // o= e.next();
! for (int i= 0; i <= nbMaxFields_; i++) {
! o= (FormatField)fields.get(i);
! if (o != null) {
! buffer_.append(o.getStringNonFormate() + " ");
}
}
***************
*** 164,168 ****
write(buffer_);
number++;
! fields.clear();
}
--- 139,146 ----
write(buffer_);
number++;
! // fields.clear();
! nbMaxFields_= -1;
! Collections.fill(fields, null);
! // fields.
}
***************
*** 171,195 ****
*/
! public void writeFields(int[] _fmt) throws IOException
! {
! int l = fields.size();
! if(buffer_==null) buffer_=new StringBuffer(200);
String s;
! Object o;
! for (int i = 0; i < l; i++)
! {
! o = fields.get(i);
! s = "";
if (o == null)
! s = addSpacesAfter(_fmt[i], "");
! else if (o instanceof Integer)
! s = addSpacesBefore(_fmt[i], o.toString());
! else if ((o instanceof Double) || (o instanceof Float))
! s = addSpacesBefore(_fmt[i], formateReel(_fmt[i], o));
! else if (o instanceof String)
! s = addSpacesAfter(_fmt[i], (String) o);
! else
! System.err.println("Type de " + o + " non reconnu pour le champ " + i);
//out_.write(s);
buffer_.append(s);
--- 149,167 ----
*/
! public void writeFields(int[] _fmt) throws IOException {
! int l= fields.size();
! if (buffer_ == null)
! buffer_= new StringBuffer(200);
String s;
! FormatField o;
! // for (int i= 0; i < l; i++) {
! for (int i= 0; i <= nbMaxFields_; i++) {
! o= (FormatField)fields.get(i);
! s= "";
if (o == null)
! s= addSpacesAfter(_fmt[i], "");
! else
! s=o.getStringFormate(_fmt[i]);
//out_.write(s);
buffer_.append(s);
***************
*** 200,204 ****
write(buffer_);
number++;
! fields.clear();
}
--- 172,178 ----
write(buffer_);
number++;
! //fields.clear();
! nbMaxFields_= -1;
! Collections.fill(fields, null);
}
***************
*** 207,226 ****
* du champ.
*/
! private final static String formateReel(int _l, Object _d)
! {
! String r = _d.toString();
! if (r.length() >= _l)
! {
// int i=0;
// while (i<r.length() && r.charAt(i)!='E') i++;
// if (i==r.length()) r=r.substring(0,lg);
// else r=r.substring(0,lg-r.length()+i)+r.substring(i);
! int i = r.indexOf('.');
! int j = r.indexOf('E');
if ((i < _l) && (j < 0))
! r = r.substring(0, _l);
else if (j > 0)
! r = r.substring(0, _l - r.length() + j) + r.substring(j);
}
--- 181,198 ----
* du champ.
*/
! public final static String formateReel(int _l, Object _d) {
! String r= _d.toString();
! if (r.length() >= _l) {
// int i=0;
// while (i<r.length() && r.charAt(i)!='E') i++;
// if (i==r.length()) r=r.substring(0,lg);
// else r=r.substring(0,lg-r.length()+i)+r.substring(i);
! int i= r.indexOf('.');
! int j= r.indexOf('E');
if ((i < _l) && (j < 0))
! r= r.substring(0, _l);
else if (j > 0)
! r= r.substring(0, _l - r.length() + j) + r.substring(j);
}
***************
*** 228,233 ****
}
! private final static String addSpacesBefore(int t, String s)
! {
//Ancienne version
/*String a="*****";
--- 200,204 ----
}
! public final static String addSpacesBefore(int t, String s) {
//Ancienne version
/*String a="*****";
***************
*** 251,259 ****
return r; */
! int l = s.length();
! int lMotif = 5;
! StringBuffer r = new StringBuffer(t);
! if (l > t)
! {
System.err.println(
"Impossible d'écrire la valeur "
--- 222,229 ----
return r; */
! int l= s.length();
! int lMotif= 5;
! StringBuffer r= new StringBuffer(t);
! if (l > t) {
System.err.println(
"Impossible d'écrire la valeur "
***************
*** 261,271 ****
+ " sur un champ de longueur "
+ t);
! String a = "*****";
! int nbMotif = t / lMotif;
! int sup = t % lMotif;
! for (int i = nbMotif; i > 0; i--)
r.append(a);
! switch (sup)
! {
case 0 :
break;
--- 231,240 ----
+ " sur un champ de longueur "
+ t);
! String a= "*****";
! int nbMotif= t / lMotif;
! int sup= t % lMotif;
! for (int i= nbMotif; i > 0; i--)
r.append(a);
! switch (sup) {
case 0 :
break;
***************
*** 285,295 ****
return r.toString();
}
! String b = " ";
! int nbMotif = (t - l) / lMotif;
! int sup = (t - l) % lMotif;
! for (int i = nbMotif; i > 0; i--)
r.append(b);
! switch (sup)
! {
case 0 :
break;
--- 254,263 ----
return r.toString();
}
! String b= " ";
! int nbMotif= (t - l) / lMotif;
! int sup= (t - l) % lMotif;
! for (int i= nbMotif; i > 0; i--)
r.append(b);
! switch (sup) {
case 0 :
break;
***************
*** 315,320 ****
}
! private final static String addSpacesAfter(int t, String s)
! {
/* String a="*****";
String b=" ";
--- 283,287 ----
}
! public final static String addSpacesAfter(int t, String s) {
/* String a="*****";
String b=" ";
***************
*** 330,338 ****
return r; */
! int l = s.length();
! int lMotif = 5;
! StringBuffer r = new StringBuffer(t);
! if (l > t)
! {
System.err.println(
"Impossible d'écrire la valeur "
--- 297,304 ----
return r; */
! int l= s.length();
! int lMotif= 5;
! StringBuffer r= new StringBuffer(t);
! if (l > t) {
System.err.println(
"Impossible d'écrire la valeur "
***************
*** 340,350 ****
+ " sur un champ de longueur "
+ t);
! String a = "*****";
! int nbMotif = t / lMotif;
! int sup = t % lMotif;
! for (int i = nbMotif; i > 0; i--)
r.append(a);
! switch (sup)
! {
case 0 :
break;
--- 306,315 ----
+ " sur un champ de longueur "
+ t);
! String a= "*****";
! int nbMotif= t / lMotif;
! int sup= t % lMotif;
! for (int i= nbMotif; i > 0; i--)
r.append(a);
! switch (sup) {
case 0 :
break;
***************
*** 365,375 ****
}
r.append(s);
! String b = " ";
! int nbMotif = (t - l) / lMotif;
! int sup = (t - l) % lMotif;
! for (int i = nbMotif; i > 0; i--)
r.append(b);
! switch (sup)
! {
case 0 :
break;
--- 330,339 ----
}
r.append(s);
! String b= " ";
! int nbMotif= (t - l) / lMotif;
! int sup= (t - l) % lMotif;
! for (int i= nbMotif; i > 0; i--)
r.append(b);
! switch (sup) {
case 0 :
break;
***************
*** 397,409 ****
* @param _v la valeur du champ de type double
*/
!
! public void doubleField(int _i, double _v)
! {
! if (fields.size() <= _i)
! fields.setSize(_i + 1);
! // fields.ensureCapacity(_i+1);
! fields.setElementAt(new Double(_v), _i);
}
/**
* Fixe la valeur du champ numero i avec un reel.
--- 361,373 ----
* @param _v la valeur du champ de type double
*/
! public void doubleField(int _i, double _v) {
! objectField(_i, getDoubleFormatField(_v));
! // if (fields.size() <= _i)
! // fields.setSize(_i + 1);
! // // fields.ensureCapacity(_i+1);
! // fields.setElementAt(new Double(_v), _i);
}
+
/**
* Fixe la valeur du champ numero i avec un reel.
***************
*** 411,422 ****
* @param _v la valeur du champ de type float
*/
! public void floatField(int _i, double _v)
! {
! if (fields.size() <= _i)
! fields.setSize(_i + 1);
! // fields.ensureCapacity(_i+1);
! fields.setElementAt(new Float(_v), _i);
}
/**
* Fixe la valeur du champ numero i avec un entier.
--- 375,387 ----
* @param _v la valeur du champ de type float
*/
! public void floatField(int _i, double _v) {
! // if (fields.size() <= _i)
! // fields.setSize(_i + 1);
! // // fields.ensureCapacity(_i+1);
! // fields.setElementAt(new Float(_v), _i);
! objectField(_i, getFloatFormatField((float)_v));
}
+
/**
* Fixe la valeur du champ numero i avec un entier.
***************
*** 424,433 ****
* @param _v la valeur du champ de type int
*/
! public void intField(int _i, int _v)
! {
! if (fields.size() <= _i)
! fields.setSize(_i + 1);
! // fields.ensureCapacity(_i+1);
! fields.setElementAt(new Integer(_v), _i);
}
--- 389,398 ----
* @param _v la valeur du champ de type int
*/
! public void intField(int _i, int _v) {
! // if (fields.size() <= _i)
! // fields.setSize(_i + 1);
! // // fields.ensureCapacity(_i+1);
! // fields.setElementAt(new Integer(_valeurChamp), _i);
! objectField(_i, getIntegerFormatField(_v));
}
***************
*** 437,448 ****
* @param _v la valeur du champ de type string
*/
! public void stringField(int _i, String _v)
! {
if (fields.size() <= _i)
fields.setSize(_i + 1);
// fields.ensureCapacity(_i+1);
! fields.setElementAt(_v, _i);
}
}
--- 402,559 ----
* @param _v la valeur du champ de type string
*/
! public void stringField(int _i, String _v) {
! objectField(_i, getStringFormatField(_v));
! }
!
! private void objectField(int _i, Object _v) {
if (fields.size() <= _i)
fields.setSize(_i + 1);
// fields.ensureCapacity(_i+1);
! fields.set(_i, _v);
! if (_i > nbMaxFields_)
! nbMaxFields_= _i;
! }
!
! private interface FormatField {
! public String getStringNonFormate();
! public String getStringFormate(int _f);
! }
! private final StringFormatField FF_EMPTY_STRING=
! new StringFormatField(DodicoLib.EMPTY_STRING);
! private final StringFormatField FF_ESPACE_STRING=
! new StringFormatField(DodicoLib.ESPACE);
!
! private final StringFormatField getStringFormatField(String _s) {
! if (_s == DodicoLib.EMPTY_STRING)
! return FF_EMPTY_STRING;
! if (_s == DodicoLib.ESPACE)
! return FF_ESPACE_STRING;
! return new StringFormatField(_s);
! }
!
! private final class StringFormatField implements FormatField {
!
! private String s_;
! public StringFormatField(String _s) {
! s_= _s;
! }
!
! /**
! *
! */
! public String getStringFormate(int _f) {
! return addSpacesAfter(_f, s_);
! }
!
! /**
! *
! */
! public String getStringNonFormate() {
! if (isStringQuoted()) {
! String r= s_;
!
! if (r.indexOf('\'') >= 0) {
! for (int j= r.length() - 1; j >= 0; j--)
! if (r.charAt(j) == '\'')
! r= r.substring(0, j) + "''" + r.substring(j + 1);
! }
! r= "'" + r + "'";
! return r;
! } else
! return s_;
!
! }
! }
!
! private final DoubleFormatField DOUBLE_ZERO= new DoubleFormatField(0d);
!
! private final DoubleFormatField getDoubleFormatField(double _d) {
! if (_d == 0d)
! return DOUBLE_ZERO;
! return new DoubleFormatField(_d);
! }
!
! private final FloatFormatField FLOAT_ZERO= new FloatFormatField(0f);
!
! private final FloatFormatField getFloatFormatField(float _d) {
! if (_d == 0f)
! return FLOAT_ZERO;
! return new FloatFormatField(_d);
! }
!
! private final class DoubleFormatField implements FormatField {
! private double d_;
! public DoubleFormatField(double _d) {
! d_= _d;
! }
! /**
! *
! */
! public String getStringFormate(int _f) {
! return addSpacesBefore(_f, formateReel(_f, Double.toString(d_)));
! }
!
! /**
! *
! */
! public String getStringNonFormate() {
! return Double.toString(d_);
! }
}
+ private final class FloatFormatField implements FormatField {
+ private float d_;
+ public FloatFormatField(float _d) {
+ d_= _d;
+ }
+ /**
+ *
+ */
+ public String getStringFormate(int _f) {
+ return addSpacesBefore(_f, formateReel(_f, Float.toString(d_)));
+ }
+
+ /**
+ *
+ */
+ public String getStringNonFormate() {
+ return Float.toString(d_);
+ }
+
+ }
+
+ IntegerFormatField[] FF_INTEGERS;
+
+ private final void initFFInteger(){
+ FF_INTEGERS=new IntegerFormatField[7];
+ for(int i=FF_INTEGERS.length-1;i>=0;i--){
+ FF_INTEGERS[i]=new IntegerFormatField(i);
+ }
+ }
+
+ private final IntegerFormatField getIntegerFormatField(int _i){
+ if(FF_INTEGERS==null) initFFInteger();
+ return ((_i>=0) && (_i<FF_INTEGERS.length))?FF_INTEGERS[_i]:new IntegerFormatField(_i);
+ }
+ private final class IntegerFormatField implements FormatField {
+ private int d_;
+ public IntegerFormatField(int _d) {
+ d_= _d;
+ }
+ /**
+ *
+ */
+ public String getStringFormate(int _f) {
+ return addSpacesBefore(_f, DodicoLib.getString(d_));
+ }
+
+ /**
+ *
+ */
+ public String getStringNonFormate() {
+ return DodicoLib.getString(d_);
+ }
+ }
+
}
Index: NativeBinaryInputStream.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/fortran/NativeBinaryInputStream.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NativeBinaryInputStream.java 4 Jul 2003 12:47:13 -0000 1.4
--- NativeBinaryInputStream.java 2 Sep 2003 08:41:24 -0000 1.5
***************
*** 25,32 ****
// extends DataInputStream
{
! public final static String X86 = "86";
! public final static String X86_NAME = "X86";
! public final static String SPARC = "sparc";
! public final static String SPARC_NAME = "SPARC";
/**
--- 25,32 ----
// extends DataInputStream
{
! public final static String X86= "86";
! public final static String X86_NAME= "X86";
! public final static String SPARC= "sparc";
! public final static String SPARC_NAME= "SPARC";
/**
***************
*** 49,71 ****
int _bufferLength,
String _machine)
! throws IOException
! {
this(new BufferedInputStream(_in, _bufferLength), _machine);
}
public NativeBinaryInputStream(InputStream _in, String _machine)
! throws IOException
! {
this(new BufferedInputStream(_in), _machine);
}
public NativeBinaryInputStream(BufferedInputStream _in, String _machine)
! throws IOException
! {
! in_ = new DataInputStream(_in);
//inutile
//buf=null;
setMachineType(_machine);
! buf=new byte[8];
}
--- 49,68 ----
int _bufferLength,
String _machine)
! throws IOException {
this(new BufferedInputStream(_in, _bufferLength), _machine);
}
public NativeBinaryInputStream(InputStream _in, String _machine)
! throws IOException {
this(new BufferedInputStream(_in), _machine);
}
public NativeBinaryInputStream(BufferedInputStream _in, String _machine)
! throws IOException {
! in_= new DataInputStream(_in);
//inutile
//buf=null;
setMachineType(_machine);
! buf= new byte[8];
}
***************
*** 75,108 ****
* @return String correspondant à la chaine de caractères
*/
! public String readCharacter(int _lgString) throws IOException
! {
! if(buf.length!=_lgString)
! buf = new byte[_lgString];
in_.read(buf);
return new String(buf);
}
! public void skip(long _l) throws IOException
! {
! in_.skip(_l);
}
! public void close() throws IOException
! {
in_.close();
}
! public int available() throws IOException
! {
return in_.available();
}
! public void skipBytes(int _l) throws IOException
! {
in_.skipBytes(_l);
}
! public static String getLocalMachine()
! {
return System.getProperty("os.arch");
}
--- 72,120 ----
* @return String correspondant à la chaine de caractères
*/
! public String readCharacter(int _lgString) throws IOException {
! if (buf.length != _lgString)
! buf= new byte[_lgString];
in_.read(buf);
return new String(buf);
}
! /**
! * Cette methode assure (au maximun) que _l octets sont ignores.
! * @return le nombre d'octets reellement ignore.
! */
! public long skip(long _l) throws IOException {
! long skipReal= in_.skip(_l);
! //si tous les octets n'ont pas ete ignore
! if (skipReal < _l) {
! //les octets restants a lire.
! long nToSkip= _l - skipReal;
! //le nombre total d'octets ignores
! long total= 0l;
! //les octets ignores lors d'une instruction.
! long nSkipped= 0l;
! //tant qu'on pas atteint le but et qu'il reste des octets a lire.
! while ((total < nToSkip)
! && ((nSkipped= in_.skip(nToSkip - total)) > 0)) {
! total += nSkipped;
! }
! return _l-nToSkip+total;
! } else
! return skipReal;
!
}
! public void close() throws IOException {
in_.close();
}
! public int available() throws IOException {
return in_.available();
}
! public void skipBytes(int _l) throws IOException {
in_.skipBytes(_l);
}
! public static String getLocalMachine() {
return System.getProperty("os.arch");
}
***************
*** 111,116 ****
* Renvoie l'identifiant correspond a la machine.
*/
! public static String getLocalMachineId()
! {
return getMachineId(System.getProperty("os.arch"));
}
--- 123,127 ----
* Renvoie l'identifiant correspond a la machine.
*/
! public static String getLocalMachineId() {
return getMachineId(System.getProperty("os.arch"));
}
***************
*** 122,127 ****
* sont utilisees.
*/
! public static String getMachineId(String _desc)
! {
if (isX86(_desc))
return X86;
--- 133,137 ----
* sont utilisees.
*/
! public static String getMachineId(String _desc) {
if (isX86(_desc))
return X86;
***************
*** 136,141 ****
* par <code>"X86"</code>). La variable <code>X86</code> est utilisee.
*/
! public static boolean isX86(String _machine)
! {
if (_machine == null)
return false;
--- 146,150 ----
* par <code>"X86"</code>). La variable <code>X86</code> est utilisee.
*/
! public static boolean isX86(String _machine) {
if (_machine == null)
return false;
***************
*** 150,155 ****
* La variable <code>SPARC</code> est utilisee.
*/
! public static boolean isSparc(String _machine)
! {
if (_machine == null)
return false;
--- 159,163 ----
* La variable <code>SPARC</code> est utilisee.
*/
! public static boolean isSparc(String _machine) {
if (_machine == null)
return false;
***************
*** 163,168 ****
* classe.
*/
! public static boolean isMachineKnown(String _machine)
! {
return (isX86(_machine) || isSparc(_machine));
}
--- 171,175 ----
* classe.
*/
! public static boolean isMachineKnown(String _machine) {
return (isX86(_machine) || isSparc(_machine));
}
***************
*** 171,213 ****
* Affecte le type de machine. Par défaut, le type sparc est utilise.
*/
! public final void setMachineType(String _machine)
! {
! if(_machine==null) _machine=NativeBinaryInputStream.getLocalMachine();
! if (isX86(_machine))
! {
! machineType_ = X86;
! l1 = i1 = s1 = 0;
! l2 = i2 = s2 = 1;
! l3 = i3 = 2;
! l4 = i4 = 3;
! l5 = 4;
! l6 = 5;
! l7 = 6;
! l8 = 7;
! }
! else
! {
! machineType_ = SPARC;
! l1 = 7;
! l2 = 6;
! l3 = 5;
! l4 = 4;
! l5 = i1 = 3;
! l6 = i2 = 2;
! l7 = i3 = s1 = 1;
! l8 = i4 = s2 = 0;
! }
}
! public String getMachineType()
! {
return machineType_;
}
! private long _readInt_64() throws IOException
! {
! if(buf.length!=8)
! buf = new byte[8];
! nbByteLus_ = in_.read(buf);
return (buf[l1] < 0 ? (256 + buf[l1]) : buf[l1])
+ (buf[l2] < 0 ? (256 + buf[l2]) : buf[l2]) * 0x100L
--- 178,215 ----
* Affecte le type de machine. Par défaut, le type sparc est utilise.
*/
! public final void setMachineType(String _machine) {
! if (_machine == null)
! _machine= NativeBinaryInputStream.getLocalMachine();
! if (isX86(_machine)) {
! machineType_= X86;
! l1= i1= s1= 0;
! l2= i2= s2= 1;
! l3= i3= 2;
! l4= i4= 3;
! l5= 4;
! l6= 5;
! l7= 6;
! l8= 7;
! } else {
! machineType_= SPARC;
! l1= 7;
! l2= 6;
! l3= 5;
! l4= 4;
! l5= i1= 3;
! l6= i2= 2;
! l7= i3= s1= 1;
! l8= i4= s2= 0;
! }
}
! public String getMachineType() {
return machineType_;
}
! private long _readInt_64() throws IOException {
! if (buf.length != 8)
! buf= new byte[8];
! nbByteLus_= in_.read(buf);
return (buf[l1] < 0 ? (256 + buf[l1]) : buf[l1])
+ (buf[l2] < 0 ? (256 + buf[l2]) : buf[l2]) * 0x100L
***************
*** 220,237 ****
}
! public byte readInt_8() throws IOException
! {
! if(buf.length!=1)
! buf = new byte[1];
! nbByteLus_ = in_.read(buf);
return buf[0];
}
! public short readUInt_8() throws IOException
! {
! if(buf.length!=1)
! buf = new byte[1];
! nbByteLus_ = in_.read(buf);
! return buf[0] < 0 ? (short) (256 + buf[0]) : (short) buf[0];
}
--- 222,237 ----
}
! public byte readInt_8() throws IOException {
! if (buf.length != 1)
! buf= new byte[1];
! nbByteLus_= in_.read(buf);
return buf[0];
}
! public short readUInt_8() throws IOException {
! if (buf.length != 1)
! buf= new byte[1];
! nbByteLus_= in_.read(buf);
! return buf[0] < 0 ? (short) (256 + buf[0]) : (short)buf[0];
}
***************
*** 241,277 ****
* @return si fin du fichier.
*/
! public boolean isFinFichier()
! {
return nbByteLus_ == -1;
}
! public short readInt_16() throws IOException
! {
! if(buf.length!=2)
! buf = new byte[2];
! nbByteLus_ = in_.read(buf);
return (short)
((buf[s1] < 0 ? (256 + buf[s1]) : buf[s1]) + (buf[s2] * 0x100));
}
! public int readUInt_16() throws IOException
! {
! if(buf.length!=2)
! buf = new byte[2];
! nbByteLus_ = in_.read(buf);
return (buf[s1] < 0 ? (256 + buf[s1]) : buf[s1])
+ (buf[s2] < 0 ? (256 + buf[s2]) : buf[s2]) * 0x100;
}
! public int readInt_32() throws IOException
! {
return _readInt_32();
}
! private int _readInt_32() throws IOException
! {
! if(buf.length!=4)
! buf = new byte[4];
! nbByteLus_ = in_.read(buf);
return (buf[i1] < 0 ? (256 + buf[i1]) : buf[i1])
+ (buf[i2] < 0 ? (256 + buf[i2]) : buf[i2]) * 0x100
--- 241,272 ----
* @return si fin du fichier.
*/
! public boolean isFinFichier() {
return nbByteLus_ == -1;
}
! public short readInt_16() throws IOException {
! if (buf.length != 2)
! buf= new byte[2];
! nbByteLus_= in_.read(buf);
return (short)
((buf[s1] < 0 ? (256 + buf[s1]) : buf[s1]) + (buf[s2] * 0x100));
}
! public int readUInt_16() throws IOException {
! if (buf.length != 2)
! buf= new byte[2];
! nbByteLus_= in_.read(buf);
return (buf[s1] < 0 ? (256 + buf[s1]) : buf[s1])
+ (buf[s2] < 0 ? (256 + buf[s2]) : buf[s2]) * 0x100;
}
! public int readInt_32() throws IOException {
return _readInt_32();
}
! private int _readInt_32() throws IOException {
! if (buf.length != 4)
! buf= new byte[4];
! nbByteLus_= in_.read(buf);
return (buf[i1] < 0 ? (256 + buf[i1]) : buf[i1])
+ (buf[i2] < 0 ? (256 + buf[i2]) : buf[i2]) * 0x100
***************
*** 280,288 ****
}
! public long readUInt_32() throws IOException
! {
! if(buf.length!=4)
! buf = new byte[4];
! nbByteLus_ = in_.read(buf);
return (buf[i1] < 0 ? (256 + buf[i1]) : buf[i1])
+ (buf[i2] < 0 ? (256 + buf[i2]) : buf[i2]) * 0x100L
--- 275,282 ----
}
! public long readUInt_32() throws IOException {
! if (buf.length != 4)
! buf= new byte[4];
! nbByteLus_= in_.read(buf);
return (buf[i1] < 0 ? (256 + buf[i1]) : buf[i1])
+ (buf[i2] < 0 ? (256 + buf[i2]) : buf[i2]) * 0x100L
***************
*** 291,296 ****
}
! public long readInt_64() throws IOException
! {
//utilise une methode privee pour eviter les problemes avec
//l'heritage
--- 285,289 ----
}
! public long readInt_64() throws IOException {
//utilise une methode privee pour eviter les problemes avec
//l'heritage
***************
*** 298,316 ****
}
! public float readFloat_32() throws IOException
! {
/*Reviens a faire readInt_32().
Ne pas utiliser cette méthode car fausse l'incrementation de
FortranBinaryInputStream*/
! int temp = _readInt_32();
return Float.intBitsToFloat(temp);
}
! public double readFloat_64() throws IOException
! {
/*Reviens a faire readInt_64().
Ne pas utiliser cette méthode car fausse l'incrementation de
FortranBinaryInputStream*/
! long temp = _readInt_64();
return Double.longBitsToDouble(temp);
}
--- 291,307 ----
}
! public float readFloat_32() throws IOException {
/*Reviens a faire readInt_32().
Ne pas utiliser cette méthode car fausse l'incrementation de
FortranBinaryInputStream*/
! int temp= _readInt_32();
return Float.intBitsToFloat(temp);
}
! public double readFloat_64() throws IOException {
/*Reviens a faire readInt_64().
Ne pas utiliser cette méthode car fausse l'incrementation de
FortranBinaryInputStream*/
! long temp= _readInt_64();
return Double.longBitsToDouble(temp);
}
|