[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/io/flat FixedWidthFlatFileFileSpec.java, 1
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-06-09 21:36:44
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/flat In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3769/flat Modified Files: FixedWidthFlatFileFileSpec.java FixedWidthFlatFileReader.java FixedWidthFlatFileWriter.java Log Message: no message Index: FixedWidthFlatFileFileSpec.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/flat/FixedWidthFlatFileFileSpec.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FixedWidthFlatFileFileSpec.java 8 Jun 2006 22:21:15 -0000 1.3 --- FixedWidthFlatFileFileSpec.java 9 Jun 2006 21:36:34 -0000 1.4 *************** *** 40,51 **** /** ! * Constructs the FixedWidthFlatFileFileSpec by accepting the file spec path and ! * file type. ! * ! * @param fileSpecPath Absolute path to the file spec. */ ! protected FixedWidthFlatFileFileSpec(String fileSpecPath) { ! super(fileSpecPath,FileType.FIXED_WIDTH_FLAT_FILE); } --- 40,48 ---- /** ! * Constructs the FixedWidthFlatFileFileSpec. */ ! protected FixedWidthFlatFileFileSpec() { ! super(FileType.FIXED_WIDTH_FLAT_FILE); } *************** *** 54,58 **** * DOM Element representing the file-spec element. * - * @param fileSpecPath Absolute path to the file spec. * @param fileSpecElement DOM Element representing the file-spec element. * --- 51,54 ---- *************** *** 62,69 **** * has the same value for the starts-with and record-type attributes. */ ! public static FileSpec createFixedWidthFlatFileFileSpec(final String fileSpecPath,final Element fileSpecElement) { ! logger.trace("Entering createFixedWidthFlatFileFileSpec " + fileSpecPath); ! FixedWidthFlatFileFileSpec fileSpec=new FixedWidthFlatFileFileSpec(fileSpecPath); NodeList recordSpecNodeList=fileSpecElement.getElementsByTagName(RecordSpec.RECORD_SPEC_TAG_NAME); logger.debug("Number of record specs found = " + recordSpecNodeList.getLength()); --- 58,65 ---- * has the same value for the starts-with and record-type attributes. */ ! public static FileSpec createFixedWidthFlatFileFileSpec(final Element fileSpecElement) { ! logger.trace("Entering createFixedWidthFlatFileFileSpec "); ! FixedWidthFlatFileFileSpec fileSpec=new FixedWidthFlatFileFileSpec(); NodeList recordSpecNodeList=fileSpecElement.getElementsByTagName(RecordSpec.RECORD_SPEC_TAG_NAME); logger.debug("Number of record specs found = " + recordSpecNodeList.getLength()); *************** *** 96,100 **** stringValue.append("[fileType = " + super.fileType.toString() + "]"); stringValue.append("[recordSpecList = "); ! for(Iterator iterator=recordSpecList.iterator();iterator.hasNext();) stringValue.append(((FixedWidthFlatFileRecordSpec)iterator.next()).toString()); stringValue.append("]}"); --- 92,96 ---- stringValue.append("[fileType = " + super.fileType.toString() + "]"); stringValue.append("[recordSpecList = "); ! for(Iterator iterator=recordSpecMap.values().iterator();iterator.hasNext();) stringValue.append(((FixedWidthFlatFileRecordSpec)iterator.next()).toString()); stringValue.append("]}"); Index: FixedWidthFlatFileWriter.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/flat/FixedWidthFlatFileWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FixedWidthFlatFileWriter.java 8 Jun 2006 22:21:15 -0000 1.4 --- FixedWidthFlatFileWriter.java 9 Jun 2006 21:36:34 -0000 1.5 *************** *** 13,16 **** --- 13,18 ---- import java.io.BufferedWriter; import java.io.IOException; + import java.io.OutputStream; + import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.HashMap; *************** *** 41,48 **** { /** - * Path of the file to be written. - */ - protected String filePath=null; - /** * File spec to be used in writing the file. */ --- 43,46 ---- *************** *** 61,84 **** * Constructs and initializes the writer with the given values. * ! * @param filePath Absolute path to the file to be generated. * @param fileSpec File spec to be used to generate the file. */ ! public FixedWidthFlatFileWriter(String filePath,FileSpec fileSpec) { logger.trace("Entering FixedWidthFlatFileWriter constructor"); ! try ! { ! this.filePath=filePath; ! this.fileSpec=(FixedWidthFlatFileFileSpec)fileSpec; ! writer=new BufferedWriter(new java.io.FileWriter(this.filePath)); ! logger.debug("Done creating and initializing the writer"); ! } ! catch(IOException exception) ! { ! exception.printStackTrace(); ! logger.fatal("IOException while creating the reader. Message = " + exception.getMessage(),exception); ! this.writer=null; ! throw new FileParseException("IOException while creating the reader. Message = " + exception.getMessage()); ! } logger.trace("Exiting FixedWidthFlatFileWriter constructor"); } --- 59,71 ---- * Constructs and initializes the writer with the given values. * ! * @param outputStream Output stream to write the records. * @param fileSpec File spec to be used to generate the file. */ ! public FixedWidthFlatFileWriter(OutputStream outputStream,FileSpec fileSpec) { logger.trace("Entering FixedWidthFlatFileWriter constructor"); ! this.fileSpec=(FixedWidthFlatFileFileSpec)fileSpec; ! writer=new BufferedWriter(new OutputStreamWriter(outputStream)); ! logger.debug("Done creating and initializing the writer"); logger.trace("Exiting FixedWidthFlatFileWriter constructor"); } Index: FixedWidthFlatFileReader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/flat/FixedWidthFlatFileReader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FixedWidthFlatFileReader.java 8 Jun 2006 22:21:15 -0000 1.4 --- FixedWidthFlatFileReader.java 9 Jun 2006 21:36:34 -0000 1.5 *************** *** 12,17 **** import java.io.BufferedReader; - import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; --- 12,18 ---- import java.io.BufferedReader; import java.io.IOException; + import java.io.InputStream; + import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; *************** *** 37,44 **** { /** - * Holds the absolute path to the file to read. - */ - protected String filePath=null; - /** * File spec to be used to read the file. */ --- 38,41 ---- *************** *** 52,56 **** * Constructs and initializes the reader with the given file path and file spec. * ! * @param filePath Absolute path to the file to read. * @param fileSpec File spec to be used to read the file. * --- 49,53 ---- * Constructs and initializes the reader with the given file path and file spec. * ! * @param fileInputStream Input stream to the file. * @param fileSpec File spec to be used to read the file. * *************** *** 58,86 **** * initializing the reader. */ ! public FixedWidthFlatFileReader(String filePath,FileSpec fileSpec) { logger.trace("Entering FixedWidthFlatFileReader constructor"); - this.filePath=filePath; this.fileSpec=(FixedWidthFlatFileFileSpec)fileSpec; ! try ! { ! reader=new BufferedReader(new java.io.FileReader(this.filePath)); ! logger.debug("Created the reader successfully = " + this.filePath); ! } ! catch(FileNotFoundException exception) ! { ! reader=null; ! exception.printStackTrace(); ! logger.fatal("File could not be found to create the reader. Message = " + exception.getMessage(),exception); ! throw new FileParseException("File could not be found to create the reader. Message = " + exception.getMessage()); ! } ! catch(IOException exception) ! { ! reader=null; ! exception.printStackTrace(); ! logger.fatal("IO Exception while initializing the file reader. Message = " + exception.getMessage(),exception); ! throw new FileParseException("IO Exception while initializing the file reader. Message = " + exception.getMessage()); ! } ! logger.trace("Exiting FixedWidthFlatFileReader constructor"); } --- 55,64 ---- * initializing the reader. */ ! public FixedWidthFlatFileReader(InputStream fileInputStream,FileSpec fileSpec) { logger.trace("Entering FixedWidthFlatFileReader constructor"); this.fileSpec=(FixedWidthFlatFileFileSpec)fileSpec; ! reader=new BufferedReader(new InputStreamReader(fileInputStream)); ! logger.debug("Created the reader successfully"); } |