API  0.9.10
CPCibConnector.j
Go to the documentation of this file.
1 /*
2  * CPCibConnector.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey",
26  _CPCibConnectorDestinationKey = @"_CPCibConnectorDestinationKey",
27  _CPCibConnectorLabelKey = @"_CPCibConnectorLabelKey";
28 
29 @implementation CPCibConnector : CPObject
30 {
31  id _source;
32  id _destination;
33  CPString _label;
34 }
35 
36 - (void)replaceObject:(id)anObject withObject:(id)anotherObject
37 {
38  if (_source === anObject)
39  _source = anotherObject;
40 
41  if (_destination === anObject)
42  _destination = anotherObject;
43 }
44 
45 - (void)replaceObjects:(Object)replacementObjects
46 {
47  var replacement = replacementObjects[[_source UID]];
48 
49  if (replacement !== undefined)
50  _source = replacement;
51 
52  replacement = replacementObjects[[_destination UID]];
53 
54  if (replacement !== undefined)
55  _destination = replacement;
56 }
57 
58 @end
59 
61 
62 - (id)initWithCoder:(CPCoder)aCoder
63 {
64  self = [super init];
65 
66  if (self)
67  {
68  _source = [aCoder decodeObjectForKey:_CPCibConnectorSourceKey];
69  _destination = [aCoder decodeObjectForKey:_CPCibConnectorDestinationKey];
70  _label = [aCoder decodeObjectForKey:_CPCibConnectorLabelKey];
71  }
72 
73  return self;
74 }
75 
76 - (void)encodeWithCoder:(CPCoder)aCoder
77 {
78  [aCoder encodeObject:_source forKey:_CPCibConnectorSourceKey];
79  [aCoder encodeObject:_destination forKey:_CPCibConnectorDestinationKey];
80  [aCoder encodeObject:_label forKey:_CPCibConnectorLabelKey];
81 }
82 
83 @end
84 
85 // For backwards compatibility.
86 @implementation _CPCibConnector : CPCibConnector
87 {
88  id __doxygen__;
89 }
90 @end
91 
93 
97 - (id)source
98 {
99  return _source;
100 }
101 
105 - (void)setSource:(id)aValue
106 {
107  _source = aValue;
108 }
109 
114 {
115  return _destination;
116 }
117 
121 - (void)setDestination:(id)aValue
122 {
123  _destination = aValue;
124 }
125 
130 {
131  return _label;
132 }
133 
137 - (void)setLabel:(CPString)aValue
138 {
139  _label = aValue;
140 }
141 
142 @end
An immutable string (collection of characters).
Definition: CPString.h:2
Defines methods for use when archiving & restoring (enc/decoding).
Definition: CPCoder.h:2
id init()
Definition: CPObject.j:145