You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXAddressBookParsedResult.h"
  17. #import "ZXParsedResultType.h"
  18. @implementation ZXAddressBookParsedResult
  19. - (id)initWithNames:(NSArray *)names phoneNumbers:(NSArray *)phoneNumbers
  20. phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
  21. addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes {
  22. return [self initWithNames:names nicknames:nil pronunciation:nil phoneNumbers:phoneNumbers phoneTypes:phoneNumbers
  23. emails:emails emailTypes:_emailTypes instantMessenger:nil note:nil addresses:addresses
  24. addressTypes:addressTypes org:nil birthday:nil title:nil urls:nil geo:nil];
  25. }
  26. - (id)initWithNames:(NSArray *)names nicknames:(NSArray *)nicknames pronunciation:(NSString *)pronunciation
  27. phoneNumbers:(NSArray *)phoneNumbers phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails
  28. emailTypes:(NSArray *)emailTypes instantMessenger:(NSString *)instantMessenger note:(NSString *)note
  29. addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes org:(NSString *)org
  30. birthday:(NSString *)birthday title:(NSString *)title urls:(NSArray *)urls geo:(NSArray *)geo {
  31. if (self = [super initWithType:kParsedResultTypeAddressBook]) {
  32. _names = names;
  33. _nicknames = nicknames;
  34. _pronunciation = pronunciation;
  35. _phoneNumbers = phoneNumbers;
  36. _phoneTypes = phoneTypes;
  37. _emails = emails;
  38. _emailTypes = emailTypes;
  39. _instantMessenger = instantMessenger;
  40. _note = note;
  41. _addresses = addresses;
  42. _addressTypes = addressTypes;
  43. _org = org;
  44. _birthday = birthday;
  45. _title = title;
  46. _urls = urls;
  47. _geo = geo;
  48. }
  49. return self;
  50. }
  51. + (id)addressBookParsedResultWithNames:(NSArray *)names phoneNumbers:(NSArray *)phoneNumbers
  52. phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
  53. addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes {
  54. return [[self alloc] initWithNames:names phoneNumbers:phoneNumbers phoneTypes:phoneTypes emails:emails
  55. emailTypes:emailTypes addresses:addresses addressTypes:addressTypes];
  56. }
  57. + (id)addressBookParsedResultWithNames:(NSArray *)names nicknames:(NSArray *)nicknames
  58. pronunciation:(NSString *)pronunciation phoneNumbers:(NSArray *)phoneNumbers
  59. phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
  60. instantMessenger:(NSString *)instantMessenger note:(NSString *)note addresses:(NSArray *)addresses
  61. addressTypes:(NSArray *)addressTypes org:(NSString *)org birthday:(NSString *)birthday
  62. title:(NSString *)title urls:(NSArray *)urls geo:(NSArray *)geo {
  63. return [[self alloc] initWithNames:names nicknames:nicknames pronunciation:pronunciation phoneNumbers:phoneNumbers
  64. phoneTypes:phoneTypes emails:emails emailTypes:emailTypes instantMessenger:instantMessenger
  65. note:note addresses:addresses addressTypes:addressTypes org:org birthday:birthday
  66. title:title urls:urls geo:geo];
  67. }
  68. - (NSString *)displayResult {
  69. NSMutableString *result = [NSMutableString string];
  70. [ZXParsedResult maybeAppendArray:self.names result:result];
  71. [ZXParsedResult maybeAppendArray:self.nicknames result:result];
  72. [ZXParsedResult maybeAppend:self.pronunciation result:result];
  73. [ZXParsedResult maybeAppend:self.title result:result];
  74. [ZXParsedResult maybeAppend:self.org result:result];
  75. [ZXParsedResult maybeAppendArray:self.addresses result:result];
  76. [ZXParsedResult maybeAppendArray:self.phoneNumbers result:result];
  77. [ZXParsedResult maybeAppendArray:self.emails result:result];
  78. [ZXParsedResult maybeAppend:self.instantMessenger result:result];
  79. [ZXParsedResult maybeAppendArray:self.urls result:result];
  80. [ZXParsedResult maybeAppend:self.birthday result:result];
  81. [ZXParsedResult maybeAppendArray:self.geo result:result];
  82. [ZXParsedResult maybeAppend:self.note result:result];
  83. return result;
  84. }
  85. @end