uk.ac.ebi.intact.application.intSeq.business
Class ManagerFiles

java.lang.Object
  |
  +--uk.ac.ebi.intact.application.intSeq.business.ManagerFiles
Direct Known Subclasses:
ManagerFilesBlast, ManagerFilesSrs

public class ManagerFiles
extends java.lang.Object

This class is a base class which allows to manage the file operations like opening, reading, writing, parsing, deleting. Previous command lines or URL in this project need the file creation and management. It allows to abstract other classes from the specific objects needed like File, FileWriter...

Version:
: $Id: ManagerFiles.java,v 1.3 2003/07/16 13:56:24 skerrien Exp $
Author:
shuet (shuet@ebi.ac.uk)

Field Summary
protected  java.lang.String absolutePath
          absolute path file
protected  java.lang.String fileName
           
 
Constructor Summary
ManagerFiles()
          constructor by default
ManagerFiles(java.lang.String pathFile, java.lang.Object extension)
          constructor which allows us to create a random file name, this application is multi-user.
ManagerFiles(java.lang.String pathFile, java.lang.String fileName)
          constructor which passes a hard file name in parameter
 
Method Summary
 boolean CreateFile()
          Create a file, checking some important points before: if it already exists, and if it is readable.
 void CreateWriter()
          if the PutInFile method needs to be managed in a loop, the FileWriter has to be created only once.
 void DeleteFile()
          Delete a file which isn't used anymore.
 java.lang.String GetFileName()
          to get the file name only
protected  java.lang.String GetLineSeparator()
          get the line separator string.
 java.lang.String GetPathFile()
          to get the absolute path of a file
 java.lang.String GetRandFileName(java.lang.Object extensionFile)
          Generate a file name randomly, with a long added at the end of the name.
protected  java.util.ArrayList ParseWithReAllFollow(java.lang.String inputStr, java.lang.String patternStr)
          This method allows to parse one line with one Regular Expression in JAVA and to retrieve all items described in this RE, except the whole line.
protected  java.lang.String ParseWithReOneGroup(java.lang.String inputStr, java.lang.String patternStr, int iWhichGroup)
          This method allows to parse one line of a file with a Regular Expression in JAVA and to retrieve only one item of this line.
protected  void PrepareBufferedReader()
          This method prepares the buffered reader, to put the file managed in a buffer, which allow to work on its content and parse it.
 void PutInFile(java.lang.String sequence)
          This method allows to write a string, more or less long, in a file which has been created before.
 java.lang.String ReadingFile()
          This method allows to recover the file content in a String.
 java.util.ArrayList ResultParsing(java.util.ArrayList patternList, int jWhichGroup)
          This method parses a file with only one item requiered and returns the list of this item possibly retrieved in several lines.
 java.util.ArrayList ResultParsingTableFile(java.lang.String pattern)
          This method parses a file from one Regular Expression given.
 void SetFileName(java.lang.String name)
           
 void SetPathFile(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

absolutePath

protected java.lang.String absolutePath
absolute path file


fileName

protected java.lang.String fileName
Constructor Detail

ManagerFiles

public ManagerFiles()
constructor by default


ManagerFiles

public ManagerFiles(java.lang.String pathFile,
                    java.lang.Object extension)
constructor which allows us to create a random file name, this application is multi-user. So, it allows to reduce possible conflicts.

Parameters:
pathFile - String to know where to put this file
extension - Object representing the logic extension behind the file name

ManagerFiles

public ManagerFiles(java.lang.String pathFile,
                    java.lang.String fileName)
constructor which passes a hard file name in parameter

Parameters:
pathFile - String to know where to put this file
fileName - String to represent the hard name file
Method Detail

GetPathFile

public java.lang.String GetPathFile()
to get the absolute path of a file

Returns:
string.

SetPathFile

public void SetPathFile(java.lang.String path)

GetFileName

public java.lang.String GetFileName()
to get the file name only

Returns:
string.

SetFileName

public void SetFileName(java.lang.String name)

GetRandFileName

public java.lang.String GetRandFileName(java.lang.Object extensionFile)
Generate a file name randomly, with a long added at the end of the name. The corresponding extension is added afterwards. the application is multi-user: each user have to get his own file name !

Returns:
string which represents the generated file name.

CreateFile

public boolean CreateFile()
Create a file, checking some important points before: if it already exists, and if it is readable.

Returns:
boolean which answers if the file has been well created.

PutInFile

public void PutInFile(java.lang.String sequence)
               throws IntactException
This method allows to write a string, more or less long, in a file which has been created before. Write the user query in a file which already exists.

Parameters:
sequence - the string which is going to full the file. It is used, for instance, in the RunSimilaritySearch method, where the blast command need to put the query protein sequence in a file.
IntactException

CreateWriter

public void CreateWriter()
                  throws IntactException
if the PutInFile method needs to be managed in a loop, the FileWriter has to be created only once. Create a File Writer separately.

IntactException

ReadingFile

public java.lang.String ReadingFile()
                             throws IntactException
This method allows to recover the file content in a String.

Returns:
string which is in the file.
IntactException

DeleteFile

public void DeleteFile()
Delete a file which isn't used anymore.


ResultParsing

public java.util.ArrayList ResultParsing(java.util.ArrayList patternList,
                                         int jWhichGroup)
                                  throws IntactException
This method parses a file with only one item requiered and returns the list of this item possibly retrieved in several lines.

Parameters:
patternList - while there are pattern strings in this list (corresponds to Regular Expression, we have to continue the parsing with this string.
jWhichGroup - decides which group of the regular expression is retrieved.
Returns:
list made of another list with the results from one line of the file.
IntactException

ResultParsingTableFile

public java.util.ArrayList ResultParsingTableFile(java.lang.String pattern)
                                           throws IntactException
This method parses a file from one Regular Expression given. When the file to parse is in a table format, this method is required instead of the ResultParsing method.

Parameters:
pattern - string which corresponds to a regular expression which will allow to parse the file.
Returns:
list made of another list with the results from one line of the file.
IntactException

PrepareBufferedReader

protected void PrepareBufferedReader()
                              throws IntactException
This method prepares the buffered reader, to put the file managed in a buffer, which allow to work on its content and parse it. This method is also separated from the parsing methods because it must be created only once.

IntactException

ParseWithReOneGroup

protected java.lang.String ParseWithReOneGroup(java.lang.String inputStr,
                                               java.lang.String patternStr,
                                               int iWhichGroup)
This method allows to parse one line of a file with a Regular Expression in JAVA and to retrieve only one item of this line. This method is useful when we want to retrieve data in one simple list. It is included in a loop, and the String is added in a list.

Parameters:
inputStr - the line reading in the file.
patternStr - the Regular Expression which describes the file line to retrieve.
iWhichGroup - to choose which group will be retrieved from the RE (if it is equal to 0, the whole line is retrieved).
Returns:
string which contains one item retrieved in the line

ParseWithReAllFollow

protected java.util.ArrayList ParseWithReAllFollow(java.lang.String inputStr,
                                                   java.lang.String patternStr)
This method allows to parse one line with one Regular Expression in JAVA and to retrieve all items described in this RE, except the whole line. The String groupStr retrieves items requiered by the regular expression. So, each group is added in the result ArrayList, like a String.

Parameters:
inputStr - the current line reading in the file.
patternStr - the Regular Expression which describes the file line to retrieve.
Returns:
ArrayList which contains the items list retrieved in the line.

GetLineSeparator

protected java.lang.String GetLineSeparator()
get the line separator string. It allows to use the same separator int the service and int the client to keep the multiplateform aspect.

Returns:
the line separator


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk