CFLib.org – Common Function Library Project

IsCFC(objectToCheck)

Last updated October 16, 2002

Version: 1 | Requires: ColdFusion MX | Library: DataManipulationLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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;        
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
4 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson