Package adams.data.conversion
Class DOMToString
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,PrettyPrintingSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<AbstractConversion>
,SizeOfHandler
,Stoppable
,Conversion
,ConversionToString
,Serializable
public class DOMToString extends AbstractConversionToString implements PrettyPrintingSupporter
Turns a org.w3c.dom.Node or org.w3c.dom.Document DOM object into a String.
In case of org.w3c.dom.Node objects, the owner document is converted to String.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use for the string. default: Default
-pretty-printing <boolean> (property: prettyPrinting) If enabled, the XML is output in pretty-print format. default: false
-num-spaces <int> (property: numSpaces) The number of spaces to use for indentation (in case of pretty-printing). default: 2 minimum: 0
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseCharset
m_Encoding
the encoding to use.protected int
m_NumSpaces
the number of spaces to use for indentation.protected boolean
m_PrettyPrinting
whether to use pretty printing.-
Fields inherited from class adams.data.conversion.AbstractConversion
m_Input, m_Output, m_Owner, m_Stopped
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description DOMToString()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class
accepts()
Returns the class that is accepted as input.void
defineOptions()
Adds options to the internal list of options.protected Object
doConvert()
Performs the actual conversion.String
encodingTipText()
Returns the tip text for this property.BaseCharset
getEncoding()
Returns the encoding to use.int
getNumSpaces()
Returns the number of spaces to use for pretty printing.boolean
getPrettyPrinting()
Returns whether pretty-printing is used or not.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
numSpacesTipText()
Returns the tip text for this property.String
prettyPrintingTipText()
Returns the tip text for this property.void
setEncoding(BaseCharset value)
Sets the encoding to use.void
setNumSpaces(int value)
Sets the number of spaces to use for pretty printing.void
setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.-
Methods inherited from class adams.data.conversion.AbstractConversionToString
generates
-
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, reset, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.CleanUpHandler
cleanUp
-
Methods inherited from interface adams.data.conversion.Conversion
convert, getInput, getInput, getOutput, getOutput, getOwner, setInput, setOwner
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.Stoppable
stopExecution
-
-
-
-
Field Detail
-
m_Encoding
protected BaseCharset m_Encoding
the encoding to use.
-
m_PrettyPrinting
protected boolean m_PrettyPrinting
whether to use pretty printing.
-
m_NumSpaces
protected int m_NumSpaces
the number of spaces to use for indentation.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setEncoding
public void setEncoding(BaseCharset value)
Sets the encoding to use.- Parameters:
value
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
getEncoding
public BaseCharset getEncoding()
Returns the encoding to use.- Returns:
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
encodingTipText
public String encodingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPrettyPrinting
public void setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.- Specified by:
setPrettyPrinting
in interfacePrettyPrintingSupporter
- Parameters:
value
- true if to use pretty-printing
-
getPrettyPrinting
public boolean getPrettyPrinting()
Returns whether pretty-printing is used or not.- Specified by:
getPrettyPrinting
in interfacePrettyPrintingSupporter
- Returns:
- true if to use pretty-printing
-
prettyPrintingTipText
public String prettyPrintingTipText()
Returns the tip text for this property.- Specified by:
prettyPrintingTipText
in interfacePrettyPrintingSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumSpaces
public void setNumSpaces(int value)
Sets the number of spaces to use for pretty printing.- Parameters:
value
- the number of spaces
-
getNumSpaces
public int getNumSpaces()
Returns the number of spaces to use for pretty printing.- Returns:
- the number of spaces
-
numSpacesTipText
public String numSpacesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractConversion
- Returns:
- null if no info available, otherwise short string
-
accepts
public Class accepts()
Returns the class that is accepted as input.- Specified by:
accepts
in interfaceConversion
- Specified by:
accepts
in classAbstractConversion
- Returns:
- the class
-
doConvert
protected Object doConvert() throws Exception
Performs the actual conversion.- Specified by:
doConvert
in classAbstractConversion
- Returns:
- the converted data
- Throws:
Exception
- if something goes wrong with the conversion
-
-