API 0.9.5
Foundation/CPData.j
Go to the documentation of this file.
00001 /*
00002  * CPData.j
00003  * Foundation
00004  *
00005  * Created by Francisco Tolmasky.
00006  * Copyright 2008, 280 North, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 
00029 @implementation CPData : CPObject
00030 {
00031     id __doxygen__;
00032 }
00033 
00034 + (id)alloc
00035 {
00036     var result = new CFMutableData();
00037     result.isa = [self class];
00038     return result;
00039 }
00040 
00041 + (CPData)data
00042 {
00043     return [[self alloc] init];
00044 }
00045 
00046 + (CPData)dataWithRawString:(CPString)aString
00047 {
00048     return [[self alloc] initWithRawString:aString];
00049 }
00050 
00051 + (CPData)dataWithPlistObject:(id)aPlistObject
00052 {
00053     return [[self alloc] initWithPlistObject:aPlistObject];
00054 }
00055 
00056 + (CPData)dataWithPlistObject:(id)aPlistObject format:(CPPropertyListFormat)aFormat
00057 {
00058     return [[self alloc] initWithPlistObject:aPlistObject format:aFormat];
00059 }
00060 
00061 + (CPData)dataWithJSONObject:(Object)anObject
00062 {
00063     return [[self alloc] initWithJSONObject:anObject];
00064 }
00065 
00066 - (id)initWithRawString:(CPString)aString
00067 {
00068     self = [super init];
00069 
00070     if (self)
00071         [self setRawString:aString];
00072 
00073     return self;
00074 }
00075 
00076 - (id)initWithPlistObject:(id)aPlistObject
00077 {
00078     self = [super init];
00079 
00080     if (self)
00081         [self setPlistObject:aPlistObject];
00082 
00083     return self;
00084 }
00085 
00086 - (id)initWithPlistObject:(id)aPlistObject format:aFormat
00087 {
00088     self = [super init];
00089 
00090     if (self)
00091         [self setPlistObject:aPlistObject format:aFormat];
00092 
00093     return self;
00094 }
00095 
00096 - (id)initWithJSONObject:(Object)anObject
00097 {
00098     self = [super init];
00099 
00100     if (self)
00101         [self setJSONObject:anObject];
00102 
00103     return self;
00104 }
00105 
00106 - (CPString)rawString
00107 {
00108     return self.rawString();
00109 }
00110 
00111 - (id)plistObject
00112 {
00113     return self.propertyList();
00114 }
00115 
00116 - (Object)JSONObject
00117 {
00118     return self.JSONObject();
00119 }
00120 
00121 - (int)length
00122 {
00123     return [[self rawString] length];
00124 }
00125 
00126 - (CPString)description
00127 {
00128     return self.toString();
00129 }
00130 
00131 @end
00132 
00133 @implementation CPData (CPMutableData)
00134 
00135 - (void)setRawString:(CPString)aString
00136 {
00137     self.setRawString(aString);
00138 }
00139 
00140 - (void)setPlistObject:(id)aPlistObject
00141 {
00142     self.setPropertyList(aPlistObject);
00143 }
00144 
00145 - (void)setPlistObject:(id)aPlistObject format:(CPPropertyListFormat)aFormat
00146 {
00147     self.setPropertyList(aPlistObject, aFormat);
00148 }
00149 
00150 - (void)setJSONObject:(Object)anObject
00151 {
00152     self.setJSONObject(anObject);
00153 }
00154 
00155 @end
00156 
00157 @implementation CPData (Deprecated)
00158 
00159 + (id)dataWithString:(CPString)aString
00160 {
00161     _CPReportLenientDeprecation(self, _cmd, @selector(dataWithRawString:));
00162 
00163     return [self dataWithRawString:aString];
00164 }
00165 
00166 - (id)initWithString:(CPString)aString
00167 {
00168     _CPReportLenientDeprecation(self, _cmd, @selector(initWithRawString:));
00169 
00170     return [self initWithRawString:aString];
00171 }
00172 
00173 - (void)setString:(CPString)aString
00174 {
00175     _CPReportLenientDeprecation(self, _cmd, @selector(setRawString:));
00176 
00177     [self setRawString:aString];
00178 }
00179 
00180 - (CPString)string
00181 {
00182     _CPReportLenientDeprecation(self, _cmd, @selector(rawString));
00183 
00184     return [self rawString];
00185 }
00186 
00187 @end
00188 
00189 CFData.prototype.isa = CPData;
00190 CFMutableData.prototype.isa = CPData;
 All Classes Files Functions Variables Defines