Class BasicItemNodeLoaderFactory
java.lang.Object
net.sf.basedb.util.overview.loader.BasicItemNodeLoaderFactory
- All Implemented Interfaces:
NodeLoaderFactory<BasicItem,
Object>
public class BasicItemNodeLoaderFactory
extends Object
implements NodeLoaderFactory<BasicItem,Object>
Node loader factory implementation for
BasicItem
node loaders.
The key used in createNodeLoader(Object)
should normally be
an Item
object.- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2020-10-21 07:39:15 +0200 (Wed, 21 Oct 2020) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionNodeLoader<? extends BasicItem>
createNodeLoader
(Object key) Create a new node loader for loading nodes for the specified item type.boolean
Get the auto load children setting.protected void
registerCheckedNodeLoader
(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass) Register a node loader implementation that you are sure fulfills the requirements.protected void
Registers default item node loaders fromBioSource
toExperiment
, etc.void
registerNodeLoader
(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass) Register a node loader implementation.void
setAutoLoadChildren
(boolean autoLoadChildren) Set a flag that determines if the factory should create node loaders that automatically loads child nodes or not.void
setUseNullLoaderIfNotFound
(boolean useNullLoader) Set a flag that determines if aNullNodeLoader
should be used or if anItemNotFoundException
should be thrown if no registered node loader is found for a specific key.boolean
Get the null loader setting.
-
Field Details
-
log
-
debug
private static final boolean debug -
loaders
-
autoLoadChildren
private boolean autoLoadChildren -
useNullLoader
private boolean useNullLoader
-
-
Constructor Details
-
BasicItemNodeLoaderFactory
public BasicItemNodeLoaderFactory()Creates a new factory.
-
-
Method Details
-
createNodeLoader
Create a new node loader for loading nodes for the specified item type. If no loader has been registered for the given item type, aNullNodeLoader
is returned or an exception is thrown depending on theuseNullLoaderIfNotFound()
option.- Specified by:
createNodeLoader
in interfaceNodeLoaderFactory<BasicItem,
Object> - Parameters:
key
- AnItem
object- Returns:
- A node loader object
- Throws:
ItemNotFoundException
- If no node loader is found and theuseNullLoaderIfNotFound()
setting is false
-
registerNodeLoader
public void registerNodeLoader(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass) throws NoSuchMethodException, ClassCastException Register a node loader implementation. The implementation must have a public no-argument constructor. The given class is checked withClassUtil.checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)
- Parameters:
key
- The item type the node loader handlesloaderClass
- The class name of a class that implementsNodeLoader
, or null to unregister a node loader- Throws:
NoSuchMethodException
- If the given class has no public no-argument constructorClassCastException
- If the given class doesn't implement theNodeLoader
interface
-
registerCheckedNodeLoader
protected void registerCheckedNodeLoader(Object key, Class<? extends NodeLoader<? extends BasicItem>> loaderClass) Register a node loader implementation that you are sure fulfills the requirements. Eg. it must have a public no-argument constructor and implement theNodeLoader
interface.- See Also:
-
setAutoLoadChildren
public void setAutoLoadChildren(boolean autoLoadChildren) Set a flag that determines if the factory should create node loaders that automatically loads child nodes or not. If this flag has been set this factory will wrap the node loaders with aAutoChildNodeLoader
.This will generate a recursive pattern if the used node loader:
- Uses this factory to create child node loaders. Eg. it should use
the node loader factory provided by
OverviewContext.getNodeLoaderFactory()
. The node loader should NOT instantiate child new loaders by itself. - Uses an implementation that recurses into folder-type nodes, for example
by extending
AbstractNodeLoader
.
- Parameters:
autoLoadChildren
- TRUE to create node loaders that automatically loads children, FALSE otherwise
- Uses this factory to create child node loaders. Eg. it should use
the node loader factory provided by
-
isAutoLoadingChildren
public boolean isAutoLoadingChildren()Get the auto load children setting.- Returns:
- TRUE if child nodes are automatically loaded, FALSE if not
-
useNullLoaderIfNotFound
public boolean useNullLoaderIfNotFound()Get the null loader setting.- See Also:
-
setUseNullLoaderIfNotFound
public void setUseNullLoaderIfNotFound(boolean useNullLoader) Set a flag that determines if aNullNodeLoader
should be used or if anItemNotFoundException
should be thrown if no registered node loader is found for a specific key.- Parameters:
useNullLoader
- TRUE to use a NullNodeLoader, FALSE to throw an exception
-
registerDefaultNodeLoaders
protected void registerDefaultNodeLoaders()Registers default item node loaders fromBioSource
toExperiment
, etc.
-