[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/io FileReader.java, 1.11, 1.12 FileWriter.
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-06-13 04:01:41
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29536 Modified Files: FileReader.java FileWriter.java package.html Log Message: no message Index: FileWriter.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileWriter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FileWriter.java 10 Jun 2006 17:50:24 -0000 1.6 --- FileWriter.java 13 Jun 2006 04:01:36 -0000 1.7 *************** *** 80,85 **** * @return Returns the appropriate writer. * ! * @throws IllegalArgumentException If the given file path or file spec path is null or ! * or if they are directoires. * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt * exist in FileType class. --- 80,84 ---- * @return Returns the appropriate writer. * ! * @throws IllegalArgumentException If the given file output stream or file spec is null. * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt * exist in FileType class. *************** *** 88,99 **** { logger.trace("Entering getFileReader"); - if(outputStream==null) throw new IllegalArgumentException("Output stream to write the records cannot be null."); - if(fileSpecInputStream==null) throw new IllegalArgumentException("Input stream to read the file spec cannot be null."); FileSpec fileSpec=FileSpec.createFileSpec(fileSpecInputStream); logger.debug("Given file spec = " + fileSpec.toString()); if(fileSpec.getFileType()==FileType.FIXED_WIDTH_FLAT_FILE) --- 87,122 ---- { logger.trace("Entering getFileReader"); if(outputStream==null) throw new IllegalArgumentException("Output stream to write the records cannot be null."); if(fileSpecInputStream==null) throw new IllegalArgumentException("Input stream to read the file spec cannot be null."); FileSpec fileSpec=FileSpec.createFileSpec(fileSpecInputStream); + return FileWriter.getFileWriter(outputStream, fileSpec); + } + + /** + * <p> + * Factory method to get the file writer. This method returns the appropriate file writer + * based on the file type specified in the file spec. + * </p> + * + * @param outputStream Output stream to write the records. + * @param fileSpec File spec to be used to create the writer. + * + * @return Returns the appropriate writer. + * + * @throws IllegalArgumentException If the given file output stream or file spec is null. + * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt + * exist in FileType class. + */ + public static FileWriter getFileWriter(OutputStream outputStream, FileSpec fileSpec) + { + logger.trace("Entering getFileReader"); + if(outputStream==null) + throw new IllegalArgumentException("Output stream to write the records cannot be null."); + if(fileSpec==null) + throw new IllegalArgumentException("File spec to create the writer cannot be null."); + logger.debug("Given file spec = " + fileSpec.toString()); if(fileSpec.getFileType()==FileType.FIXED_WIDTH_FLAT_FILE) *************** *** 104,108 **** return new XMLFileWriter(outputStream,fileSpec); else ! throw new FileSpecException("Unsupported file type in the file spec = " + fileSpec.getFileType().toString()); ! } } --- 127,131 ---- return new XMLFileWriter(outputStream,fileSpec); else ! throw new FileSpecException("Unsupported file type in the file spec = " + fileSpec.getFileType().toString()); ! } } Index: package.html =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** package.html 9 Jun 2006 03:57:22 -0000 1.1 --- package.html 13 Jun 2006 04:01:36 -0000 1.2 *************** *** 5,9 **** </head> <body> ! Here explain the usage of IO API. </body> </html> --- 5,9 ---- </head> <body> ! Explain the usage of IO API. </body> </html> Index: FileReader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileReader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FileReader.java 10 Jun 2006 17:50:24 -0000 1.11 --- FileReader.java 13 Jun 2006 04:01:35 -0000 1.12 *************** *** 77,82 **** * @return Returns the appropriate reader. * ! * @throws IllegalArgumentException If the given file path or file spec path is null or ! * doesnt exist and if they are directoires. * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt * exist in FileType class. --- 77,81 ---- * @return Returns the appropriate reader. * ! * @throws IllegalArgumentException If the given fileInputStream or fileSpecInputStream is null. * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt * exist in FileType class. *************** *** 85,96 **** { logger.trace("Entering getFileReader"); - if(fileInputStream==null) throw new IllegalArgumentException("Input stream to read the data file cannot be null."); - if(fileSpecInputStream==null) throw new IllegalArgumentException("Input stream to read the file spec cannot be null."); FileSpec fileSpec=FileSpec.createFileSpec(fileSpecInputStream); logger.debug("Given file spec = " + fileSpec.toString()); if(fileSpec.getFileType()==FileType.FIXED_WIDTH_FLAT_FILE) --- 84,118 ---- { logger.trace("Entering getFileReader"); if(fileInputStream==null) throw new IllegalArgumentException("Input stream to read the data file cannot be null."); if(fileSpecInputStream==null) throw new IllegalArgumentException("Input stream to read the file spec cannot be null."); FileSpec fileSpec=FileSpec.createFileSpec(fileSpecInputStream); + return FileReader.getFileReader(fileInputStream, fileSpec); + } + /** + * <p> + * Factory method to get the file reader. This method returns the appropriate file reader + * based on the file type specified in the file spec. + * </p> + * + * @param fileInputStream Input stream to read the data file. + * @param fileSpec File spec to create the file reader. + * + * @return Returns the appropriate reader. + * + * @throws IllegalArgumentException If the given fileInputStream or fileSpec is null. + * @throws org.jmonks.batchserver.io.FileSpecException If the configured file type in file spec doesnt + * exist in FileType class. + */ + public static FileReader getFileReader(InputStream fileInputStream, FileSpec fileSpec) + { + logger.trace("Entering getFileReader"); + if(fileInputStream==null) + throw new IllegalArgumentException("Input stream to read the data file cannot be null."); + if(fileSpec==null) + throw new IllegalArgumentException("File spec cannot be null to create the file reader."); + logger.debug("Given file spec = " + fileSpec.toString()); if(fileSpec.getFileType()==FileType.FIXED_WIDTH_FLAT_FILE) *************** *** 101,105 **** return new XMLFileReader(fileInputStream,fileSpec); else ! throw new FileSpecException("Unsupported file type in the file spec = " + fileSpec.getFileType().toString()); } } --- 123,127 ---- return new XMLFileReader(fileInputStream,fileSpec); else ! throw new FileSpecException("Unsupported file type in the file spec = " + fileSpec.getFileType().toString()); } } |