WebObjects 5.4.2

com.webobjects.foundation
Interface NSKeyValueCodingAdditions

All Superinterfaces:
NSKeyValueCoding
All Known Subinterfaces:
EOEnterpriseObject, EOKeyValueCodingAdditions
All Known Implementing Classes:
BASConfirmPage, BASDefaultHeader, BASEditRelationshipPage, BASErrorPage, BASHead, BASInspectPage, BASListPage, BASMasterDetailPage, BASPlainListPage, BASQueryAllEntitiesPage, BASQueryPage, BASSideHeader, BASSidePageWrapper, D2WActions, D2WCollapsibleComponentContent, D2WCompactInspectComponent, D2WComponent, D2WConfirmPage, D2WContext, D2WCustomComponent, D2WCustomQueryComponent, D2WDefaultCustomComponent, D2WDisplayBoolean, D2WDisplayDate, D2WDisplayHyperlink, D2WDisplayImage, D2WDisplayImageFromPath, D2WDisplayLargeString, D2WDisplayMailTo, D2WDisplayNumber, D2WDisplayString, D2WDisplayStyledDate, D2WDisplayStyledNumber, D2WDisplayStyledString, D2WDisplayThresholdColoredNumber, D2WDisplayToMany, D2WDisplayToMany2, D2WDisplayToManyBrowser, D2WDisplayToManyFault, D2WDisplayToManyTable, D2WDisplayToOne, D2WDisplayToOneFault, D2WEdit, D2WEditBoolean, D2WEditDate, D2WEditLargeString, D2WEditNumber, D2WEditRelationshipPage, D2WEditString, D2WEditToManyFault, D2WEditToManyRelationship, D2WEditToOneFault, D2WEditToOneRelationship, D2WEditUneditable, D2WEmbeddedComponent, D2WEmptyWrapper, D2WErrorPage, D2WGenerationWrapper, D2WHead, D2WInspect, D2WInspectPage, D2WKeyPathContainer, D2WList, D2WListPage, D2WMasterDetailPage, D2WPage, D2WPlainListPage, D2WQuery, D2WQueryAllEntitiesPage, D2WQueryAnyField, D2WQueryBoolean, D2WQueryDateOperator, D2WQueryDateRange, D2WQueryNumberOperator, D2WQueryNumberRange, D2WQueryPage, D2WQueryRangeComponent, D2WQueryRelationship, D2WQueryStringComponent, D2WQueryStringOperator, D2WQueryToManyField, D2WQueryToManyRelationship, D2WQueryToOneField, D2WQueryToOneRelationship, D2WQueryUnavailable, D2WRemoteControl, D2WSelect, D2WStandAloneWebAssistantFrame, D2WStatelessComponent, D2WSwitchComponent, D2WTabInspectPage, D2WWebAssistantFrame, D2WWebAssistantPage, DarwinShadow, DefaultHeader, EditComponent, EditRelationship, EOActionButtonsController, EOActionController, EOActionMenuController, EOActionTrigger, EOActionWidgetController, EOAppletController, EOApplication, EOArchiveController, EOAssociationController, EOBoxController, EOCheckBoxController, EOComboBoxController, EOComponentController, EOController, EOCustomObject, EODefaultActionTrigger, EODetailSelectionController, EODialogController, EODisplayStatisticsController, EODocumentController, EODynamicApplication, EOEditingController, EOEntityController, EOEnumerationController, EOFormatValueController, EOFormController, EOFrameController, EOGenericRecord, EOImageViewController, EOInspectorController, EOInterfaceController, EOListController, EOMenuSwitchController, EOModalDialogController, EOMultipleValuesEnumerationController, EOOneValueEnumerationController, EOProgrammaticSwitchController, EOQueryController, EOQuickTimeViewController, EORangeTextFieldController, EORangeValueController, EORangeWidgetController, EOSchemaColumnDescription, EOSchemaForeignKeyConstraintDescription, EOSchemaIndexDescription, EOSchemaPropertyDescription, EOSchemaSynchronizationChanges, EOSchemaSynchronizationColumnChanges, EOSchemaSynchronizationModelChanges, EOSchemaSynchronizationTableChanges, EOSchemaTableDescription, EOSimpleWindowController, EOSplitController, EOStaticIconController, EOStaticLabelController, EOStaticTextFieldController, EOSwitchController, EOTableColumnController, EOTableController, EOTabSwitchController, EOTextAreaController, EOTextFieldController, EOTitlesController, EOTreeController, EOValueAndURLController, EOValueController, EOWidgetController, EOWindowController, FrontbasePlugIn.FrontbaseSynchronizationFactory.FrontbaseColumnDescription, FrontbasePlugIn.FrontbaseSynchronizationFactory.FrontbaseIndexDescription, FrontbasePlugIn.FrontbaseSynchronizationFactory.FrontbaseTableDescription, JSAlertPanel, JSComponent, JSConfirmPanel, JSImageFlyover, JSModalWindow, JSTextFlyover, JSValidatedField, NEUCompactInspectComponent, NEUConfirmPage, NEUEditRelationshipPage, NEUErrorPage, NEUHeader, NEUInspectPage, NEUListPage, NEUMasterDetailPage, NEUPlainListPage, NEUQueryAllPage, NEUQueryPage, NEUTabInspectPage, NSArray, NSDictionary, NSMutableArray, NSMutableDictionary, OpenBasePlugIn.OpenBaseSynchronizationFactory.OpenBaseColumnDescription, OpenBasePlugIn.OpenBaseSynchronizationFactory.OpenBaseIndexDescription, OpenBasePlugIn.OpenBaseSynchronizationFactory.OpenBaseTableDescription, QueryComponent, QueryOperatorComponent, WOAdminAction, WOAggregateEventRow, WOAnyField, WOApplication, WOAssociationEventRow, WOBatchNavigationBar, WOBeginTransactionOperation, WOCheckboxMatrix, WOCollapsibleComponentContent, WOCommitTransactionOperation, WOCompletionBar, WOComponent, WOContext, WOCookie, WODeleteOperation, WODictionaryRepetition, WODirectAction, WOEventDisplay, WOEventDisplayPage, WOEventPage, WOEventRow, WOEventSetup, WOEventSetupPage, WOExceptionPage, WOFetchSpecSearchOperation, WOHTTPConnection, WOIFrame, WOInsertOperation, WOJavaClientApplet, WOJavaClientComponent, WOJavaClientJNLP, WOKeyValueConditional, WOLCompactInspectComponent, WOLConfirmPage, WOLEditRelationshipPage, WOLErrorPage, WOLHeader, WOLInspectPage, WOLListPage, WOLMasterDetailPage, WOLongResponsePage, WOLPlainListPage, WOLQueryAllPage, WOLQueryPage, WOLTabInspectPage, WOMessage, WOMetaRefresh, WOOperation, WOOperationWSDLTemplate, WOPageRestorationError, WOProjectBuilderAction, WORadioButtonMatrix, WORedirect, WORequest, WOResponse, WORollbackTransactionOperation, WOSearchOperation, WOServletContext, WOSession, WOSessionCreationError, WOSessionRestorationError, WOSimpleArrayDisplay, WOSimpleArrayDisplay2, WOSortOrder, WOSortOrderManyKey, WOStatisticsStore, WOStats, WOStatsPage, WOStringKeyMap, WOTable, WOTableString, WOTabPanel, WOThresholdColoredNumber, WOToManyRelationship, WOToOneRelationship, WOUpdateOperation, WOWSDLGeneration, WXAccessControl, WXBar, WXOutlineControl, WXOutlineEntry, WXOutlineRepetition, WXSortOrder

public interface NSKeyValueCodingAdditions
extends NSKeyValueCoding

The NSKeyValueCodingAdditions interface defines an extension to the basic NSKeyValueCoding interface. The pair of methods in NSKeyValueCodingAdditions -- takeValueForKeyPath and valueForKeyPath -- give access to properties across relationships with key paths of the form relationship.property; for example, "department.name".

The NSKeyValueCodingAdditions interface contains two inner classes, NSKeyValueCodingAdditions.DefaultImplementation and NSKeyValueCodingAdditions.Utility. The former provides a default implementation of the interface, making it easy to implement custom classes. The latter is a convenience class that allows you to access the properties of NSKeyValueCodingAdditions objects and objects using the same code.

Default Implementation

The methods in the NSKeyValueCodingAdditions.DefaultImplementation class are just like the methods defined by the NSKeyValueCodingAdditions interface, except they are static methods and they take an extra argument -- the object on which the default implementation should operate.

For example, suppose it is wanted to implement an Employee class that implements NSKeyValueCodingAdditions using NSKeyValueCodingAdditions.DefaultImplementation. Employee's valueForKeyPath method would then look like this:

public Object valueForKeyPath(String keyPath) { return NSKeyValueCodingAdditions.DefaultImplementation.valueForKeyPath( this, keyPath); }

Utility

Recall that the NSKeyValueCodingAdditions.Utility class is a convenience that allows to access the properties of NSKeyValueCodingAdditions objects and non-NSKeyValueCodingAdditions objects using the same code.

Utility's methods are similar to DefaultImplementation's methods in that they are static methods and they take an extra argument -- the object on which the method should operate. However, Utility's methods simply check to see if the object on which they operate is an NSKeyValueCodingAdditions object and invoke the corresponding NSKeyValueCodingAdditions method on the object if it is. Otherwise, they invoke the corresponding DefaultImplementation method, passing the object on which to operate.

For example, suppose that you want to access an object with the NSKeyValueCodingAdditions API but you do not know if the object is an NSKeyValueCodingAdditions object. To do so, you simply use the corresponding Utility API, as in the following line of code:

theValue = NSKeyValueCodingAdditions.Utility.valueForKeyPath(object, keyPath);

The above line of code is essentially a short-cut for the following:

if (object instanceof NSKeyValueCodingAdditions) { theValue = ((NSKeyValueCodingAdditions)object).valueForKeyPath(keyPath); } else { theValue = NSKeyValueCodingAdditions.DefaultImplementation.valueForKeyPath( object, keyPath); }

See Also:
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String), NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String), NSKeyValueCoding, NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility

Nested Class Summary
static class NSKeyValueCodingAdditions.DefaultImplementation
          The NSKeyValueCodingAdditions.DefaultImplementation class provides default implementations of the NSKeyValueCodingAdditions interface.
static class NSKeyValueCodingAdditions.Utility
          The NSKeyValueCodingAdditions.Utility class is a convenience that allows one to access the properties of NSKeyValueCodingAdditions objects and non-NSKeyValueCodingAdditions objects using the same code.
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Field Summary
static String KeyPathSeparator
          The string used to separate components of a key path, "."
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Method Summary
 void takeValueForKeyPath(Object value, String keyPath)
          Sets the value for the property identified by keyPath to value.
 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 interface com.webobjects.foundation.NSKeyValueCoding
takeValueForKey, valueForKey
 

Field Detail

KeyPathSeparator

static final String KeyPathSeparator
The string used to separate components of a key path, "."

See Also:
Constant Field Values
Method Detail

valueForKeyPath

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"). 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 returns the result of a valueForKey message to the final object.

Parameters:
keyPath - the keypath to evaluate
Returns:
the value for the derived property identified by keyPath
See Also:
NSKeyValueCoding.valueForKey(java.lang.String), NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String), NSKeyValueCodingAdditions.DefaultImplementation

takeValueForKeyPath

void takeValueForKeyPath(Object value,
                         String keyPath)
Sets the value for the property identified by 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.

Parameters:
value - the property identified by keyPath is set to this
keyPath - identifies the property of an object
See Also:
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String), NSKeyValueCodingAdditions.DefaultImplementation

Last updated June 2008

Copyright © 2000-2008 Apple Inc.