[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/io/xml XMLFileReader.java, 1.6, 1.7 XMLFil
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-06-09 21:36:42
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/xml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3769/xml Modified Files: XMLFileReader.java XMLFileSpec.java XMLFileWriter.java Log Message: no message Index: XMLFileReader.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/xml/XMLFileReader.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XMLFileReader.java 8 Jun 2006 22:21:15 -0000 1.6 --- XMLFileReader.java 9 Jun 2006 21:36:34 -0000 1.7 *************** *** 12,15 **** --- 12,17 ---- import java.io.FileNotFoundException; + import java.io.InputStream; + import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; *************** *** 49,56 **** { /** - * Path to the file to be read. - */ - protected String filePath=null; - /** * File spec to read the file. */ --- 51,54 ---- *************** *** 70,88 **** * Constructs and initializes the XML File reader. * ! * @param filePath Absolute path to the file to be read. ! * @param fileSpec File spec for the file to be read. * * @throws org.jmonks.batchserver.io.FileParseException If root element doesnt match * with the element specified in file spec and problems to initializes the reader. */ ! public XMLFileReader(String filePath,FileSpec fileSpec) { logger.trace("Entering XMLFileReader constructor"); - this.filePath=filePath; this.fileSpec=(XMLFileSpec)fileSpec; try { XMLInputFactory inputFactory=XMLInputFactory.newInstance(); ! reader=inputFactory.createXMLEventReader(new java.io.FileReader(this.filePath)); logger.debug("Created the XML Event reader"); if(this.validateRootElement()) --- 68,85 ---- * Constructs and initializes the XML File reader. * ! * @param fileInputStream Input stream to the file. ! * @param fileSpec File spec to be used to read the file. * * @throws org.jmonks.batchserver.io.FileParseException If root element doesnt match * with the element specified in file spec and problems to initializes the reader. */ ! public XMLFileReader(InputStream filInputStream,FileSpec fileSpec) { logger.trace("Entering XMLFileReader constructor"); this.fileSpec=(XMLFileSpec)fileSpec; try { XMLInputFactory inputFactory=XMLInputFactory.newInstance(); ! reader=inputFactory.createXMLEventReader(new InputStreamReader(filInputStream)); logger.debug("Created the XML Event reader"); if(this.validateRootElement()) *************** *** 95,105 **** logger.debug("Validate the root tag of the file"); } - catch(FileNotFoundException exception) - { - exception.printStackTrace(); - this.reader=null; - logger.fatal("File to create the reader cannot be found. Exception Message = " + exception.getMessage(),exception); - throw new FileParseException("File to create the reader cannot be found. Exception Message = " + exception.getMessage()); - } catch(XMLStreamException exception) { --- 92,95 ---- Index: XMLFileWriter.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/xml/XMLFileWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLFileWriter.java 8 Jun 2006 22:21:15 -0000 1.4 --- XMLFileWriter.java 9 Jun 2006 21:36:34 -0000 1.5 *************** *** 10,15 **** package org.jmonks.batchserver.io.xml; ! ! import java.io.IOException; import java.util.HashMap; import java.util.Iterator; --- 10,14 ---- package org.jmonks.batchserver.io.xml; ! import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; *************** *** 44,51 **** { /** - * Path to the file to be generated. - */ - protected String filePath=null; - /** * File spec to be adhered with. */ --- 43,46 ---- *************** *** 63,78 **** * 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 XMLFileWriter(String absoluteFilePath,FileSpec fileSpec) { logger.trace("Entering XMLFileWriter constructor"); try { - this.filePath=absoluteFilePath; this.fileSpec=(XMLFileSpec)fileSpec; XMLOutputFactory outputFactory=XMLOutputFactory.newInstance(); ! writer=outputFactory.createXMLStreamWriter(new java.io.FileWriter(this.filePath)); logger.debug("Writer has been created."); writer.writeStartDocument("ISO-8859-1", "1.0"); --- 58,72 ---- * 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 XMLFileWriter(OutputStream outputStream,FileSpec fileSpec) { logger.trace("Entering XMLFileWriter constructor"); try { this.fileSpec=(XMLFileSpec)fileSpec; XMLOutputFactory outputFactory=XMLOutputFactory.newInstance(); ! writer=outputFactory.createXMLStreamWriter(outputStream); logger.debug("Writer has been created."); writer.writeStartDocument("ISO-8859-1", "1.0"); *************** *** 80,89 **** writer.writeStartElement(this.fileSpec.rootElement); } - catch(IOException exception) - { - exception.printStackTrace(); - logger.fatal("IOException while creating the writer. Message = " + exception.getMessage(), exception); - throw new FileParseException("IOException while creating the writer. Message = " + exception.getMessage()); - } catch(XMLStreamException exception) { --- 74,77 ---- Index: XMLFileSpec.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/xml/XMLFileSpec.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLFileSpec.java 8 Jun 2006 22:21:15 -0000 1.2 --- XMLFileSpec.java 9 Jun 2006 21:36:34 -0000 1.3 *************** *** 50,59 **** /** * Constructs the XMLFileSpec instance. - * - * @fileSpecPath Absolute path to the file spec. */ ! protected XMLFileSpec(String fileSpecPath) { ! super(fileSpecPath,FileType.XML_FILE); } --- 50,57 ---- /** * Constructs the XMLFileSpec instance. */ ! protected XMLFileSpec() { ! super(FileType.XML_FILE); } *************** *** 67,74 **** /** ! * Factory method create the xml file spec object from the given * DOM Element representing the file-spec element. * - * @param fileSpecPath Absolute path to the file spec. * @param fileSpecElement DOM Element representing the file-spec element. * --- 65,71 ---- /** ! * Factory method to create the xml file spec object from the given * DOM Element representing the file-spec element. * * @param fileSpecElement DOM Element representing the file-spec element. * *************** *** 78,84 **** * has the same value for the record-xpath and record-type attributes. */ ! public static FileSpec createXMLFileSpec(final String fileSpecPath,final Element fileSpecElement) { ! XMLFileSpec fileSpec=new XMLFileSpec(fileSpecPath); String rootElement=fileSpecElement.getAttribute(XMLFileSpec.ROOT_ELEMENT_ATTRIB_NAME); --- 75,81 ---- * has the same value for the record-xpath and record-type attributes. */ ! public static FileSpec createXMLFileSpec(final Element fileSpecElement) { ! XMLFileSpec fileSpec=new XMLFileSpec(); String rootElement=fileSpecElement.getAttribute(XMLFileSpec.ROOT_ELEMENT_ATTRIB_NAME); *************** *** 116,120 **** stringValue.append("[rootElement = " + this.rootElement + "]"); stringValue.append("[recordSpecList = "); ! for(Iterator iterator=recordSpecList.iterator();iterator.hasNext();) stringValue.append(((XMLRecordSpec)iterator.next()).toString()); stringValue.append("]}"); --- 113,117 ---- stringValue.append("[rootElement = " + this.rootElement + "]"); stringValue.append("[recordSpecList = "); ! for(Iterator iterator=recordSpecMap.values().iterator();iterator.hasNext();) stringValue.append(((XMLRecordSpec)iterator.next()).toString()); stringValue.append("]}"); |