ObjectUtil

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:10/27/08
Author:Aaron Clinger, David Nelson
Classpath:org.casalib.util.ObjectUtil
File last modified:Wednesday, 31 December 2008, 20:18:28
Utilities for working with Objects.

Summary


Class methods
  • contains (obj:Object, member:Object) : Boolean
    • Searches the first level properties of an object for a another object.
  • clone (obj:Object) : Object
    • Makes a clone of the original Object.
  • getKeys (obj:Object) : Array
    • Creates an Array comprised of all the keys in an Object.
  • isUndefined (obj:Object) : Boolean
    • Uses the strict equality operator to determine if object is undefined.
  • isNull (obj:Object) : Boolean
    • Uses the strict equality operator to determine if object is null.
  • isEmpty (obj:*) : Boolean
    • Determines if object contains no value(s).

Class methods

clone

public static function clone (
obj:Object) : Object

Makes a clone of the original Object.
Parameters:
obj:
Object to make the clone of.
Returns:
  • Returns a duplicate Object.
Example:
  • this._author      = new Person();
    this._author.name = "Aaron";
    
    registerClassAlias("Person", Person);
    
    var humanClone:Person = Person(ObjectUtil.clone(this._author));
    
    trace(humanClone.name);

contains

public static function contains (
obj:Object, member:Object) : Boolean

Searches the first level properties of an object for a another object.
Parameters:
obj :
Object to search in.
member:
Object to search for.
Returns:
  • Returns true if object was found; otherwise false.

getKeys

public static function getKeys (
obj:Object) : Array

Creates an Array comprised of all the keys in an Object.
Parameters:
obj:
Object in which to find keys.
Returns:
  • Array containing all the string key names.

isEmpty

public static function isEmpty (
obj:*) : Boolean

Determines if object contains no value(s).
Parameters:
obj:
Object to derimine if empty.
Returns:
  • Returns true if object is empty; otherwise false.
Example:
  • var testNumber:Number;
    var testArray:Array   = new Array();
    var testString:String = "";
    var testObject:Object = new Object();
    
    trace(ObjectUtil.isEmpty(testNumber)); // traces "true"
    trace(ObjectUtil.isEmpty(testArray));  // traces "true"
    trace(ObjectUtil.isEmpty(testString)); // traces "true"
    trace(ObjectUtil.isEmpty(testObject)); // traces "true"

isNull

public static function isNull (
obj:Object) : Boolean

Uses the strict equality operator to determine if object is null.
Parameters:
obj:
Object to determine if null.
Returns:
  • Returns true if object is null; otherwise false.

isUndefined

public static function isUndefined (
obj:Object) : Boolean

Uses the strict equality operator to determine if object is undefined.
Parameters:
obj:
Object to determine if undefined.
Returns:
  • Returns true if object is undefined; otherwise false.