]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoLookupAssociation.m
fixed OGo bug #888
[sope] / sope-appserver / NGObjWeb / SoObjects / SoLookupAssociation.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "SoLookupAssociation.h"
24 #include "SoObject.h"
25 #include <NGObjWeb/WOComponent.h>
26 #include "common.h"
27
28 @implementation SoLookupAssociation
29
30 + (int)version {
31   return [super version] /* v2 */;
32 }
33 + (void)initialize {
34   NSAssert2([super version] == 2,
35             @"invalid superclass (%@) version %i !",
36             NSStringFromClass([self superclass]), [super version]);
37 }
38
39 - (id)initWithTraversalPath:(NSArray *)_tp acquire:(BOOL)_ac {
40   if ((self = [super init])) {
41     self->traversalPath = [_tp copy];
42     self->acquire = _ac;
43   }
44   return self;
45 }
46
47 - (id)initWithString:(NSString *)_s {
48   BOOL acq;
49   
50   if ((acq = [_s hasPrefix:@"+"]))
51     _s = [_s substringFromIndex:1];
52   
53   return [self initWithTraversalPath:[_s pathComponents] acquire:acq];
54 }
55
56 - (void)dealloc {
57   [self->traversalPath release];
58   [super dealloc];
59 }
60
61 /* accessors */
62
63 - (NSArray *)traversalPath {
64   return self->traversalPath;
65 }
66 - (BOOL)doesAcquire {
67   return self->acquire;
68 }
69
70 /* value */
71
72 - (BOOL)isValueConstant {
73   return NO;
74 }
75 - (BOOL)isValueSettable {
76   return NO;
77 }
78
79 /* op */
80
81 - (void)setValue:(id)_value inComponent:(WOComponent *)_component {
82   // not settable
83   [NSException raise:@"AssociationException"
84                format:@"association value is not settable !"];
85 }
86
87 - (id)valueInComponent:(WOComponent *)_component {
88   return [_component traversePathArray:self->traversalPath 
89                      acquire:self->acquire];
90 }
91
92 @end /* SoLookupAssociation */