/***************************************************************** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. ****************************************************************/ #import "CAYObjEntity.h" @implementation CAYObjEntity -(id)initWithCoder:(NSCoder*)coder { [super init]; [self setAttributes:[coder decodeObjectForKey:@"attributes"]]; [self setName:[coder decodeObjectForKey:@"name"]]; [self setRelationships:[coder decodeObjectForKey:@"relationships"]]; [self setServerClassName:[coder decodeObjectForKey:@"className"]]; // remove extra entry created by hessian framework // TODO: fix in framework? [[self relationships] removeObjectForKey:@"hessianClassName"]; [[self attributes] removeObjectForKey:@"hessianClassName"]; return self; } -(void)encodeWithCoder:(NSCoder*)coder { [coder encodeObject:serverClassName forKey:@"className"]; [coder encodeObject:[self attributes] forKey:@"attributes"]; [coder encodeObject:[self name] forKey:@"name"]; [coder encodeObject:[self relationships] forKey:@"relationships"]; } - (id)copyWithZone:(NSZone *)zone { CAYObjEntity *copy = [[[self class] allocWithZone:zone] init]; [copy setServerClassName:[self serverClassName]]; [copy setAttributes:[self attributes]]; [copy setName:[self name]]; [copy setRelationships:[self relationships]]; return copy; } -(void)setAttributes:(NSMutableDictionary *)a { [a retain]; [attributes release]; attributes = a; } -(NSMutableDictionary *)attributes { return attributes; } -(void)setName:(NSString *)n { [n retain]; [name release]; name = n; } -(NSString *)name { return name; } -(void)setRelationships:(NSMutableDictionary *)r { [r retain]; [relationships release]; relationships = r; } -(NSMutableDictionary *)relationships { return relationships; } -(void)setServerClassName:(NSString *)n { [n retain]; [serverClassName release]; serverClassName = n; } -(NSString *)serverClassName { return serverClassName; } -(NSString *)description { NSString *result = [[NSString alloc] initWithFormat:@"%@ {name = %@; attributes = %@, serverClassName = %@, relationships = %@}", [self class], [self name], [self attributes], [self serverClassName], [self relationships]]; [result autorelease]; return result; } -(void)dealloc { [self setAttributes:nil]; [self setRelationships:nil]; [self setName:nil]; [self setServerClassName:nil]; [super dealloc]; } @end