public class TLcyFormatTool extends ALcyTool
Support class to plug the format-related objects created by an ALcyFormat
(e.g.
ILcdGXYLayerFactory
) into the ILcyLucyEnv
. Call the plugInto(ILcyLucyEnv)
method to plug all the format-related objects of the
given ALcyFormat
into the Lucy back-end.
Using this TLcyFormatTool
to plug in an ALcyFormat
will register
most objects as service to the Lucy back-end. As a consequence, everything that is plugged in
using this TLcyFormatTool
should be unplugged using a TLcyFormatTool
as well.
ILcyLucyEnv.addService(Object)
Constructor and Description |
---|
TLcyFormatTool(ALcyFormat aFormat)
Creates a
TLcyFormatTool for the given ALcyFormat . |
Modifier and Type | Method and Description |
---|---|
static ALcyFormat |
findBaseFormat(ALcyFormat aFormat)
Utility method to, in a chain of wrapped formats, find the deepest format.
|
static <T extends ALcyFormat> |
findFormat(ALcyFormat aFormat,
Class<T> aFormatClass)
Utility method to find an
ALcyFormat (or ALcyFormatWrapper ) of the
given class. |
ALcyFormat |
getFormat()
Returns the
ALcyFormat for which this tool was created. |
void |
plugInto(ILcyLucyEnv aLucyEnv)
Plugs this tool.
|
void |
unplugFrom(ILcyLucyEnv aLucyEnv)
Unplugs this tool.
|
addPropertyChangeListener, addPropertyChangeListener, assertPlugged, firePropertyChange, getLongPrefix, getLongPrefixWithClassName, getLucyEnv, getShortPrefix, removePropertyChangeListener, removePropertyChangeListener
public TLcyFormatTool(ALcyFormat aFormat)
Creates a TLcyFormatTool
for the given ALcyFormat
.
aFormat
- The ALcyFormat
whose contents needs to be plugged into the Lucy
backend. Must not be null
.public ALcyFormat getFormat()
Returns the ALcyFormat
for which this tool was created.
ALcyFormat
for which this tool was created. Never null
.public void plugInto(ILcyLucyEnv aLucyEnv)
Plugs this tool. This method is usually called from
ALcyAddOn#plugInto
.
Lets the format create all the format-related objects and plugs them into the given Lucy backend.
public void unplugFrom(ILcyLucyEnv aLucyEnv)
ALcyTool
Unplugs this tool. This method is usually called from
ALcyAddOn#unplugFrom
.
unplugFrom
in class ALcyTool
aLucyEnv
- The environment to unplug from, must be identical to the environment given to
plugInto
.public static <T extends ALcyFormat> T findFormat(ALcyFormat aFormat, Class<T> aFormatClass)
Utility method to find an ALcyFormat
(or ALcyFormatWrapper
) of the
given class. This can be useful to, in a chain of wrapped formats, retrieve a format of the
given class.
To do so, it assumes every format wrapper extends from ALcyFormatWrapper
.
Consider for example this chain of formats:
ALcyFormat format =
new TLcyAsynchronousFormatWrapper( new TLcySafeGuardFormatWrapper( new MyFormat() ) )
A call to
findFormat(format, TLcySafeGuardFormatWrapper.class)
will return the TLcySafeGuardFormatWrapper
instance. A call to
findFormat(format, TLcyMutableFileFormatWrapper.class)
will return null
.aFormat
- The format to start looking from.aFormatClass
- The class to find.null
if no such format was found, or an instance of (a subclass of) the
given aFormatClass
.public static ALcyFormat findBaseFormat(ALcyFormat aFormat)
Utility method to, in a chain of wrapped formats, find the deepest format.
To do so, it assumes every format wrapper extends from ALcyFormatWrapper
.
Consider for example this chain of formats:
ALcyFormat format =
new TLcyAsynchronousFormatWrapper( new TLcySafeGuardFormatWrapper( new MyFormat() ) )
A call to
findBaseFormat(format)
will return the MyFormat
instance.aFormat
- The format to find the base format of.aFormat
.