Packagecom.almirun.common.util
Classpublic class StringManipulator

Class containing static utility methods for dealing with strings.



Public Methods
 MethodDefined by
  
addSlashes(str:String):String
[static]
StringManipulator
  
chop(str:String):String
[static]
StringManipulator
  
chunkSplit(body:String, chunkLength:int = 76, end:String = " "):String
[static] Split a string into smaller chunks

Can be used to split a string into smaller chunks which is useful for e.g.

StringManipulator
  
countChars(str:String):Array
[static] Return an array containing totals of each character used in a string

Counts the number of occurrences of every character, and returns them as an array.

StringManipulator
  
countWords(str:String):Array
[static] Return an array containing totals of each word used in a string

Counts the number of occurrences of every word, and returns them as an array.

StringManipulator
  
isSpace(chr:String):Boolean
[static]
StringManipulator
  
ltrim(str:String):String
[static]
StringManipulator
  
rtrim(str:String):String
[static]
StringManipulator
  
sprintf(format:String, ... args):String
[static]
StringManipulator
  
trim(str:String):String
[static]
StringManipulator
  
vsprintf(format:String, args:Array):String
[static]
StringManipulator
  
zerofill(num:int, decimalPlaces:int):String
[static] Adds zeroes in front of a number
StringManipulator
Method detail
addSlashes()method
public static function addSlashes(str:String):StringParameters
str:String

Returns
String
chop()method 
public static function chop(str:String):StringParameters
str:String

Returns
String
chunkSplit()method 
public static function chunkSplit(body:String, chunkLength:int = 76, end:String = " "):String

Split a string into smaller chunks

Can be used to split a string into smaller chunks which is useful for e.g. converting base64_encode() output to match RFC 2045 semantics. It inserts end every chunklen characters.

Parameters
body:String — The string to be chunked
 
chunkLength:int (default = 76) — The chunk length. Default to 76.
 
end:String (default = " ") — The line ending sequence. Defaults to "\r\n".

Returns
String
countChars()method 
public static function countChars(str:String):Array

Return an array containing totals of each character used in a string

Counts the number of occurrences of every character, and returns them as an array. Note that this is the same as the PHP function count_chars() with the default mode 0 - modes are not implemented.

Parameters
str:String — The string to inspect for character counting

Returns
Array — An associative array in which the keys are the characters found, and the values are the number of times in which each character was used.
countWords()method 
public static function countWords(str:String):Array

Return an array containing totals of each word used in a string

Counts the number of occurrences of every word, and returns them as an array. Inspired by PHP's count_chars(), except for words rather than characters. I think this could be useful for writers to make sure they don't use the same words over and over.

Note: a word is defined as any sequence of characters bounded by regexp's \w.

Parameters
str:String — The string to inspect for word counting

Returns
Array — An associative array in which the keys are the words found, and the values are the number of times in which each word was used.
isSpace()method 
public static function isSpace(chr:String):BooleanParameters
chr:String

Returns
Boolean
ltrim()method 
public static function ltrim(str:String):StringParameters
str:String

Returns
String
rtrim()method 
public static function rtrim(str:String):StringParameters
str:String

Returns
String
sprintf()method 
public static function sprintf(format:String, ... args):StringParameters
format:String
 
... args

Returns
String
trim()method 
public static function trim(str:String):StringParameters
str:String

Returns
String
vsprintf()method 
public static function vsprintf(format:String, args:Array):StringParameters
format:String
 
args:Array

Returns
String
zerofill()method 
public static function zerofill(num:int, decimalPlaces:int):String

Adds zeroes in front of a number

Parameters
num:int — The number to be zero-filled.
 
decimalPlaces:int — The minimum number of characters in the returned number-String.

Returns
String — A string representation of the number, with zeroes added to the front as padding.