/examples/api_jsonxml/resources/AnythingToXML/TabUtils.cfc

http://github.com/atuttle/Taffy · ColdFusion CFScript · 55 lines · 47 code · 8 blank · 0 comment · 1 complexity · 9a069bb1337f1466e15eb4f74f58e75c MD5 · raw file

  1. <cfcomponent displayname="TabUtils" namespace="TabUtils" output="no">
  2. <!--- Tab Utilities by Daniel Gaspar <daniel.gaspar@gmail.com> 5/1/2008 --->
  3. <!--- Keeps track of tabs 'n prints them -Dg--->
  4. <!---
  5. Copyright 2008 Daniel Gaspar Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License. You may obtain a copy of the
  7. License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or
  8. agreed to in writing, software distributed under the License is distributed on an "AS IS"
  9. BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  10. for the specific language governing permissions and limitations under the License.
  11. --->
  12. <cfproperty name="tabs" default="0" type="numeric" />
  13. <cffunction name="init" access="public" output="no" returntype="any">
  14. <cfargument name="tabs" type="numeric" required="no" default="0" />
  15. <cfset this.tabs = arguments.tabs />
  16. <cfreturn this>
  17. </cffunction>
  18. <cffunction name="setTabs" access="public" output="no" returntype="any">
  19. <cfargument name="tabs" type="numeric" required="no" default="#this.tabs#" />
  20. <cfset this.tabs = arguments.tabs />
  21. </cffunction>
  22. <cffunction name="addtab" access="public" output="no" returntype="void">
  23. <cfargument name="num" type="numeric" required="no" default="1" />
  24. <cfset this.tabs = this.tabs + arguments.num />
  25. </cffunction>
  26. <cffunction name="removetab" access="public" output="no" returntype="void">
  27. <cfargument name="num" type="numeric" required="no" default="1" />
  28. <cfset this.tabs = this.tabs - arguments.num />
  29. </cffunction>
  30. <cffunction name="printtabs" access="public" output="no" returntype="string" >
  31. <cfargument name="tabs" type="numeric" required="no" default="#this.tabs#" />
  32. <cfset var returnstring = "" />
  33. <cfset var i = 1 />
  34. <!---<cfif this.tabs gt 0 > --->
  35. <cfprocessingdirective suppresswhitespace="yes">
  36. <cfsetting enablecfoutputonly="yes">
  37. <cfsavecontent variable="returnstring" >
  38. <cfoutput>#chr(10)#</cfoutput>
  39. <cfloop from="1" to="#arguments.tabs#" index="i" >
  40. <cfoutput>#chr(09)#</cfoutput>
  41. </cfloop>
  42. </cfsavecontent>
  43. </cfprocessingdirective>
  44. <!---</cfif>--->
  45. <cfreturn returnstring>
  46. </cffunction>
  47. </cfcomponent>