T
- the type of the data of this component handlerS
- the type of the child handlerspublic abstract class AbstractCompositeComponentHandler<T,S> extends Object implements CompositeComponentHandler<T,S>
An abstract base class for concrete implementations of the
CompositeComponentHandler
interface.
This base class already provides functionality for managing a list of child
ComponentHandler
objects. It also has base implementations for most
of the methods defined by the CompositeComponentHandler
interface.
Concrete sub classes mainly have to implement the methods for accessing the
data of this handler. Here the idea is that the data of the child component
handlers must be converted into an object that is the data of this composite
handler. For the base implementations of the other interface methods refer to
the method documentation.
Implementation note: This class is not thread-safe.
Modifier | Constructor and Description |
---|---|
protected |
AbstractCompositeComponentHandler(Class<T> dataType)
Creates a new instance of
AbstractCompositeComponentHandler and
initializes it with the data type class. |
Modifier and Type | Method and Description |
---|---|
void |
addHandler(String name,
ComponentHandler<S> handler)
Adds the specified child
ComponentHandler to this CompositeComponentHandler . |
protected ComponentHandler<S> |
getChildHandler(String name)
Returns the child handler with the specified name.
|
int |
getChildHandlerCount()
Returns the number of child
ComponentHandler s that have been
added to this CompositeComponentHandler . |
protected int |
getChildHandlerIndex(String name)
Returns the index for the child handler with the given name.
|
protected String |
getChildHandlerNameAt(int index)
Returns the name of the child handler at the specified index.
|
protected Set<String> |
getChildHandlerNames()
Returns a set with the names of the child handlers that have been added
to this handler.
|
protected List<ComponentHandler<S>> |
getChildHandlers()
Returns a list with all child handlers managed by this
CompositeComponentHandler . |
Object |
getComponent()
Returns the component this handler is associated with.
|
Object |
getOuterComponent()
Returns the outer component this handler is associated with.
|
Class<?> |
getType()
Returns the data type of this component handler.
|
boolean |
isEnabled()
Returns a flag whether this
ComponentHandler is enabled. |
void |
setEnabled(boolean f)
Changes the enabled state of this
ComponentHandler . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getData, setData
public void addHandler(String name, ComponentHandler<S> handler)
ComponentHandler
to this CompositeComponentHandler
.addHandler
in interface CompositeComponentHandler<T,S>
name
- the name of the child handlerhandler
- the child handler to be added (must not be null)IllegalArgumentException
- if the handler is null or a child
handler with this name already existspublic Object getComponent()
getComponent
in interface ComponentHandler<T>
public Object getOuterComponent()
getOuterComponent
in interface ComponentHandler<T>
public Class<?> getType()
getType
in interface ComponentHandler<T>
public boolean isEnabled()
ComponentHandler
is enabled. This
implementation returns true if and only if all child handlers are
enabled.isEnabled
in interface ComponentHandler<T>
ComponentHandler
is enabledpublic void setEnabled(boolean f)
ComponentHandler
. This
implementation calls setEnabled()
on all child handlers passing
in the argument.setEnabled
in interface ComponentHandler<T>
f
- the new enabled statepublic final int getChildHandlerCount()
ComponentHandler
s that have been
added to this CompositeComponentHandler
.protected List<ComponentHandler<S>> getChildHandlers()
CompositeComponentHandler
. Derived classes can call this method to
access the child handlers. Note: the list must not be modified.protected Set<String> getChildHandlerNames()
protected ComponentHandler<S> getChildHandler(String name)
name
- the name of the child handler in questionComponentHandler
or nullprotected int getChildHandlerIndex(String name)
name
- the name of the child handler in questionprotected String getChildHandlerNameAt(int index)
CompositeComponentHandler
. If the index passed in is invalid, this
method returns null.index
- the index of the desired child handlerComponentHandler
or nullCopyright © 2016 The JGUIraffe Team. All rights reserved.