CFLib.org – Common Function Library Project

IsCFC(objectToCheck)

Last updated October 16, 2002

author

Nathan Dintenfass

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Description:
Pass it any CF variable, it returns a boolean value to tell you if it is a CFC instance.

Return Values:
Returns a boolean.

Example:

<cfscript>
    cfc = createObject("component","cflib.udf");
    str = createObject("java","java.lang.String");
</cfscript>

<cfoutput>
    isCFC(cfc) = #isCFC(cfc)#<br>
    isCFC(str) = #isCFC(str)#<br>
    isCFC(structNew()) = #isCFC(structNew())#<br>
</cfoutput>

Parameters:

Name Description Required
objectToCheck The object to check. Yes

Full UDF Source:

/**
 * Returns a boolean for whether a CF variable is a CFC instance.
 * 
 * @param objectToCheck      The object to check. (Required)
 * @return Returns a boolean. 
 * @author Nathan Dintenfass (nathan@changemedia.com) 
 * @version 1, October 16, 2002 
 */
function IsCFC(objectToCheck){
    //get the meta data of the object we're inspecting
    var metaData = getMetaData(arguments.objectToCheck);
    //if it's an object, let's try getting the meta Data
    if(isObject(arguments.objectToCheck)){
        //if it has a type, and that type is "component", then it's a component
        if(structKeyExists(metaData,"type") AND metaData.type is "component"){
            return true;
        }
    }    
    //if we've gotten here, it must not have been a contentObject            
    return false;        
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson