Package adams.data.conversion
Class AbstractSwapObject
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.conversion.AbstractConversion
-
- adams.data.conversion.AbstractSwapObject
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<AbstractConversion>
,SizeOfHandler
,Stoppable
,Conversion
,InPlaceProcessing
,Serializable
- Direct Known Subclasses:
SwapObjects
,SwapPLS
public abstract class AbstractSwapObject extends AbstractConversion implements InPlaceProcessing
Ancestor for classes that swap all occurrences of one object for another.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractSwapObject.SwapObserver
Observer that performs the swapping of the objects.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_NoCopy
whether to create no copy of the object.protected PropertyTraversal
m_Traversal
the property traversal.-
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 AbstractSwapObject()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class
accepts()
Returns the class that is accepted as input.protected abstract boolean
canSwap(PropertyPath.Path path, PropertyDescriptor desc, Object parent, Object child)
Checks whether a swap can be made.void
defineOptions()
Adds options to the internal list of options.protected Object
doConvert()
Performs the actual conversion.protected Object
doConvert(Object input)
Performs the swap.Class
generates()
Returns the class that is generated as output.boolean
getNoCopy()
Returns whether to skip creating a copy of the object before swapping.String
noCopyTipText()
Returns the tip text for this property.protected abstract boolean
performSwap(PropertyPath.Path path, PropertyDescriptor desc, Object parent, Object child)
Performs the swap.void
setNoCopy(boolean value)
Sets whether to skip creating a copy of the object before swapping.-
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, getQuickInfo, reset, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, 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
-
-
-
-
Field Detail
-
m_NoCopy
protected boolean m_NoCopy
whether to create no copy of the object.
-
m_Traversal
protected transient PropertyTraversal m_Traversal
the property traversal.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setNoCopy
public void setNoCopy(boolean value)
Sets whether to skip creating a copy of the object before swapping.- Specified by:
setNoCopy
in interfaceInPlaceProcessing
- Parameters:
value
- true if to skip creating copy
-
getNoCopy
public boolean getNoCopy()
Returns whether to skip creating a copy of the object before swapping.- Specified by:
getNoCopy
in interfaceInPlaceProcessing
- Returns:
- true if copying is skipped
-
noCopyTipText
public String noCopyTipText()
Returns the tip text for this property.- Specified by:
noCopyTipText
in interfaceInPlaceProcessing
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
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
-
generates
public Class generates()
Returns the class that is generated as output.- Specified by:
generates
in interfaceConversion
- Specified by:
generates
in classAbstractConversion
- Returns:
- the class
-
canSwap
protected abstract boolean canSwap(PropertyPath.Path path, PropertyDescriptor desc, Object parent, Object child)
Checks whether a swap can be made.- Parameters:
path
- the current pathdesc
- the property descriptorparent
- the parent object to swapchild
- the child object to swap- Returns:
- true if swap can be done
-
performSwap
protected abstract boolean performSwap(PropertyPath.Path path, PropertyDescriptor desc, Object parent, Object child)
Performs the swap.- Parameters:
path
- the current pathdesc
- the property descriptorparent
- the parent object to swapchild
- the child object to swap- Returns:
- true if swap was successful
-
doConvert
protected Object doConvert(Object input)
Performs the swap.- Parameters:
input
- the object to update- Returns:
- the updated object
-
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
-
-