/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Finance/GDataEntryFinancePortfolio.m

http://macfuse.googlecode.com/ · Objective C · 125 lines · 71 code · 37 blank · 17 comment · 3 complexity · 448e73616c8b4107d7d532c845cec8bf MD5 · raw file

  1. /* Copyright (c) 2008 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. //
  16. // GDataEntryFinancePortfolio.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_FINANCE_SERVICE
  19. #define GDATAENTRYFINANCEPORTFOLIO_DEFINE_GLOBALS 1
  20. #import "GDataEntryFinancePortfolio.h"
  21. @implementation GDataEntryFinancePortfolio
  22. + (NSDictionary *)financeNamespaces {
  23. NSMutableDictionary *namespaces;
  24. namespaces = [NSMutableDictionary dictionaryWithObject:kGDataNamespaceFinance
  25. forKey:kGDataNamespaceFinancePrefix];
  26. [namespaces addEntriesFromDictionary:[GDataEntryBase baseGDataNamespaces]];
  27. return namespaces;
  28. }
  29. + (GDataEntryFinancePortfolio *)portfolioEntry {
  30. GDataEntryFinancePortfolio *obj;
  31. obj = [self object];
  32. [obj setNamespaces:[GDataEntryFinancePortfolio financeNamespaces]];
  33. return obj;
  34. }
  35. #pragma mark -
  36. + (NSString *)standardEntryKind {
  37. return kGDataCategoryFinancePortfolio;
  38. }
  39. + (void)load {
  40. [self registerEntryClass];
  41. }
  42. - (void)addExtensionDeclarations {
  43. [super addExtensionDeclarations];
  44. Class entryClass = [self class];
  45. [self addExtensionDeclarationForParentClass:entryClass
  46. childClasses:
  47. [GDataPortfolioData class],
  48. [GDataFeedLink class],
  49. nil];
  50. }
  51. #if !GDATA_SIMPLE_DESCRIPTIONS
  52. - (NSMutableArray *)itemsForDescription {
  53. NSMutableArray *items = [super itemsForDescription];
  54. [self addToArray:items objectDescriptionIfNonNil:[self portfolioData] withName:@"portfolio"];
  55. [self addToArray:items objectDescriptionIfNonNil:[self feedLink] withName:@"feedLink"];
  56. return items;
  57. }
  58. #endif
  59. + (NSString *)defaultServiceVersion {
  60. return kGDataFinanceDefaultServiceVersion;
  61. }
  62. #pragma mark -
  63. - (void)setPortfolioData:(GDataPortfolioData *)obj {
  64. [self setObject:obj forExtensionClass:[GDataPortfolioData class]];
  65. }
  66. - (GDataPortfolioData *)portfolioData {
  67. return [self objectForExtensionClass:[GDataPortfolioData class]];
  68. }
  69. - (void)setFeedLink:(GDataFeedLink *)feedLink {
  70. [self setObject:feedLink forExtensionClass:[GDataFeedLink class]];
  71. }
  72. - (GDataFeedLink *)feedLink {
  73. return [self objectForExtensionClass:[GDataFeedLink class]];
  74. }
  75. #pragma mark Convenience accessors
  76. - (NSURL *)positionURL {
  77. GDataFeedLink *feedLink = [self feedLink];
  78. if (feedLink) {
  79. NSString *urlStr = [feedLink href];
  80. if ([urlStr length] > 0) {
  81. NSURL *url = [NSURL URLWithString:urlStr];
  82. return url;
  83. }
  84. }
  85. return nil;
  86. }
  87. @end
  88. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_FINANCE_SERVICE