|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.eoapplication.EOController
The EOController class defines basic behavior for controller objects that are responsible for managing and sometimes generating the user interface for the client side of a Java Client application. An application's controllers are arranged in a hierarchy which describes the complete functionality of an application.
The controller hierarchy mirrors the hierarchy of windows and widgets that make up the client application's user interface. The root of the hierarchy is an EOApplication object. The EOApplication's subcontrollers are usually window or applet controllers, which themselves have subcontrollers.
The most significant functionality provided by the EOController class is managing the controller hierarchy (building, connecting, and traversing the hierarchy) and handling actions.
ConstructorsAll controller classes need to implement the no-argument constructor. In addition, if they may be instantiated from an XML description, they need to implement a constructor taking a single EOXMLUnarchiver argument. The no-argument constructor is used for all programmatic creation of controllers.
Controllers should avoid complex initialization procedures in the constructor. Instead they should attempt to create all the objects they need to perform their task lazily, only when they are needed. Controllers are usually used in various types of situations and there is no guarantee that they are ever used, even if they are in the controller hierarchy. For example the user interface managed by a controller might be placed in a tab view and never be activated by the user. By creating objects and user interfaces lazily, the response time of average applications gets much better.
Traversing the Controller HierarchyEOController defines numerous methods for traversing the controller
hierarchy, but a single method provides the basic traversal functionality.
The method controllerEnumeration
creates and returns an enumeration that
includes all the subcontrollers of a controller (not including the controller),
all the supercontrollers of a controller (not including the controller), or a
controller and its subcontrollers. You can further restrict the controllers
included in an enumeration by specifying an interface the controllers must
implement in order to be included. For more information, see the
EOController.Enumeration interface specification and the method description
for controllerEnumeration
.
Other methods that traverse the controller hierarchy use a controller
enumeration to perform the traversal. There are methods that return
controllers in an enumeration that match one or more key-value pairs and
methods that use key-value coding on the controllers in an enumeration,
returning the first controller that has a specified key or returning the
value for that key. Also, there's a method invokeMethod
that
invokes a particular method on the controllers in an enumeration.
A controller in the controller hierarchy can be connected to its supercontroller or not. Controllers are connected when they're performing their duties, and they are disconnected when they become idle. Generally controllers are connected only when their user interface is visible. For example, the controllers associated with a window are connected when the window is visible, and they're disconnected when the window becomes invisible.
When a controller connects to its supercontroller, it gets from its supercontroller whatever resources or information it needs, and it prepares itself in whatever way necessary to perform its duties (for example, setting delegates). Similarly, when a controller breaks its connection to its supercontroller, it cleans up its resources for an idle period.
The EOController class defines methods for connecting controllers. There are
methods for connecting and disconnecting a controller from its supercontroller
(establishConnection
and breakConnection
), and also
methods that make connections all the way up the controller hierarchy
(establishConnectionToSupercontrollers
) and break connections all
the way down (breakConnectionToSubcontrollers
). Generally you use
the latter methods that connect or disconnect an entire branch of a tree.
EOController's implementations of all these methods is generally sufficient
for subclasses. They set the connection status of a controller (setConnected
),
and notify the controller that its connection has been established or broken.
You shouldn't have to override these methods.
If you do need to do something when a controller is connected or
disconnected, you should override the methods connectionWasEstablished
and
connectionWasBroken
. These methods are invoked automatically by
establishConnection
and breakConnection
.
Controllers define actions that users can perform (such as quitting the application or saving a document) and they know how to respond to those actions when they're performed. EOController defines methods that manage a controllers actions.
A controller has a set of actions. It also keeps track of which of those
actions are enabled and which are disabled. For performance reasons,
EOController's method implementations cache some of this information. Thus,
whenever you do something that changes a controller's actions
(such as adding a new subcontroller or enabling or disabling an action),
the caches must be reset. Most of the time they're reset automatically, but
subclasses might need to explicitly reset them with the method resetActions
.
To specify the actions a subclass understands, override the method
defaultActions
. However, to find out what actions a controller
understands, use actions
. This method simply manages and returns a
cache of the methods returned by defaultActions
. Some implementations
of a defaultActions
method are potentially costly to invoke over and
over again, because they dynamically build their collections of actions. The
actions
method is simply an optimization. EOController's implementation
of actions should be sufficient for subclasses; you should never need to override it.
To find out what actions a controller can perform at a specific point in
time, use the method enabledActions
. This method returns only the
controller's actions that aren't explicitly disabled. As with actions
,
enabledActions
manages and returns a cache of methods, and
EOController's implemenation should be sufficient for subclasses.
Some controllers are needed only to dynamically generate the user interface
and don't serve any purpose after the user interface has been created and
connected. For example, an EOTextFieldController creates a widget and a
corresponding association and then is no longer needed. Controllers such as
EOTextFieldController can be transient, because after their work is done,
they can usually be removed from the controller hierarchy and disposed of
(with disposeIfTransient
). This keeps the controller hierarchy
simple, which makes user interface management more efficient.
Controllers specify whether or not they can be transient by overriding the
method canBeTransient
. Some controllers can be transient sometimes
and not other times, so not all implementations simply return true or false. For
example, an EOTableController can be transient if the double click action is
unassigned. If the action is assigned, however, the controller must listen
for a double click and react when one occurs.
Subclasses that can be transient should invoke the method
disposeIfTransient
as soon as their work is done and they can be
disposed of. Sometimes a controller's supercontroller doesn't allow the controller
to be disposed of. For example, the EOTabSwitchComponent doesn't allow its
subcontrollers to become transient.
Inner Class Summary | |
static interface |
EOController.Enumeration
EOController.Enumeration is an interface that defines an enumeration
that iterates over a set of EOController objects. |
Inner classes inherited from class com.webobjects.foundation.NSKeyValueCoding |
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor |
Inner classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions |
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Field Summary | |
static int |
ControllerAndSubcontrollersEnumeration
The constant describing enumerations that enumerate over a controller and its subcontrollers. |
static int |
ControllerAndSupercontrollersEnumeration
The constant describing enumerations that enumerate over a controller's supercontrollers, not including the controller itself. |
static int |
SubcontrollersEnumeration
The constant describing enumerations that enumerate over a controller's subcontrollers, not including the controller itself. |
static int |
SupercontrollersEnumeration
The constant describing enumerations that enumerate over a controller's supercontrollers, not including the controller itself. |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
NullValue |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
KeyPathSeparator |
Constructor Summary | |
EOController()
Creates a new controller. |
|
EOController(EOXMLUnarchiver unarchiver)
Creates a new controller. |
Method Summary | |
NSArray |
actionNames()
Returns an array of action method names the controller defines and responds to. |
NSArray |
actions()
Returns a cached array containing the receiver's actions. |
EOAction |
actionWithName(String actionName)
If the receiver has an action for a method with name actionName ,
this method returns that action; otherwise, the method returns null . |
NSArray |
additionalActions()
Returns actions to be added to the controllers default actions. |
NSDictionary |
additionalKeyValuePairs()
Returns an NSDictionary of additional key-value pairs used by handleQueryWithUnboundKey() . |
void |
addSubcontroller(EOController controller)
Adds controller as a subcontroller of the receiver and
sets the receiver as controller 's supercontroller - first removing
controller from its supercontroller if it already has one. |
void |
breakConnection()
Breaks the receiver's connection to its supercontroller. |
void |
breakConnectionToSubcontrollers()
Breaks the connections the receiver's subcontrollers have to their subcontrollers, and then breaks the receiver's connections to its subcontrollers. |
static boolean |
canAccessFieldsDirectly()
Conformance to NSKeyValueCoding. |
boolean |
canBeTransient()
Returns whether the controller can be transient. |
boolean |
canPerformActionNamed(String actionName)
Returns true if the receiver can perform the action method
(sent by an EOAction object) named actionName , false otherwise. |
protected void |
connectionWasBroken()
Invoked from breakConnection to notify the receiver that its
connection to its supercontroller has been broken, giving the receiver the
opportunity to clean up after its become idle. |
protected void |
connectionWasEstablished()
Invoked from establishConnection to notify the receiver that its
connection to the controller hierarchy has been established, giving the
receiver the opportunity to prepare itself (for example, setting delegates). |
EOController.Enumeration |
controllerEnumeration(int enumerationType,
Class controllerInterface)
Returns an EOController.Enumeration object you can use to
traverse the controller hierarchy. |
NSArray |
controllersInEnumeration(int enumerationType,
Class controllerInterface)
Returns all the controllers in an enumeration as an array. |
NSArray |
controllersWithKeyValuePair(int enumerationType,
Class controllerInterface,
String key,
Object value)
Traverses the controller hierarchy, and returns all controllers in the hierarchy whose value for key matches value . |
NSArray |
controllersWithKeyValuePairs(int enumerationType,
Class controllerInterface,
NSDictionary keyValuePairs)
Traverses the controller hierarchy, and returns all controllers in the hierarchy which match all key/value pairs in keyValuePairs . |
EOController |
controllerWithKeyValuePair(int enumerationType,
Class controllerInterface,
String key,
Object value)
Traverses the controller hierarchy, and returns the first controller in the hierarchy whose value for key matches value . |
EOController |
controllerWithKeyValuePairs(int enumerationType,
Class controllerInterface,
NSDictionary keyValuePairs)
Traverses the controller hierarchy, and returns the first controller in the hierarchy which matches all key-value pairs in keyValuePairs . |
protected NSArray |
defaultActions()
Returns an array of the receiver's default actions (EOAction objects). |
void |
disableActionNamed(String actionName)
Explicitly disables the action method actionName and resets the receiver's actions. |
NSDisposableRegistry |
disposableRegistry()
Returns the receiver's disposable registry. |
void |
dispose()
Prepares the receiver so it is disposed when Java performs garbage collection. |
protected boolean |
disposeIfTransient()
Disposes the receiver if it's transient, first removing it from its supercontroller with removeTransientSubcontroller If the
receiver's supercontroller is non-null , this method also attempts to
dispose of the supercontroller if it's transient. |
void |
enableActionNamed(String actionName)
Enables the action method actionName and resets the receiver's actions. |
NSArray |
enabledActions()
Returns an array of the receiver's actions which are not explicitly disabled. |
void |
establishConnection()
Connects the receiver to the controller hierarchy. |
void |
establishConnectionToSupercontrollers()
Connects the receiver's supercontroller to the controller hierarchy, and then establishes the receiver's connection to the controller hierarchy. |
Object |
handleQueryWithUnboundKey(String key)
Invoked from valueForKey when it finds no property binding
for key . |
void |
handleTakeValueForUnboundKey(Object value,
String key)
Invoked from takeValueForKey when it finds no property binding
for key . |
EOController |
hierarchicalControllerForKey(Class controllerInterface,
String key)
Starting at the receiver, searches up the controller hierarchy for the first controller that implements the interface controllerInterface and
has a non-null value for key and returns that controller. |
Object |
hierarchicalValueForKey(Class controllerInterface,
String key)
Starting at the receiver, searches up the controller hierarchy for the first controller that implements the interface controllerInterface and
has a non-null value for key and returns that value. |
void |
invokeMethod(int enumerationType,
Class controllerInterface,
String methodName,
Class[] parameterTypes,
Object[] parameters)
Traverses the controller hierarchy, invoking the method specified by methodName and parameterTypes on the
appropriate controllers. |
boolean |
isActionNamedEnabled(String actionName)
Returns whether the action method actionName isn't explicitly disabled. |
boolean |
isAncestorOfController(EOController controller)
Returns whether controller is a subcontroller of the receiver,
of the receiver's subcontrollers, or their subcontrollers, and so on. |
boolean |
isConnected()
Returns the receiver's connection status. |
boolean |
isSupercontrollerOfController(EOController controller)
Returns whether controller is a direct subcontroller of the receiver. |
protected boolean |
isTransientExplicitlyForbidden()
Returns whether transience is explicitly forbidden for this controller. |
void |
prepareForNewTask(boolean prepareSubcontrollersForNewTask)
Prepares the receiver for performing a new task by resetting any data. |
void |
removeFromSupercontroller()
Removes the receiver from its supercontroller's set of subcontrollers. |
protected void |
removeSubcontroller(EOController controller)
Removes controller from the controller hierarchy. |
protected boolean |
removeTransientSubcontroller(EOController controller)
Removes controller from the controller hierarchy if controller
can be transient and if the receiver allows it. |
void |
resetActions()
Destroys the receiver's cache of actions and enabled actions, and destroys the action caches of the receiver's supercontrollers. |
void |
setAdditionalActions(NSArray additionalActions)
Sets actions to be added to the controllers default actions. |
void |
setAdditionalKeyValuePair(Object value,
String key)
Adds key . |
void |
setAdditionalKeyValuePairs(NSDictionary dictionary)
Sets NSDictionary, dictionary , of key-value pairs for use in handleQueryWithUnboundKey() |
protected void |
setConnected(boolean flag)
Sets the receiver's connection status. |
protected boolean |
setSupercontroller(EOController controller)
Sets the receiver's supercontroller to controller and resets
the receiver's actions. |
protected void |
setTransientExplicitlyForbidden(boolean flag)
Sets whether transience is explicitly forbidden for this controller. |
void |
setTypeName(String typeName)
Sets the receiver's type name. |
NSArray |
subcontrollers()
Returns the receiver's direct subcontrollers. |
protected void |
subcontrollerWasAdded(EOController controller)
Invoked from addSubcontroller to notify the receiver that a
subcontroller has been added to the controller hierarchy, giving
the receiver the opportunity to prepare the subcontroller for use. |
protected void |
subcontrollerWasRemoved(EOController controller)
Invoked from removeSubcontroller to notify the receiver that a
subcontroller has been removed from the controller hierarchy, giving
the receiver the opportunity to perform any necessary clean up. |
EOController |
supercontroller()
Returns the receiver's supercontroller, or null
if the receiver has no supercontroller. |
EOController |
supercontroller(Class controllerInterface)
Searching from the receiver's direct supercontroller, returns the first supercontroller that implements the interface controllerInterface . |
void |
takeValueForKey(Object value,
String key)
Conformance to NSKeyValueCoding. |
void |
takeValueForKeyPath(Object value,
String keyPath)
Sets the value for the property identified by keyPath
to value . |
String |
toString()
Returns the receiver as a string that states the receiver's class name and type name, whether the receiver is connected, and the number of subcontrollers. |
String |
typeName()
Returns the receiver's type name a string that uniquely identifies the receiver as a node in the controller hierarchy. |
void |
unableToSetNullForKey(String key)
Invoked from takeValueForKey when it is given a null value
for a scalar property (such as an int or a float ). |
Object |
valueForKey(String key)
Retrieves the value of the property named by key . |
Object |
valueForKeyPath(String keyPath)
Retrieves the value of a property of the object at the end of the key path (a key path is a string of the form "key1.key2"). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int ControllerAndSubcontrollersEnumeration
public static final int ControllerAndSupercontrollersEnumeration
public static final int SubcontrollersEnumeration
public static final int SupercontrollersEnumeration
Constructor Detail |
public EOController()
public EOController(EOXMLUnarchiver unarchiver)
unarchiver
- the unarchiver providing XML attributesMethod Detail |
public NSArray actionNames()
public EOAction actionWithName(String actionName)
actionName
,
this method returns that action; otherwise, the method returns null
.actionName
- the action method namenull
otherwisepublic NSArray actions()
defaultActions
and returns that.
The cache is cleared with the method resetActions
.defaultActions()
,
enabledActions()
,
resetActions()
public void addSubcontroller(EOController controller)
Adds controller
as a subcontroller of the receiver and
sets the receiver as controller
's supercontroller - first removing
controller
from its supercontroller if it already has one.
Invoke this method to add a subcontroller to the hierarchy.
EOController's implementation sets subcontroller's supercontroller
and notifies the receiver that a subcontroller was added. It does nothing
if the receiver is already a supercontroller of controller
.
The default implementation of this method should be sufficient for most
subclasses; you shouldn't have to override it. If you need to do something
special when a subcontroller is added, override subcontrollerWasAdded
.
controller
- the controller to be addedsubcontrollerWasAdded(EOController)
public NSArray additionalActions()
actions()
public NSDictionary additionalKeyValuePairs()
handleQueryWithUnboundKey()
.#handleQueryWithUnboundKey()
public void breakConnection()
connectionWasBroken
to give the receiver a chance to clean
up, and informs all its supercontrolllers that a subcontroller's connection
status has changed so the supercontrolllers can react appropriately. Use this
method to programmatically disconnect a single controller (and not its
supercontrollers). EOController's implementation is sufficient for most
subclasses, so you don't ordinarily override this method.connectionWasBroken()
,
breakConnectionToSubcontrollers()
public void breakConnectionToSubcontrollers()
breakConnection()
public static boolean canAccessFieldsDirectly()
false
.false
NSKeyValueCoding
public boolean canBeTransient()
false
.true
if the controller can be transient; false
otherwisepublic boolean canPerformActionNamed(String actionName)
EOAction.Enabling
true
if the receiver can perform the action method
(sent by an EOAction object) named actionName
, false
otherwise.
An EOController's implementation of this method generally returns
false
if the receiver doesn't have an action named
actionName or if the actionName action is explicitly disabled.canPerformActionNamed
in interface EOAction.Enabling
com.webobjects.eoapplication.EOAction.Enabling
actionName
- the name of the EOActiontrue
if the receiver can perform the action; false
otherwiseprotected void connectionWasBroken()
breakConnection
to notify the receiver that its
connection to its supercontroller has been broken, giving the receiver the
opportunity to clean up after its become idle.breakConnection()
protected void connectionWasEstablished()
establishConnection
to notify the receiver that its
connection to the controller hierarchy has been established, giving the
receiver the opportunity to prepare itself (for example, setting delegates).establishConnection()
public EOController.Enumeration controllerEnumeration(int enumerationType, Class controllerInterface)
EOController.Enumeration
object you can use to
traverse the controller hierarchy. enumerationType
determines
how to traverse the hiearchy. The enumeration will only contain controllers
implementing the interface controllerInterface
. If
controllerInterface
is null
, the enumeration will contain all
controllers for the specified enumeration type.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
controllerInterface
- the interface to filter controllers outEOController.Enumeration
public EOController controllerWithKeyValuePair(int enumerationType, Class controllerInterface, String key, Object value)
key
matches value
. This
method uses a controller enumeration specified by enumerationType
and controllerInterface
to find the controller. The method tests
the controllers returned by the enumeration for a match and returns
the first one that matches. Matches are determined with the method
valueForKeyPath
.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
controllerInterface
- the interface to filter controllers outkey
- the key to matchvalue
- the value to matchcontrollerWithKeyValuePairs(int, Class, NSDictionary)
,
controllerEnumeration(int, Class)
,
valueForKeyPath(String)
public EOController controllerWithKeyValuePairs(int enumerationType, Class controllerInterface, NSDictionary keyValuePairs)
keyValuePairs
. This
method uses a controller enumeration specified by enumerationType
and controllerInterface
to find the controller. The method tests
the controllers returned by the enumeration for a match and returns
the first one that matches. Matches are determined with the method
valueForKeyPath
.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
controllerInterface
- the interface to filter controllers outkeyValuePairs
- the key-value pairs to matchcontrollerWithKeyValuePair(int, Class, String, Object)
,
controllerEnumeration(int, Class)
,
valueForKeyPath(String)
public NSArray controllersInEnumeration(int enumerationType, Class controllerInterface)
enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
controllerInterface
- the interface to filter controllers outcontrollerEnumeration(int, Class)
public NSArray controllersWithKeyValuePair(int enumerationType, Class controllerInterface, String key, Object value)
key
matches value
. This
method uses a controller enumeration specified by enumerationType
and controllerInterface
to find the controllers. The method tests
the controllers returned by the enumeration for a match and returns all the ones
which match the key-value pair. Matches are determined with the method
valueForKeyPath
.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
.controllerInterface
- the interface to filter controllers outkey
- the key to matchvalue
- the value to matchcontrollersWithKeyValuePairs(int, Class, NSDictionary)
,
controllerEnumeration(int, Class)
,
valueForKeyPath(String)
public NSArray controllersWithKeyValuePairs(int enumerationType, Class controllerInterface, NSDictionary keyValuePairs)
keyValuePairs
. This
method uses a controller enumeration specified by enumerationType
and controllerInterface
to find the controllers. The method tests
the controllers returned by the enumeration for a match and returns all the ones
which match the key-value pairs. Matches are determined with the method
valueForKeyPath
.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
.controllerInterface
- the interface to filter controllers outkeyValuePairs
- the key/value pairs to matchcontrollersWithKeyValuePair(int, Class, String, Object)
,
controllerEnumeration(int, Class)
,
valueForKeyPath(String)
protected NSArray defaultActions()
actions
, which caches the
results of defaultActions
and is therefore more efficient.actions()
,
resetActions()
public void disableActionNamed(String actionName)
actionName
and resets the receiver's actions.actionName
- the action method namepublic NSDisposableRegistry disposableRegistry()
public void dispose()
dispose
in interface NSDisposable
protected boolean disposeIfTransient()
removeTransientSubcontroller
If the
receiver's supercontroller is non-null
, this method also attempts to
dispose of the supercontroller if it's transient. Supercontrollers can
prevent a controller from becoming transient, in which case this method
returns false
. Subclasses should first invoke the super
implementation and only continue disposing if the super implementation
returns true
.true
if the receiver can be transient and has been
disposed; false
otherwiseremoveTransientSubcontroller(EOController)
public void enableActionNamed(String actionName)
actionName
and resets the receiver's actions.actionName
- the action method namepublic NSArray enabledActions()
resetActions
.defaultActions()
,
actions()
,
resetActions()
public void establishConnection()
connectionWasEstablished
to give the receiver a chance to
prepare the user interface. After connecting the receiver, this method
disposes of it if it's transient and is therefore no longer needed.
Use this method to connect a single controller (and not its supercontrollers).
EOController's implementation is sufficient for most subclasses,
so you don't ordinarily override this method.connectionWasEstablished()
,
establishConnectionToSupercontrollers()
public void establishConnectionToSupercontrollers()
establishConnection()
public Object handleQueryWithUnboundKey(String key)
NSKeyValueCoding.ErrorHandling
valueForKey
when it finds no property binding
for key
. The default implementation
throws an NSKeyValueCoding.UnknownKeyException,
with the target object(TargetObjectUserInfoKey)
and
key(UnknownUserInfokey)
in the user info. An NSKeyValueCoding.ErrorHandling class can override this
method to handle the query in some other way. The method can return a value,
in which case that value is returned by the corresponding
valueForKey
invocation.handleQueryWithUnboundKey
in interface NSKeyValueCoding.ErrorHandling
com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
key
- the property name which generated this errornull
that the custom implementation desires. The default implementation throws an exception instead.NSKeyValueCoding.UnknownKeyException
- when it finds no
property binding for keyNSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value, String key)
NSKeyValueCoding.ErrorHandling
takeValueForKey
when it finds no property binding
for key
. The default implementation
throws an NSKeyValueCoding.UnknownKeyException, with the
target object(TargetObjectUserInfoKey)
and key(UnknownUserInfoKey)
in the user info dictionary of the exception. An NSKeyValueCoding.ErrorHandling class can override this
method to handle the error in some other way.handleTakeValueForUnboundKey
in interface NSKeyValueCoding.ErrorHandling
com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
value
- the new value which could not be setkey
- the name of the property which generated this errorNSKeyValueCoding.UnknownKeyException
- when it finds
no property binding for keyNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public EOController hierarchicalControllerForKey(Class controllerInterface, String key)
controllerInterface
and
has a non-null
value for key
and returns that controller. If
controllerInterface
is null
, tests all controllers.controllerInterface
- the interface required by the controllers to be testedkey
- the key to look upnull
otherwisepublic Object hierarchicalValueForKey(Class controllerInterface, String key)
controllerInterface
and
has a non-null
value for key
and returns that value. If
controllerInterface
is null
, tests all controllers.controllerInterface
- the interface required by the controllers to be testedkey
- the key to look upnull
value for the key if one exists; null
otherwisepublic void invokeMethod(int enumerationType, Class controllerInterface, String methodName, Class[] parameterTypes, Object[] parameters)
methodName
and parameterTypes
on the
appropriate controllers. Uses a controller enumeration specified by
enumerationType
and controllerInterface
to find
the controllers on which to invoke the specified method. For each controller
in the enumeration, this method invokes the method methodName
with the values in parameters
as arguments.enumerationType
- the type of the enumeration, one of
EOController.SubcontrollersEnumeration
,
EOController.SupercontrollersEnumeration
, or
EOController.ControllerAndSubcontrollersEnumeration
controllerInterface
- the interface to filter controllers outmethodName
- the name of the methodparameterTypes
- the types of the parametersparameters
- the parameterscontrollerEnumeration(int, Class)
public boolean isActionNamedEnabled(String actionName)
actionName
isn't explicitly disabled.actionName
- the action method nametrue
if the action isn't explicitly disabled; false
otherwisepublic boolean isAncestorOfController(EOController controller)
controller
is a subcontroller of the receiver,
of the receiver's subcontrollers, or their subcontrollers, and so on.controller
- the controller to testtrue
if controller
is a subcontroller of the receiver, of the receiver's
subcontrollers, or their subcontrollers, and so on; false
otherwisepublic boolean isConnected()
true
if the controller is connected; false
otherwisepublic boolean isSupercontrollerOfController(EOController controller)
controller
is a direct subcontroller of the receiver.controller
- the controller to testtrue
if the controller is a direct subcontroller of the receiver; false
otherwiseprotected boolean isTransientExplicitlyForbidden()
true
if the controller cannot be transient; false
otherwisepublic void prepareForNewTask(boolean prepareSubcontrollersForNewTask)
prepareSubcontrollersForNewTask
is true
,
this method also sends prepareForNewTask
to each of the receiver's subcontrollers.
This method is usually invoked to prepare a branch of the controller
for reuse. Subclasses should override this method to get rid of data
and perform any additional clean up.prepareSubcontrollersForNewTask
- true
if the method should be forwarded
to all subcontrollers; false
otherwisepublic void removeFromSupercontroller()
removeSubcontroller
on the receiver's supercontroller. This method is mostly a convenience
so you don't have to look up a controller's supercontroller.
The default implementation should be sufficient for subclasses;
you shouldn't have to override it.removeSubcontroller(EOController)
protected void removeSubcontroller(EOController controller)
Removes controller
from the controller hierarchy.
EOController's implementation disconnects controller
from the controller hierarchy, and invokes subcontrollerWasRemoved
on the receiver to give it a chance to react appropriately.
Never invoke this method directly; use removeFromSupercontroller
instead. The default implementation should be sufficient for subclasses;
you shouldn't have to override it. If you need to do something when a
subcontroller is removed, override subcontrollerWasRemoved.
controller
- the controller to be removedsubcontrollerWasRemoved(EOController)
protected boolean removeTransientSubcontroller(EOController controller)
controller
from the controller hierarchy if controller
can be transient and if the receiver allows it. Returns whether the
controller can be removed. This method is invoked from
disposeIfTransient
, which is invoked in various situations
to remove controllers as soon as they can become transient.controller
- the controller to remove because it becomes transienttrue
if the controller could be removed; false
otherwisedisposeIfTransient()
public void resetActions()
public void setAdditionalActions(NSArray additionalActions)
additionalActions
- the array of additional actionsactions()
public void setAdditionalKeyValuePair(Object value, String key)
key
.value
- an Objectkey
- the String key to store value
with#handleQueryWithUnboundKey()
public void setAdditionalKeyValuePairs(NSDictionary dictionary)
dictionary
, of key-value pairs for use in handleQueryWithUnboundKey()
dictionary
- the NSDictionary to include as additional key-value pairsadditionalKeyValuePairs()
,
#handleQueryWithUnboundKey()
protected void setConnected(boolean flag)
establishConnection
and
breakConnection
set the controller's connection status automatically.flag
- true
if the controller is connected; false
otherwiseestablishConnection()
,
breakConnection()
protected boolean setSupercontroller(EOController controller)
controller
and resets
the receiver's actions. Returns whether the supercontroller accepted the
receiver as subcontroller. Also, controller
can be null
to unset the
receiver's supercontroller. EOController's implementation is sufficient
for most subclasses; you don't normally override this method. Nor should you
ever need to invoke it; addSubcontroller
sets the supercontroller automatically.controller
- the supercontrollertrue
if the supercontroller accepted the controller as subcontroller; false
otherwiseaddSubcontroller(EOController)
protected void setTransientExplicitlyForbidden(boolean flag)
flag
- true
if the controller cannot be transient; false
otherwisepublic void setTypeName(String typeName)
typeName
- the controller's type nameprotected void subcontrollerWasAdded(EOController controller)
addSubcontroller
to notify the receiver that a
subcontroller has been added to the controller hierarchy, giving
the receiver the opportunity to prepare the subcontroller for use.controller
- the subcontroller just addedaddSubcontroller(EOController)
protected void subcontrollerWasRemoved(EOController controller)
removeSubcontroller
to notify the receiver that a
subcontroller has been removed from the controller hierarchy, giving
the receiver the opportunity to perform any necessary clean up.controller
- the subcontroller just removedremoveSubcontroller(EOController)
public NSArray subcontrollers()
controllerEnumeration
or controllersInEnumeration
to return all the controllers in the
hierarchy under the receiver.controllerEnumeration(int, Class)
,
controllersInEnumeration(int, Class)
public EOController supercontroller()
null
if the receiver has no supercontroller.public EOController supercontroller(Class controllerInterface)
controllerInterface
.
Returns null
if the receiver has no supercontroller or if
none of the supercontrollers implement the interface. Returns receiver's direct
supercontroller if controllerInterface
is null
.controllerInterface
- the controller interface to look fornull
otherwisepublic void takeValueForKey(Object value, String key)
takeValueForKey
in the interface specification for
NSKeyValueCoding
.takeValueForKey
in interface NSKeyValueCoding
NSKeyValueCoding
public void takeValueForKeyPath(Object value, String keyPath)
NSKeyValueCodingAdditions
keyPath
to value
. A key path has the form relationship.property
(with one or more relationships); for example "movieRole.roleName"
or "movieRole.talent.lastName". The default implementation of
this method (provided by NSKeyValueCodingAdditions.DefaultImplementation)
gets the destination object for each relationship using valueForKey
,
and sends the final object a takeValueForKey
message with value
and property
.takeValueForKeyPath
in interface NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions
value
- the property identified by keyPath
is set to thiskeyPath
- identifies the property of an objectNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public String toString()
toString
in class Object
public String typeName()
null
. The type name is used to identify controllers that have the same
task. It is used to configure a controller with user defaults and also to
reuse controllers when possible.public void unableToSetNullForKey(String key)
NSKeyValueCoding.ErrorHandling
takeValueForKey
when it is given a null
value
for a scalar property (such as an int
or a float
).
The default implementation throws an IllegalArgumentException
.
You might want to implement the method (or override the inherited
implementation) to handle the request in some other way, such as by
substituting new Integer(0)
or a sentinel value and invoking takeValueForKey
again.unableToSetNullForKey
in interface NSKeyValueCoding.ErrorHandling
com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
key
- the name of the property which generated this errorIllegalArgumentException
- when it is given a null value
for a scalar propertyNSKeyValueCoding.takeValueForKey(Object value, String key)
,
NSKeyValueCoding.DefaultImplementation
public Object valueForKey(String key)
NSKeyValueCoding
key
.The default implementation provided by NSKeyValueCoding.DefaultImplementation works as follows:
key
. For
example, with a key of "lastName", the method looks for a method named
getLastName, lastName, or isLastName.canAccessFieldsDirectly
returns true
, the method searches
for a field based on key
and returns its value
directly. For the key "lastName", this would be _lastName, _isLastName, lastName, or isLastName.Note: The default implementations have significant performance optimizations. To benefit from them, implement NSKeyValueCoding on a custom class as shown above by using the methods in NSKeyValueCoding.DefaultImplementation, or if your class inherits from an WebObjects class that implements NSKeyValueCoding, do not override the inherited implementation. Using a custom implementation incurs significant performance penalties.
valueForKey
in interface NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding
key
- identifies the property to retrievekey
. Depending on the object you invoke this method upon, null
may be replaced with NullValue
NSKeyValueCoding.UnknownKeyException
- if key
cannot be found on the object this method was invoked upon.NSKeyValueCoding.NullValue
,
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)
public Object valueForKeyPath(String keyPath)
NSKeyValueCodingAdditions
valueForKey
,
and returns the result of a valueForKey
message to the final
object.valueForKeyPath
in interface NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions
keyPath
- the keypath to evaluatekeyPath
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |