public class TLcyLspFormatTool extends ALcyTool
Support class to plug the format-related objects created by an ALcyLspFormat
(e.g. ILspLayerFactory
) into the ILcyLucyEnv
. Call the plugInto(com.luciad.lucy.ILcyLucyEnv)
method to plug all the format-related objects of the
given ALcyLspFormat
into the Lucy back-end.
Using this TLcyLspFormatTool
to plug in an ALcyLspFormat
will register
most objects as service to the Lucy back-end. As a consequence, everything that is plugged in
using this TLcyLspFormatTool
should be unplugged using a
TLcyLspFormatTool
as well.
A typical usage might look like (for example in the
ALcyAddOn#plugInto
method):
ALcyLspFormat format = ... ;
TLcyLspFormatTool formatTool = new TLcyLspFormatTool( format );
//plug in the whole format at once
formatTool.plugInto( aLucyEnv );
When the format components are no longer needed, the same format tool can be used to unregister
those instances (for example in the ALcyAddOn#unplugFrom
method):
//same TLcyLspFormatTool and Lucy back-end as used in the plugInto method
formatTool.unplugFrom( aLucyEnv );
Note: when you want to create an add-on which plugs in an ALcyLspFormat
you can
as well extend from ALcyLspFormatAddOn
directly,
which does what is shown above.
ILcyLucyEnv.addService(Object)
Constructor and Description |
---|
TLcyLspFormatTool(ALcyLspFormat aFormat)
Creates a
TLcyLspFormatTool for the given ALcyLspFormat . |
TLcyLspFormatTool(ALcyLspFormat aFormat,
int aPriorityForAllObjects)
Creates a
TLcyLspFormatTool for the given ALcyLspFormat which will
plug in all objects into the Lucy back-end using the specified priority. |
Modifier and Type | Method and Description |
---|---|
static ALcyLspFormat |
findBaseFormat(ALcyLspFormat aFormat)
Utility method to, in a chain of wrapped formats, find the deepest format.
|
static <T extends ALcyLspFormat> |
findFormat(ALcyLspFormat aFormat,
Class<T> aFormatClass)
Utility method to find an
ALcyLspFormat (or ALcyLspFormatWrapper )
of the
given class. |
ALcyLspFormat |
getFormat()
Returns the
ALcyLspFormat 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 TLcyLspFormatTool(ALcyLspFormat aFormat)
Creates a TLcyLspFormatTool
for the given ALcyLspFormat
.
aFormat
- The ALcyLspFormat
whose contents needs to be plugged into the Lucy
back-end. Must not be null
.public TLcyLspFormatTool(ALcyLspFormat aFormat, int aPriorityForAllObjects)
Creates a TLcyLspFormatTool
for the given ALcyLspFormat
which will
plug in all objects into the Lucy back-end using the specified priority.
aFormat
- The ALcyLspFormat
whose contents needs to be plugged into the Lucy
back-end. Must not be null
.aPriorityForAllObjects
- The priority which will be used to plug in all the objects
into the Lucy back-end.
Lower values mean higher priorities.
Common values are ILcyLucyEnv.PRIORITY_DEFAULT
and ILcyLucyEnv.PRIORITY_FALLBACK
.public ALcyLspFormat getFormat()
Returns the ALcyLspFormat
for which this tool was created.
ALcyLspFormat
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 back-end.
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 ALcyLspFormat> T findFormat(ALcyLspFormat aFormat, Class<T> aFormatClass)
Utility method to find an ALcyLspFormat
(or ALcyLspFormatWrapper
)
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 ALcyLspFormatWrapper
.
Consider for example this chain of formats:
ALcyLspFormat format =
new TLcyLspSafeGuardFormatWrapper( new MyFormat() )
A call to
findFormat(format, TLcyLspSafeGuardFormatWrapper.class)
will return the TLcyLspSafeGuardFormatWrapper
instance. A call to
findFormat(format, SomeOtherFormatWrapper.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 ALcyLspFormat findBaseFormat(ALcyLspFormat aFormat)
Utility method to, in a chain of wrapped formats, find the deepest format.
To do so, it assumes every format wrapper extends from ALcyLspFormatWrapper
.
Consider for example this chain of formats:
ALcyLspFormat format =
new TLcyLspSafeGuardFormatWrapper( new MyFormat() )
A call to
findBaseFormat(format)
will return the MyFormat
instance.aFormat
- The format to find the base format of.aFormat
.