PageRenderTime 61ms CodeModel.GetById 40ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Analytics/GDataAnalyticsGoal.m

http://macfuse.googlecode.com/
Objective C | 130 lines | 80 code | 31 blank | 19 comment | 1 complexity | bc2bbb23827504cd2d1d310b75df86be MD5 | raw file
  1/* Copyright (c) 2009 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//
 17//  GDataAnalyticsGoal.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE
 21
 22#import "GDataAnalyticsGoal.h"
 23#import "GDataAnalyticsConstants.h"
 24
 25static NSString *const kActiveAttr = @"active";
 26static NSString *const kNameAttr = @"name";
 27static NSString *const kNumberAttr = @"number";
 28static NSString *const kValueAttr = @"value";
 29
 30@implementation GDataAnalyticsGoal
 31
 32+ (NSString *)extensionElementURI       { return kGDataNamespaceAnalyticsGA; }
 33+ (NSString *)extensionElementPrefix    { return kGDataNamespaceAnalyticsGAPrefix; }
 34+ (NSString *)extensionElementLocalName { return @"goal"; }
 35
 36- (void)addParseDeclarations {
 37
 38  NSArray *attrs = [NSArray arrayWithObjects:
 39                    kActiveAttr, kNameAttr, kNumberAttr, kValueAttr, nil];
 40
 41  [self addLocalAttributeDeclarations:attrs];
 42}
 43
 44- (void)addExtensionDeclarations {
 45  [super addExtensionDeclarations];
 46
 47  [self addExtensionDeclarationForParentClass:[self class]
 48                                 childClasses:
 49   [GDataAnalyticsDestination class],
 50   [GDataAnalyticsEngagement class],
 51   nil];
 52}
 53
 54#if !GDATA_SIMPLE_DESCRIPTIONS
 55- (NSMutableArray *)itemsForDescription {
 56
 57  static struct GDataDescriptionRecord descRecs[] = {
 58    { @"destination", @"destination", kGDataDescValueLabeled },
 59    { @"engagement",  @"engagement",  kGDataDescValueLabeled },
 60    { nil, nil, (GDataDescRecTypes)0 }
 61  };
 62
 63  NSMutableArray *items = [super itemsForDescription];
 64  [self addDescriptionRecords:descRecs toItems:items];
 65  return items;
 66}
 67#endif
 68
 69#pragma mark -
 70
 71// Attributes
 72
 73- (BOOL)isActive {
 74  BOOL flag = [self boolValueForAttribute:kActiveAttr
 75                             defaultValue:NO];
 76  return flag;
 77}
 78
 79- (void)setIsActive:(BOOL)flag {
 80  [self setExplicitBoolValue:flag forAttribute:kActiveAttr];
 81}
 82
 83- (NSString *)name {
 84  NSString *str = [self stringValueForAttribute:kNameAttr];
 85  return str;
 86}
 87
 88- (void)setName:(NSString *)str {
 89  [self setStringValue:str forAttribute:kNameAttr];
 90}
 91
 92- (NSNumber *)number { // int
 93  NSNumber *num = [self intNumberForAttribute:kNumberAttr];
 94  return num;
 95}
 96
 97- (void)setNumber:(NSNumber *)num {
 98  [self setStringValue:[num stringValue] forAttribute:kNumberAttr];
 99}
100
101- (NSNumber *)value { // double
102  NSNumber *num = [self doubleNumberForAttribute:kValueAttr];
103  return num;
104}
105
106- (void)setValue:(NSNumber *)num {
107  [self setStringValue:[num stringValue] forAttribute:kValueAttr];
108}
109
110// Extensions
111
112- (GDataAnalyticsDestination *)destination {
113  return [self objectForExtensionClass:[GDataAnalyticsDestination class]];
114}
115
116- (void)setDestination:(GDataAnalyticsDestination *)obj {
117  [self setObject:obj forExtensionClass:[GDataAnalyticsDestination class]];
118}
119
120- (GDataAnalyticsEngagement *)engagement {
121  return [self objectForExtensionClass:[GDataAnalyticsEngagement class]];
122}
123
124- (void)setEngagement:(GDataAnalyticsEngagement *)obj {
125  [self setObject:obj forExtensionClass:[GDataAnalyticsEngagement class]];
126}
127
128@end
129
130#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_ANALYTICS_SERVICE