Class TLcyCompositeModelContentTypeProvider
- All Implemented Interfaces:
ILcyModelContentType
,ILcyModelContentTypeProvider
,Iterable<ILcyModelContentTypeProvider>
A composite implementation of ILcyModelContentTypeProvider
according to the
composite design pattern.
When creating a new TLcyCompositeModelContentTypeProvider
using the default
constructor (see TLcyCompositeModelContentTypeProvider()
), the created instance will
only work on/with the ILcyModelContentTypeProviders registered
on this composite instance (see addModelContentTypeProvider(ILcyModelContentTypeProvider)
and removeModelContentTypeProvider(ILcyModelContentTypeProvider)
).
When creating a new TLcyCompositeModelContentTypeProvider
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeModelContentTypeProvider(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcyModelContentTypeProvider instances of the
Lucy back-end, adding and/or removing an ILcyModelContentTypeProvider
will
add/remove the ILcyModelContentTypeProvider
as service from Lucy, ... .
Retrieving the model content type for an ILcdModel
using the back-end based implementation
can be done by creating a new instance of this class:
//Create a new instance whenever you need it.
TLcyCompositeModelContentTypeProvider provider = new TLcyCompositeModelContentTypeProvider( aLucyEnv );
int modelContentType = provider.getModelContentType( aModel );
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
provider = null;
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeModelContentTypeProvider
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addModelContentTypeProvider
(ILcyModelContentTypeProvider aModelContentTypeProvider) Adds the given model content type provider to the list of registered content type providers.int
getModelContentType
(ILcdModel aModel) Implementation of ILcyModelContentTypeProvider.getModelContentType.getModelContentTypeProvider
(int aIndex) Returns the model content type provider at the given index.int
Returns the number of currently registered content type providers.void
removeModelContentTypeProvider
(ILcyModelContentTypeProvider aModelContentTypeProvider) Removes the given model content type provider from the list of registered content type providers.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeModelContentTypeProvider
public TLcyCompositeModelContentTypeProvider()Default constructor.
The created instance will only work on the
ILcyModelContentTypeProvider
instances registered to it. If you want to use all registeredILcyModelContentTypeProvider
instances of the Lucy back-end, useTLcyCompositeModelContentTypeProvider(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeModelContentTypeProvider
Construct a
TLcyCompositeModelContentTypeProvider
working on the Lucy back-endIt will use all
ILcyModelContentTypeProvider
instances registered to the back-end, and adding and/or removingILcyModelContentTypeProvider
s to/from thisTLcyCompositeModelContentProvider
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeModelContentTypeProvider
which does not use the back-end, useTLcyCompositeModelContentTypeProvider()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addModelContentTypeProvider
Adds the given model content type provider to the list of registered content type providers.
If the constructor specifying an
ILcyLucyEnv
is used, theILcyModelContentTypeProvider
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aModelContentTypeProvider
will only be included in the returned list when the requested class wasILcyModelContentTypeProvider.class
.
Note: if you want to remove the registeredILcyModelContentTypeProvider
afterwards, useremoveModelContentTypeProvider(ILcyModelContentTypeProvider)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aModelContentTypeProvider
- The model content type provider to add.- See Also:
-
removeModelContentTypeProvider
Removes the given model content type provider from the list of registered content type providers. Nothing will happen if the given provider was never added before.
If the constructor specifying an
ILcyLucyEnv
is used, theILcyModelContentTypeProvider
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcyModelContentTypeProvider
instances which were registered using theaddModelContentTypeProvider(ILcyModelContentTypeProvider)
method.- Parameters:
aModelContentTypeProvider
- The content type provider to remove.- See Also:
-
getModelContentTypeProviderCount
public int getModelContentTypeProviderCount()Returns the number of currently registered content type providers.
- Returns:
- the number of currently registered content type providers.
- See Also:
-
getModelContentTypeProvider
Returns the model content type provider at the given index.- Parameters:
aIndex
- The index to retrieve the model content provider for.Note that 0 <= aIndex < getModelContentTypeProviderCount()
- Returns:
- the model content type provider at the given index.
- See Also:
-
getModelContentType
Implementation of ILcyModelContentTypeProvider.getModelContentType. It loops over all registeredILcyModelContentTypeProvider
s and tries to find a suitableILcyModelContentTypeProvider
. Suitable means that the provider does not return ILcyModelContentType.UNKNOWN. The content type value of the first suitableILcyModelContentTypeProvider
is returned, or ILcyModelContentType.UNKNOWN if no suitableILcyModelContentTypeProvider
could be found.- Specified by:
getModelContentType
in interfaceILcyModelContentTypeProvider
- Parameters:
aModel
- The model to retrieve the content type of.- Returns:
- One of ILcyModelContentType, or ILcyModelContentType.UNKNOWN if no suitable
ILcyModelContentTypeProvider
could be found. - See Also:
-