From: <de...@us...> - 2011-10-23 19:42:48
|
Revision: 6562 http://fudaa.svn.sourceforge.net/fudaa/?rev=6562&view=rev Author: deniger Date: 2011-10-23 19:42:41 +0000 (Sun, 23 Oct 2011) Log Message: ----------- generalisation de l'utilisation de CtuluLog Modified Paths: -------------- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLog.java trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLogGroup.java trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationAbstract.java trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileOpReadCharSimpleAbstract.java Added Paths: ----------- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluIOResult.java trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationReaderAbstract.java trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationWriterAbstract.java trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileReadWriteAbstract.java trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleReaderAbstract.java trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleWriterAbstract.java Added: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluIOResult.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluIOResult.java (rev 0) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluIOResult.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,95 @@ +/** + * @creation 12 mars 2003 + * @modification $Date: 2006-09-19 14:36:54 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne +* @mail de...@fu... + */ +package org.fudaa.ctulu; + +/** + * @author deniger + * @version $Id: CtuluIOOperationSynthese.java,v 1.7 2006-09-19 14:36:54 deniger Exp $ + */ +public class CtuluIOResult<T> { + + private CtuluLog log; + + private String exClose_; + + private T source_; + + public CtuluIOResult() {} + + /** + * @return true si exception lors de la fermeture des flux. + */ + public boolean containsClosingError() { + return exClose_ != null; + } + + /** + * @return true si une erreur fatale est survenue + */ + public boolean containsFatalError() { + return (log != null) && (log.containsFatalError()); + } + + /** + * @return true si message + */ + public boolean containsMessages() { + return (log != null) && (!log.isEmpty()); + } + + /** + * @return l'analyse de l'operation + */ + public CtuluLog getAnalyze() { + return log; + } + + /** + * @return le message d'erreur issu de la fermeture du(des) flux. + */ + public String getClosingException() { + return exClose_; + } + + /** + * @return la source utilise pour l'ecriture/recuperee par la lecture + */ + public T getSource() { + return source_; + } + + /** + * Ecrit sur la sortie standard les messages. + */ + public void printAnalyze() { + if (log != null) { + log.printResume(); + } + } + + /** + * @param _editor l'analyse de l'operation + */ + public void setAnalyze(final CtuluLog _editor) { + log = _editor; + } + + /** + * @param _exception le message d'exception obtenu lors de la fermeture du/des flux. + */ + public void setClosingOperation(final String _exception) { + exClose_ = _exception; + } + + /** + * @param _object La nouvelle source (resultat de la lecture ou source pour l'ecriture) + */ + public void setSource(final T _object) { + source_ = _object; + } +} \ No newline at end of file Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLog.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLog.java 2011-10-21 16:31:02 UTC (rev 6561) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLog.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -30,7 +30,6 @@ */ public class CtuluLog { - /** * Constructeur par defaut */ @@ -298,13 +297,26 @@ return containsLevel(CtuluLogLevel.INFO); } + public int getNbOccurence(CtuluLogLevel level) { + int count = 0; + for (final CtuluLogRecord log : logs) { + if (level.equals(log.getLevel())) { + count++; + } + } + return count; + + } + /** * @param l le level a tester * @return true si au moins un message et de niveau l. */ public boolean containsLevel(final CtuluLogLevel l) { for (final CtuluLogRecord log : logs) { - if (l.equals(log.getLevel())) { return true; } + if (l.equals(log.getLevel())) { + return true; + } } return false; } @@ -350,19 +362,21 @@ public String getResume() { return getDesc() + "\n" + CtuluDefaultLogFormatter.formatLogs(logs); } - + public String getFatalError() { - CtuluLogRecord log = getFirstOfLevel(CtuluLogLevel.FATAL ); + CtuluLogRecord log = getFirstOfLevel(CtuluLogLevel.FATAL); return log == null ? null : CtuluDefaultLogFormatter.DEFAULT.formatLogs(log); } - + /** * @param l le level a tester * @return true si au moins un message et de niveau l. */ private CtuluLogRecord getFirstOfLevel(final CtuluLogLevel l) { for (final CtuluLogRecord log : logs) { - if (l.equals(log.getLevel())) { return log; } + if (l.equals(log.getLevel())) { + return log; + } } return null; } @@ -435,10 +449,10 @@ public void manageExceptionFromFile(final Exception _e, final String msg, final int line) { addRecord(CtuluLogLevel.ERROR, msg, line).setThrown(_e); } - public String getDesci18n() { - if (defaultResourceBundle == null) return desc; + if (defaultResourceBundle == null) + return desc; return defaultResourceBundle.getString(desc); } Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLogGroup.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLogGroup.java 2011-10-21 16:31:02 UTC (rev 6561) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLogGroup.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -1,19 +1,20 @@ package org.fudaa.ctulu; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.ResourceBundle; /** - * Manager qui indique toutes les erreurs,messages qui se sont produites pendant le chargement. + * Manager qui indique toutes les erreurs,messages qui se sont produites pendant le chargement. * * @author Adrien Hadoux */ public class CtuluLogGroup { - private List<CtuluLog> analyser = new ArrayList<CtuluLog>(); - private CtuluLog mainAnalyze = new CtuluLog(); + private List<CtuluLog> logs = new ArrayList<CtuluLog>(); + private CtuluLog mainLog = new CtuluLog(); /** * @@ -26,31 +27,65 @@ public CtuluLogGroup(ResourceBundle defaultResource) { super(); - analyser.add(mainAnalyze); + logs.add(mainLog); this.defaultResource = defaultResource; } - public void addAnalyzer(CtuluLog analyze) { - analyser.add(analyze); + public void addLog(CtuluLog analyze) { + logs.add(analyze); } - // /** - // * Ajoute un message d'erreur au tout dernier analyzer dispo. - // * - // * @param message - // */ - // public void addMessageError(final String message) { - // analyser.get(analyser.size() - 1).addError(message); - // } + public void addAll(Collection<CtuluLog> logs) { + logs.addAll(logs); + } + public void addGroup(CtuluLogGroup logGroup) { + groups.add(logGroup); + } + + public void addNotEmptyLog(CtuluLog log) { + if(log.isNotEmpty()){ + addLog(log); + } + + } + + public void addNotEmptyLogs(Collection<CtuluLog> logs) { + for (CtuluLog log : logs) { + addNotEmptyLog(log); + } + + } + + public int getNbOccurence(CtuluLogLevel level) { + int count = mainLog.getNbOccurence(level); + for (CtuluLog log : logs) { + count += log.getNbOccurence(level); + + } + for (CtuluLogGroup group : groups) { + count += group.getNbOccurence(level); + + } + return count; + } + public void clear() { - analyser.clear(); + mainLog.clear(); + for (CtuluLog log : logs) { + log.clear(); + } + logs.clear(); + for (CtuluLogGroup logGroup : groups) { + logGroup.clear(); + } + groups.clear(); } - public CtuluLog getNewAnalyser(String desc) { + public CtuluLog createNewLog(String desc) { CtuluLog analyzer = createAnalyzer(); analyzer.setDesc(desc); - analyser.add(analyzer); + logs.add(analyzer); return analyzer; } @@ -58,26 +93,38 @@ * @return true si un analyseur contient des erreur */ public boolean containsError() { - if (isContentEmpty()) { return false; } - for (CtuluLog analyze : analyser) { - if (analyze.containsFatalError() || analyze.containsErrors()) { return true; } + if (isContentEmpty()) { + return false; } + for (CtuluLog analyze : logs) { + if (analyze.containsFatalError() || analyze.containsErrors()) { + return true; + } + } if (groups != null) { for (CtuluLogGroup mng : groups) { - if (mng.containsError()) { return true; } + if (mng.containsError()) { + return true; + } } } return false; } public boolean containsFatalError() { - if (isContentEmpty()) { return false; } - for (CtuluLog analyze : analyser) { - if (analyze.containsFatalError()) { return true; } + if (isContentEmpty()) { + return false; } + for (CtuluLog analyze : logs) { + if (analyze.containsFatalError()) { + return true; + } + } if (groups != null) { for (CtuluLogGroup mng : groups) { - if (mng.containsFatalError()) { return true; } + if (mng.containsFatalError()) { + return true; + } } } return false; @@ -87,26 +134,38 @@ * @return true si les analyseur ne sont pas vide */ public boolean containsSomething() { - if (isContentEmpty()) { return false; } - for (CtuluLog analyze : analyser) { - if (!analyze.isEmpty()) { return true; } + if (isContentEmpty()) { + return false; } + for (CtuluLog analyze : logs) { + if (!analyze.isEmpty()) { + return true; + } + } if (groups != null) { for (CtuluLogGroup mng : groups) { - if (mng.containsSomething()) { return true; } + if (mng.containsSomething()) { + return true; + } } } return false; } public boolean containsWarning() { - if (isContentEmpty()) { return false; } - for (CtuluLog analyze : analyser) { - if (analyze.containsWarnings()) { return true; } + if (isContentEmpty()) { + return false; } + for (CtuluLog analyze : logs) { + if (analyze.containsWarnings()) { + return true; + } + } if (groups != null) { for (CtuluLogGroup mng : groups) { - if (mng.containsWarning()) { return true; } + if (mng.containsWarning()) { + return true; + } } } return false; @@ -124,7 +183,7 @@ */ public CtuluLogGroup createGroup(String name) { CtuluLogGroup res = new CtuluLogGroup(defaultResource); - res.getMainAnalyze().setDesc(name); + res.getMainLog().setDesc(name); if (groups == null) { groups = new ArrayList<CtuluLogGroup>(); } @@ -135,15 +194,17 @@ /** * @return la liste des anayliser utilis� */ - public List<CtuluLog> getAnalyser() { - return analyser; + public List<CtuluLog> getLogs() { + return logs; } /** * @return the groups */ public List<CtuluLogGroup> getGroups() { - if (groups == null) { return Collections.emptyList(); } + if (groups == null) { + return Collections.emptyList(); + } if (groupsExt == null) { groupsExt = Collections.unmodifiableList(groups); } @@ -156,19 +217,19 @@ * @param message * @return */ - public CtuluLog getLastAnalyser() { - return analyser.get(analyser.size() - 1); + public CtuluLog getLastLog() { + return logs.get(logs.size() - 1); } /** * @return the mainAnalyze */ - public CtuluLog getMainAnalyze() { - return mainAnalyze; + public CtuluLog getMainLog() { + return mainLog; } public String getMainDesc() { - return mainAnalyze.getDesc(); + return mainLog.getDesc(); } /** @@ -176,26 +237,25 @@ * * @return */ - public CtuluLog getNewAnalyser() { - CtuluLog analyzer = createAnalyzer(); - // ajout dans la liste des analyze - analyser.add(analyzer); - return analyzer; + public CtuluLog createLog() { + CtuluLog log = createAnalyzer(); + logs.add(log); + return log; } private boolean isContentEmpty() { - return CtuluLibArray.isEmpty(analyser) && CtuluLibArray.isEmpty(groups); + return CtuluLibArray.isEmpty(logs) && CtuluLibArray.isEmpty(groups); } public void setListeMessageError(final List<CtuluLog> listeMessageError) { - this.analyser = listeMessageError; + this.logs = listeMessageError; } /** * @param mainAnalyze the mainAnalyze to set */ public void setMainAnalyze(CtuluLog mainAnalyze) { - this.mainAnalyze = mainAnalyze; + this.mainLog = mainAnalyze; } } Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationAbstract.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationAbstract.java 2011-10-21 16:31:02 UTC (rev 6561) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -19,6 +19,7 @@ import org.fudaa.ctulu.CtuluIOOperationSynthese; import org.fudaa.ctulu.ProgressionInterface; /** + * @deprecated use {@link FileReadWriteAbstract} * @author deniger * @version $Id: FileOperationAbstract.java,v 1.5 2006-07-13 13:34:41 deniger Exp $ */ Added: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationReaderAbstract.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationReaderAbstract.java (rev 0) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationReaderAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,57 @@ +/* + * @creation 6 juin 2003 + * + * @modification $Date: 2006-09-19 14:36:56 $ + * + * @license GNU General Public License 2 + * + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * + * @mail de...@fu... + */ +package org.fudaa.ctulu.fileformat; + +import java.io.File; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.CtuluIOResult; +import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluLibString; +import org.fudaa.ctulu.ProgressionInterface; + +/** + * @author deniger + * @version $Id: FileReadOperationAbstract.java,v 1.7 2006-09-19 14:36:56 deniger Exp $ + */ +public abstract class FileOperationReaderAbstract<T> extends FileReadWriteAbstract<T> { + protected String getOperationDescription(final File _f) { + return CtuluLib.getS("Lecture") + CtuluLibString.ESPACE + _f.getName(); + } + + protected abstract T internalRead(); + + /** + * lit le fichier et ferme le flux. Pour recuperer les donnees, il suffit d'utiliser getSource. + * + * @return la synthese de la lecture + */ + public final CtuluIOResult<T> read() { + return closeOperation(internalRead()); + } + + /** + * @param _f le fichier a lire + * @param _inter la barre de progression + * @return la synthese de la lecture + */ + public final CtuluIOResult<T> read(final File _f, final ProgressionInterface _inter) { + setFile(_f); + final String s = getOperationDescription(_f); + analyze_.setDesc(s); + if (_inter != null) { + _inter.setDesc(s); + } + setProgressReceiver(_inter); + return read(); + } +} Added: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationWriterAbstract.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationWriterAbstract.java (rev 0) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileOperationWriterAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,62 @@ +/* + * @creation 22 ao\xFBt 2003 + * @modification $Date: 2007-01-26 14:57:26 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ctulu.fileformat; + +import java.io.File; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.CtuluIOResult; +import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluLibString; +import org.fudaa.ctulu.ProgressionInterface; +/** + * @author deniger + * @version $Id: FileWriteOperationAbstract.java,v 1.8 2007-01-26 14:57:26 deniger Exp $ + */ +public abstract class FileOperationWriterAbstract<T> extends FileReadWriteAbstract<T> { + + protected abstract void internalWrite(T _o); + + /** + * @param _o la source pour l'ecriture + * @return la synthese de l'operation + */ + public final CtuluIOResult<T> write(final T _o){ + internalWrite(_o); + return closeOperation(_o); + } + + /** + * @param _o + * @param _f + * @param _inter + * @return la synthese de l'ecriture + */ + public final CtuluIOResult<T> write(final T _o,final File _f,final ProgressionInterface _inter){ + setFile(_f); + final String s = getOperationDescription(_f); + analyze_.setDesc(s); + if (_inter != null) { + _inter.setDesc(s); + } + setProgressReceiver(_inter); + return write(_o); + } + + /** + * + */ + protected String getOperationDescription(final File _f){ + return CtuluLib.getS("Ecriture") + CtuluLibString.ESPACE + _f.getName(); + } + + protected void donneesInvalides(final T _o){ + analyze_.addFatalError(CtuluLib.getS("Donn\xE9es invalides")); + analyze_.addInfo(_o==null?"null":_o.getClass().toString(), 0); + } +} \ No newline at end of file Added: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileReadWriteAbstract.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileReadWriteAbstract.java (rev 0) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/fileformat/FileReadWriteAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,75 @@ +/* + * @file FileWriteOperation.java + * @creation 22 ao\xFBt 2003 + * @modification $Date: 2006-07-13 13:34:41 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ctulu.fileformat; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +import com.memoire.fu.FuLog; + +import org.fudaa.ctulu.CtuluAnalyze; +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.CtuluIOResult; +import org.fudaa.ctulu.CtuluLog; +import org.fudaa.ctulu.ProgressionInterface; +/** + * @author deniger + * @version $Id: FileOperationAbstract.java,v 1.5 2006-07-13 13:34:41 deniger Exp $ + */ +public abstract class FileReadWriteAbstract<T> { + protected ProgressionInterface progress_; + protected CtuluLog analyze_; + /** + * @param _progressReceiver l'ecouter pour la progression + */ + public void setProgressReceiver(final ProgressionInterface _progressReceiver) { + progress_= _progressReceiver; + } + protected abstract FortranInterface getFortranInterface(); + + /** + * @param _f le fichier a lire + */ + public abstract void setFile(File _f); + + protected final CtuluIOResult<T> closeOperation(final T _o) { + final CtuluIOResult<T> r= new CtuluIOResult<T>(); + final FortranInterface out= getFortranInterface(); + r.setClosingOperation(FortranLib.closeState(out)); + r.setAnalyze(analyze_); + r.setSource(_o); + progress_= null; + analyze_= null; + return r; + } + /** + * @param _f le fichier a lire + * @return le FileReader correspondant + */ + public static final FileReader initFileReader(final File _f) { + FileReader r= null; + try { + r= new FileReader(_f); + } catch (final FileNotFoundException _e) {FuLog.error(_e);} + return r; + } + /** + * @param _f le fichier a ecrire + * @return le FileWriter correspondant + */ + public static final FileWriter initFileWriter(final File _f) { + FileWriter r= null; + try { + r= new FileWriter(_f); + } catch (final IOException _e) {FuLog.error(_e);} + return r; + } +} Added: trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleReaderAbstract.java =================================================================== --- trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleReaderAbstract.java (rev 0) +++ trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleReaderAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,66 @@ +/** + * @creation 21 mars 2003 + * @modification $Date: 2006-09-19 14:42:29 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne +* @mail de...@fu... + */ +package org.fudaa.dodico.fortran; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.Reader; + +import org.fudaa.ctulu.CtuluLog; +import org.fudaa.ctulu.fileformat.FileOperationReaderAbstract; +import org.fudaa.ctulu.fileformat.FortranInterface; +import org.fudaa.dodico.commun.DodicoLib; +/** + * @author deniger + * @version $Id: FileOpReadCharSimpleAbstract.java,v 1.4 2006-09-19 14:42:29 deniger Exp $ + */ +public abstract class FileCharSimpleReaderAbstract<T> extends FileOperationReaderAbstract<T>{ + + protected FortranReader in_; + + protected void setFile(final Reader _r){ + in_ = new FortranReader(_r); + } + + protected void addAnalyzeLigneLue(){ + analyze_.addInfo(DodicoLib.getS("Ligne lue") + ": " + in_.getLine(), in_.getLineNumber()); + } + + protected FortranInterface getFortranInterface(){ + return in_; + } + + + protected void processFile(final File _f){ + + } + + public void setFile(final File _f){ + analyze_ = new CtuluLog(); + analyze_.setResource(_f.getAbsolutePath()); + FileReader r = null; + try { + r = new FileReader(_f); + processFile(_f); + } + catch (final FileNotFoundException _e) { + analyze_.addFatalError(DodicoLib.getS("Fichier inconnu")); + } + if (r != null) { + setFile(r); + } + } + + /** + * @param _f le fichier a lire (_f[0]) + */ + public final void setFile(final File[] _f){ + setFile(_f[0]); + } +} \ No newline at end of file Added: trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleWriterAbstract.java =================================================================== --- trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleWriterAbstract.java (rev 0) +++ trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileCharSimpleWriterAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -0,0 +1,113 @@ +/** + * @creation 21 mars 2003 + * @modification $Date: 2006-09-19 14:42:29 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.dodico.fortran; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +import org.fudaa.ctulu.CtuluLibString; +import org.fudaa.ctulu.CtuluLog; +import org.fudaa.ctulu.fileformat.FileOperationWriterAbstract; +import org.fudaa.ctulu.fileformat.FortranInterface; + +/** + * @author deniger + * @version $Id: FileOpWriterCharSimpleAbstract.java,v 1.4 2006-09-19 14:42:29 deniger Exp $ + */ +public abstract class FileCharSimpleWriterAbstract<T> extends FileOperationWriterAbstract<T> { + + protected String lineSep_; + protected Writer out_; + + /** + * Initialise le separateur de ligne. + */ + public FileCharSimpleWriterAbstract() { + lineSep_ = CtuluLibString.LINE_SEP; + } + + protected FortranInterface getFortranInterface() { + return new FortranInterface() { + + public void close() throws IOException { + if (out_ != null) { + out_.close(); + } + } + }; + } + + /** + * Renvoie le separateur de ligne. + * + * @return separateur de ligne + */ + public final String getLineSeparator() { + return lineSep_; + } + + public void setFile(final File _f) { + analyze_ = new CtuluLog(); + analyze_.setResource(_f.getAbsolutePath()); + FileWriter out = null; + try { + out = new FileWriter(_f); + } catch (final IOException _e) { + analyze_.manageException(_e); + } + if (out != null) { + out_ = out; + } + } + + /** + * @param _f le fichier a ecrire (_f[0]). + */ + public final void setFile(final File[] _f) { + setFile(_f[0]); + } + + /** + * Modifie le separateur de ligne. + * + * @param _lineSep The lineSep to set + */ + public final void setLineSeparator(final String _lineSep) { + lineSep_ = _lineSep; + } + + /** + * @param _b la chaine a ajouter au flux + * @throws IOException + */ + public void writeToOut(final String _b) throws IOException { + out_.write(_b); + } + + /** + * Ecrit un retour chariot. + * + * @throws IOException + */ + public void writelnToOut() throws IOException { + out_.write(lineSep_); + } + + /** + * Ecrit la chaine plus un retour chariot. + * + * @param _b la chaine a ajouter au flux + * @throws IOException + */ + public void writelnToOut(final String _b) throws IOException { + writeToOut(_b + lineSep_); + } + +} \ No newline at end of file Modified: trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileOpReadCharSimpleAbstract.java =================================================================== --- trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileOpReadCharSimpleAbstract.java 2011-10-21 16:31:02 UTC (rev 6561) +++ trunk/framework/dodico-common/src/main/java/org/fudaa/dodico/fortran/FileOpReadCharSimpleAbstract.java 2011-10-23 19:42:41 UTC (rev 6562) @@ -18,6 +18,7 @@ import org.fudaa.dodico.commun.DodicoLib; /** + * @deprecated use {@link FileCharSimpleReaderAbstract} * @author deniger * @version $Id: FileOpReadCharSimpleAbstract.java,v 1.4 2006-09-19 14:42:29 deniger Exp $ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |