2 // AddressBookDoCoMoParsedResult.m
5 // Created by Christian Brunschen on 29/05/2008.
7 * Copyright 2008 ZXing authors
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
22 #import "AddressBookDoCoMoParsedResult.h"
23 #import "AddContactAction.h"
25 @implementation AddressBookDoCoMoParsedResult
28 @synthesize phoneNumbers;
31 @synthesize urlString;
34 + parsedResultForString:(NSString *)s {
35 NSRange foundRange = [s rangeOfString:@"MECARD:"];
36 if (foundRange.location == NSNotFound) {
40 NSString *name = [s fieldWithPrefix:@"N:"];
45 AddressBookDoCoMoParsedResult *result = [[self alloc] init];
47 result.phoneNumbers = [s fieldsWithPrefix:@"TEL:"];
48 result.email = [s fieldWithPrefix:@"EMAIL:"];
49 result.note = [s fieldWithPrefix:@"NOTE:"];
50 result.urlString = [s fieldWithPrefix:@"URL:"];
51 result.address = [s fieldWithPrefix:@"ADR:"];
53 return [result autorelease];
56 - (NSString *)stringForDisplay {
57 NSMutableString *result = [NSMutableString stringWithString:self.name];
58 if (self.phoneNumbers) {
59 for (NSString *number in self.phoneNumbers) {
60 [result appendFormat:@"\n%@", number];
65 [result appendFormat:@"\n%@", self.email];
68 [result appendFormat:@"\n%@", self.urlString];
71 [result appendFormat:@"\n%@", self.note];
74 [result appendFormat:@"\n%@", self.address];
76 return [NSString stringWithString:result];
79 - (NSString *)typeName {
80 return @"DoCoMo MeCard";
83 - (void)populateActions {
84 [actions addObject:[AddContactAction actionWithName:self.name
85 phoneNumbers:self.phoneNumbers
94 [phoneNumbers release];