/***************************************************************** * 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 "CAYArcDeleteOperation.h" #import "CAYArcCreateOperation.h" #import "CAYUtil.h" @implementation CAYArcDeleteOperation -(id)initWithNodeId:(NSObject *)nid targetNodeId:(NSObject *)tnid arcId:(NSObject *)aid { self = [super initWithNodeId:nid]; if(self) { [self setTargetNodeId:tnid]; [self setArcId:aid]; } return self; } -(id)initWithCoder:(NSCoder*)coder { [super initWithCoder:coder]; [self setTargetNodeId:[coder decodeObjectForKey:@"targetNodeId"]]; [self setArcId:[coder decodeObjectForKey:@"arcId"]]; return self; } -(void)encodeWithCoder:(NSCoder*)coder { [super encodeWithCoder:coder]; [coder encodeObject:targetNodeId forKey:@"targetNodeId"]; [coder encodeObject:arcId forKey:@"arcId"]; } -(void)setTargetNodeId:(NSObject *)o { [o retain]; [targetNodeId release]; targetNodeId = o; } -(NSObject *)targetNodeId { return targetNodeId; } -(void)setArcId:(NSObject *)o { [o retain]; [arcId release]; arcId = o; } -(NSObject *)arcId { return arcId; } -(BOOL)isOpposite:(CAYNodeDiff *)diff { if(![diff isKindOfClass:[CAYArcCreateOperation class]]) { return NO; } if(![[diff nodeId] isEqualTo:[self nodeId]]) { return NO; } CAYArcCreateOperation *other = (CAYArcCreateOperation *)diff; return ([[other arcId] isEqualTo:[self arcId]] && [CAYUtil nilSafe:[other targetNodeId] isEqualTo:[self targetNodeId]]); } -(NSString *)description { NSString *result; result = [[NSString alloc] initWithFormat:@"CAYArcDeleteOperation {nodeId = %@; arcId = %@; targetNodeId = %@ }", [self nodeId], [self arcId], [self targetNodeId]]; [result autorelease]; return result; } -(void)dealloc { [self setTargetNodeId:nil]; [self setArcId:nil]; [super dealloc]; } @end