|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jmonks.batch.io.FileWriter
org.jmonks.batch.io.xml.XMLFileWriter
XMLFileWriter writes the specified xml file according to the given file spec with the the recrods submitted to write into the file. It generates the root tag from the attribute given in file-spec. It uses the last part in record xpath to write the record element. If nested elements or repeated elements needs to be written, writer record provides the methods to write these elements.
XMLFileWriter looks for two attributes "indentation-engine" and "encoding" in the file spec to format the generated xml and use the encoding value in generated xml processing instruction. The value to the "indentation-engine" should be the class name implements XMLIndentationEngine interface. If it doesnt find this attribute or not a valid value in this attribute, it uses the default indentation engine. The value specified in "encoding" attribute will be used in the processing instruction.
Nested Class Summary | |
class |
XMLFileWriter.XMLWriterRecord
XMLWriterRecord implements WriterRecord by maintaing the field names and values as a map and provides the methods with proper access privileges to read into and write from the record. |
Field Summary | |
protected XMLFileSpec |
fileSpec
File spec to be adhered with. |
Constructor Summary | |
XMLFileWriter(java.io.OutputStream outputStream,
FileSpec fileSpec)
Constructs and initializes the writer with the given values. |
|
XMLFileWriter(java.io.Writer writer,
FileSpec fileSpec)
Constructs and initializes the writer with the given values. |
Method Summary | |
void |
close()
Closes the writer. |
WriterRecord |
createWriterRecord(RecordType recordType)
Creates the writer record assocites with the given record type. |
protected void |
writeComplexElement(java.lang.String recordElementName,
XMLFileWriter.XMLWriterRecord fieldValueAsRecord)
Writes the nested/composite element into the file. |
void |
writeRecord(WriterRecord writerRecord)
Writes the record into the file. |
protected void |
writeRepeatElement(java.lang.String multiElementName,
java.util.List fieldValueAsList)
Writes the repeated element into the file. |
protected void |
writeSimpleElement(java.lang.String fieldName,
java.lang.Object fieldValue)
Writes the simple element into the file. |
Methods inherited from class org.jmonks.batch.io.FileWriter |
getFileWriter, getFileWriter, getFileWriter, getFileWriter |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected XMLFileSpec fileSpec
Constructor Detail |
public XMLFileWriter(java.io.OutputStream outputStream, FileSpec fileSpec)
outputStream
- Output stream to write the records.fileSpec
- File spec to be used to generate the file.public XMLFileWriter(java.io.Writer writer, FileSpec fileSpec)
writer
- Writer to write the records.fileSpec
- File spec to be used to generate the file.Method Detail |
public void writeRecord(WriterRecord writerRecord)
writeRecord
in class FileWriter
writerRecord
- Record to be written into the file.
java.lang.IllegalStateException
- If writer is closed and trying to write the recrod.
java.lang.IllegalArgumentException
- If writer record is null.
FileParseException
- Problems while trying to write the record.protected void writeSimpleElement(java.lang.String fieldName, java.lang.Object fieldValue) throws javax.xml.stream.XMLStreamException
fieldName
- Name of the element.fieldValue
- Value of the element.
javax.xml.stream.XMLStreamException
protected void writeComplexElement(java.lang.String recordElementName, XMLFileWriter.XMLWriterRecord fieldValueAsRecord) throws javax.xml.stream.XMLStreamException
recordElementName
- Name of the nested element.fieldValueAsRecord
- Value of the nested element.
javax.xml.stream.XMLStreamException
protected void writeRepeatElement(java.lang.String multiElementName, java.util.List fieldValueAsList) throws javax.xml.stream.XMLStreamException
multiElementName
- Name of the repeated element.fieldValueAsList
- Value of the repeated element.
javax.xml.stream.XMLStreamException
public WriterRecord createWriterRecord(RecordType recordType)
createWriterRecord
in class FileWriter
recordType
- Type fo the record to be created.
java.lang.IllegalArgumentException
- No record spec is found with this record type.public void close()
close
in class FileWriter
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |