]> err.no Git - sope/blob - sope-appserver/WOXML/WOXMLMappingProperty.m
improved editing context support
[sope] / sope-appserver / WOXML / WOXMLMappingProperty.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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
22 #include "WOXMLMappingProperty.h"
23 #include "common.h"
24
25 @implementation WOXMLMappingProperty
26
27 - (id)initWithEntity:(WOXMLMappingEntity *)_entity {
28   self->entity = _entity;
29   return self;
30 }
31
32 - (void)dealloc {
33   RELEASE(self->name);
34   RELEASE(self->xmlTag);
35   RELEASE(self->codeBasedOn);
36   RELEASE(self->outputTags);
37   [super dealloc];
38 }
39
40 /* validity */
41
42 - (BOOL)isValid {
43   if ([self->name length] == 0)
44     return NO;
45   if ([self->xmlTag length] == 0)
46     return NO;
47   return YES;
48 }
49
50 - (WOXMLMappingEntity *)entity {
51   return self->entity;
52 }
53
54 /* attributes */
55
56 - (void)setName:(NSString *)_name {
57   ASSIGN(self->name, _name);
58 }
59 - (NSString *)name {
60   return self->name;
61 }
62
63 - (void)setXmlTag:(NSString *)_xmlTag {
64   ASSIGN(self->xmlTag, _xmlTag);
65 }
66 - (NSString *)xmlTag {
67   return self->xmlTag;
68 }
69
70 - (void)setCodeBasedOn:(NSString *)_codeBasedOn {
71   ASSIGN(self->codeBasedOn, _codeBasedOn);
72 }
73 - (NSString *)codeBasedOn {
74   return self->codeBasedOn;
75 }
76
77 - (void)setOutputTags:(NSString *)_tags {
78   ASSIGN(self->outputTags, _tags);
79 }
80 - (NSString *)outputTags {
81   return self->outputTags;
82 }
83
84 - (void)setAttribute:(BOOL)_flag {
85   self->attribute = _flag;
86 }
87 - (BOOL)attribute {
88   return self->attribute;
89 }
90
91 - (void)setForceList:(BOOL)_flag {
92   self->forceList = _flag;
93 }
94 - (BOOL)forceList {
95   return self->forceList;
96 }
97
98 - (void)setReportEmptyValues:(BOOL)_flag {
99   self->reportEmptyValues = _flag;
100 }
101 - (BOOL)reportEmptyValues {
102   return self->reportEmptyValues;
103 }
104
105 /* XML representation */
106
107 - (NSString *)xmlStringValue {
108   NSMutableString *s;
109   
110   s = [NSMutableString stringWithCapacity:100];
111   [s appendString:@"<property"];
112   [s appendString:@" name='"];
113   [s appendString:[self name]];
114   [s appendString:@"' xmlTag='"];
115   [s appendString:[self xmlTag]];
116   [s appendString:@"'"];
117   
118   if ([self reportEmptyValues])
119     [s appendString:@" reportEmptyValues='YES'"];
120   if ([self forceList])
121     [s appendString:@" forceList='YES'"];
122   if ([self attribute])
123     [s appendString:@" attribute='YES'"];
124   
125   [s appendString:@"/>\n"];
126   return s;
127 }
128
129 /* description */
130
131 - (NSString *)description {
132   NSMutableString *s;
133
134   s = [NSMutableString stringWithCapacity:100];
135   [s appendFormat:@"<%@ 0x%08X:", NSStringFromClass([self class]), self];
136
137   if ([self name])
138     [s appendFormat:@" name=%@", [self name]];
139   if ([self xmlTag])
140     [s appendFormat:@" tag=%@", [self xmlTag]];
141   if ([self codeBasedOn])
142     [s appendFormat:@" codeBasedOn=%@", [self codeBasedOn]];
143   if ([self outputTags])
144     [s appendFormat:@" out-tags=%@", [self outputTags]];
145
146   if ([self attribute])
147     [s appendString:@" attribute"];
148   if ([self forceList])
149     [s appendString:@" forceList"];
150   if ([self reportEmptyValues])
151     [s appendString:@" reportEmptyValues"];
152   
153   [s appendString:@">"];
154   return s;
155 }
156
157 @end /* WOXMLMappingProperty */