
473
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
<h2>Object Classes</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Superior class</th>
<th>Must have</th>
<th>May have</th>
</tr>
<cfloop index = "thisElement" list =
#Entrylist2.objectclasses#>
<cfscript>
thiselement = Trim(thisElement);
nameloc = Find("NAME", thisElement);
descloc = Find("DESC", thisElement);
suploc = Find("SUP", thisElement);
mustloc = Find("MUST", thisElement);
mayloc = Find("MAY", thisElement);
endloc = Len(thisElement);
</cfscript>
Displays the object class name, superior class, required attributes,
and optional attributes for each object class in a table.
The schema contains the definitions of all object classes in a comma
delimited list, so the code uses a list type cfloop tag.
The thisElement variable contains the object class definition. Trim off
any leading or trailing spaces, then use the class definition field
keywords in Find functions to get the starting locations of the
required fields, including the Object class ID. (The ID is not displayed.)
Gets the length of the
thisElement
string for use in later
calculations.
<tr>
<td><cfoutput>#Mid(thisElement, 6, descloc-
nameloc-8)#
</cfoutput></td>
<cfif #suploc# NEQ 0>
<td><cfoutput>#Mid(thisElement, 5, mustloc-
suploc-7)#
</cfoutput></td>
<cfelse>
<td>NONE</td>
</cfif>
<cfif #mayloc# NEQ 0>
<td><cfoutput>#Replace(Mid(thisElement, 6,
mayloc-mustloc-9), " $ ", ", ",
"all")#</cfoutput></td>
<td><cfoutput>#Replace(Mid(thisElement, 5,
endloc-mayloc-8),
" $ ", ", ", "all")#</cfoutput></td>
<cfelse>
<td><cfoutput>#Replace(Mid(thisElement, 6,
endloc-mustloc-9), " $ ", ", ",
"all")#</cfoutput></td>
<td>NONE</td>
</cfif>
</tr>
</cfloop>
</table>
Displays the field values. Uses the Mid function to extract individual
field values from the thisElement string.
The top object class does not have a superior class entry. Handles this
special case by testing the suploc location variable. If the value is not
0, handles normally, otherwise, output "NONE".
There might not be any optional attributes. Handles this case
similarly to the superior class. The calculation of the location of
required attributes uses the location of the optional attributes if the
field exists; otherwise, uses the end of the object class definition
string.
Code
Description
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...