bdw429s
11/03/2022, 8:15 PMisObject()
BIF in CF returns true
for basically any unrecognized Java class which makes it sort of useless in many instances where a framework needs to deal smartly with any sort of input.bdw429s
11/03/2022, 8:16 PMgetMetaData()
without error and you'll basically get back a java.lang.Class
that represents what the class is (differs for static refences vs instances)bdw429s
11/03/2022, 8:17 PMwebsolete
11/03/2022, 8:18 PMwebsolete
11/03/2022, 8:18 PMbdw429s
11/03/2022, 8:20 PMisValid()
may be what I'm after. It's a little odd that CFML has isEverythingElseUnderTheSun()
but not isComponen()
bdw429s
11/03/2022, 8:22 PMisObject()
was a little ambiguous since in Java EVERYTHING'S an object, even strings!bdw429s
11/03/2022, 8:23 PMisObject()
will return true for java.lang.System
, but not java.lang.String
!bdw429s
11/03/2022, 8:24 PMwebsolete
11/03/2022, 8:25 PM/**
* Returns the datatype of the object's value
*
* @value any the value whose datatype to determine
*
* @return string the datatype of the provided argument
*/
public string function getDatatype( required any value ) output=false {
if( isValid( "array", arguments.value ) ) { return 'Array'; }
else if( isValid( "binary", arguments.value ) ) { return 'Binary'; }
else if( isValid( "numeric", arguments.value ) ) { return 'Numeric'; }
else if( isValid( "date", arguments.value ) ) { return 'Date'; }
else if( isValid( "query", arguments.value ) ) { return 'Query'; }
else if( isValid( "struct", arguments.value ) ) { return 'Struct'; }
else if( isWDDX( arguments.value ) ) { return 'WDDX'; }
else if( isJSON( arguments.value ) ) { return 'JSON'; }
else if( isValid( "boolean", arguments.value ) ) { return 'Boolean'; }
else if( isValid( "component", arguments.value ) ) { return 'Component'; }
else if( isCustomFunction( arguments.value ) ) { return 'Function'; }
else if( isSimpleValue( arguments.value ) ) { return 'String'; }
else { return 'Unknown'; }
}
bdw429s
11/03/2022, 8:26 PMisClosure()
should probably apply to Function
abovewebsolete
11/03/2022, 8:27 PMbdw429s
11/03/2022, 8:27 PMisCustomFunction()
and isClosure()
websolete
11/03/2022, 8:27 PMbdw429s
11/03/2022, 8:27 PMisUDF()
all along IMObdw429s
11/03/2022, 8:28 PMbdw429s
11/03/2022, 8:28 PMAdam Cameron
isInstanceOf
? https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-in-k/isinstanceof.htmlbdw429s
11/03/2022, 10:44 PMNote: The isInstanceOf function returns false if the CFC specified by the object parameter does not define any functions.Like... why?
bdw429s
11/03/2022, 10:49 PMCFSCRIPT-REPL: IsInstanceOf(23324,'Component')
false
CFSCRIPT-REPL: IsInstanceOf(new query(),'Component')
true
CFSCRIPT-REPL: IsInstanceOf(new http(),'Component')
true
CFSCRIPT-REPL: IsInstanceOf('sdf','Component')
false
CFSCRIPT-REPL: IsInstanceOf([],'Component')
false
CFSCRIPT-REPL: IsInstanceOf({},'Component')
false
CFSCRIPT-REPL: IsInstanceOf(xmlNew(),'Component')
false
CFSCRIPT-REPL: IsInstanceOf(createObject('java','java.lang.System'),'Component')
false
It seems it will accept pretty much any input without blowing upgamesover
11/04/2022, 4:40 PM