PageRenderTime 68ms CodeModel.GetById 18ms app.highlight 47ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Spreadsheets/GDataQuerySpreadsheet.m

http://macfuse.googlecode.com/
Objective C | 152 lines | 104 code | 29 blank | 19 comment | 2 complexity | fbec5febc8fbea03659a7b54fd60dcfe MD5 | raw file
  1/* Copyright (c) 2007 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//  GDataQuerySpreadsheet.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE
 21
 22#import "GDataQuerySpreadsheet.h"
 23
 24static NSString *const kSpreadsheetQueryParamName = @"sq";
 25static NSString *const kReverseParamName = @"reverse";
 26static NSString *const kTitleParamName = @"title";
 27static NSString *const kExactTitleParamName = @"title-exact";
 28static NSString *const kMinRowParamName = @"min-row";
 29static NSString *const kMaxRowParamName = @"max-row";
 30static NSString *const kMinColParamName = @"min-col";
 31static NSString *const kMaxColParamName = @"max-col";
 32static NSString *const kRangeParamName = @"range";
 33static NSString *const kReturnEmptyParamName = @"return-empty";
 34
 35@implementation GDataQuerySpreadsheet
 36
 37+ (GDataQuerySpreadsheet *)spreadsheetQueryWithFeedURL:(NSURL *)feedURL {
 38  return [self queryWithFeedURL:feedURL];   
 39}
 40
 41- (NSString *)titleQuery {
 42  NSString *str = [self valueForParameterWithName:kTitleParamName];
 43  return str;
 44}
 45
 46- (void)setTitleQuery:(NSString *)str {
 47  [self addCustomParameterWithName:kTitleParamName value:str];
 48}
 49
 50- (BOOL)isTitleQueryExact {
 51  return [self boolValueForParameterWithName:kExactTitleParamName
 52                                defaultValue:NO];
 53}
 54
 55- (void)setIsTitleQueryExact:(BOOL)flag {
 56  [self addCustomParameterWithName:kExactTitleParamName
 57                         boolValue:flag
 58                      defaultValue:NO];
 59}
 60
 61// list feed parameters
 62- (void)setSpreadsheetQuery:(NSString *)queryStr {
 63  [self addCustomParameterWithName:kSpreadsheetQueryParamName
 64                             value:queryStr];
 65}
 66
 67- (NSString *)spreadsheetQuery {
 68  return [self valueForParameterWithName:kSpreadsheetQueryParamName];
 69}
 70
 71- (void)setIsReverseSort:(BOOL)isReverse {
 72  [self addCustomParameterWithName:kReverseParamName
 73                         boolValue:isReverse
 74                      defaultValue:NO];
 75}
 76
 77- (BOOL)isReverseSort {
 78  return [self boolValueForParameterWithName:kReverseParamName
 79                                defaultValue:NO];
 80}
 81
 82// cell feed parameters
 83- (NSString *)stringParamOrNilForInt:(NSInteger)val {
 84  if (val > 0) {
 85    return [NSString stringWithFormat:@"%ld", (long)val]; 
 86  }
 87  return nil;
 88}
 89
 90- (void)setMinimumRow:(NSInteger)val {
 91  [self addCustomParameterWithName:kMinRowParamName
 92                             value:[self stringParamOrNilForInt:val]];
 93}
 94
 95- (NSInteger)minimumRow {
 96  return [self intValueForParameterWithName:kMinRowParamName
 97                      missingParameterValue:0];
 98}
 99
100- (void)setMaximumRow:(NSInteger)val {
101  [self addCustomParameterWithName:kMaxRowParamName
102                             value:[self stringParamOrNilForInt:val]];
103}
104
105- (NSInteger)maximumRow {
106  return [self intValueForParameterWithName:kMaxRowParamName
107                      missingParameterValue:0];
108}
109
110
111- (void)setMinimumColumn:(NSInteger)val {
112  [self addCustomParameterWithName:kMinColParamName
113                             value:[self stringParamOrNilForInt:val]];
114}
115
116- (NSInteger)minimumColumn {
117  return [self intValueForParameterWithName:kMinColParamName
118                      missingParameterValue:0];
119}
120
121- (void)setMaximumColumn:(NSInteger)val {
122  [self addCustomParameterWithName:kMaxColParamName
123                             value:[self stringParamOrNilForInt:val]];
124}
125
126- (NSInteger)maximumColumn {
127  return [self intValueForParameterWithName:kMaxColParamName
128                      missingParameterValue:0];
129}
130
131- (void)setRange:(NSString *)str {
132  [self addCustomParameterWithName:kRangeParamName
133                             value:str];
134}
135- (NSString *)range {
136  return [self valueForParameterWithName:kRangeParamName];
137}
138
139- (void)setShouldReturnEmpty:(BOOL)flag {
140  [self addCustomParameterWithName:kReturnEmptyParamName
141                         boolValue:flag
142                      defaultValue:NO];
143}
144- (BOOL)shouldReturnEmpty {
145  return [self boolValueForParameterWithName:kReturnEmptyParamName
146                                defaultValue:NO];
147}
148
149
150@end
151
152#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE