CPString Class Reference
[Foundation]

An immutable string (collection of characters). More...

List of all members.

Public Member Functions

(BOOL) - boolValue [implementation]
(CPString- capitalizedString [implementation]
(CPComparisonResult) - caseInsensitiveCompare: [implementation]
(CPString- characterAtIndex: [implementation]
(CPString- commonPrefixWithString: [implementation]
(CPString- commonPrefixWithString:options: [implementation]
(CPComparisonResult) - compare: [implementation]
(CPComparisonResult) - compare:options: [implementation]
(CPComparisonResult) - compare:options:range: [implementation]
(CPArray- componentsSeparatedByString: [implementation]
(CPString- copy [implementation]
(CPString- cssString [implementation]
(CPString- description [implementation]
(double) - doubleValue [implementation]
(float) - floatValue [implementation]
(BOOL) - hasPrefix: [implementation]
(BOOL) - hasSuffix: [implementation]
(id) - initWithFormat: [implementation]
(id) - initWithString: [implementation]
(int) - intValue [implementation]
(BOOL) - isEqualToString: [implementation]
(CPString- lastPathComponent [implementation]
(int) - length [implementation]
(CPString- lowercaseString [implementation]
(JSObject) - objectFromJSON [implementation]
(CPArray- pathComponents [implementation]
(CPString- pathExtension [implementation]
(CPRange) - rangeOfString: [implementation]
(CPRange) - rangeOfString:options: [implementation]
(CPRange) - rangeOfString:options:range: [implementation]
(CGSize) - sizeWithFont: [implementation]
(CGSize) - sizeWithFont:inWidth: [implementation]
(CPString- string [implementation]
(CPString- stringByAppendingFormat: [implementation]
(CPString- stringByAppendingString: [implementation]
(CPString- stringByDeletingLastPathComponent [implementation]
(CPString- stringByEscapingRegexControlCharacters [implementation]
(CPString- stringByPaddingToLength:withString:startingAtIndex: [implementation]
(CPString- stringByReplacingCharactersInRange:withString: [implementation]
(CPString- stringByReplacingOccurrencesOfString:withString: [implementation]
(CPString- stringByReplacingOccurrencesOfString:withString:options:range: [implementation]
(CPString- stringByStandardizingPath [implementation]
(CPString- stringByTrimmingWhitespace [implementation]
(CPString- substringFromIndex: [implementation]
(CPString- substringToIndex: [implementation]
(CPString- substringWithRange: [implementation]
(unsigned) - UID [implementation]
(CPString- uppercaseString [implementation]

Static Public Member Functions

(CPString+ JSONFromObject: [implementation]
(id) + stringWithFormat: [implementation]
(id) + stringWithHash: [implementation]
(id) + stringWithString: [implementation]
(CPString+ UUID [implementation]

Detailed Description

An immutable string (collection of characters).

A case insensitive search

Exact character match

Start searching from the end of the string

Numbers in the string are compared as numbers instead of strings

CPString is an object that allows management of strings. Because CPString is based on the JavaScript String object, CPStrings are immutable, although the class does have methods that create new CPStrings generated from modifications to the receiving instance.

A handy feature of CPString instances is that they can be used wherever a JavaScript is required, and vice versa.

Definition at line 28 of file CPStringDrawing.j.


Member Function Documentation

- (BOOL) boolValue   [implementation]

Returns YES on encountering one of "Y", "y", "T", "t", or a digit 1-9. Returns NO otherwise. This method skips the initial whitespace characters, +,- followed by Zeroes.

Definition at line 623 of file CPString.j.

- (CPString) capitalizedString   [implementation]

Returns a copy of the receiver with all the first letters of words capitalized.

Definition at line 581 of file CPString.j.

- (CPComparisonResult) caseInsensitiveCompare: (CPString aString   [implementation]

Definition at line 451 of file CPString.j.

- (CPString) characterAtIndex: (unsigned)  anIndex   [implementation]

Returns the character at the specified index.

Parameters:
anIndex the index of the desired character

Definition at line 184 of file CPString.j.

- (CPString) commonPrefixWithString: (CPString aString   [implementation]

Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren't equivalent.

Parameters:
aString the string with which to compare the receiver

Definition at line 545 of file CPString.j.

- (CPString) commonPrefixWithString: (CPString aString
options: (int)  aMask 
[implementation]

Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren't equivalent.

Parameters:
aString the string with which to compare the receiver
aMask options for comparision

Definition at line 556 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString   [implementation]

Compares the receiver to the specified string.

Parameters:
aString the string with which to compare
Returns:
the result of the comparison

Definition at line 440 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString
options: (int)  aMask 
[implementation]

Compares the receiver to the specified string, using options.

Parameters:
aString the string with which to compare
aMask the options to use for the comparison
Returns:
the result of the comparison

Definition at line 462 of file CPString.j.

- (CPComparisonResult) compare: (CPString aString
options: (int)  aMask
range: (CPRange)  range 
[implementation]

Compares the receiver to the specified string, using options in range.

Parameters:
aString the string with which to compare the range of the receiver specified by range.
aMask the options to use for the comparison
range the range of the receiver over which to perform the comparison. The range must not exceed the bounds of the receiver.
Returns:
the result of the comparison

Definition at line 488 of file CPString.j.

- (CPArray) componentsSeparatedByString: (CPString aString   [implementation]

Tokenizes the receiver string using the specified delimiter. For example, if the receiver is: "arash.francisco.ross.tom" and the delimiter is: "." the returned array would contain:

 ["arash", "francisco", "ross", "tom"] 
Parameters:
the delimiter
Returns:
the array of tokens

Definition at line 260 of file CPString.j.

- (CPString) copy   [implementation]

Definition at line 707 of file CPString.j.

- (CPString) cssString   [implementation]

Returns the string

Definition at line 33 of file CPStringDrawing.j.

- (CPString) description   [implementation]

Returns a description of this CPString object.

Definition at line 167 of file CPString.j.

- (double) doubleValue   [implementation]

Returns the text as a floating point value.

Definition at line 613 of file CPString.j.

- (float) floatValue   [implementation]

Returns the text as a float point value.

Definition at line 632 of file CPString.j.

- (BOOL) hasPrefix: (CPString aString   [implementation]

Returns YES if the receiver starts with the specified string. If aString is empty, the method will return NO.

Definition at line 501 of file CPString.j.

- (BOOL) hasSuffix: (CPString aString   [implementation]

Returns NO if the receiver ends with the specified string. If aString is empty, the method will return NO.

Definition at line 511 of file CPString.j.

- (id) initWithFormat: (CPString format
,   ... 
[implementation]

Initializes a string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated.

Parameters:
format the format to be used, printf-style
Returns:
the initialized CPString

Definition at line 139 of file CPString.j.

- (id) initWithString: (CPString aString   [implementation]

Initializes the string with data from the specified string.

Parameters:
aString the string to copy data from
Returns:
the initialized CPString

Definition at line 129 of file CPString.j.

- (int) intValue   [implementation]

Returns the text as an integer

Definition at line 640 of file CPString.j.

- (BOOL) isEqualToString: (CPString aString   [implementation]

Returns YES if the specified string contains the same characters as the receiver.

Definition at line 519 of file CPString.j.

+ (CPString) JSONFromObject: (JSObject)  anObject   [implementation]

Returns a string representing the supplied JavaScript object encoded as JSON.

Definition at line 720 of file CPString.j.

- (CPString) lastPathComponent   [implementation]

Returns the last component of this string. This method assumes that the string's content is a '/' separated file system path.

Definition at line 675 of file CPString.j.

- (int) length   [implementation]

Returns the number of UTF-8 characters in the string.

Definition at line 175 of file CPString.j.

- (CPString) lowercaseString   [implementation]

Returns a copy of the string with all its characters made lower case.

Definition at line 597 of file CPString.j.

- (JSObject) objectFromJSON   [implementation]

Returns a JavaScript object decoded from the string's JSON representation.

Definition at line 728 of file CPString.j.

- (CPArray) pathComponents   [implementation]

Returns an the path components of this string. This method assumes that the string's content is a '/' separated file system path.

Definition at line 650 of file CPString.j.

- (CPString) pathExtension   [implementation]

Returns the extension of the file denoted by this string. The '.' is not a part of the extension. This method assumes that the string's contents is the path to a file or just a filename.

Definition at line 665 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString   [implementation]

Finds the range of characters in the receiver where the specified string exists. If the string does not exist in the receiver, the range length will be 0.

Parameters:
aString the string to search for in the receiver
Returns:
the range of charactrs in the receiver

Definition at line 303 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString
options: (int)  aMask 
[implementation]

Finds the range of characters in the receiver where the specified string exists. The search is subject to the options specified in the specified mask which can be a combination of:

    CPCaseInsensitiveSearch
    CPLiteralSearch
    CPBackwardsSearch
    CPAnchoredSearch
    CPNumericSearch
    
Parameters:
aString the string to search for
aMask the options to use in the search
Returns:
the range of characters in the receiver. If the string was not found, the length of the range will be 0.

Definition at line 325 of file CPString.j.

- (CPRange) rangeOfString: (CPString aString
options: (int)  aMask
range: (CPrange)  aRange 
[implementation]

Finds the range of characters in the receiver where the specified string exists in the given range of the receiver.The search is subject to the options specified in the specified mask which can be a combination of:

    CPCaseInsensitiveSearch
    CPLiteralSearch
    CPBackwardsSearch
    CPAnchoredSearch
    CPNumericSearch
    
Parameters:
aString the string to search for
aMask the options to use in the search
aRange the range of the receiver in which to search for
Returns:
the range of characters in the receiver. If the string was not found, the length of the range will be 0.

Definition at line 348 of file CPString.j.

- (CGSize) sizeWithFont: (CPFont aFont   [implementation]

Definition at line 38 of file CPStringDrawing.j.

- (CGSize) sizeWithFont: (CPFont aFont
inWidth: (float)  aWidth 
[implementation]

Definition at line 43 of file CPStringDrawing.j.

- (id) string   [implementation]

Returns the string (self).

Returns a new string

Definition at line 62 of file CPTextField.j.

- (CPString) stringByAppendingFormat: (CPString format
,   ... 
[implementation]

Returns a string made by appending to the reciever a string constructed from a given format string and the floowing arguments

Parameters:
format the format string in printf-style.
Returns:
the initialized CPString

Definition at line 197 of file CPString.j.

- (CPString) stringByAppendingString: (CPString aString   [implementation]

Creates a new CPString from the concatenation of the receiver and the specified string.

Parameters:
aString the string to append to the receiver
Returns:
the new string

Definition at line 210 of file CPString.j.

- (CPString) stringByDeletingLastPathComponent   [implementation]

Deletes the last path component of a string. This method assumes that the string's content is a '/' separated file system path.

Definition at line 686 of file CPString.j.

- (CPString) stringByEscapingRegexControlCharacters   [implementation]

Definition at line 371 of file CPString.j.

- (CPString) stringByPaddingToLength: (unsigned)  aLength
withString: (CPString aString
startingAtIndex: (unsigned)  anIndex 
[implementation]

Returns a new string formed by padding characters or removing them. If the padding length is shorter than the receiver's length, the new string will be trimmed down to the padding length size. If the padding length is longer than the receiver's length, then the new string is repeatedly padded with the characters from the specified string starting at the specified index.

Parameters:
aLength the desired length of the new CPString
aString the padding string to use (if necessary)
anIndex the index of the padding string to start from (if necessary to use)
Returns:
the new padded string

Definition at line 227 of file CPString.j.

- (CPString) stringByReplacingCharactersInRange: (CPRange)  range
withString: (CPString replacement 
[implementation]

Definition at line 420 of file CPString.j.

- (CPString) stringByReplacingOccurrencesOfString: (CPString target
withString: (CPString replacement 
[implementation]

Returns a new string in which all occurrences of a target string in the reciever are replaced by another given string.

Parameters:
target The string to replace.
replacement the string with which to replace the target

Definition at line 383 of file CPString.j.

- (CPString) stringByReplacingOccurrencesOfString: (CPString target
withString: (CPString replacement
options: (int)  options
range: (CPRange)  searchRange 
[implementation]

Definition at line 397 of file CPString.j.

- (CPString) stringByStandardizingPath   [implementation]

Definition at line 702 of file CPString.j.

- (CPString) stringByTrimmingWhitespace   [implementation]

Returns a new string with leading and trailing whitespace trimmed

Definition at line 428 of file CPString.j.

+ (id) stringWithFormat: (CPString format
,   ... 
[implementation]

Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated.

Parameters:
format the format to be used, printf-style
Returns:
the initialized CPString

Definition at line 155 of file CPString.j.

+ (id) stringWithHash: (unsigned)  aHash   [implementation]

Returns a CPString containing the specified hash.

Parameters:
aHash the hash to represent as a string

Definition at line 103 of file CPString.j.

+ (id) stringWithString: (CPString aString   [implementation]

Returns a copy of the specified string.

Parameters:
aString a non-nil string to copy
Exceptions:
CPInvalidArgumentException if aString is nil
Returns:
the new CPString

Definition at line 115 of file CPString.j.

- (CPString) substringFromIndex: (unsigned)  anIndex   [implementation]

Returns a substring starting from the specified index to the end of the receiver.

Parameters:
anIndex the starting string (inclusive)
Returns:
the substring

Definition at line 270 of file CPString.j.

- (CPString) substringToIndex: (unsigned)  anIndex   [implementation]

Creates a substring from the beginning of the receiver to the specified index.

Parameters:
anIndex the last index of the receiver to use for the substring (inclusive)
Returns:
the substring

Definition at line 290 of file CPString.j.

- (CPString) substringWithRange: (CPRange)  aRange   [implementation]

Returns a substring starting from the specified range location to the range length.

Parameters:
the range of the substring
Returns:
the substring

Definition at line 280 of file CPString.j.

- (unsigned) UID   [implementation]

Returns a hash of the string instance.

Definition at line 527 of file CPString.j.

- (CPString) uppercaseString   [implementation]

Returns a copy of the string with all its characters made upper case.

Definition at line 605 of file CPString.j.

+ (CPString) UUID   [implementation]

Returns a randomly generated Universally Unique Identifier.

Definition at line 741 of file CPString.j.


The documentation for this class was generated from the following files:

Generated on Fri Apr 9 11:04:22 2010 for Cappuccino API by  doxygen 1.6.1