• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need detailed information about structure functions

New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

I am a beginner in learning cf. I want to know the details of the structure functions like why they are used, what are the parameters and their internal logic

Views

289

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

Hi

I have moved your post from the Lounge , which is for non-technical questions, to the Cold Fusion forum

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

You can find the parameters listed in the documentation. Why they are used is usually pretty self-explanatory, but not in all cases.

ColdFusion Help | Structure functions

Beyond the documentation alone, I'd have to recommend a book or a class if you're interested in that level of detail about why structure functions are used.

As for the internal logic, why on earth would you need that? The whole point of functions is that you shouldn't need to understand the internals to use the functions themselves. I've been using CF for twenty-two years without needing to know the internal logic of a built-in function.

Dave Watts, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

Thanks Dave for the information. I was trying to convert StructGetMetaData function into its equivalent Java code. That's the reason why I need the detailed information and internal logic to proceed further.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

If I recall correctly, Java doesn't have structures. So I'm not sure how useful you'd find the internals of the functions without the internals of the rest of the language (the CF runtime, basically).

Dave Watts, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2018 Jun 03, 2018

Copy link to clipboard

Copied

LATEST

saig243  wrote

I was trying to convert StructGetMetaData function into its equivalent Java code. That's the reason why I need the detailed information and internal logic to proceed further.

ColdFusion is itself a Java application. What it exposes as the method structGetMetadata is the result of some nifty, often complex, Java coding under the hood. Luckily for us, by encapsulating all the Java details and exposing just the functionality of structGetMetadata, ColdFusion spares us the complexity.

You can usually get the underlying Java class of a ColdFusion object by calling the methods

getClass().getName()

getClass().getSuperClass().getName()

To illustrate, take the example from Adobe's documentation on StructGetMetaData. If you run the code below, you will see the following Java class hierarchy:

structGetMetadata

    is a subclass of coldfusion.runtime.CFPageMethod

      is a subclass of java.lang.Object

example (an ordered struct)

    is a subclass of coldfusion.runtime.StructOrdered

      is a subclass of coldfusion.runtime.Struct

          is a subclass of coldfusion.util.CaseInsensitiveMap

myMetadata (struct metadata)

    is a subclass of coldfusion.runtime.CaseInsensitiveMap

        is a subclass of java.lang.Object

<cfscript>

   example = structnew("ordered");

   example.firstname = "Yes";

   example.lastname = "Man";

   // set the metadata for the struct keys

   metadata = {firstname: {type:"string",name:"fname"},lastname:{name:"lname"}};

   structSetMetaData(example,metadata);

   // retrieve the metadata for the keys and display

   myMetadata=structGetMetaData(example);

   // assign variable to the function

   functionVar =  structGetMetaData;

   writedump(var=functionVar, label="method: structGetMetadata");

   writeoutput("functionVar.getClass().getName(): " & functionVar.getClass().getName() & "<br>");

   writeoutput("functionVar.getClass().getsuperclass().getName(): " & functionVar.getClass().getsuperclass().getName() & "<br>" & "<br>");  

   writedump(var=example, label="struct: example");

   writeoutput("example.getClass().getName(): " & example.getClass().getName() & "<br>");

   writeoutput("example.getClass().getsuperclass().getName(): " & example.getClass().getsuperclass().getName() & "<br>");

   writeoutput("example.getClass().getsuperclass().getsuperclass().getName(): " & example.getClass().getsuperclass().getsuperclass().getName() & "<br>" & "<br>");   

   writedump(var=myMetadata, label="struct metadata: myMetadata");

   writeoutput("myMetadata.getClass().getName(): " & myMetadata.getClass().getName() & "<br>");

   writeoutput("myMetadata.getClass().getsuperclass().getName(): " & myMetadata.getClass().getsuperclass().getName());   

</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation