de.fu_berlin.ties.xml.convert
Class DSVtoXMLConverter

java.lang.Object
  extended by de.fu_berlin.ties.ConfigurableProcessor
      extended by de.fu_berlin.ties.TextProcessor
          extended by de.fu_berlin.ties.DocumentWriter
              extended by de.fu_berlin.ties.xml.convert.DSVtoXMLConverter
All Implemented Interfaces:
Processor

public class DSVtoXMLConverter
extends DocumentWriter

Converts data in DSV format (or any other FieldContainers) into XML format. Optionally, all attributes can be omitted.

Instances of this class are not thread-safe and must be synchronized externally, if required (if setter methods are used -- otherwise this class is stateless and can be used to convert multiple documents in parallel).

Version:
$Revision: 1.9 $, $Date: 2006/10/21 16:04:31 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
 
Fields inherited from class de.fu_berlin.ties.TextProcessor
CONFIG_POST, KEY_DIRECTORY, KEY_LOCAL_NAME, KEY_OUT_DIRECTORY, KEY_URL
 
Constructor Summary
DSVtoXMLConverter(String outExt)
          Creates a new instance, using the standard configuration.
DSVtoXMLConverter(String outExt, TiesConfiguration conf)
          Creates a new instance.
DSVtoXMLConverter(String outExt, TiesConfiguration conf, QName rootElement, boolean omitAttribs, QName secondLevelName, String secondLevelPattern)
          Creates a new instance.
 
Method Summary
 Document convert(FieldContainer data)
          Converts a field container into XML.
 QName getLevel2Name()
          Returns the name of elements inserted as second level; if null, no second level is used.
 QName getRootName()
          Returns the name used for the root element.
 boolean isOmittingAttribs()
          Whether attributes are omitted.
 Document process(Reader reader, ContextMap context)
          Processes the contents of a reader and stores the results of processing in an XML document. This implementation delegates to convert(FieldContainer), reading input in DSV format.
 void setLevel2Name(QName newLevel2Name)
          Modifies the name of elements to insert as second level; if null, no second level is used.
 void setOmittingAttribs(boolean newOmittingAttribs)
          Specifies whether to omit attributes.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class de.fu_berlin.ties.DocumentWriter
doProcess
 
Methods inherited from class de.fu_berlin.ties.TextProcessor
getOutFileExt, process, process, process, process, process, process
 
Methods inherited from class de.fu_berlin.ties.ConfigurableProcessor
getConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DSVtoXMLConverter

public DSVtoXMLConverter(String outExt)
Creates a new instance, using the standard configuration.

Parameters:
outExt - the extension to use for output files

DSVtoXMLConverter

public DSVtoXMLConverter(String outExt,
                         TiesConfiguration conf)
Creates a new instance.

Parameters:
outExt - the extension to use for output files
conf - used to configure this instance; must not be null

DSVtoXMLConverter

public DSVtoXMLConverter(String outExt,
                         TiesConfiguration conf,
                         QName rootElement,
                         boolean omitAttribs,
                         QName secondLevelName,
                         String secondLevelPattern)
Creates a new instance.

Parameters:
outExt - the extension to use for output files
conf - used to configure this instance; if null, the standard configuration is used
rootElement - the name of the root element
omitAttribs - whether to omit all attributes
secondLevelName - the name of elements inserted as second level; if null, no second level is used
secondLevelPattern - pattern that must be matched for second-level elements to be created
Method Detail

convert

public Document convert(FieldContainer data)
Converts a field container into XML.

Parameters:
data - the container to convert
Returns:
the converted XML document

getLevel2Name

public QName getLevel2Name()
Returns the name of elements inserted as second level; if null, no second level is used.

Returns:
the value of the attribute

getRootName

public QName getRootName()
Returns the name used for the root element.

Returns:
the value of the attribute

isOmittingAttribs

public boolean isOmittingAttribs()
Whether attributes are omitted.

Returns:
the value of the attribute

process

public Document process(Reader reader,
                        ContextMap context)
                 throws IOException,
                        ProcessingException
Processes the contents of a reader and stores the results of processing in an XML document. This implementation delegates to convert(FieldContainer), reading input in DSV format.

Specified by:
process in class DocumentWriter
Parameters:
reader - reader containing the text to process; not closed by this method
context - a map of objects that are made available for processing
Returns:
the created document
Throws:
IOException - if an I/O error occurs
ProcessingException - if an error occurs during processing

setLevel2Name

public void setLevel2Name(QName newLevel2Name)
Modifies the name of elements to insert as second level; if null, no second level is used.

Parameters:
newLevel2Name - the new value of the attribute

setOmittingAttribs

public void setOmittingAttribs(boolean newOmittingAttribs)
Specifies whether to omit attributes.

Parameters:
newOmittingAttribs - the new value of the attribute

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class TextProcessor
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.