Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 09f97f72140bdbc346d8fdb73f8ad446bbb6cb09 @mhenke committed
54 index.cfm
@@ -0,0 +1,54 @@
+<cfsavecontent variable="test">
+<html>
+<head>
+<title>jtidy test page</title>
+</head>
+<body>
+</tr>
+<!-- examples from http://en.wikipedia.org/wiki/XHTML -->
+<table
+id="companyAccountsTable"><tbody><tr><td>mike henke</td></tr></tbody></table>
+<form action="/index.cfm">
+
+<!-- Not putting quotation marks around attribute values -->
+<input type=text value=hello />
+</form>
+
+<!-- Not closing non-empty elements -->
+<p>
+
+<!-- Improperly nesting elements -->
+<em><strong>This is some text.</em></strong>
+
+<!-- Using the ampersand character outside of entities -->
+<div>Cars & Trucks</div>
+
+<!-- Not closing empty elements -->
+<br>
+
+<div>
+<!-- Using the ampersand character outside of entities -->
+<a href="index.cfm?page=news&id=5">News</a>
+</div>
+<div>
+
+<!-- Using attribute minimization -->
+<textarea readonly>READ-ONLY</textarea>
+</div>
+
+<!-- Failing to recognize that XHTML elements and attributes are case sensitive -->
+<P ID="ONE">The Best Page Ever</P>
+</body>
+</html>
+</cfsavecontent>
+
+<cfinvoke
+ component="jtidy"
+ method="makexHTMLValid"
+ strToParse="#test#"
+ returnvariable="validxHTML"
+ >
+<cfdump var="#validxHTML#">
+<cfoutput>
+#validxHTML#
+</cfoutput>
223 javaloader/JavaLoader.cfc
@@ -0,0 +1,223 @@
+<!--- Document Information -----------------------------------------------------
+
+Title: JavaLoader.cfc
+
+Author: Mark Mandel
+Email: mark@compoundtheory.com
+
+Website: http://www.compoundtheory.com
+
+Purpose: Utlitity class for loading Java Classes
+
+Usage:
+
+Modification Log:
+
+Name Date Description
+================================================================================
+Mark Mandel 08/05/2006 Created
+Mark Mandel 22/06/2006 Added verification that the path exists
+
+------------------------------------------------------------------------------->
+<cfcomponent name="JavaLoader" hint="Loads External Java Classes, while providing access to ColdFusion classes">
+
+<cfscript>
+ instance = StructNew();
+ instance.static.uuid = "A0608BEC-0AEB-B46A-0E1E1EC5F3CE7C9C";
+</cfscript>
+
+<!------------------------------------------- PUBLIC ------------------------------------------->
+
+<cffunction name="init" hint="Constructor" access="public" returntype="JavaLoader" output="false">
+ <cfargument name="loadPaths" hint="An array of directories of classes, or paths to .jar files to load" type="array" default="#ArrayNew(1)#" required="no">
+ <cfargument name="loadColdFusionClassPath" hint="Loads the ColdFusion libraries" type="boolean" required="No" default="false">
+ <cfargument name="parentClassLoader" hint="(Expert use only) The parent java.lang.ClassLoader to set when creating the URLClassLoader" type="any" default="" required="false">
+
+ <cfscript>
+ var iterator = arguments.loadPaths.iterator();
+ var file = 0;
+ var classLoader = 0;
+ var networkClassLoaderClass = 0;
+ var networkClassLoaderProxy = 0;
+
+ initUseJavaProxyCFC();
+
+ if(arguments.loadColdFusionClassPath)
+ {
+ //arguments.parentClassLoader = createObject("java", "java.lang.Thread").currentThread().getContextClassLoader();
+ //can't use above, as doesn't work in some... things
+
+ arguments.parentClassLoader = getPageContext().getClass().getClassLoader();
+
+ //arguments.parentClassLoader = createObject("java", "java.lang.ClassLoader").getSystemClassLoader();
+ //can't use the above, it doesn't have the CF stuff in it.
+ }
+
+ ensureNetworkClassLoaderOnServerScope();
+
+ //classLoader = createObject("java", "com.compoundtheory.classloader0.NetworkClassLoader").init();
+ networkClassLoaderClass = getServerURLClassLoader().loadClass("com.compoundtheory.classloader.NetworkClassLoader");
+
+ networkClassLoaderProxy = createJavaProxy(networkClassLoaderClass);
+
+ if(isObject(arguments.parentClassLoader))
+ {
+ classLoader = networkClassLoaderProxy.init(arguments.parentClassLoader);
+ }
+ else
+ {
+ classLoader = networkClassLoaderProxy.init();
+ }
+
+ while(iterator.hasNext())
+ {
+ file = createObject("java", "java.io.File").init(iterator.next());
+ if(NOT file.exists())
+ {
+ throw("PathNotFoundException", "The path you have specified could not be found", file.getAbsolutePath() & " does not exist");
+ }
+
+ classLoader.addUrl(file.toURL());
+ }
+
+ //pass in the system loader
+ setURLClassLoader(classLoader);
+
+ return this;
+ </cfscript>
+</cffunction>
+
+<cffunction name="create" hint="Retrieves a reference to the java class. To create a instance, you must run init() on this object" access="public" returntype="any" output="false">
+ <cfargument name="className" hint="The name of the class to create" type="string" required="Yes">
+ <cfscript>
+ var class = getURLClassLoader().loadClass(arguments.className);
+
+ return createJavaProxy(class);
+ </cfscript>
+</cffunction>
+
+<cffunction name="getURLClassLoader" hint="Returns the java.net.URLClassLoader in case you need access to it" access="public" returntype="any" output="false">
+ <cfreturn instance.ClassLoader />
+</cffunction>
+
+<cffunction name="getVersion" hint="Retrieves the version of the loader you are using" access="public" returntype="string" output="false">
+ <cfreturn "0.6">
+</cffunction>
+
+<!------------------------------------------- PACKAGE ------------------------------------------->
+
+<!------------------------------------------- PRIVATE ------------------------------------------->
+
+<cffunction name="ensureNetworkClassLoaderOnServerScope"
+ hint="makes sure there is a URL class loader on the server scope that can load me up some networkClassLoader goodness"
+ access="private" returntype="void" output="false">
+ <cfscript>
+ var Class = createObject("java", "java.lang.Class");
+ var Array = createObject("java", "java.lang.reflect.Array");
+ var jars = queryJars();
+ var iterator = jars.iterator();
+ var file = 0;
+ var urls = Array.newInstance(Class.forName("java.net.URL"), ArrayLen(jars));
+ var counter = 0;
+ var urlClassLoader = 0;
+ var key = instance.static.uuid & "." & getVersion();
+ //server scope uuid
+
+ //we have it already? escape.
+ if(StructKeyExists(server, key))
+ {
+ return;
+ }
+
+ while(iterator.hasNext())
+ {
+ Array.set(urls, counter, createObject("java", "java.io.File").init(iterator.next()).toURL());
+ counter = counter + 1;
+ }
+
+ urlClassLoader = createObject("java", "java.net.URLClassLoader").init(urls);
+
+ //put it on the server scope
+ server[key] = urlClassLoader;
+ </cfscript>
+</cffunction>
+
+<cffunction name="createJavaProxy" hint="create a javaproxy, dependent on CF server settings" access="private" returntype="any" output="false">
+ <cfargument name="class" hint="the java class to create the proxy with" type="any" required="Yes">
+ <cfscript>
+ if(getUseJavaProxyCFC())
+ {
+ return createObject("component", "JavaProxy")._init(arguments.class);
+ }
+
+ return createObject("java", "coldfusion.runtime.java.JavaProxy").init(arguments.class);
+ </cfscript>
+</cffunction>
+
+<cffunction name="initUseJavaProxyCFC" hint="initialise whether or not to use the JavaProxy CFC instead of the coldfusion java object" access="public" returntype="string" output="false">
+ <cfscript>
+ setUseJavaProxyCFC(false);
+
+ try
+ {
+ createObject("java", "coldfusion.runtime.java.JavaProxy");
+ }
+ catch(Object exc)
+ {
+ setUseJavaProxyCFC(true);
+ }
+ </cfscript>
+</cffunction>
+
+<cffunction name="queryJars" hint="pulls a query of all the jars in the /resources/lib folder" access="private" returntype="array" output="false">
+ <cfscript>
+ var qJars = 0;
+ //the path to my jar library
+ var path = getDirectoryFromPath(getMetaData(this).path) & "lib/";
+ var jarList = "";
+ var aJars = ArrayNew(1);
+ var libName = 0;
+ </cfscript>
+
+ <cfdirectory action="list" name="qJars" directory="#path#" filter="*.jar" sort="name desc"/>
+ <cfloop query="qJars">
+ <cfscript>
+ libName = ListGetAt(name, 1, "-");
+ //let's not use the lib's that have the same name, but a lower datestamp
+ if(NOT ListFind(jarList, libName))
+ {
+ ArrayAppend(aJars, path & "/" & name);
+ jarList = ListAppend(jarList, libName);
+ }
+ </cfscript>
+ </cfloop>
+
+ <cfreturn aJars>
+</cffunction>
+
+<cffunction name="getServerURLClassLoader" hint="returns the server URL class loader" access="private" returntype="any" output="false">
+ <cfreturn server[instance.static.uuid & "." & getVersion()] />
+</cffunction>
+
+<cffunction name="setURLClassLoader" access="private" returntype="void" output="false">
+ <cfargument name="ClassLoader" type="any" required="true">
+ <cfset instance.ClassLoader = arguments.ClassLoader />
+</cffunction>
+
+<cffunction name="getUseJavaProxyCFC" access="private" returntype="boolean" output="false">
+ <cfreturn instance.UseJavaProxyCFC />
+</cffunction>
+
+<cffunction name="setUseJavaProxyCFC" access="private" returntype="void" output="false">
+ <cfargument name="UseJavaProxyCFC" type="boolean" required="true">
+ <cfset instance.UseJavaProxyCFC = arguments.UseJavaProxyCFC />
+</cffunction>
+
+<cffunction name="throw" access="private" hint="Throws an Exception" output="false">
+ <cfargument name="type" hint="The type of exception" type="string" required="Yes">
+ <cfargument name="message" hint="The message to accompany the exception" type="string" required="Yes">
+ <cfargument name="detail" type="string" hint="The detail message for the exception" required="No" default="">
+ <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#">
+</cffunction>
+
+</cfcomponent>
354 javaloader/JavaProxy.cfc
@@ -0,0 +1,354 @@
+<!--- Document Information -----------------------------------------------------
+
+Title: JavaProxy.cfc
+
+Author: Mark Mandel
+Email: mark@compoundtheory.com
+
+Website: http://www.compoundtheory.com
+
+Purpose: JavaProxy to replace the ColdFusion one when you don't have access
+ to coldfusion.* packages due to CF8 settings.
+
+Usage:
+
+Modification Log:
+
+Name Date Description
+================================================================================
+Mark Mandel 27/08/2007 Created
+
+------------------------------------------------------------------------------->
+
+<cfcomponent output="false">
+
+<!---
+ All CF based methods have a _ in front, so that they don't interfere with the possible Java
+ calls
+ --->
+
+<cffunction name="_init" hint="Constructor" access="public" returntype="JavaProxy" output="false">
+ <cfargument name="class" hint="the java.lang.Class object this represents" type="any" required="Yes">
+ <cfscript>
+ var classLoader = createObject("java", "java.lang.ClassLoader").getSystemClassLoader();
+ var objectClass = classLoader.loadClass("java.lang.Object");
+
+ _setArray(createObject("java", "java.lang.reflect.Array"));
+
+ _setClassMethod(objectClass.getMethod("getClass", JavaCast("null", 0)));
+
+ _setObjectClass(objectClass);
+
+ _setClass(arguments.class);
+
+ _setModifier(createObject("java", "java.lang.reflect.Modifier"));
+
+ _setStaticFields();
+
+ _initMethodCollection();
+
+ return this;
+ </cfscript>
+</cffunction>
+
+<cffunction name="init" hint="create an instance of this object" access="public" returntype="any" output="false">
+ <cfscript>
+ var constructor = 0;
+ var instance = 0;
+
+ //make sure we only ever have one instance
+ if(_hasClassInstance())
+ {
+ return _getClassInstance();
+ }
+
+ constructor = _resolveMethodByParams("Constructor", _getClass().getConstructors(), arguments);
+
+ instance = constructor.newInstance(_buildArgumentArray(arguments));
+
+ _setClassInstance(instance);
+
+ return _getClassInstance();
+ </cfscript>
+</cffunction>
+
+<cffunction name="onMissingMethod" access="public" returntype="any" output="false" hint="wires the coldfusion invocation to the Java Object">
+ <cfargument name="missingMethodName" type="string" required="true" hint="" />
+ <cfargument name="missingMethodArguments" type="struct" required="true" hint=""/>
+
+ <cfscript>
+ var method = _findMethod(arguments.missingMethodName, arguments.missingMethodArguments);
+
+ if(_getModifier().isStatic(method.getModifiers()))
+ {
+ return method.invoke(JavaCast("null", 0), _buildArgumentArray(arguments.missingMethodArguments));
+ }
+ else
+ {
+ if(NOT _hasClassInstance())
+ {
+ //run the default constructor, just like in normal CF, if there is no instance
+ init();
+ }
+
+ return method.invoke(_getClassInstance(), _buildArgumentArray(arguments.missingMethodArguments));
+ }
+ </cfscript>
+</cffunction>
+
+<!------------------------------------------- PUBLIC ------------------------------------------->
+
+<!------------------------------------------- PACKAGE ------------------------------------------->
+
+<!------------------------------------------- PRIVATE ------------------------------------------->
+
+<cffunction name="_setStaticFields" hint="loops around all the fields and sets the static one to this scope" access="private" returntype="void" output="false">
+ <cfscript>
+ var fields = _getClass().getFields();
+ var counter = 1;
+ var len = ArrayLen(fields);
+ var field = 0;
+
+ for(; counter <= len; counter++)
+ {
+ field = fields[counter];
+ if(_getModifier().isStatic(field.getModifiers()))
+ {
+ this[field.getName()] = field.get(JavaCast("null", 0));
+ }
+ }
+ </cfscript>
+</cffunction>
+
+<cffunction name="_buildArgumentArray" hint="builds an argument array out of the arguments" access="private" returntype="array" output="false">
+ <cfargument name="arguments" hint="the arguments passed through" type="struct" required="Yes">
+ <cfscript>
+ var len = StructCount(arguments);
+ var objArray = _getArray().newInstance(_getObjectClass(), len);
+ var counter = 1;
+ var obj = 0;
+
+ for(; counter <= len; counter++)
+ {
+ obj = arguments[counter];
+ _getArray().set(objArray, counter - 1, obj);
+ }
+
+ return objArray;
+ </cfscript>
+</cffunction>
+
+<cffunction name="_findMethod" hint="finds the method that closest matches the signature" access="public" returntype="any" output="false">
+ <cfargument name="methodName" hint="the name of the method" type="string" required="Yes">
+ <cfargument name="methodArgs" hint="the arguments to look for" type="struct" required="Yes">
+ <cfscript>
+ var decision = 0;
+
+ if(StructKeyExists(_getMethodCollection(), arguments.methodName))
+ {
+ decision = StructFind(_getMethodCollection(), arguments.methodName);
+
+ //if there is only one option, try it, it's only going to throw a runtime exception if it doesn't work.
+ if(ArrayLen(decision) == 1)
+ {
+ return decision[1];
+ }
+ else
+ {
+ return _resolveMethodByParams(arguments.methodName, decision, arguments.methodArgs);
+ }
+ }
+
+ throw("JavaProxy.MethodNotFoundException", "Could not find the designated method", "Could not find the method '#arguments.methodName#' in the class #_getClass().getName()#");
+ </cfscript>
+</cffunction>
+
+<cffunction name="_resolveMethodByParams" hint="resolves the method to use by the parameters provided" access="private" returntype="any" output="false">
+ <cfargument name="methodName" hint="the name of the method" type="string" required="Yes">
+ <cfargument name="decision" hint="the array of methods to decide from" type="array" required="Yes">
+ <cfargument name="methodArgs" hint="the arguments to look for" type="struct" required="Yes">
+ <cfscript>
+ var decisionLen = ArrayLen(arguments.decision);
+ var method = 0;
+ var counter = 1;
+ var argLen = ArrayLen(arguments.methodArgs);
+ var parameters = 0;
+ var paramLen = 0;
+ var pCounter = 0;
+ var param = 0;
+ var class = 0;
+ var found = true;
+
+ for(; counter <= decisionLen; counter++)
+ {
+ method = arguments.decision[counter];
+ parameters = method.getParameterTypes();
+ paramLen = ArrayLen(parameters);
+
+ found = true;
+
+ if(argLen eq paramLen)
+ {
+ for(pCounter = 1; pCounter <= paramLen AND found; pCounter++)
+ {
+ param = parameters[pCounter];
+ class = _getClassMethod().invoke(arguments.methodArgs[pCounter], JavaCast("null", 0));
+
+ if(param.isAssignableFrom(class))
+ {
+ found = true;
+ }
+ else if(param.isPrimitive()) //if it's a primitive, it can be mapped to object primtive classes
+ {
+ if(param.getName() eq "boolean" AND class.getName() eq "java.lang.Boolean")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "int" AND class.getName() eq "java.lang.Integer")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "long" AND class.getName() eq "java.lang.Long")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "float" AND class.getName() eq "java.lang.Float")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "double" AND class.getName() eq "java.lang.Double")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "char" AND class.getName() eq "java.lang.Character")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "byte" AND class.getName() eq "java.lang.Byte")
+ {
+ found = true;
+ }
+ else if(param.getName() eq "short" AND class.getName() eq "java.lang.Short")
+ {
+ found = true;
+ }
+ else
+ {
+ found = false;
+ }
+ }
+ else
+ {
+ found = false;
+ }
+ }
+
+ if(found)
+ {
+ return method;
+ }
+ }
+ }
+
+ throw("JavaProxy.MethodNotFoundException", "Could not find the designated method", "Could not find the method '#arguments.methodName#' in the class #_getClass().getName()#");
+ </cfscript>
+</cffunction>
+
+<cffunction name="_initMethodCollection" hint="creates a method collection of all the methods that are available on the class (this may be cached externally later)" access="private" returntype="void" output="false">
+ <cfscript>
+ var methods = _getClass().getMethods();
+ var len = ArrayLen(methods);
+ var counter = 1;
+ var method = 0;
+
+ _setMethodCollection(StructNew());
+
+ for(; counter <= len; counter++)
+ {
+ method = methods[counter];
+
+ if(NOT StructKeyExists(_getMethodCollection(), method.getName()))
+ {
+ StructInsert(_getMethodCollection(), method.getName(), ArrayNew(1));
+ }
+
+ ArrayAppend(StructFind(_getMethodCollection(), method.getName()), method);
+ }
+ </cfscript>
+</cffunction>
+
+<cffunction name="_getMethodCollection" access="private" returntype="struct" output="false">
+ <cfreturn instance.MethodCollection />
+</cffunction>
+
+<cffunction name="_setMethodCollection" access="private" returntype="void" output="false">
+ <cfargument name="MethodCollection" type="struct" required="true">
+ <cfset instance.MethodCollection = arguments.MethodCollection />
+</cffunction>
+
+<cffunction name="_hasClassInstance" hint="if the proxy has an instance yet" access="private" returntype="boolean" output="false">
+ <cfreturn StructKeyExists(instance, "ClassInstance") />
+</cffunction>
+
+<cffunction name="_getClassInstance" access="private" returntype="any" output="false">
+ <cfreturn instance.ClassInstance />
+</cffunction>
+
+<cffunction name="_setClassInstance" access="private" returntype="void" output="false">
+ <cfargument name="ClassInstance" type="any" required="true">
+ <cfset instance.ClassInstance = arguments.ClassInstance />
+</cffunction>
+
+<cffunction name="_getObjectClass" access="private" returntype="any" output="false">
+ <cfreturn instance.ObjectClass />
+</cffunction>
+
+<cffunction name="_setObjectClass" access="private" returntype="void" output="false">
+ <cfargument name="ObjectClass" type="any" required="true">
+ <cfset instance.ObjectClass = arguments.ObjectClass />
+</cffunction>
+
+<cffunction name="_getArray" access="private" returntype="any" output="false">
+ <cfreturn instance.Array />
+</cffunction>
+
+<cffunction name="_setArray" access="private" returntype="void" output="false">
+ <cfargument name="Array" type="any" required="true">
+ <cfset instance.Array = arguments.Array />
+</cffunction>
+
+<cffunction name="_getClassMethod" access="private" returntype="any" output="false">
+ <cfreturn instance.ClassMethod />
+</cffunction>
+
+<cffunction name="_setClassMethod" access="private" returntype="void" output="false">
+ <cfargument name="ClassMethod" type="any" required="true">
+ <cfset instance.ClassMethod = arguments.ClassMethod />
+</cffunction>
+
+<cffunction name="_getClass" access="private" returntype="any" output="false">
+ <cfreturn instance.Class />
+</cffunction>
+
+<cffunction name="_setClass" access="private" returntype="void" output="false">
+ <cfargument name="Class" type="any" required="true">
+ <cfset instance.Class = arguments.Class />
+</cffunction>
+
+<cffunction name="_getModifier" access="private" returntype="any" output="false">
+ <cfreturn instance.Modifier />
+</cffunction>
+
+<cffunction name="_setModifier" access="private" returntype="void" output="false">
+ <cfargument name="Modifier" type="any" required="true">
+ <cfset instance.Modifier = arguments.Modifier />
+</cffunction>
+
+<cffunction name="throw" access="private" hint="Throws an Exception" output="false">
+ <cfargument name="type" hint="The type of exception" type="string" required="Yes">
+ <cfargument name="message" hint="The message to accompany the exception" type="string" required="Yes">
+ <cfargument name="detail" type="string" hint="The detail message for the exception" required="No" default="">
+ <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#">
+</cffunction>
+
+</cfcomponent>
BIN javaloader/lib/classloader-20080514084644.jar
Binary file not shown.
BIN javaloader/lib/classloader-src.zip
Binary file not shown.
213 javaloader/licence.txt
@@ -0,0 +1,213 @@
+Common Public License Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses
+to its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license set
+forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title and
+non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for
+damages, including direct, indirect, special, incidental and consequential
+damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered
+by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable manner on or
+through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the
+Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement, including but not limited to the risks and costs of
+program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to
+a patent applicable to software (including a cross-claim or counterclaim in a
+lawsuit), then any patent licenses granted by that Contributor to such Recipient
+under this Agreement shall terminate as of the date such litigation is filed. In
+addition, if Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
+itself (excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
+as the Agreement Steward to a suitable separate entity. Each new version of the
+Agreement will be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the Agreement
+is published, Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated in Sections
+2(a) and 2(b) above, Recipient receives no rights or licenses to the
+intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
69 javaloader/readme.txt
@@ -0,0 +1,69 @@
+JavaLoader v0.5
+Author: Mark Mandel
+Date: 2nd October 2007
+
+Installation
+----------------
+To install the javaloader, either put the javaloader in the
+root of your web application, or make a mapping called
+'javaloader' to the javaloader folder.
+
+
+Utilisation
+----------------
+To access the JavaLoader CFC, you call createObject on it like so:
+
+createObject("component", "javaloader.JavaLoader").init(loadPaths,
+ [loadColdFusionClassPath,]
+ [parentClassLoader]);
+
+There are three arguments that possible to configure how and what the JavaLoader loads.
+
+* param: loadPaths
+An array of directories of classes, or paths to .jar files to load.
+
+An example would be:
+loadPaths = ArrayNew(1);
+loadPaths[1] = expandPath("icu4j.jar");
+loadPaths[2] = expandPath("log4j.jar");
+
+* param: loadColdFusionClassPath (default: false)
+Loads the ColdFusion libraries with the loaded libraries.
+This used to be on by default, however now you must implicitly set it to be true if
+you wish to access any of the libraries that ColdFusion loads at application startup.
+
+* parentClassLoader (null)
+(Expert use only) The parent java.lang.ClassLoader to set when creating the URLClassLoader.
+Note - when setting loadColdFusionClassPath to 'true', this value is overwritten with the
+ColdFusion classloader.
+
+
+To create an instance of a Java Class, you then only need to call:
+
+javaloader.create(className).init(arg1, arg2...);
+
+* param className
+The name of the Java Class to create.
+
+This works exactly the same as createObject("java", className), such that simply calling create(className)
+gives you access to the static properties of the class, but to get an instance through calling the
+Constructor you are required to call create(className).init();
+
+Example:
+javaloader.create("org.apache.log4j.Logger").init("my log");
+
+Memory Issues
+----------------
+Due to a bug in ColdFusion 7 that can cause URLClassLoaders not to be garbage collected,
+it is advised that instances of JavaLoader are stored in the Server scope, so that they
+never time out.
+
+
+Integration
+----------------
+Previously JavaLoader was a simple CFC that was very portable, and while JavaLoader
+now has dependencies, it can still be integrated into existing applications quite easily.
+
+The only dependency that much be maintained is that the /lib/ folder and its contents
+must sit in the same directory as JavaLoader.cfc Other than that, JavaLoader can be
+integrated into existing applications and frameworks quite easily.
88 jtidy.cfc
@@ -0,0 +1,88 @@
+<cfcomponent name="jtidy" displayname="jTidy" hint="clean out invalid html">
+
+ <cffunction name="makexHTMLValid" displayname="Tidy parser" hint="Takes a string as an argument and returns parsed and valid xHTML" output="false">
+ <cfargument name="strToParse" required="true" type="string" default="" />
+
+ <cfset var returnPart = "" /> <!--- // return variable --->
+ <cfset parseData = trim(arguments.strToParse) />
+
+ <!--- Simply return the sting if its empty --->
+ <cfif not len(parseData)>
+ <cfreturn parseData />
+ </cfif>
+
+ <cftry>
+
+ <cfscript>
+ /**
+ * This function reads in a string, checks and corrects any invalid HTML.
+ * By Greg Stewart
+ *
+ * @param strToParse The string to parse (will be written to file).
+ * accessible from the web browser
+ * @return returnPart
+ * @author Greg Stewart (gregs(at)tcias.co.uk)
+ * @version 1, August 22, 2004
+
+ * @version 1.1, September 09, 2004
+ * with the help of Mark Woods this UDF no longer requires temp files and only accepts
+ * the string to parse
+
+ * @version 1.2, January 01, 2010
+ * slightly modified version by Mike Henke
+ * added javaloader
+ */
+
+ warning="jTidy is not installed on your server.";
+
+ // jtidy-r938.zip from http://sourceforge.net/projects/jtidy/files/
+ loadPaths = ArrayNew(1);
+ loadPaths[1] = expandPath("lib/jtidy-r938.jar");
+
+ javaloader = createObject("component", "javaloader.JavaLoader").init(loadPaths);
+ jTidy = javaloader.create("org.w3c.tidy.Tidy").init();
+
+ jTidy.setQuiet(false);
+ jTidy.setIndentContent(true);
+ jTidy.setSmartIndent(true);
+ jTidy.setIndentAttributes(true);
+ jTidy.setWraplen(1024);
+ jTidy.setXHTML(true);
+
+ // create the in and out streams for jTidy
+ readBuffer = CreateObject("java","java.lang.String").init(parseData).getBytes();
+ inP = createobject("java","java.io.ByteArrayInputStream").init(readBuffer);
+
+ //ByteArrayOutputStream
+ outx = createObject("java", "java.io.ByteArrayOutputStream").init();
+
+ // do the parsing
+ jTidy.parse(inP,outx);
+
+ // close the stream
+ // outx.close();
+ outstr = outx.toString();
+ </cfscript>
+
+ // ok now strip all the header/body stuff
+ <cfset startPos = REFind("<body>", outstr)+6 />
+ <cfset endPos = REFind("</body>", outstr) />
+
+ <!--- check if output from jtidy is blank --->
+ <cfif outstr eq '' >
+ <cfset warning = "output from jtidy empty" />
+ <cfthrow />
+ </cfif>
+
+ <cfset returnPart = Mid(outstr, startPos, endPos-startPos) />
+
+ <cfreturn returnPart />
+
+ <cfcatch type="any">
+ <!--- This could error because jTidy has not been installed on the server. --->
+ <cftrace type="warning" text="#warning#" />
+ <cfreturn parseData />
+ </cfcatch>
+ </cftry>
+ </cffunction>
+</cfcomponent>
53 lib/LICENSE.txt
@@ -0,0 +1,53 @@
+/**
+* Java HTML Tidy - JTidy
+* HTML parser and pretty printer
+*
+* Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
+* Institute of Technology, Institut National de Recherche en
+* Informatique et en Automatique, Keio University). All Rights
+* Reserved.
+*
+* Contributing Author(s):
+*
+* Dave Raggett <dsr@w3.org>
+* Andy Quick <ac.quick@sympatico.ca> (translation to Java)
+* Gary L Peskin <garyp@firstech.com> (Java development)
+* Sami Lempinen <sami@lempinen.net> (release management)
+* Fabrizio Giustina <fgiust at users.sourceforge.net>
+*
+* The contributing author(s) would like to thank all those who
+* helped with testing, bug fixes, and patience. This wouldn't
+* have been possible without all of you.
+*
+* COPYRIGHT NOTICE:
+*
+* This software and documentation is provided "as is," and
+* the copyright holders and contributing author(s) make no
+* representations or warranties, express or implied, including
+* but not limited to, warranties of merchantability or fitness
+* for any particular purpose or that the use of the software or
+* documentation will not infringe any third party patents,
+* copyrights, trademarks or other rights.
+*
+* The copyright holders and contributing author(s) will not be
+* liable for any direct, indirect, special or consequential damages
+* arising out of any use of the software or documentation, even if
+* advised of the possibility of such damage.
+*
+* Permission is hereby granted to use, copy, modify, and distribute
+* this source code, or portions hereof, documentation and executables,
+* for any purpose, without fee, subject to the following restrictions:
+*
+* 1. The origin of this source code must not be misrepresented.
+* 2. Altered versions must be plainly marked as such and must
+* not be misrepresented as being the original source.
+* 3. This Copyright notice may not be removed or altered from any
+* source or altered source distribution.
+*
+* The copyright holders and contributing author(s) specifically
+* permit, without fee, and encourage the use of this source code
+* as a component for supporting the Hypertext Markup Language in
+* commercial products. If you use this source code in a product,
+* acknowledgment is not required but would be appreciated.
+*
+*/
BIN lib/jtidy-r938.jar
Binary file not shown.

0 comments on commit 09f97f7

Please sign in to comment.
Something went wrong with that request. Please try again.