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 "OFSFactoryContext.h"
24 #include "OFSFolder.h"
27 @implementation OFSFactoryContext
29 + (OFSFactoryContext *)contextForChild:(NSString *)_name
30 storagePath:(NSString *)_sp
31 ofFolder:(OFSFolder *)_folder
33 OFSFactoryContext *ctx;
35 ctx = [[self alloc] init];
36 ctx->fileManager = [[_folder fileManager] retain];
37 ctx->storagePath = [_sp copy];
38 ctx->container = [_folder retain];
39 ctx->name = [_name copy];
40 return [ctx autorelease];
42 + (OFSFactoryContext *)contextForNewChild:(NSString *)_name
43 storagePath:(NSString *)_sp
44 ofFolder:(OFSFolder *)_folder
46 OFSFactoryContext *ctx;
48 if ((ctx = [self contextForChild:_name storagePath:_sp ofFolder:_folder])) {
49 ctx->isNewObject = YES;
54 + (OFSFactoryContext *)contextWithFileManager:(id<NSObject,NGFileManager>)_fm
55 storagePath:(NSString *)_sp
57 OFSFactoryContext *ctx;
59 ctx = [[self alloc] init];
60 ctx->fileManager = [_fm retain];
61 ctx->storagePath = [_sp copy];
62 return [ctx autorelease];
66 [self->fileType release];
67 [self->mimeType release];
68 [self->fileManager release];
69 [self->container release];
71 [self->storagePath release];
77 - (id<NSObject,NGFileManager>)fileManager {
78 return self->fileManager;
80 - (NSString *)storagePath {
81 return self->storagePath;
84 return self->container;
86 - (NSString *)nameInContainer {
90 - (NSString *)fileType {
91 return self->fileType;
93 - (NSString *)mimeType {
94 return self->mimeType;
98 return self->isNewObject;
103 - (NSString *)description {
106 ms = [NSMutableString stringWithCapacity:64];
107 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
109 if (self->isNewObject)
110 [ms appendString:@" NEW"];
111 if (self->name) [ms appendFormat:@" create=%@", self->name];
112 if (self->container) [ms appendFormat:@" in=%@", self->container];
113 if (self->fileType) [ms appendFormat:@" type=%@", self->fileType];
114 if (self->mimeType) [ms appendFormat:@" mime=%@", self->mimeType];
115 if (self->storagePath) [ms appendFormat:@" path=%@", self->storagePath];
117 [ms appendString:@">"];
121 @end /* OFSFactoryContext */