Package adams.data.conversion
Class AbstractConversion
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.conversion.AbstractConversion
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<AbstractConversion>
,SizeOfHandler
,Stoppable
,Conversion
,Serializable
- Direct Known Subclasses:
AbstractConversionFromString
,AbstractConversionToString
,AbstractImageToByteArray
,AbstractMatchWekaInstanceAgainstHeader
,AbstractMatrixToSpreadSheet
,AbstractObjectToJson
,AbstractScript
,AbstractScriptedConversion
,AbstractSpreadSheetConversion
,AbstractSpreadSheetToMatrix
,AbstractStringConversion
,AbstractSwapObject
,AdamsInstanceToWekaInstance
,AnyImageToOpenCV
,ArrayToCollection
,ArrayToJsonArray
,ArrayToReport
,BlobContainerToByteArray
,BoofCVToBufferedImage
,BooleanToString
,BufferedImageBitmaskContainerToBufferedImages
,BufferedImagesToBufferedImageBitmaskContainer
,BufferedImageSupporterToBufferedImageContainer
,BufferedImageToBoofCV
,BufferedImageToBufferedImage
,ByteArrayToBlobContainer
,ByteArrayToBufferedImage
,ByteArrayToImageContainer
,ByteArrayToJavaObject
,ByteArrayToPrimitiveArray
,ByteToInt
,CollectionToArray
,ColorToHex
,ContainerToSpreadSheet
,ConvertDateTimeType
,DOMNodeListToArray
,DOMToProperties
,DoubleMatrixToBufferedImage
,DoubleMatrixToMat5Array
,DoubleToFloat
,DoubleToInt
,DoubleToLong
,ExtractDateTimeField
,ExtractSimpleContainerContent
,FloatToDouble
,HashCode
,HexToColor
,ImageContainerToByteArray
,ImageContainerToSpreadSheet
,InformativeStatistic
,IntToByte
,IntToDouble
,IntToLong
,JavaObjectToByteArray
,JoinOptions
,JsonArrayToArray
,JsonArrayToList
,JsonObjectToMap
,JsonToReport
,JsonToSpreadSheet
,ListToJsonArray
,LocatedObjectsToReport
,LocatedObjectToRectangle
,LongToDouble
,LongToInt
,MapToKeyValuePairs
,MapToMat5File
,MapToMat5Struct
,MapToReport
,MapToSpreadSheet
,MapToString
,MapToWekaInstance
,Mat5ArrayToDoubleMatrix
,Mat5ArrayToSpreadSheet
,Mat5FileToMap
,Mat5StructToMap
,MathExpression
,Maximum
,Minimum
,MovingAverage
,MultiConversion
,NotesSubset
,NotesToSpreadSheet
,NumberToByte
,NumberToDouble
,NumberToFloat
,NumberToInt
,NumberToLong
,ObjectAnnotationsToImageSegmentationLayers
,ObjectArrayToPrimitiveArray
,ObjectContainerToObject
,ObjectToObject
,ObjectToObjectContainer
,OpenCVToBufferedImage
,PathSplit
,PrimitiveArrayToByteArray
,PrimitiveArrayToObjectArray
,PropertiesToKeyValuePairs
,PropertiesToMap
,PropertiesToSpreadSheet
,QuadrilateralLocationCenter
,RectangleCenter
,ReportArrayToMap
,ReportToJson
,ReportToMap
,ReportToSpreadSheet
,ReportToWekaInstance
,Round
,RowArrayToSpreadSheet
,SplitOptions
,SpreadSheetCellFinderToPositions
,SpreadSheetCellLocationToCoordinates
,SpreadSheetCellLocationToPosition
,SpreadSheetColumnFinderToRange
,SpreadSheetColumnsToReport
,SpreadSheetHeaderToMat5Array
,SpreadSheetRowFinderToRange
,SpreadSheetRowsToReport
,SpreadSheetSupporterToSpreadSheet
,SpreadSheetToCreateTableStatement
,SpreadSheetToDataset
,SpreadSheetToJson
,SpreadSheetToMap
,SpreadSheetToMat5Array
,SpreadSheetToNumeric
,SpreadSheetToRowArray
,SpreadSheetToString
,SpreadSheetToTimeseries
,SpreadSheetToWekaInstances
,StringArrayToURLParameters
,StringToBoolean
,StringToSpreadSheet
,StringToURL
,TimeseriesToArray
,TimeseriesToSpreadSheet
,TimeseriesToWekaInstances
,UnknownToUnknown
,URLParametersToStringArray
,URLToString
,WekaCapabilitiesToInstances
,WekaCapabilitiesToSpreadSheet
,WekaEvaluationToCostCurve
,WekaEvaluationToMarginCurve
,WekaEvaluationToThresholdCurve
,WekaForecastContainerToArray
,WekaForecastContainerToTimeseries
,WekaInstancesToSpreadSheet
,WekaInstancesToTimeseries
,WekaInstanceToAdamsInstance
,WekaInstanceToMap
,WekaPackageToMap
,WekaPredictionContainerToSpreadSheet
public abstract class AbstractConversion extends AbstractOptionHandler implements Conversion, CleanUpHandler, ShallowCopySupporter<AbstractConversion>, AdditionalInformationHandler
Ancestor for all conversions.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
m_Input
the input data.protected Object
m_Output
the generated output.protected Object
m_Owner
the owner.protected boolean
m_Stopped
whether the conversion was 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 AbstractConversion()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Class
accepts()
Returns the class that is accepted as input.protected String
checkData()
Checks whether the data can be processed.void
cleanUp()
Cleans up data structures, frees up memory.String
convert()
Performs the conversion.protected abstract Object
doConvert()
Performs the actual conversion.abstract Class
generates()
Returns the class that is generated as output.String
getAdditionalInformation()
Returns the additional information.Object
getInput()
The currently set input data to convert.<T> T
getInput(Class<T> cls)
The currently set input data to convert.Object
getOutput()
Returns the generated output.<T> T
getOutput(Class<T> cls)
Returns the generated output.Object
getOwner()
Returns the owner of this conversion.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.protected void
reset()
Resets the converter.void
setInput(Object value)
Sets the original data to convert.void
setOwner(Object value)
Sets the owner of this conversion.AbstractConversion
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractConversion
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.void
stopExecution()
Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, 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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformation
in interfaceAdditionalInformationHandler
- Returns:
- the additional information, null or 0-length string for no information
-
reset
protected void reset()
Resets the converter.- Overrides:
reset
in classAbstractOptionHandler
-
setOwner
public void setOwner(Object value)
Sets the owner of this conversion.- Specified by:
setOwner
in interfaceConversion
- Parameters:
value
- the owner
-
getOwner
public Object getOwner()
Returns the owner of this conversion.- Specified by:
getOwner
in interfaceConversion
- Returns:
- the owner, null if none set
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
accepts
public abstract Class accepts()
Returns the class that is accepted as input.- Specified by:
accepts
in interfaceConversion
- Returns:
- the class
-
setInput
public void setInput(Object value)
Sets the original data to convert. For converters implementingStreamConversion
this only resets the m_Output variable, but not the whole converter like it does nor simple converters.- Specified by:
setInput
in interfaceConversion
- Parameters:
value
- the data to convert- See Also:
StreamConversion
,m_Output
-
getInput
public Object getInput()
The currently set input data to convert.- Specified by:
getInput
in interfaceConversion
- Returns:
- the data to convert, can be null if not yet set
-
getInput
public <T> T getInput(Class<T> cls)
The currently set input data to convert.- Specified by:
getInput
in interfaceConversion
- Parameters:
cls
- for casting- Returns:
- the data to convert, can be null if not yet set
-
generates
public abstract Class generates()
Returns the class that is generated as output.- Specified by:
generates
in interfaceConversion
- Returns:
- the class
-
getOutput
public Object getOutput()
Returns the generated output.- Specified by:
getOutput
in interfaceConversion
- Returns:
- the output, null if none produced yet
-
getOutput
public <T> T getOutput(Class<T> cls)
Returns the generated output.- Specified by:
getOutput
in interfaceConversion
- Parameters:
cls
- for casting- Returns:
- the output, null if none produced yet
-
checkData
protected String checkData()
Checks whether the data can be processed.- Returns:
- null if checks passed, otherwise error message
-
doConvert
protected abstract Object doConvert() throws Exception
Performs the actual conversion.- Returns:
- the converted data
- Throws:
Exception
- if something goes wrong with the conversion
-
convert
public String convert()
Performs the conversion.- Specified by:
convert
in interfaceConversion
- Returns:
- null if everything worked otherwise the error message
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
shallowCopy
public AbstractConversion shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<AbstractConversion>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractConversion shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<AbstractConversion>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
-