– Common Function Library Project

IsCFCType(objectToCheck, type[, checkFullName])

Last updated December 23, 2002


Nathan Dintenfass

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Given a variable and a type to check for, this UDF returns a boolean value for whether the given variable is a component of the given type. You can use either "long notation" (i.e.: "org.bacfug.myCFC"), which will check for the complete component type, or you can use "short notation" (i.e.: "myCFC"), which will check only the name of the component, without concern for where it sits in the directory hierarchy. If you want to force full name checking, regardles off using long or short notation, pass a boolean value as an optional third argument.

Return Values:
Returns a boolean.


    //create a component instance
    myCFC = createObject("component","CFIDE.componentutils.utils");
    //which types shall we check?
    typesToCheck = arrayNew(1);
    typesToCheck[1] = "utils";
    typesToCheck[2] = "CFIDE.componentutils.utils";
    typesToCheck[3] = "banana";
    typesToCheck[4] = "org.bacfug.utils";

<!--- loop through the types to check, checking each one --->
<cfloop from="1" to="#arrayLen(typesToCheck)#" index="ii">
    <cfset thisType = typesToCheck[ii]>
        Is myCFC a <em>#thisType#</em>?: #yesNoFormat(isCFCType(myCFC,thisType))#<br />

<cfdump var="#getMetaData(myCFC)#">


Name Description Required
objectToCheck CFC instance to check. Yes
type String name of CFC. Yes
checkFullName Boolean specifying if type should only match for the full name of the CFC. Defaults to false. If any value is passed, checkFullname is true. No

Full UDF Source:

 * Checks if a given variable is a specific CFC type
 * @param objectToCheck      CFC instance to check. (Required)
 * @param type      String name of CFC. (Required)
 * @param checkFullName      Boolean specifying if type should only match for the full name of the CFC. Defaults to false. If any value is passed, checkFullname is true. (Optional)
 * @return Returns a boolean. 
 * @author Nathan Dintenfass ( 
 * @version 1, December 23, 2002 
function isCFCType(objectToCheck,type){
    //get the meta data of the object we're inspecting (we use duplicate so we don't mess with the instance)
    var metaData = getMetaData(arguments.objectToCheck);
    //are we going to check for a full name, or just the end?
    var checkFullName = true;
    //which component are we checking? (used to allow traversing the "extends" for extended components)
    var metaToCheck = metaData;
    //which name shall we check?
    var nameToCheck =;
    //if the arguments.type has no periods, don't check the full name
    if(listLen(arguments.type,".") LTE 1)
        checkFullName = false;
    //allow a third argument to force the checkFullName
    if(structCount(arguments) GT 2)
        checkFullName = arguments[3];
    //if it's an object, see if it's the right kind of component
        //if it has a type, and that type is "component", then it's a component, so we then look at the type
        if(structKeyExists(metaData,"type") AND metaData.type is "component"){    
            //do a while loop to be sure we see if this component extends the type we want
                //if we are not checking the full name, then take only the last element in the full name
                if(NOT checkFullName)
                    nameToCheck = listLast(,".");
                    nameToCheck =;
                //if the name of the component we're looking at is the type we're looking for, return true
                if(nameToCheck is arguments.type)
                    return true;
                //set this to the extends of the current component to traverse the meta data tree    
                metaToCheck = metaToCheck.extends;    
    //if we've gotten here, it must not have been a the right kind of object
    return false;        


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson