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,ByteArrayToDataContainer,ByteArrayToImageContainer,ByteArrayToJavaObject,ByteArrayToPrimitiveArray,ByteToInt,CollectionToArray,ColorToHex,ContainerToSpreadSheet,ConvertDateTimeType,DataContainerToByteArray,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,OneBasedToZeroBased,OpenCVToBufferedImage,PathSplit,PrimitiveArrayToByteArray,PrimitiveArrayToObjectArray,PropertiesToKeyValuePairs,PropertiesToMap,PropertiesToSpreadSheet,QuadrilateralLocationCenter,ReceivedEmailToMap,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,ZeroBasedToOneBased
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 Objectm_Inputthe input data.protected Objectm_Outputthe generated output.protected Objectm_Ownerthe owner.protected booleanm_Stoppedwhether 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 Classaccepts()Returns the class that is accepted as input.protected StringcheckData()Checks whether the data can be processed.voidcleanUp()Cleans up data structures, frees up memory.Stringconvert()Performs the conversion.protected abstract ObjectdoConvert()Performs the actual conversion.abstract Classgenerates()Returns the class that is generated as output.StringgetAdditionalInformation()Returns the additional information.ObjectgetInput()The currently set input data to convert.<T> TgetInput(Class<T> cls)The currently set input data to convert.ObjectgetOutput()Returns the generated output.<T> TgetOutput(Class<T> cls)Returns the generated output.ObjectgetOwner()Returns the owner of this conversion.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.protected voidreset()Resets the converter.voidsetInput(Object value)Sets the original data to convert.voidsetOwner(Object value)Sets the owner of this conversion.AbstractConversionshallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.AbstractConversionshallowCopy(boolean expand)Returns a shallow copy of itself, i.e., based on the commandline options.voidstopExecution()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:
getAdditionalInformationin interfaceAdditionalInformationHandler- Returns:
- the additional information, null or 0-length string for no information
-
reset
protected void reset()
Resets the converter.- Overrides:
resetin classAbstractOptionHandler
-
setOwner
public void setOwner(Object value)
Sets the owner of this conversion.- Specified by:
setOwnerin interfaceConversion- Parameters:
value- the owner
-
getOwner
public Object getOwner()
Returns the owner of this conversion.- Specified by:
getOwnerin 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:
getQuickInfoin 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:
acceptsin interfaceConversion- Returns:
- the class
-
setInput
public void setInput(Object value)
Sets the original data to convert. For converters implementingStreamConversionthis only resets the m_Output variable, but not the whole converter like it does nor simple converters.- Specified by:
setInputin 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:
getInputin 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:
getInputin 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:
generatesin interfaceConversion- Returns:
- the class
-
getOutput
public Object getOutput()
Returns the generated output.- Specified by:
getOutputin interfaceConversion- Returns:
- the output, null if none produced yet
-
getOutput
public <T> T getOutput(Class<T> cls)
Returns the generated output.- Specified by:
getOutputin 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:
convertin interfaceConversion- Returns:
- null if everything worked otherwise the error message
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
shallowCopy
public AbstractConversion shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin 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:
shallowCopyin 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:
stopExecutionin interfaceStoppable
-
-