# ECXMLControlReferenceRule

## Abstract

This rule allows the definition of anchors and their corresponding references.

## Discussion

Through this rule it is possible to set an anchor and by doing so, to refer to the corresponding object later in the xml parsing step. The reference results in a corresponding setter call. Example:

<house id="house-id"/>
<Contract price="128.231,75" object-idref="house-id"/> In this example the object allocated by <Contracr> will be hand-off the previously allocate instance related to <house> by calling the related setter method setObject or addObject.

The underlying rules are as follows:

- id-attribute: This attribute specifies the name under which the object, which is currently on top of the stack, has to be registered. The identifier behind has to be unique wrt. the whole file.
- <attributename>-idref-attribute: Looks for an object which has been registered with the value specified by this attribute. The registration must habe been done before! If the registired object is found then the underlying setting method is called using <attributename> as the base name.

Regarding the lookup for the corresponding setting method please refer to ECXMLControlSetterLookupUtil.

## Methods

`-actOn:`
`-addObject`
  Internal method used to register an object which may be references.
`-addObject:withRefId:usingDictionary:`
  Internal method used to register an object which may be references.
`-mayActOn:`
`-respondsToContext`
`-setReferenceToObject`
  Hands-off a referenced object to the object currently being on top of the stack
`-setReferenceToObject:objectIdReference:usingMethod:usingDictionary:`
  Hands-off a referenced object to the object currently being on top of the stack

### actOn:

>     - (BOOL) actOn: (ECXMLControlContext *) aContext;

##### Parameter Descriptions

> `aContext`
>   current context to evaluate

method result
  YES if no more rules should be evaluated

### addObject

Internal method used to register an object which may be references.

See Also:

> addObject:withRefId:usingDictionary:

>     - addObject: (id) anObject withRefId: (NSString *) aRefId usingDictionary: (NSMutableDictionary *) aDicitonary;

##### Parameter Descriptions

> `anObject`
>   related object
> `aRefId`
>   underlying reference identifier
> `aDictionary`
>   dictionary used to store the new identifier and the corresponding object

method result
  self

### addObject:withRefId:usingDictionary:

Internal method used to register an object which may be references.

See Also:

> addObject

>     - addObject: (id) anObject withRefId: (NSString *) aRefId usingDictionary: (NSMutableDictionary *) aDicitonary;

##### Parameter Descriptions

> `anObject`
>   related object
> `aRefId`
>   underlying reference identifier
> `aDictionary`
>   dictionary used to store the new identifier and the corresponding object

### mayActOn:

See Also:

> respondsToContext

>     - (BOOL) mayActOn: (ECXMLControlContext *) aContext;

##### Parameter Descriptions

> `aContext`
>   current context to evaluate

### respondsToContext

See Also:

> mayActOn:

>     - (BOOL) mayActOn: (ECXMLControlContext *) aContext;

##### Parameter Descriptions

> `aContext`
>   current context to evaluate

method result
  YES if the receiver should be valuated according to the given context

### setReferenceToObject

Hands-off a referenced object to the object currently being on top of the stack

See Also:

> setReferenceToObject:objectIdReference:usingMethod:usingDictionary:

>     - setReferenceToObject: (id) anObject objectIdReference: (NSString *) idName usingMethod: (NSString *) methodName usingDictionary: (NSMutableDictionary *) aDictionary;

##### Parameter Descriptions

> `idName`
>   identifier string which references the object to hand-off
> `anObject`
>   object to which the referenced object has to be hand-off
> `methodName`
>   method to call
> `aDicitonary`
>   global rule dictionary where the references are managed.

method result
  self

### setReferenceToObject:objectIdReference:usingMethod:usingDictionary:

Hands-off a referenced object to the object currently being on top of the stack

See Also:

> setReferenceToObject

>     - setReferenceToObject: (id) anObject objectIdReference: (NSString *) idName usingMethod: (NSString *) methodName usingDictionary: (NSMutableDictionary *) aDictionary;

##### Parameter Descriptions

> `idName`
>   identifier string which references the object to hand-off
> `anObject`
>   object to which the referenced object has to be hand-off
> `methodName`
>   method to call
> `aDicitonary`
>   global rule dictionary where the references are managed.

(Last Updated August 27, 2006)