2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
23 #include "WOResourceURLAssociation.h"
24 #include <NGObjWeb/WOApplication.h>
25 #include <NGObjWeb/WOComponent.h>
26 #include <NGObjWeb/WOContext.h>
27 #include <NGObjWeb/WORequest.h>
28 #include <NGObjWeb/WOResourceManager.h>
29 #include <NGObjWeb/WOSession.h>
32 @implementation WOResourceURLAssociation
34 static BOOL doDebug = NO;
37 return [super version] + 0 /* v2 */;
40 NSAssert2([super version] == 2,
41 @"invalid superclass (%@) version %i !",
42 NSStringFromClass([self superclass]), [super version]);
45 - (id)initWithString:(NSString *)_name {
46 if ([_name length] == 0) {
48 NSLog(@"WARNING(%s): got passed no resource name!",
54 if ((self = [super init])) {
55 self->resourceName = [_name copy];
60 return [self initWithString:nil];
64 [self->resourceName release];
70 - (NSString *)resourceName {
71 return self->resourceName;
73 - (NSString *)frameworkName {
79 - (void)setValue:(id)_value inComponent:(WOComponent *)_component {
80 /* resource-url association values cannot be set */
81 [NSException raise:@"AssociationException"
82 format:@"association value is not settable !"];
84 - (id)valueInComponent:(WOComponent *)_component {
85 WOResourceManager *rm;
90 if ((ctx = [_component context]) == nil)
91 ctx = [[WOApplication application] context];
93 langs = [ctx hasSession]
94 ? [[ctx session] languages]
95 : [[ctx request] browserLanguages];
97 if ((rm = [_component resourceManager]) == nil) {
100 if ((app = [ctx application]) == nil)
101 app = [WOApplication application];
103 rm = [app resourceManager];
106 [self logWithFormat:@"WARNING: found no resource manager!"];
110 return [rm urlForResourceNamed:[self resourceName]
111 inFramework:[self frameworkName]
116 - (BOOL)isValueConstant {
119 - (BOOL)isValueSettable {
125 - (id)copyWithZone:(NSZone *)_zone {
126 /* rsrc-url associations are immutable and don't need to be copied */
127 return [self retain];
130 - (NSString *)description {
131 NSMutableString *str;
133 str = [NSMutableString stringWithCapacity:64];
134 [str appendFormat:@"<%@[0x%08X]:", NSStringFromClass([self class]), self];
135 [str appendFormat:@" rsrc='%@'", [self resourceName]];
136 [str appendString:@">"];
140 @end /* WOResourceURLAssociation */