diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..3d51f7d0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: https://EditorConfig.org + +root = true + +[*] +end_of_line = lf +indent_size = 2 +indent_style = spaces +insert_final_newline = true +trim_trailing_whitespace = true + +[*.java] +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index b0bf03d2..2d7e32fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,20 @@ -apps* -!apps/manage -classes/* -db* -dist -docs -launcher.jar -lib/helma*.jar -lib/ext -log/* -passwd -server.properties .gradle +.settings +build + +/apps +/bin +/backups +/db +/docs +/extras +/lib +/log +/static + +/*.properties +/launcher.jar +/passwd +/start.* + +!/gradle.properties diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a442cae6..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "modules/jala"] - path = modules/jala - url = git@github.com:antville/jala.git diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..df5926e7 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,37 @@ +# License + +Copyright (c) 1999-2008 Helma Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. Products derived from this software may not be called "Helma" + or "Hop", nor may "Helma" or "Hop" appear in their name, without + prior written permission of the Helma Project Group. For written + permission, please contact helma@helma.org. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE HELMA PROJECT OR ITS +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +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 OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +Helma includes third party software released under different specific +license terms. See the licenses directory in the Helma distribution +for a list of these licenses. diff --git a/apps.properties b/apps.properties deleted file mode 100644 index 962ebe05..00000000 --- a/apps.properties +++ /dev/null @@ -1,4 +0,0 @@ -# List of apps to start. - -test - diff --git a/build.gradle b/build.gradle index 5aeeca7f..30c5165c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,86 @@ -apply plugin: 'java' -defaultTasks 'jar' +allprojects { + apply plugin: 'java' + apply plugin: 'application' -ant.importBuild 'build.xml' -tasks.jar.dependsOn 'mkjar' + compileJava { + dependsOn 'processSource' + sourceCompatibility = JavaVersion.VERSION_1_6 + targetCompatibility = JavaVersion.VERSION_1_6 + } + + // FIXME: start scripts are not working, yet + startScripts { + mainClassName = 'helma.main.launcher.Main' + applicationName = 'helma' + classpath = files('launcher.jar') + } + + task processSource(type: Sync) { + def date = new Date().format("MMMM dd, yyyy") + def gitOutput = new ByteArrayOutputStream() + + exec { + commandLine 'git', 'describe' + standardOutput = gitOutput + errorOutput = new ByteArrayOutputStream() + ignoreExitValue = true + } + + def description = date + def tag = gitOutput.toString().trim() + + if (tag) description = "$tag; $description" + + from 'src' + + filter { + line -> line.replaceAll('__builddate__', date) + } into "${project.buildDir}/src" + } +} + +version = new Date().format("yyyyMMdd") + +distributions { + main { + contents { + from project(':launcher').jar + } + } +} + +applicationDistribution.from(projectDir) { + include 'modules/**' + include 'LICENSE.md' + include 'README.md' + include 'start.*' +} + +applicationDistribution.from(javadoc.destinationDir) { + include '**' + into 'docs' +} + +sourceSets { + main { + java { + srcDirs = ["$buildDir/src/main/java"] + exclude '**/package.html', '**/main/launcher/**' + } + } +} repositories { mavenCentral() jcenter() } +configurations { + // Wrapping implementation because it does not allow access to its files + // (i.e. cannot be resolved) + library.extendsFrom implementation +} + dependencies { implementation 'commons-codec:commons-codec:1.10' implementation 'commons-fileupload:commons-fileupload:1.4' @@ -25,7 +97,76 @@ dependencies { implementation 'xmlrpc:xmlrpc:2.0.1' } -task deps(type: Copy) { - from configurations.compileClasspath - into 'lib/' +distTar { + compression = Compression.GZIP +} + +installDist { + dependsOn javadoc + finalizedBy 'update' +} + +run { + classpath = files('launcher.jar') + args '-w', '8080' + args '-x', '8081' + args '-i', projectDir + args '-h', projectDir + jvmArgs '-Dorg.eclipse.jetty.LEVEL=WARN' +} + +task shell(type: JavaExec) { + def rhinoJar = configurations.library.files.find { f -> + f.name.startsWith('rhino') + } + + // if (environment.get('TERM') != 'dumb') { + // println 'Run this task with `TERM=dumb ./gradlew shell` to get rid of the progress output' + // } + + classpath = files(rhinoJar) + main = 'org.mozilla.javascript.tools.shell.Main' + + standardInput = System.in +} + +task commandline(type: JavaExec) { + classpath = files('launcher.jar') + main = 'helma.main.launcher.Commandline' + args '-h', projectDir, 'manage.getAllApplications' +} + +task update { + def rsyncArgs = ['-a', '--info=progress2', '--exclude', 'backups'] + + def confirm = { + ant.input(message: 'Update this installation?', validargs: 'y,n', addproperty: 'continue') + return ant.continue == 'y' + } + + onlyIf { confirm() } + + doFirst { + def backupDir = 'backups/' + new Date().format('yyyyMMdd-HHmmss') + + mkdir backupDir + + exec { + // Using rsync instead of a CopyTask because the latter chokes on multi-byte characters + // See https://github.com/gradle/gradle/issues/789 + executable 'rsync' + args rsyncArgs + args "$projectDir/", backupDir + } + } + + doLast { + exec { + // Using rsync instead of installDist task because it does not overwrite the project directory + executable 'rsync' + args rsyncArgs + args '--exclude', 'bin' + args "${installDist.destinationDir}/", projectDir + } + } } diff --git a/build.xml b/build.xml deleted file mode 100644 index ae7f0d82..00000000 --- a/build.xml +++ /dev/null @@ -1,480 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/README.md b/build/README.md deleted file mode 100644 index bf60ba49..00000000 --- a/build/README.md +++ /dev/null @@ -1,38 +0,0 @@ -_This is the README file for the Helma build files as part of the Helma Object Publisher._ - -## Prerequisites - -The Helma build script is using Apache Ant. -For more information about Ant, see . - -## Building - -The build system is started by invoking the shell script appropriate to your -platform, ie. build.sh for *nix (Linux, NetBSD etc.) and build.bat for Windows -systems. You probably need to modify the script and set the `JAVA_HOME` to fit your system. - -The generic syntax is - - ant target - -The parameter `target` specifies one of the build targets listed below. - -## Build Targets - -**compile** -Compiles the source files into the `./classes` directory (which will be created if necessary). - -**jar** -Creates a helma.jar file (snapshot) in the lib directory. The file is named `helma-yyyymmdd.jar`. - -**javadocs** -Creates the JavaDoc API documentation. - -**package** -Creates the full Helma distribution packages and places them in the dist directory. - -**app [name]** -Gets an application from the source code repository, zips / targzs it and places the files in the dist directory. - -**module [name]** -Gets a module from the source code repository, zips it and places the file in the dist directory. diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..31396f61 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.console = plain diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 51288f9c..9ab0a835 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7a1adaa9..95feb49f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Dec 04 13:10:15 CET 2016 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 4453ccea..cccdd3d5 100755 --- a/gradlew +++ b/gradlew @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/launcher/build.gradle b/launcher/build.gradle new file mode 100644 index 00000000..9cc27cc4 --- /dev/null +++ b/launcher/build.gradle @@ -0,0 +1,18 @@ +sourceSets { + main { + java { + srcDirs = ["${rootProject.buildDir}/src/main/java"] + include '**/main/launcher/**' + } + } +} + +jar { + manifest { + from "${rootProject.projectDir}/src/main/java/helma/main/launcher/manifest.txt" + } +} + +task copyJars(type: Copy) { + from jar into "${rootProject.projectDir}" +} diff --git a/lib/commons-codec-1.10.jar b/lib/commons-codec-1.10.jar deleted file mode 100644 index 1d7417c4..00000000 Binary files a/lib/commons-codec-1.10.jar and /dev/null differ diff --git a/lib/commons-fileupload-1.4.jar b/lib/commons-fileupload-1.4.jar deleted file mode 100644 index e25a6bc9..00000000 Binary files a/lib/commons-fileupload-1.4.jar and /dev/null differ diff --git a/lib/commons-io-2.2.jar b/lib/commons-io-2.2.jar deleted file mode 100644 index 84ca5658..00000000 Binary files a/lib/commons-io-2.2.jar and /dev/null differ diff --git a/lib/commons-logging-1.2.jar b/lib/commons-logging-1.2.jar deleted file mode 100644 index 93a3b9f6..00000000 Binary files a/lib/commons-logging-1.2.jar and /dev/null differ diff --git a/lib/commons-net-3.6.jar b/lib/commons-net-3.6.jar deleted file mode 100644 index 4537623e..00000000 Binary files a/lib/commons-net-3.6.jar and /dev/null differ diff --git a/lib/javax.activation-1.2.0.jar b/lib/javax.activation-1.2.0.jar deleted file mode 100644 index 9637479a..00000000 Binary files a/lib/javax.activation-1.2.0.jar and /dev/null differ diff --git a/lib/javax.mail-api-1.6.2.jar b/lib/javax.mail-api-1.6.2.jar deleted file mode 100644 index bbe702ef..00000000 Binary files a/lib/javax.mail-api-1.6.2.jar and /dev/null differ diff --git a/lib/javax.servlet-api-4.0.1.jar b/lib/javax.servlet-api-4.0.1.jar deleted file mode 100644 index 844ec7f1..00000000 Binary files a/lib/javax.servlet-api-4.0.1.jar and /dev/null differ diff --git a/lib/jetty-http-9.4.18.v20190429.jar b/lib/jetty-http-9.4.18.v20190429.jar deleted file mode 100644 index e2e6282c..00000000 Binary files a/lib/jetty-http-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-io-9.4.18.v20190429.jar b/lib/jetty-io-9.4.18.v20190429.jar deleted file mode 100644 index 56acc565..00000000 Binary files a/lib/jetty-io-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-security-9.4.18.v20190429.jar b/lib/jetty-security-9.4.18.v20190429.jar deleted file mode 100644 index d3557689..00000000 Binary files a/lib/jetty-security-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-server-9.4.18.v20190429.jar b/lib/jetty-server-9.4.18.v20190429.jar deleted file mode 100644 index 4372350b..00000000 Binary files a/lib/jetty-server-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-servlet-9.4.18.v20190429.jar b/lib/jetty-servlet-9.4.18.v20190429.jar deleted file mode 100644 index 1d3a94b2..00000000 Binary files a/lib/jetty-servlet-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-util-9.4.18.v20190429.jar b/lib/jetty-util-9.4.18.v20190429.jar deleted file mode 100644 index b80bfe8f..00000000 Binary files a/lib/jetty-util-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/jetty-xml-9.4.18.v20190429.jar b/lib/jetty-xml-9.4.18.v20190429.jar deleted file mode 100644 index 51aa9a5a..00000000 Binary files a/lib/jetty-xml-9.4.18.v20190429.jar and /dev/null differ diff --git a/lib/rhino-1.7.12.jar b/lib/rhino-1.7.12.jar deleted file mode 100644 index 44caf65a..00000000 Binary files a/lib/rhino-1.7.12.jar and /dev/null differ diff --git a/lib/rhino-1.7.9.jar b/lib/rhino-1.7.9.jar deleted file mode 100644 index 4d353517..00000000 Binary files a/lib/rhino-1.7.9.jar and /dev/null differ diff --git a/lib/tagsoup-1.2.1.jar b/lib/tagsoup-1.2.1.jar deleted file mode 100644 index 27516019..00000000 Binary files a/lib/tagsoup-1.2.1.jar and /dev/null differ diff --git a/lib/xercesImpl-2.12.0.jar b/lib/xercesImpl-2.12.0.jar deleted file mode 100644 index b69d01da..00000000 Binary files a/lib/xercesImpl-2.12.0.jar and /dev/null differ diff --git a/lib/xml-apis-1.4.01.jar b/lib/xml-apis-1.4.01.jar deleted file mode 100644 index 46733464..00000000 Binary files a/lib/xml-apis-1.4.01.jar and /dev/null differ diff --git a/lib/xmlrpc-2.0.1.jar b/lib/xmlrpc-2.0.1.jar deleted file mode 100644 index 47b46375..00000000 Binary files a/lib/xmlrpc-2.0.1.jar and /dev/null differ diff --git a/license.txt b/license.txt deleted file mode 100644 index d8e184f9..00000000 --- a/license.txt +++ /dev/null @@ -1,37 +0,0 @@ - Copyright (c) 1999-2008 Helma Project. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. Products derived from this software may not be called "Helma" - or "Hop", nor may "Helma" or "Hop" appear in their name, without - prior written permission of the Helma Project Group. For written - permission, please contact helma@helma.org. - - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE HELMA PROJECT OR ITS - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - 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 OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - - -Helma includes third party software released under different specific -license terms. See the licenses directory in the Helma distribution -for a list of these licenses. diff --git a/modules/jala b/modules/jala deleted file mode 160000 index 24e7b111..00000000 --- a/modules/jala +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 24e7b11100365cd7ab1d23c757c3b4a2379af223 diff --git a/modules/jala/README.md b/modules/jala/README.md new file mode 100644 index 00000000..d52c0c84 --- /dev/null +++ b/modules/jala/README.md @@ -0,0 +1,37 @@ +_This is the README file for version 1.2 of the Jala Javascript Library._ + +# About Jala + +Jala is an open-source collection of JavaScript modules for Helma Object Publisher. Copyright 2004 ORF Online und Teletext GmbH, Vienna (Austria). You can find more information about each module in the API Documentation located in the `docs` directory. + +## Licensing + +Jala itself is licensed under the Apache 2.0 License, but parts of Jala require third party libraries coming with different licenses. You can find all necessary information in the `licenses` directory. + +## Installation + +Move the Jala folder into the `modules` directory of your Helma installation. To include a certain Jala module simply add the following line to your Helma application's source code (replace `[name]` with the desired module name): + + app.addRepository("./modules/jala/code/[name].js"); + +If you want to include the whole Jala package at once, you can use the `all` module for convenience: + + app.addRepository("./modules/jala/code/all.js"); + +Alternatively, you can import the Jala module from within Helma's +`apps.properties` file (replace `[appName]` with the name of your Helma application, `[n]` with a number between 0 and 9 and `[moduleName]` with the desired module +name): + + [appName].respository.[n] = ./modules/jala/code/[moduleName].js + +More information about the `addRepository()` method and generally including repositories in a Helma application is available at +http://helma.org/stories/77712/. + +## Contact, Bugs and Feedback + +The Jala Project is hosted at https://dev.orf.at/jala/ providing all necessary information about Subversion access, Ticketing, Releases etc. + +Although we encourage you to post your questions and comments as ticket, we also provide a mailing list for convenience (details at +https://dev.orf.at/trac/jala/wiki/MailingList). + +For immediate contact you can reach the developers via jaladev AT gmail.com. diff --git a/modules/jala/build.properties b/modules/jala/build.properties new file mode 100644 index 00000000..387dc22a --- /dev/null +++ b/modules/jala/build.properties @@ -0,0 +1,7 @@ +## build properties for jsdoc api documentation +## all paths *must* be relative to the directory where +## this file is located + +docs.source = ./code +docs.destination = ./docs +docs.projectName = Jala 1.3 diff --git a/modules/jala/code/.jsdoc/summary.html b/modules/jala/code/.jsdoc/summary.html new file mode 100644 index 00000000..3474c714 --- /dev/null +++ b/modules/jala/code/.jsdoc/summary.html @@ -0,0 +1 @@ +Jala is a Helma-based library and utility project initially developed to ease the work at ORF.at's software development department. diff --git a/modules/jala/code/AsyncRequest.js b/modules/jala/code/AsyncRequest.js new file mode 100644 index 00000000..40c19c7a --- /dev/null +++ b/modules/jala/code/AsyncRequest.js @@ -0,0 +1,175 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.AsyncRequest class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Creates a new AsyncRequest instance. + * @class This class is used to create requests of type "INTERNAL" + * (like cron-jobs) that are processed in a separate thread and + * therefor asynchronous. + * @param {Object} obj Object in whose context the method should be called + * @param {String} funcName Name of the function to call + * @param {Array} args Array containing the arguments that should be passed + * to the function (optional). This option is deprecated, instead + * pass the arguments directly to the {@link #run} method. + * @constructor + * @returns A new instance of AsyncRequest + * @type AsyncRequest + * @deprecated Use the {@link http://helma.zumbrunn.net/reference/core/app.html#invokeAsync + * app.invokeAsync} method instead (built-in into Helma as + * of version 1.6) + */ +jala.AsyncRequest = function(obj, funcName, args) { + app.logger.warn("Use of jala.AsyncRequest is deprecated in this version."); + app.logger.warn("This module will probably be removed in a " + + "future version of Jala."); + + /** + * Contains a reference to the thread started by this AsyncRequest + * @type java.lang.Thread + * @private + */ + var thread; + + /** + * Contains the timeout defined for this AsyncRequest (in milliseconds) + * @type Number + * @private + */ + var timeout; + + /** + * Contains the number of milliseconds to wait before starting + * the asynchronous request. + * @type Number + * @private + */ + var delay; + + /** + * Run method necessary to implement java.lang.Runnable. + * @private + */ + var runner = function() { + // evaluator that will handle the request + var ev = app.__app__.getEvaluator(); + + if (delay != null) { + java.lang.Thread.sleep(delay); + } + try { + if (args === undefined || args === null || args.constructor != Array) { + args = []; + } + if (timeout != null) { + ev.invokeInternal(obj, funcName, args, timeout); + } else { + ev.invokeInternal(obj, funcName, args); + } + } catch (e) { + // ignore it, but log it + app.log("[Runner] Caught Exception: " + e); + } finally { + // release the ev in any case + app.__app__.releaseEvaluator(ev); + // remove reference to underlying thread + thread = null; + } + return; + }; + + /** + * Sets the timeout of this asynchronous request. + * @param {Number} seconds Thread-timeout. + */ + this.setTimeout = function(seconds) { + timeout = seconds * 1000; + return; + }; + + /** + * Defines the delay to wait before evaluating this asynchronous request. + * @param {Number} millis Milliseconds to wait + */ + this.setDelay = function(millis) { + delay = millis; + return; + }; + + /** + * Starts this asynchronous request. Any arguments passed to + * this method will be passed to the method executed by + * this AsyncRequest instance. + */ + this.run = function() { + if (arguments.length > 0) { + // convert arguments object into array + args = Array.prototype.slice.call(arguments, 0, arguments.length); + } + thread = (new java.lang.Thread(new java.lang.Runnable({"run": runner}))); + thread.start(); + return; + }; + + /** + * Starts this asynchronous request. + * @deprecated Use {@link #run} instead + */ + this.evaluate = function() { + this.run.apply(this, arguments); + return; + }; + + /** + * Returns true if the underlying thread is alive + * @returns True if the underlying thread is alive, + * false otherwise. + * @type Boolean + */ + this.isAlive = function() { + return thread != null && thread.isAlive(); + } + + /** @ignore */ + this.toString = function() { + return "[jala.AsyncRequest]"; + }; + + /** + * Main constructor body + */ + if (!obj || !funcName) + throw "jala.AsyncRequest: insufficient arguments."; + return this; +} diff --git a/modules/jala/code/BitTorrent.js b/modules/jala/code/BitTorrent.js new file mode 100644 index 00000000..05ad1311 --- /dev/null +++ b/modules/jala/code/BitTorrent.js @@ -0,0 +1,429 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.BitTorrent class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Module dependencies + */ +app.addRepository("modules/core/String.js"); +app.addRepository("modules/helma/File.js"); + + +/** + * Constructs a new BitTorrent file. + * @class This class provides methods to create a BitTorrent + * metadata file from any desired file. + * @param {String} trackerUrl The URL string of the tracker. + * @param {String} filePath The path to the original file. + * @returns A new BitTorrent file. + * @constructor + */ +jala.BitTorrent = function(filePath, trackerUrl) { + var self = this; + self.arguments = arguments; + + // FIXME: Add support for multitracker mode as specified in + // http://www.bittornado.com/docs/multitracker-spec.txt + + var torrent, sourceFile, torrentFile; + var pieceLength = 256; + + var updateTorrent = function() { + if (torrent.info) { + return torrent; + } + + var file = new java.io.File(filePath); + if (!file.exists()) { + throw Error("File " + file + " does not exist!"); + } + + var md5 = java.security.MessageDigest.getInstance("MD5"); + var sha1 = java.security.MessageDigest.getInstance("SHA-1"); + + var fis = new java.io.FileInputStream(file); + var bis = new java.io.BufferedInputStream(fis); + var cache = new java.io.ByteArrayOutputStream(); + + var pieces = []; + var length = pieceLength * 1024; + var buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, length); + + while (bis.read(buffer, 0, buffer.length) > -1) { + app.debug("Updating SHA-1 hash with " + buffer.length + " bytes"); + sha1.reset(); + sha1["update(byte[])"](buffer); + cache["write(byte[])"](buffer); + pieces.push(new java.lang.String(sha1.digest())); + } + + bis.close(); + fis.close(); + + torrent.info = { + //md5sum: new java.lang.String(md5.digest(cache.toByteArray())), + length: cache.size(), + name: file.getName(), + "piece length": length, + pieces: pieces.join("") + }; + + return torrent; + }; + + /** + * Get all available property names. + * @returns The list of property names. + * @type Array + */ + this.keys = function() { + var keys = []; + for (var i in torrent) { + keys.push(i); + } + keys.sort(); + return keys; + }; + + /** + * Get a torrent property. + * @param {String} name The name of the property. + * @returns The value of the property. + */ + this.get = function(name) { + return torrent[name]; + }; + + /** + * Set a torrent property. + * @param {String} name The name of the property. + * @param {Object} value The property's value. + */ + this.set = function(name, value) { + if (typeof torrent[name] == "undefined") { + throw Error("Cannot set torrent property " + name); + } + torrent[name] = value; + delete torrent.info; + return; + }; + + /** + * Get the creation date of the torrent. + * @returns The torrent's creation date. + * @type Date + */ + this.getCreationDate = function() { + return new Date(torrent["creation date"] * 1000); + }; + + /** + * Set the creation date of the torrent. + * @param {Date} date The desired creation date. + */ + this.setCreationDate = function(date) { + this.set("creation date", Math.round((date || new Date()).getTime() / 1000)); + return; + }; + + /** + * Get the piece length of the torrent. + * @returns The torrent's piece length. + * @type Number + */ + this.getPieceLength = function() { + return pieceLength; + }; + + /** + * Set the piece length of the torrent. + * @param {Number} length The desired piece length. + */ + this.setPieceLength = function(length) { + pieceLength = length; + delete torrent.info; + return; + }; + + /** + * Returns the underlying torrent file. + * @returns The torrent file. + * @type helma.File + */ + this.getTorrentFile = function() { + return torrentFile; + }; + + /** + * Returns the underlying source file. + * @returns The source file. + * @type helma.File + */ + this.getSourceFile = function() { + return sourceFile; + }; + + /** + * Saves the torrent as file. + * @param {String} filename An optional name for the torrent file. + * If no name is given it will be composed from name of source + * file as defined in the torrent plus the ending ".torrent". + */ + this.save = function(filename) { + updateTorrent(); + if (!filename) { + filename = torrent.info.name + ".torrent"; + } + torrentFile = new helma.File(sourceFile.getParent(), filename); + torrentFile.remove(); + torrentFile.open(); + torrentFile.write(jala.BitTorrent.bencode(torrent)); + torrentFile.close(); + return; + }; + + /** + * Get a string representation of the torrent. + * @returns The torrent as string. + * @type String + */ + this.toString = function() { + return "[jala.BitTorrent " + filePath + "]"; + }; + + if (String(filePath).endsWith(".torrent")) { + torrentFile = new helma.File(filePath); + torrent = jala.BitTorrent.bdecode(torrentFile.readAll()); + sourceFile = new helma.File(torrent.info.name); + } else { + torrent = { + announce: trackerUrl || null, + "announce-list": null, + "creation date": null, + comment: null, + "created by": null, + }; + this.setCreationDate(); + sourceFile = new helma.File(filePath); + } + + return this; +}; + + +/** + * The bencode method. Turns an arbitrary JavaScript + * object structure into a corresponding encoded + * string. + * @param {Object} obj The target JavaScript object. + * @returns The encoded string. + * @type String + */ +jala.BitTorrent.bencode = function(obj) { + var bencode = arguments.callee; + var str = obj.toString(); + res.push(); + switch (obj.constructor) { + case Array: + res.write("l"); + for (var i in obj) { + if (obj[i]) + res.write(bencode(obj[i])); + } + res.write("e"); + break; + + case Number: + res.write("i" + str + "e"); + break; + + case Object: + res.write("d"); + var keys = []; + for (var i in obj) { + keys.push(i); + } + keys.sort(); + var key; + for (var i in keys) { + key = keys[i]; + if (obj[key]) { + res.write(bencode(key)); + res.write(bencode(obj[key])); + } + } + res.write("e"); + break; + + default: + res.write(str.length + ":" + str); + } + return res.pop(); +}; + + +/** + * The bdecode method. Turns an encoded string into + * a corresponding JavaScript object structure. + * FIXME: Handle with caution... + * @param {String} code The encoded string. + * @returns The decoded JavaScript structure. + * @type Object + */ +jala.BitTorrent.bdecode = function(code) { + var DICTIONARY = "d"; + var LIST = "l"; + var INTEGER = "i"; + var STRING = "s"; + var END = "e"; + + var stack = []; + var overflowCounter = 0; + + var position = -1, current; + + function getResult() { + update(); + var result; + switch (current) { + case DICTIONARY: + result = bdecodeDictionary(); + break; + case LIST: + result = bdecodeList(); + break; + case INTEGER: + result = bdecodeInteger(); + break; + case END: + case null: + //res.debug("*** end detected in getResult()"); + result = null; + break; + default: + result = bdecodeString(); + } + return result; + } + + function update() { + position += 1; + current = code.charAt(position); + /* res.debug("stack: " + stack); + res.debug("position: " + position); + res.debug("current: " + current); + res.debug("remains: " + code.substr(position)); */ + return; + } + + function overflow() { + if (overflowCounter++ > 100) + throw Error("Error parsing bdecoded string"); + return false; + } + + function bdecodeDictionary() { + stack.push(DICTIONARY); + var dictionary = {}, key, value; + while (current && !overflow()) { + key = getResult(); + if (key === null) + break; + value = getResult(); + if (key && value) + dictionary[key] = value; + else + break; + } + stack.pop(); + return dictionary; + } + + function bdecodeList() { + stack.push(LIST); + var list = [], value; + while (current && !overflow()) { + var value = getResult(); + if (value) + list.push(value); + else + break; + } + stack.pop(); + return list; + } + + function bdecodeInteger() { + var integer = ""; + stack.push(integer); + while (current && !overflow()) { + update(); + if (current == "e") + break; + integer += current; + } + if (isNaN(integer)) + throw("Error in bdecoded integer: " + integer + " is not a number"); + //res.debug("integer = " + integer); + stack.pop(); + return parseInt(integer); + } + + function bdecodeString() { + var length = current, string = ""; + stack.push(string); + update(); + while (current && current != ":" && !overflow()) { + length += current; + update(); + } + if (isNaN(length)) + throw("Error in bdecoded string: invalid length " + length); + //res.debug("length = " + length); + length = parseInt(length); + if (length > code.length - position) + throw Error("Error parsing bdecoded string"); + for (var i=0; i + *
  • name (String): The name of the table
  • + *
  • schema (String): The name of the schema the table belongs to
  • + *
  • columns (Array): An array of column metadata (see {@link #getColumns})
  • + *
  • keys (Array): An array containing primary key column names (see {@link #getPrimaryKeys}
  • + * + * @type Array + */ +jala.db.metadata.getTables = function(dbMetadata, tablePattern, schemaPattern) { + var result = []; + var tableMeta = null; + try { + tableMeta = dbMetadata.getTables(null, (schemaPattern || "%"), + (tablePattern || "%"), null); + while (tableMeta.next()) { + var tableName = tableMeta.getString("TABLE_NAME"); + var schemaName = tableMeta.getString("TABLE_SCHEM") || null; + result.push({ + "name": tableName, + "schema": schemaName, + "columns": jala.db.metadata.getColumns(dbMetadata, tableName, schemaName), + "keys": jala.db.metadata.getPrimaryKeys(dbMetadata, tableName, schemaName) + }); + } + return result; + } finally { + if (tableMeta != null) { + tableMeta.close(); + } + } + return null; +}; + +/** + * Returns the column metadata of a table (or multiple tables, if a tableName + * pattern matching several tables is specified). + * @param {java.sql.DatabaseMetaData} dbMetadata The metadata to use for retrieval + * @param {String} tablePattern Optional table name pattern + * @param {String} schemaPattern Optional schema name pattern + * @param {String} columnPattern Optional column name pattern + * @returns An array containing column metadata. Each one is represented by a + * javascript object containing the following properties: + *
      + *
    • name (String): The name of the column
    • + *
    • type (Number): The data type of the column
    • + *
    • length (Number): The maximum length of the column
    • + *
    • nullable (Boolean): True if the column may contain null values, false otherwise
    • + *
    • default (String): The default value of the column
    • + *
    • precision (Number): The precision of the column
    • + *
    • scale (Number): The radix of the column
    • + *
    + * @type Array + */ +jala.db.metadata.getColumns = function(dbMetadata, tablePattern, schemaPattern, columnPattern) { + var result = []; + var columnMeta = null; + try { + columnMeta = dbMetadata.getColumns(null, schemaPattern || null, + tablePattern || null, columnPattern || "%"); + while (columnMeta.next()) { + result.push({ + "name": columnMeta.getString("COLUMN_NAME"), + "type": columnMeta.getInt("DATA_TYPE"), + "length": columnMeta.getInt("COLUMN_SIZE"), + "nullable": (columnMeta.getInt("NULLABLE") == dbMetadata.typeNoNulls) ? false : true, + "default": columnMeta.getString("COLUMN_DEF"), + "precision": columnMeta.getInt("DECIMAL_DIGITS"), + "scale": columnMeta.getInt("NUM_PREC_RADIX") + }); + } + return result; + } finally { + if (columnMeta != null) { + columnMeta.close(); + } + } + return null; +}; + +/** + * Returns an array containing the primary key names of the specified table. + * @param {java.sql.DatabaseMetaData} dbMetadata The metadata to use for retrieval + * @param {String} tableName The name of the table + * @param {String} schemaName Optional name of the schema + * @returns An array containing the primary key column names + * @type Array + */ +jala.db.metadata.getPrimaryKeys = function(dbMetadata, tableName, schemaName) { + var result = []; + var keyMeta = null; + try { + // retrieve the primary keys of the table + var keyMeta = dbMetadata.getPrimaryKeys(null, schemaName || null, tableName); + while (keyMeta.next()) { + result.push(keyMeta.getString("COLUMN_NAME")); + } + return result; + } finally { + if (keyMeta != null) { + keyMeta.close(); + } + } + return null; +}; + + +/** + * Returns the table metadata of the given database. The optional patterns + * can contain "_" for matching a single character or "%" for any + * character sequence. + * @param {helma.Database} database The database to connect to + * @param {String} schemaPattern An optional schema name pattern + * @param {String} tablePattern An optional table name pattern + * @returns An array containing the metadata of all matching tables (see {@link #getTables}) + * @type Array + */ +jala.db.getTableMetadata = function(database, tablePattern, schemaPattern) { + var conn = null; + try { + conn = database.getConnection(); + return jala.db.metadata.getTables(conn.getMetaData(), tablePattern, schemaPattern); + } finally { + if (conn != null) { + conn.close(); + } + } + return null; +}; + + + + +/***************************************** + *** D A T A B A S E S E R V E R *** + *****************************************/ + + +/** + * Returns a new Server instance. + * @class Instances of this class represent a H2 database listener that + * allows multiple databases to be accessed via tcp. + *
    Important: You need the h2.jar in directory "lib/ext" + * of your helma installation for this library to work, which you can get + * at http://www.h2database.com/. + * @param {helma.File} baseDir The directory where the database files + * are located or should be stored + * @param {Number} port The port to listen on (defaults to 9001) + * @param {Boolean} createOnDemand If true this server will create non-existing + * databases on-the-fly, if false it only accepts connections to already + * existing databases in the given base directory + * @param {Boolean} makePublic If true this database is reachable from outside, + * if false it's only reachable from localhost + * @param {Boolean} useSsl If true SSL will be used to encrypt the connection + * @returns A newly created Server instance + * @constructor + */ +jala.db.Server = function(baseDir, port) { + + /** + * Private variable containing the h2 server instance + * @type org.h2.tools.Server + * @private + */ + var server = null; + + /** + * An object containing configuration properties used when creating + * the server instance + * @private + */ + var config = { + "baseDir": baseDir.getAbsolutePath(), + "tcpPort": port || 9092, + "tcpSSL": false, + "ifExists": true, + "tcpAllowOthers": false, + "log": false + }; + + /** + * Returns the wrapped database server instance + * @returns The wrapped database server + * @type org.h2.tools.Server + * @private + */ + this.getServer = function() { + return server; + }; + + /** + * Returns the directory used by this server instance + * @returns The directory where the databases used by this + * server are located in + * @type helma.File + */ + this.getDirectory = function() { + return baseDir; + }; + + /** + * Returns the port this server listens on + * @returns The port this server listens on + * @type Number + */ + this.getPort = function() { + return config.tcpPort; + }; + + /** + * Returns the config of this server + * @returns The config of this server + * @private + */ + this.getConfig = function() { + return config; + }; + + /** + * Starts the database server. + * @returns True in case the server started successfully, false otherwise + * @type Boolean + */ + this.start = function() { + if (server != null && server.isRunning(true)) { + throw "jala.db.Server: already listening on port " + this.getPort(); + } + // convert properties into an array + var config = this.getConfig(); + var args = []; + for (var propName in config) { + args.push("-" + propName); + args.push(config[propName].toString()); + } + // create the server instance + server = Packages.org.h2.tools.Server.createTcpServer(args); + try { + server.start(); + } catch (e) { + app.logger.error("jala.db.Server: unable to start server, reason: " + e); + return false; + } + app.logger.info("jala.db.Server: listening on localhost:" + this.getPort()); + return true; + }; + + + return this; +}; + +/** @ignore */ +jala.db.Server.prototype.toString = function() { + return "[Jala Database Server]"; +}; + +/** + * Stops the database server. + * @returns True if stopping the server was successful, false otherwise + * @type Boolean + */ +jala.db.Server.prototype.stop = function() { + try { + this.getServer().stop(); + app.logger.info("jala.db.Server: stopped listening on localhost:" + + this.getPort()); + } catch (e) { + app.logger.error("jala.db.Server: Unable to stop, reason: " + e); + return false; + } + return true; +}; + +/** + * Returns true if the database server is running. + * @returns True if the database server is running + * @type Boolean + */ +jala.db.Server.prototype.isRunning = function() { + return this.getServer().isRunning(true); +}; + +/** + * Toggles the use of Ssl encryption within this server. This should be set + * before starting the server. + * @param {Boolean} bool If true SSL encryption will be used, false + * otherwise. If no argument is given, this method returns the + * current setting. + * @returns The current setting if no argument is given, or void + * @type Boolean + */ +jala.db.Server.prototype.useSsl = function(bool) { + var config = this.getConfig(); + if (bool != null) { + config.tcpSSL = (bool === true); + } else { + return config.tcpSSL; + } + return; +}; + +/** + * If called with boolean true as argument, this server creates databases + * on-the-fly, otherwise it only accepts connections to already existing + * databases. This should be set before starting the server. + * @param {Boolean} bool If true this server creates non-existing databases + * on demand, if false it only allows connections to existing databases. + * If no argument is given, this method returns the current setting. + * @returns The current setting if no argument is given, or void + * @type Boolean + */ +jala.db.Server.prototype.createOnDemand = function(bool) { + var config = this.getConfig(); + if (bool != null) { + config.ifExists = (bool === false); + } else { + return !config.ifExists; + } + return; +}; + +/** + * If called with boolean true as argument, this server accepts connections + * from outside localhost. This should be set before starting the server. + * @param {Boolean} bool If true this server accepts connections from outside + * localhost. If no argument is given, this method returns the current setting. + * @returns The current setting if no argument is given, or void + * @type Boolean + */ +jala.db.Server.prototype.isPublic = function(bool) { + var config = this.getConfig(); + if (bool != null) { + config.tcpAllowOthers = (bool === true); + } else { + return config.tcpAllowOthers; + } + return; +}; + +/** + * Returns the JDBC Url to use for connections to a given database. + * @param {String} name An optional name of a database running + * @param {Object} props Optional connection properties to add + * @returns The JDBC Url to use for connecting to a database + * within this sever + * @type String + */ +jala.db.Server.prototype.getUrl = function(name, props) { + res.push(); + res.write("jdbc:h2:"); + res.write(this.useSsl() ? "ssl" : "tcp"); + res.write("://localhost:"); + res.write(this.getPort()); + res.write("/"); + res.write(name); + res.write(jala.db.getPropertyString(props)) + return res.pop(); +}; + +/** + * Returns a properties object containing the connection properties + * of the database with the given name. + * @param {String} name The name of the database + * @param {String} username Optional username to use for this connection + * @param {String} password Optional password to use for this connection + * @param {Object} props An optional parameter object containing + * connection properties to add to the connection Url. + * @returns A properties object containing the connection properties + * @type helma.util.ResourceProperties + */ +jala.db.Server.prototype.getProperties = function(name, username, password, props) { + var rp = new Packages.helma.util.ResourceProperties(); + rp.put(name + ".url", this.getUrl(name, props)); + rp.put(name + ".driver", "org.h2.Driver"); + rp.put(name + ".user", username || "sa"); + rp.put(name + ".password", password || ""); + return rp; +}; + +/** + * Returns a connection to a database within this server. + * @param {String} name The name of the database running + * within this server + * @param {String} username Optional username to use for this connection + * @param {String} password Optional password to use for this connection + * @param {Object} props An optional parameter object + * containing connection properties to add to the connection Url. + * @returns A connection to the specified database + * @type helma.Database + */ +jala.db.Server.prototype.getConnection = function(name, username, password, props) { + var rp = this.getProperties(name, username, password, props); + var dbSource = new Packages.helma.objectmodel.db.DbSource(name, rp); + return new helma.Database(dbSource); +}; + + + +/***************************** + *** D A T A T Y P E *** + *****************************/ + + +/** + * Returns a newly created DataType instance. + * @class Instances of this class represent a data type. Each instance + * contains the code number as defined in java.sql.Types, the name of + * the data type as defined in java.sql.Types and optional creation parameters + * allowed for this data type. + * @param {Number} type The sql code number of this data type + * @param {String} typeName The type name of this data type, as used within sql statements + * @param {String} params Optional creation parameters allowed for this data type. + * @returns A newly created instance of DataType. + * @constructor + * @private + */ +jala.db.DataType = function(type, typeName, params) { + + /** + * Returns the sql type code number as defined in java.sql.Types + * @returns The sql type code number of this data type + * @type Number + */ + this.getType = function() { + return type; + }; + + /** + * Returns the type name of this data type, which can be + * used in sql queries. + * @returns The type name of this data type + * @type String + */ + this.getTypeName = function() { + return typeName; + }; + + /** + * Returns the creation parameter string of this data type + * @returns The creation parameter string of this data type + * @type String + */ + this.getParams = function() { + return params; + }; + + /** @ignore */ + this.toString = function() { + return "[DataType " + + " CODE: " + code + + ", SQL: " + sqlType + + ", PARAMS: " + params + "]"; + }; + + return this; +}; + +/** + * Returns true if values for this data type should be surrounded + * by (single) quotes. + * @returns True if values for this data type should be surrounded + * by quotes, false if not + * @type Boolean + */ +jala.db.DataType.prototype.needsQuotes = function() { + switch (this.getType()) { + case java.sql.Types.CHAR: + case java.sql.Types.VARCHAR: + case java.sql.Types.LONGVARCHAR: + case java.sql.Types.BINARY: + case java.sql.Types.VARBINARY: + case java.sql.Types.LONGVARBINARY: + case java.sql.Types.DATE: + case java.sql.Types.TIME: + case java.sql.Types.TIMESTAMP: + return true; + default: + return false; + } +}; + + + +/*********************************** + *** R A M D A T A B A S E *** + ***********************************/ + + +/** + * Returns a newly created RamDatabase instance. + * @class Instances of this class represent an in-memory sql database. + *
    Important: You need the h2.jar in directory "lib/ext" + * of your helma installation for this library to work, which you can get + * at http://www.h2database.com/. + * @param {String} name The name of the database. If not given a private + * un-named database is created, that can only be accessed through this instance + * of jala.db.RamDatabase + * @param {String} username Optional username (defaults to "sa"). This username + * is used when creating the database, so the same should be used when + * creating subsequent instances of jala.db.RamDatabase pointing to a named + * database. + * @param {String} password Optional password (defaults to ""). + * @returns A newly created instance of RamDatabase + * @constructor + */ +jala.db.RamDatabase = function(name, username, password) { + + /** + * Returns the name of the database + * @returns The name of the database + * @type String + */ + this.getName = function() { + return name; + }; + + /** + * Returns the username of this database + * @returns The username of this database + * @type String + */ + this.getUsername = function() { + return username || "sa"; + }; + + /** + * Returns the password of this database + * @returns The password of this database + * @type String + */ + this.getPassword = function() { + return password || ""; + }; + + return; +}; + +/** @ignore */ +jala.db.RamDatabase.prototype.toString = function() { + return "[Jala RamDatabase " + this.getName() + "]"; +} + +/** + * Returns the JDBC Url to connect to this database + * @param {Object} props Optional connection properties to add + * @returns The JDBC url to use for connecting to this database + * @type String + */ +jala.db.RamDatabase.prototype.getUrl = function(props) { + var url = "jdbc:h2:" + this.getDatabasePath(); + if (props != null) { + url += jala.db.getPropertyString(props); + } + return url; +}; + +/** + * Returns the path of this database, which is used by jala.db.Server + * when adding the database to its set of hosted databases. + * @returns The path of this database within a server instance + * @type String + * @private + */ +jala.db.RamDatabase.prototype.getDatabasePath = function() { + return "mem:" + this.getName(); +} + +/** + * Returns a properties object containing the connection properties + * for this database. + * @param {Object} props An optional parameter object containing + * connection properties to add to the connection Url. + * @returns A properties object containing the connection properties + * @type helma.util.ResourceProperties + */ +jala.db.RamDatabase.prototype.getProperties = function(props) { + var name = this.getName(); + var rp = new Packages.helma.util.ResourceProperties(); + rp.put(name + ".url", this.getUrl(props)); + rp.put(name + ".driver", "org.h2.Driver"); + rp.put(name + ".user", this.getUsername()); + rp.put(name + ".password", this.getPassword()); + return rp; +}; + +/** + * Returns a connection to this database + * @param {Object} An optional parameter object containing connection + * properties to add to the connection Url. + * @returns A connection to this database + * @type helma.Database + */ +jala.db.RamDatabase.prototype.getConnection = function(props) { + var name = this.getName(); + var rp = this.getProperties(props); + var dbSource = new Packages.helma.objectmodel.db.DbSource(name, rp); + return new helma.Database(dbSource); +}; + +/** + * Stops this in-process database by issueing a "SHUTDOWN" sql command. + */ +jala.db.RamDatabase.prototype.shutdown = function() { + var conn = this.getConnection(); + conn.execute("SHUTDOWN"); + return; +}; + +/** + * Creates a table in this database. + * @param {String} name The name of the table + * @param {Array} columns The columns to create in the table. Each column + * must be described using an object containing the following properties: + *
      + *
    • name (String): The name of the column
    • + *
    • type (Number): The type of the column as defined in java.sql.Types
    • + *
    • nullable (Boolean): If true the column may contain null values (optional, defaults to true)
    • + *
    • length (Number): The maximum length of the column (optional)
    • + *
    • precision (Number): The precision to use (optional)
    • + *
    • unique (Boolean): If true the column may only contain unique values (optional, defaults to false)
    • + *
    • default (Object): The default value to use (optional)
    • + *
    + * @param {String} primaryKey The name of the column that contains + * the primary key + * @private + */ +jala.db.RamDatabase.prototype.createTable = function(tableName, columns, primaryKey) { + res.push(); + res.write("CREATE TABLE "); + res.write(tableName); + res.write(" ("); + var column, dataType, params; + for (var i=0;i 0) { + res.write("("); + res.write(arr.join(",")); + res.write(")"); + } + } + if (column["default"]) { + res.write(" DEFAULT "); + if (dataType.needsQuotes() === true) { + res.write("'"); + res.write(column["default"]); + res.write("'"); + } else { + res.write(column["default"]); + } + } + if (column.nullable === false) { + res.write(" NOT NULL"); + } + if (i < columns.length - 1) { + res.write(", "); + } + } + if (primaryKey != null) { + res.write(", PRIMARY KEY ("); + if (primaryKey instanceof Array) { + res.write(primaryKey.join(", ")); + } else { + res.write(primaryKey); + } + res.write(")"); + } + res.write(")"); + var sql = res.pop(); + try { + var conn = this.getConnection(); + conn.execute(sql); + app.logger.info("Successfully created table " + tableName); + app.logger.debug("Sql statement used: " + sql); + return true; + } catch (e) { + app.logger.error("Unable to create table " + tableName + ", reason: " + e); + return false; + } +}; + +/** + * Drops the table with the given name + * @param {String} tableName The name of the table + * @returns True if the table was successfully dropped, false otherwise + * @type Boolean + */ +jala.db.RamDatabase.prototype.dropTable = function(tableName) { + var conn = this.getConnection(); + var sql = "DROP TABLE " + tableName; + conn.execute(sql); + return; +}; + +/** + * Returns true if the table exists already in the database + * @param {String} name The name of the table + * @returns True if the table exists, false otherwise + * @type Boolean + */ +jala.db.RamDatabase.prototype.tableExists = function(name) { + var conn = this.getConnection().getConnection(); + var meta = conn.getMetaData(); + var t = meta.getTables(null, "PUBLIC", "%", null); + var tableName; + try { + while (t.next()) { + tableName = t.getString(3).toUpperCase(); + if (tableName.toLowerCase() === name.toLowerCase()) { + return true; + } + } + return false; + } finally { + if (t != null) { + t.close(); + } + } +}; + +/** + * Copies all tables in the database passed as argument into this embedded database. + * If any of the tables already exists in this database, they will be removed before + * re-created. Please mind that this method ignores any indexes in the source database, + * but respects the primary key settings. + * @param {helma.Database} database The database to copy the tables from + * @param {Array} tables An optional array containing the names of the tables to copy. + * If not given all tables are copied + */ +jala.db.RamDatabase.prototype.copyTables = function(database, tables) { + // retrieve the metadata for all tables in this schema + var conn = null; + try { + conn = database.getConnection(); + var dbMetadata = conn.getMetaData(); + if (tables === null || tables === undefined) { + // no tables specified, so copy all available + tables = jala.db.metadata.getTableNames(dbMetadata); + } + + for each (var tableName in tables) { + // drop the table if it exists + if (this.tableExists(tableName)) { + this.dropTable(tableName); + } + // retrieve the table metadata and create the table + var metadata = jala.db.metadata.getTables(dbMetadata, tableName); + if (metadata !== null && metadata.length > 0) { + this.createTable(metadata[0].name, metadata[0].columns, metadata[0].keys); + } + } + } finally { + if (conn != null) { + conn.close(); + } + } + return; +}; + +/** + * Returns an array containing all available data types. + * @returns All available data types + * @type Array + * @see jala.db.DataType + * @private + */ +jala.db.RamDatabase.prototype.getDataTypes = function() { + // data types are cached for performance reasons + if (!arguments.callee.cache) { + // java.sql data types + arguments.callee.cache = []; + var con = this.getConnection().getConnection(); + var meta = con.getMetaData(); + var rs = meta.getTypeInfo(); + var code, name, params; + while (rs.next()) { + code = rs.getInt("DATA_TYPE"); + name = rs.getString("TYPE_NAME"); + params = rs.getString("CREATE_PARAMS"); + arguments.callee.cache.push(new jala.db.DataType(code, name, params)); + } + } + return arguments.callee.cache; +}; + +/** + * Returns the data type for the code passed as argument + * @param {Number} type The type code as defined in java.sql.Types + * @returns The data type object for the code + * @type jala.db.DataType + * @private + */ +jala.db.RamDatabase.prototype.getDataType = function(type) { + var types = this.getDataTypes(); + var dataType; + for (var i=0;iImportant: You need the h2.jar in directory "lib/ext" + * of your helma installation for this library to work, which you can get + * at http://www.h2database.com/. + * @param {String} name The name of the database. This name is used as + * prefix for all database files + * @param {helma.File} directory The directory where the database files + * should be stored in. + * @param {String} username Optional username (defaults to "sa"). This username + * is used when creating the database, so the same should be used when + * creating subsequent instances of jala.db.FileDatabase pointing to the + * same database + * @param {String} password Optional password (defaults to ""). + * @returns A newly created FileDatabase instance + * @constructor + */ +jala.db.FileDatabase = function(name, directory, username, password) { + + /** + * Returns the name of the database. This name is used as prefix + * for all files of this database in the specified directory + * @returns The name of the database + * @type String + */ + this.getName = function() { + return name; + }; + + /** + * Returns the directory where the database files are stored. + * @returns The directory where this database is stored. + * @type helma.File + */ + this.getDirectory = function() { + return directory; + }; + + /** + * Returns the username of this database + * @returns The username of this database + * @type String + */ + this.getUsername = function() { + return username || "sa"; + }; + + /** + * Returns the password of this database + * @returns The password of this database + * @type String + */ + this.getPassword = function() { + return password || ""; + }; + + if (!name || typeof(name) != "string" || + !directory || !(directory instanceof helma.File)) { + throw "jala.db.FileDatabase: Missing or invalid arguments" + } else if (!directory.exists()) { + throw "jala.db.FileDatabase: directory '" + directory + "' does not exist"; + } + + return this; +}; +// extend RamDatabase +jala.db.FileDatabase.prototype = new jala.db.RamDatabase(); + +/** @ignore */ +jala.db.FileDatabase.prototype.toString = function() { + return "[Jala FileDatabase '" + this.getName() + "' in " + + this.getDirectory().getAbsolutePath() + "]"; +}; + +/** + * Returns the path of this database, which is used when adding + * the database to a server instance. + * @returns The path of this database within a server instance + * @type String + * @private + */ +jala.db.FileDatabase.prototype.getDatabasePath = function() { + var directory = new helma.File(this.getDirectory(), this.getName()); + return "file:" + directory.getAbsolutePath(); +}; + +/** + * Deletes all files of this database on disk. Note that this also + * closes the database before removing it. + * @returns True in case the database was removed successfully, false otherwise + * @type Boolean + */ +jala.db.FileDatabase.prototype.remove = function() { + var directory = this.getDirectory(); + try { + // shut down the database + this.shutdown(); + Packages.org.h2.tools.DeleteDbFiles.execute( + directory.getAbsolutePath(), + this.getName(), + false + ); + } catch(e) { + app.logger.error("jala.db: Unable to delete database in " + + directory.getAbsolutePath() + ", reason: " + e); + return false; + } + return true; +}; + +/** + * Creates a backup of this database, using the file passed as argument. The + * result will be a zipped file containing the database files + * @param {helma.File} file The file to write the backup to + * @returns True if the database backup was created successfully, false otherwise + * @type Boolean + */ +jala.db.FileDatabase.prototype.backup = function(file) { + try { + Packages.org.h2.tools.Backup.execute( + file.getAbsolutePath(), + this.getDirectory().getAbsolutePath(), + this.getName(), + false + ); + } catch (e) { + app.logger.error("jala.db: Unable to backup database to '" + + file.getAbsolutePath() + ", reason: " + e); + return false; + } + return true; +}; + +/** + * Restores this database using a backup on disk. + * @param {helma.File} backupFile The backup file to use for restore + * @returns True if the database was successfully restored, false otherwise + * @type Boolean + */ +jala.db.FileDatabase.prototype.restore = function(backupFile) { + try { + Packages.org.h2.tools.Restore.execute( + backupFile.getAbsolutePath(), + this.getDirectory().getAbsolutePath(), + this.getName(), + false + ); + } catch (e) { + app.logger.error("jala.db: Unable to restore database using '" + + backupFile.getAbsolutePath() + ", reason: " + e); + return false; + } + return true; +}; diff --git a/modules/jala/code/Date.js b/modules/jala/code/Date.js new file mode 100644 index 00000000..0a282af1 --- /dev/null +++ b/modules/jala/code/Date.js @@ -0,0 +1,545 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Fields and methods of the jala.Date class. + */ + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * HelmaLib dependencies + */ +app.addRepository("modules/core/Date.js"); +app.addRepository("modules/helma/Html.js"); + +/** + * Constructs a new Renderings object. + * @class This class provides various convenience + * methods for rendering purposes. + * @constructor + */ +jala.Date = function() { + return this; +}; + +/** + * Renders a timestamp as set of DropDown boxes, following the + * format passed as argument. Every <select> + * item is prefixed with a string so that it can be retrieved + * easily from the values of a submitted POST request. + * @param {String} prefix The prefix to use for all dropdown boxes, eg. "postdate" + * @param {Date} date A Date object to use as preselection (optional) + * @param {Object} fmt Array containing one parameter object for every single + * select box that should be rendered, with the following properties set: + *
      + *
    • pattern - The date format pattern that should be rendered. Valid + * patterns are: "dd", "MM", "yyyy", "HH", "ss".
    • + *
    • firstOption - The string to use as first option, eg.: "choose a day"
    • + *
    + */ +jala.Date.prototype.renderEditor = function(prefix, date, fmt) { + /** + * rendering method + * @private + */ + var render = function(param, date) { + switch (param.pattern) { + case "dd": + param.offset = 1; + param.max = 31; + param.selected = (date ? date.getDate() : null); + break; + + case "MM": + param.offset = 1; + param.max = 12; + param.selected = (date ? date.getMonth() +1 : null); + break; + + case "yyyy": + param.offset = 2002; + param.max = 20; + param.selected = (date ? date.getFullYear() : null); + break; + + case "HH": + param.offset = 0; + param.max = 24; + param.selected = (date ? date.getHours() : null); + break; + + case "mm": + param.offset = 0; + param.max = 60; + param.selected = (date ? date.getMinutes() : null); + break; + + case "ss": + param.offset = 0; + param.max = 60; + param.selected = (date ? date.getSeconds() : null); + break; + } + + var key = prefix + ":" + param.pattern; + if (req.data[key]) + param.selected = req.data[key]; + var options = []; + var opt; + for (var i=0;i days) { + renderer.renderDay(null); + } else { + date.setDate(daycnt); + if ((dayObj = collection.get(date.format(accessNameFormat))) != null) { + idx = collection.contains(dayObj); + if (idx > -1) { + if (idx > firstDayIndex) { + firstDayIndex = idx; + } + if (idx < lastDayIndex) { + lastDayIndex = idx; + } + } + } + selected = (today != null) ? date.equals(today) : false; + renderer.renderDay(date, dayObj != null, selected); + daycnt++; + } + } + renderer.renderRow(res.pop()); + } + var prevMonth = prevNextMonth("prev", firstDayIndex) || null; + var nextMonth = prevNextMonth("next", lastDayIndex) || null; + renderer.renderCalendar(date, res.pop(), prevMonth, nextMonth); + return; +}; + +/** + * Returns a rendered calendar + * @see #renderCalendar + * @type String + */ +jala.Date.Calendar.prototype.getCalendar = function(today) { + res.push(); + this.render(today); + return res.pop(); +}; + +/** + * Returns a new instance of the default calendar renderer. + * @class A default renderer to use in conjunction with jala.Date.Calendar + * @param {jala.Date.Calendar} calendar The calendar utilizing this renderer + * @returns A newly created instance of jala.Date.Calendar.Renderer + * @constructor + */ +jala.Date.Calendar.Renderer = function(calendar) { + + /** + * An instance of helma.Html used for rendering the calendar + * @type helma.Html + */ + this.html = new helma.Html(); + + /** + * The calendar utilizing this renderer instance + * @type jala.Date.Calendar + */ + this.calendar = calendar; + + return this; +}; + +/** @ignore */ +jala.Date.Calendar.Renderer.prototype.toString = function() { + return "[Jala Calendar Default Renderer]"; +}; + +/** + * Renders a single cell in the calendar day header row directly to response. + * @param {String} text The text to display in the header field. + */ +jala.Date.Calendar.Renderer.prototype.renderDayHeader = function(text) { + this.html.element("th", text); + return; +}; + +/** + * Renders a single calendar row directly to response. + * @param {String} row The body of the calendar row. + */ +jala.Date.Calendar.Renderer.prototype.renderRow = function(row) { + this.html.element("tr", row); + return; +}; + +/** + * Renders a single day within the calendar directly to response. + * @param {Date} date A date instance representing the day within the calendar. + * @param {Boolean} isExisting True if there is a child object in the calendar's + * collection to which the date cell should link to + * @param {Boolean} isSelected True if this calendar day should be rendered + * as selected day. + */ +jala.Date.Calendar.Renderer.prototype.renderDay = function(date, isExisting, isSelected) { + var attr = {"class": "jala-calendar-day day"}; + if (isSelected === true) { + attr["class"] += " jala-calendar-selected selected"; + } + this.html.openTag("td", attr); + if (date != null) { + var text = date.getDate(); + if (isExisting === true) { + attr = {"href": this.calendar.getCollection().href() + + date.format(this.calendar.getHrefFormat())}; + this.html.link(attr, text); + } else { + res.write(text); + } + } + this.html.closeTag("td"); + return; +}; + +/** + * Renders a link to the previous or next month's calendar directly to response. + * @param {Date} date A date object set to the previous or next available + * month. This can be null in case there is no previous or next month. + */ +jala.Date.Calendar.Renderer.prototype.renderPrevNextLink = function(date) { + if (date != null) { + var attr = {"href": this.calendar.getCollection().href() + + date.format(this.calendar.getHrefFormat())}; + this.html.link(attr, date.format("MMMM", this.calendar.getLocale())); + } + return; +}; + +/** + * Renders the calendar directly to response. + * @param {Date} date A date object representing this calendar's month and year. + * Please mind that the day will be set to the last date in this + * month. + * @param {String} body The rendered calendar weeks including the day header + * (basically the whole kernel of the table). + * @param {Date} prevMonth A date object set to the last available date of + * the previous month. This can be used to render a navigation link to + * the previous month. + * @param {Date} nextMonth A date object set to the first available date + * of the next month. This can be used to render a navigation link to + * the next month. + */ +jala.Date.Calendar.Renderer.prototype.renderCalendar = function(date, body, prevMonth, nextMonth) { + var locale = this.calendar.getLocale(); + this.html.openTag("table", {"class": "jala-calendar calendar"}); + this.html.openTag("thead"); + this.html.openTag("tr"); + this.html.openTag("th", {"colspan": 7}); + res.write(date.format("MMMM", locale)); + res.write(' '); + res.write(date.format("yyyy", locale)); + this.html.closeTag("th"); + this.html.closeTag("tr"); + this.html.closeTag("thead"); + this.html.element("tbody", body); + this.html.openTag("tfoot"); + this.html.openTag("tr"); + this.html.openTag("td", {"class": "jala-calendar-left left", "colspan": 3}); + this.renderPrevNextLink(prevMonth); + this.html.closeTag("td"); + this.html.openTag("td"); + this.html.closeTag("td"); + this.html.openTag("td", {"class": "jala-calendar-right right", "colspan": 3}); + this.renderPrevNextLink(nextMonth); + this.html.closeTag("td"); + this.html.closeTag("tr"); + this.html.closeTag("tfoot"); + this.html.closeTag("table"); + return; +}; + +/** + * Default date class instance. + * @type jala.Date + * @final + */ +jala.date = new jala.Date(); diff --git a/modules/jala/code/DnsClient.js b/modules/jala/code/DnsClient.js new file mode 100644 index 00000000..810cf15b --- /dev/null +++ b/modules/jala/code/DnsClient.js @@ -0,0 +1,312 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.DnsClient class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Jala dependencies + */ +app.addRepository(getProperty("jala.dir", "modules/jala") + + "/lib/javadns.jar"); + +/** + * Constructs a new DnsClient object. + * @class This is a wrapper around the Dns Client by wonderly.org + * providing methods for querying Dns servers. For more information + * about the Java DNS client visit + * https://javadns.dev.java.net/. + * Please mind that the nameserver specified must accept queries on port + * 53 TCP (the Java DNS client used doesn't support UDP nameserver queries), + * and that reverse lookups are not supported. + * @param {String} nameServer IP-Address or FQDN of nameserver to query + * @constructor + */ +jala.DnsClient = function(nameServer) { + /** + * Contains the IP Adress/FQDN of the name server to query. + * @type String + */ + this.nameServer = nameServer; + + if (!this.nameServer) { + throw "jala.DnsClient: missing nameserver argument"; + } else { + // test if required javadns library is available + try { + var clazz = java.lang.Class.forName("org.wonderly.net.dns.Query", + false, app.getClassLoader()) + } catch (e) { + throw "jala.DnsClient requires JavaDNS.jar" + + " in lib/ext or application directory " + + "[https://javadns.dev.java.net/]"; + } + } + + return this; +}; + +/** @ignore */ +jala.DnsClient.PKG = Packages.org.wonderly.net.dns; + +/** + * The "A" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_A = jala.DnsClient.PKG.Question.TYPE_A; + +/** + * The "CNAME" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_CNAME = jala.DnsClient.PKG.Question.TYPE_CNAME; + +/** + * The "MX" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_MX = jala.DnsClient.PKG.Question.TYPE_MX; + +/** + * The "NS" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_NS = jala.DnsClient.PKG.Question.TYPE_NS; + +/** + * The "PTR" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_PTR = jala.DnsClient.PKG.Question.TYPE_PTR; + +/** + * The "SOA" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_SOA = jala.DnsClient.PKG.Question.TYPE_SOA; + +/** + * The "TXT" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_TXT = jala.DnsClient.PKG.Question.TYPE_TXT; + +/** + * The "WKS" record/query type. + * @type Number + * @final + */ +jala.DnsClient.TYPE_WKS = jala.DnsClient.PKG.Question.TYPE_WKS; + +/** + * Queries the nameserver for a specific domain + * and the given type of record. + * @param {String} dName The domain name to query for + * @param {Number} queryType The type of records to retrieve + * @returns The records retrieved from the nameserver + * @type org.wonderly.net.dns.RR + */ +jala.DnsClient.prototype.query = function(dName, queryType) { + if (dName == null) { + throw new Error("no domain-name to query for"); + } + if (queryType == null) { + queryType = jala.DnsClient.TYPE_A; + } + // construct the question for querying the nameserver + var question = new jala.DnsClient.PKG.Question(dName, + queryType, + jala.DnsClient.PKG.Question.CLASS_IN); + // construct the query + var query = new jala.DnsClient.PKG.Query(question); + // run the query + query.runQuery(this.nameServer); + // wrap the records received in instances of jala.DnsClient.Record + var answers = query.getAnswers(); + var arr = []; + for (var i=0;i<% param.label prefix=' ' suffix='\n' %><% param.controls prefix=' ' suffix='\n' %><% param.help prefix=' ' suffix='\n' %>"); + + /** + * Contains a map of component objects. + * @type Object + */ + this.components = {}; + + /** + * Returns an array containing the components + * of this jala.Form instance. + * @returns The components of this jala.Form instance. + * @type Array + */ + this.listComponents = function() { + return components; + }; + + /** + * Adds a component to this jala.Form instance + * @param {jala.Form.Component.Input} component + */ + this.addComponent = function(component) { + component.setForm(this); + components.push(component); + this.components[component.name] = component; + return; + }; + + /** + * Returns true if this instance of jala.Form contains at least + * one component doing a file upload. + * @see jala.Form.Component#containsFileUpload + * @type Boolean + */ + this.containsFileUpload = function() { + for (var i=0; ithe name of the element
  • + *
  • the parsed value of the element if all requirements have + * been fulfilled. E.g., for a date editor, the parsed value would + * be a date object.
  • + *
  • the map containing all user inputs as string (req.data)
  • + *
  • the form object
  • + * @see #validate + * @type Function + */ + this.validator; + + this.__defineGetter__("validator", function() { return validator; }); + this.__defineSetter__("validator", function(newValidator) { + if (newValidator instanceof Function) { + validator = newValidator; + } else { + throw "Invalid argument: validator must be a function"; + } + return; + }); + + return this; +}; +// extend jala.Form.Component +jala.Form.extend(jala.Form.Component.Input, jala.Form.Component); + +/** + * Validates the input provided to this component. First, + * checkRequirements is called. If no error occurs, the input + * is parsed using parseValue and passed on to the validator + * function. + * @see #checkRequirements + * @see #parseValue + * @param {jala.Form.Tracker} tracker Tracker object collecting + * request data, error messages and parsed values. + */ +jala.Form.Component.Input.prototype.validate = function(tracker) { + var error = this.checkRequirements(tracker.reqData); + if (error != null) { + tracker.errors[this.name] = error; + } else { + tracker.values[this.name] = this.parseValue(tracker.reqData); + if (this.validator) { + error = this.validator.call( + this.form.getDataObject(), + this.name, + tracker.values[this.name], + tracker.reqData, + this.form + ); + if (error != null) { + tracker.errors[this.name] = error; + } + } + } + return; +}; + +/** + * Saves the parsed value using setValue. + * @see #setValue + * @param {jala.Form.Tracker} tracker Tracker object collecting + * request data, error messages and parsed values. + * @param {Object} destObj (optional) object whose values will be changed. + */ +jala.Form.Component.Input.prototype.save = function(tracker, destObj) { + this.setValue(destObj, tracker.values[this.name]); + return; +}; + +/** + * Retrieves the property which is edited by this component. + * + * @returns The value of the property + * @type String|Number|Date + */ +jala.Form.Component.Input.prototype.getValue = function() { + if (this.form.getTracker()) { + // handling re-rendering + return null; + } else { + var getter = (this.getter) ? this.getter : this.form.getter; + return getter.call(this.form.getDataObject(), this.name); + } +}; + +/** + * Sets a property of the object passed as argument to the given value. + *
  • If no setter is set at the component, the primitive property + * of the data object is changed.
  • + *
  • If a setter function is defined it is executed with the data object + * as scope and with the name and new value provided as arguments
  • + *
  • If the setter is explicitly set to null, no changes are made at all.
  • + * @param {Object} destObj (optional) object whose values will be changed. + * @param {Object} value The value to set the property to + * @returns True in case the update was successful, false otherwise. + * @see jala.Form#setter + */ +jala.Form.Component.Input.prototype.setValue = function(destObj, value) { + // default value for this.setter is undefined, so if it has been + // set to explicitly null, we don't save the value. in this case, + // we assume, the property is handled outside of jala.Form or purposely + // ignored at all. + if (this.setter !== null) { + var setter = (this.setter) ? this.setter : this.form.setter; + setter.call(destObj, this.name, value); + } + return; +}; + +/** + * Renders this component including label, error and help messages directly + * to response. + */ +jala.Form.Component.Input.prototype.render = function() { + var className = (this.getRequirement(jala.Form.REQUIRE) == true) ? "require" : "optional"; + if (this.getClassName()) { + className += " " + this.getClassName(); + } + var tracker = this.form.getTracker(); + if (tracker && tracker.errors[this.name]) { + className += " error"; + } + + jala.Form.html.openTag("div", + {id: this.createDomId(), + "class": "component " + className} + ); + res.write("\n"); + renderSkin(this.form.componentSkin, this); + jala.Form.html.closeTag("div"); + res.write("\n"); + return; +}; + +/** + * If the error tracker holds an error message for this component, + * it is wrapped in a div-tag and returned as a string. + * @returns Rendered string + * @type String + */ +jala.Form.Component.Input.prototype.renderError = function() { + var tracker = this.form.getTracker(); + if (tracker && tracker.errors[this.name]) { + return jala.Form.html.elementAsString("div", + tracker.errors[this.name], + {"class": "errorText"} + ); + } + return null; +}; + +/** + * Returns the rendered label of this component + * @returns The rendered label of this component + * @type String + */ +jala.Form.Component.Input.prototype.renderLabel = function() { + return jala.Form.html.elementAsString( + "label", + this.getLabel() || "", + {"for": this.createDomId("control")} + ); +}; + +/** + * If this component contains a help message, it is wrapped in + * a div-tag and returned as a string. + * @returns The rendered help message + * @type String + */ +jala.Form.Component.Input.prototype.renderHelp = function() { + var help = this.getHelp(); + if (help) { + return jala.Form.html.elementAsString( + "div", + help, + {"class": "helpText"} + ); + } + return null; +}; + + +/** + * Renders this component including label, error and help messages + * directly to response + */ +jala.Form.Component.Input.prototype.render_macro = function() { + this.render(); + return; +}; + +/** + * Renders the control(s) of this component + */ +jala.Form.Component.Input.prototype.controls_macro = function() { + var attr = this.getControlAttributes(); + var tracker = this.form.getTracker() + if (tracker) { + this.renderControls(attr, null, tracker.reqData); + } else { + this.renderControls(attr, this.getValue()); + } + return; +}; + +/** + * Renders this component's error message (if set) directly to response + */ +jala.Form.Component.Input.prototype.error_macro = function() { + res.write(this.renderError()); + return; +}; + +/** + * Renders this component's label. + */ +jala.Form.Component.Input.prototype.label_macro = function() { + res.write(this.renderLabel()); + return; +}; + +/** + * Renders this component's help text, if set. + */ +jala.Form.Component.Input.prototype.help_macro = function() { + res.write(this.renderHelp()); + return; +}; + +/** + * Renders this component's id + * @see jala.Form#createDomId + */ +jala.Form.Component.Input.prototype.id_macro = function() { + res.write(this.createDomId()); + return; +}; + +/** + * Renders this component's name + */ +jala.Form.Component.Input.prototype.name_macro = function() { + res.write(this.name); + return; +}; + +/** + * Renders this component's type + */ +jala.Form.Component.Input.prototype.type_macro = function() { + res.write(this.getType()); + return; +}; + +/** + * Renders this component's class name. + * Note that this is just the class name that has been explicitly + * assigned using setClassName. + * @see #setClassName + */ +jala.Form.Component.Input.prototype.class_macro = function() { + var className = this.getClassName(); + if (className) { + res.write(className); + } + return; +}; + + +/** + * Creates a new attribute object for this element. + * @returns Object with properties id, name, class + * @type Object + */ +jala.Form.Component.Input.prototype.getControlAttributes = function() { + var attr = { + id: this.createDomId("control"), + name: this.name, + "class": this.getType() + }; + if (this.getClassName()) { + attr["class"] += " " + this.getClassName(); + } + return attr; +}; + +/** + * Checks user input for maximum length, minimum length and require + * if the corresponding options have been set using the require method. + * @param {Object} reqData request data + * @returns String containing error message or null if everything is ok. + * @type String + * @see #require + */ +jala.Form.Component.Input.prototype.checkLength = function(reqData) { + var require = this.getRequirement(jala.Form.REQUIRE); + var minLength = this.getRequirement(jala.Form.MINLENGTH); + var maxLength = this.getRequirement(jala.Form.MAXLENGTH); + + if (require && (reqData[this.name] == null || reqData[this.name].trim() == "")) { + return this.getMessage(jala.Form.REQUIRE, "Please enter text into this field."); + } else if (maxLength && reqData[this.name].length > maxLength) { + return this.getMessage(jala.Form.MAXLENGTH, "Input for this field is too long ({0} characters). Please enter no more than {1} characters.", + reqData[this.name].length, maxLength); + } else if (minLength) { + // set an error if the element is required but the input is too short + // but don't throw an error if the element is optional and empty + if (reqData[this.name].length < minLength && + (require || (!require && reqData[this.name].length > 0))) { + return this.getMessage(jala.Form.MINLENGTH, "Input for this field is too short ({0} characters). Please enter at least {1} characters.", + reqData[this.name].length, minLength); + } + } + return null; +}; + +/** + * Checks user input against options set using the require method. + * @param {Object} reqData request data + * @returns String containing error message or null if everything is ok. + * @type String + * @see #checkLength + * @see #require + */ +jala.Form.Component.Input.prototype.checkRequirements = function(reqData) { + return this.checkLength(reqData); +}; + +/** + * Parses the string input from the form and creates the datatype that + * is edited with this component. For the input component this method + * is not of much use, but subclasses that edit other datatypes may use + * it. For example, a date editor should convert the user input from string + * to a date object. + * @param {Object} reqData request data + * @returns parsed value + * @type Object + */ +jala.Form.Component.Input.prototype.parseValue = function(reqData) { + return reqData[this.name]; +}; + +/** + * Renders the html form elements to the response. + * This method shall be overridden by subclasses of input component. + * @param {Object} attr Basic attributes for the html form elements. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Input.prototype.renderControls = function(attr, value, reqData) { + attr.value = (reqData) ? reqData[this.name] : value; + if (this.getRequirement(jala.Form.MAXLENGTH)) { + attr.maxlength = this.getRequirement(jala.Form.MAXLENGTH); + } + jala.Form.html.input(attr); + return; +}; + +/** + * Constructs a newly created Password component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * password input tag. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Password component instance + * @constructor + */ +jala.Form.Component.Password = function Password(name) { + jala.Form.Component.Password.superConstructor.apply(this, arguments); + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Password, jala.Form.Component.Input); + +/** + * Renders a password input tag to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Password.prototype.renderControls = function(attr, value, reqData) { + attr.value = (reqData) ? reqData[this.name] : value; + if (this.getRequirement(jala.Form.MAXLENGTH)) { + attr.maxlength = this.getRequirement(jala.Form.MAXLENGTH); + } + jala.Form.html.password(attr); + return; +}; + +/** + * Constructs a newly created Hidden component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * hidden input tag. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Hidden component instance + * @constructor + */ +jala.Form.Component.Hidden = function Hidden(name) { + jala.Form.Component.Hidden.superConstructor.apply(this, arguments); + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Hidden, jala.Form.Component.Input); + +/** + * Renders this component directly to response. For a hidden tag, this is + * just an input element, no div tag or anything. + */ +jala.Form.Component.Hidden.prototype.render = function() { + var attr = this.getControlAttributes(); + var tracker = this.form.getTracker() + if (tracker) { + this.renderControls(attr, null, tracker.reqData); + } else { + this.renderControls(attr, this.getValue()); + } + return; +}; + +/** + * Renders a hidden input tag to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Hidden.prototype.renderControls = function(attr, value, reqData) { + attr.value = (reqData) ? reqData[this.name] : value; + jala.Form.html.hidden(attr); + return; +}; + +/** + * Constructs a new Textarea component. + * @class Subclass of jala.Form.Component.Input which renders and validates a + * textarea input field. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Textarea component instance + * @constructor + */ +jala.Form.Component.Textarea = function Textarea(name) { + jala.Form.Component.Textarea.superConstructor.apply(this, arguments); + + var rows, cols = undefined; + + /** + * Returns the row numbers for this component. + * @returns row numbers + * @type String + */ + this.getRows = function() { + return rows; + }; + + /** + * Sets the row numbers for this component. + * @param {String} newRows new row numbers + */ + this.setRows = function(newRows) { + rows = newRows; + return; + }; + + /** + * Returns the col numbers for this component. + * @returns col numbers + * @type String + */ + this.getCols = function() { + return cols; + }; + + /** + * Sets the col numbers for this component. + * @param {String} newCols new col numbers + */ + this.setCols = function(newCols) { + cols = newCols; + return; + }; + + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Textarea, jala.Form.Component.Input); + +/** + * Renders a textarea input field to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Textarea.prototype.renderControls = function(attr, value, reqData) { + attr.value = (reqData) ? reqData[this.name] : value; + attr.rows = this.getRows() || 5; + attr.cols = this.getCols() || 25; + jala.Form.html.textArea(attr); + return; +}; + +/** + * Constructs a new Date component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * date editor. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Date component + * @constructor + */ +jala.Form.Component.Date = function Date(name) { + jala.Form.Component.Date.superConstructor.apply(this, arguments); + + var dateFormat = "d.M.yyyy H:m"; + var dateFormatObj; + + /** + * Returns the date format for this component. + * @returns date format object + * @type java.text.SimpleDateFormat + */ + this.getDateFormat = function() { + if (!dateFormatObj || dateFormatObj.toPattern() != dateFormat) { + dateFormatObj = new java.text.SimpleDateFormat(dateFormat); + } + return dateFormatObj; + }; + + /** + * Sets the date format for this component. + * @param {String} newDateFormat new date format + */ + this.setDateFormat = function(newDateFormat) { + dateFormat = newDateFormat; + return; + }; + + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Date, jala.Form.Component.Input); + +/** + * Renders a textarea tag to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Date.prototype.renderControls = function(attr, value, reqData) { + if (reqData) { + attr.value = reqData[this.name]; + } else if (value instanceof Date) { + attr.value = this.getDateFormat().format(value); + } + if (this.getRequirement(jala.Form.MAXLENGTH)) { + attr.maxlength = this.getRequirement(jala.Form.MAXLENGTH); + } + jala.Form.html.input(attr); + return; +}; + +/** + * Validates user input from a date editor. + * @param {Object} reqData request data + * @returns null if everything is ok or string containing error message + * @type String + */ +jala.Form.Component.Date.prototype.checkRequirements = function(reqData) { + try { + this.parseValue(reqData); + return null; + } catch(e) { + return this.getMessage("invalid", "This date cannot be parsed."); + } +}; + +/** + * Parses the string input from the form and converts it to a date object. + * Throws an error if the string cannot be parsed. + * @param {Object} reqData request data + * @returns parsed date value + * @type Date + */ +jala.Form.Component.Date.prototype.parseValue = function(reqData) { + return this.getDateFormat().parse(reqData[this.name]); +}; + +/** + * Constructs a new Select component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * dropdown element. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Select component + * @constructor + */ +jala.Form.Component.Select = function Select(name) { + jala.Form.Component.Select.superConstructor.apply(this, arguments); + + var options, firstOption = undefined; + + /** + * Returns the option list for this component. + */ + this.getOptions = function() { + return options; + }; + + /** + * Sets the option list for this component. + * The argument may either be an array that will be used as option list, + * or a function that is called when the option component is rendered and + * has to return an option array. + * For both arrays those formats are allowed: + *
  • Array of arrays [ [val, display], [val, display], .. ]
  • + *
  • Array of objects [ {value:val, display:display}, .. ]
  • + *
  • Array of strings [ display, display, .. ] In this case, + * the index position of the string will be the value.
  • + * @param {Array Function} newOptions Array or function defining option list. + */ + this.setOptions = function(newOptions) { + options = newOptions; + return; + }; + + /** + * Returns the text that should be displayed if no value is selected. + * @type String + */ + this.getFirstOption = function() { + return firstOption; + }; + + /** + * Sets the text that is displayed if no value is selected + * @param {String} newFirstOption text to display as first option element. + */ + this.setFirstOption = function(newFirstOption) { + firstOption = newFirstOption; + return; + }; + + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Select, jala.Form.Component.Input); + +/** + * Renders a dropdown element to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Select.prototype.renderControls = function(attr, value, reqData) { + value = (reqData) ? reqData[this.name] : value; + jala.Form.html.dropDown(attr, this.parseOptions(), value, this.getFirstOption()); + return; +}; + +/** + * Validates user input from a dropdown element by making sure that + * the option value list contains the user input. + * @see jala.Form.Component.Select#checkOptions + * @param {Object} reqData request data + * @returns string containing error message or null if everything is ok. + * @type String + */ +jala.Form.Component.Select.prototype.checkRequirements = function(reqData) { + return this.checkOptions(reqData); +}; + +/** + * Creates an array of options for a dropdown element or a + * group of radiobuttons. If options field of this element's + * config is an array, that array is returned. + * If options is a function, its return value is returned. + * @returns array of options + * @type Array + */ +jala.Form.Component.Select.prototype.parseOptions = function() { + var options = this.getOptions(); + if (options != null) { + if (options instanceof Array) { + return options; + } else if (options instanceof Function) { + return options.call(this.form.getDataObject(), this.name); + } + } + return []; +}; + +/** + * Checks user input for optiongroups: Unless require("checkoptions") + * has ben set to false, the user input must exist in the option array. + * @param {Object} reqData request data + * @returns null if everything is ok or string containing error message + * @type String + */ +jala.Form.Component.Select.prototype.checkOptions = function(reqData) { + // if field is required, an empty option is not allowed: + var found = (!this.getRequirement(jala.Form.REQUIRE) && !reqData[this.name]); + if (!found) { + if (this.getRequirement(jala.Form.CHECKOPTIONS) === false) { + // exit, if option check shall be suppressed + return null; + } + var options = this.parseOptions(); + var val = reqData[this.name]; + for (var i=0; i 0) { + // option is an array (1st element = value, 2nd = display) + if (options[i][0] == reqData[this.name]) { + found = true; + break; + } + } else if (options[i].value && options[i].display) { + // option is an object with fields value + display + if (options[i].value == reqData[this.name]) { + found = true; + break; + } + } else { + // option is a string, value is index number + if (i == reqData[this.name]) { + found = true; + break; + } + } + } + } + if (!found) { + return "Please select a valid option."; + } + return null; +}; + +/** + * Creates a new Radio component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * set of radio buttons. + * @base jala.Form.Component.Select + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Radio component + * @constructor + */ +jala.Form.Component.Radio = function Radio(name) { + jala.Form.Component.Radio.superConstructor.apply(this, arguments); + return this; +}; +// extend jala.Form.Component.Select +jala.Form.extend(jala.Form.Component.Radio, jala.Form.Component.Select); + +/** + * Renders a set of radio buttons to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + */ +jala.Form.Component.Radio.prototype.renderControls = function(attr, value) { + var options = this.parseOptions(); + var optionAttr, optionDisplay; + for (var i=0; i 0) { + optionAttr.value = options[i][0]; + optionDisplay = options[i][1]; + } else if (options[i].value && options[i].display) { + optionAttr.value = options[i].value; + optionDisplay = options[i].display; + } else { + optionAttr.value = i; + optionDisplay = options[i]; + } + if (String(value) == String(optionAttr.value)) { + optionAttr.checked = "checked"; + } + jala.Form.html.radioButton(optionAttr); + res.write(optionDisplay); + jala.Form.html.tag("br"); + } + return; +}; + +/** + * Validates user input from a set of radio buttons and makes sure that + * option value list contains the user input. + * @see jala.Form.Component.Select#checkOptions + * @param {Object} reqData request data + * @returns null if everything is ok or string containing error message + * @type String + */ +jala.Form.Component.Radio.prototype.checkRequirements = function(reqData) { + return this.checkOptions(reqData); +}; + +/** + * Creates a new Checkbox component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * checkbox. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Checkbox component instance + * @constructor + */ +jala.Form.Component.Checkbox = function Checkbox(name) { + jala.Form.Component.Checkbox.superConstructor.apply(this, arguments); + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.Checkbox, jala.Form.Component.Input); + +/** + * Renders an checkbox to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + */ +jala.Form.Component.Checkbox.prototype.renderControls = function(attr, value, reqData) { + if (value == 1 || (reqData && reqData[this.name] == "1")) { + attr.checked = "checked"; + } + attr.value = "1"; + jala.Form.html.checkBox(attr); + return; +}; + +/** + * Parses the string input from the form. For a checked box, the value is 1, + * for an unchecked box the value is 0. + * @param {Object} reqData request data + * @returns parsed value + * @type Number + */ +jala.Form.Component.Checkbox.prototype.parseValue = function(reqData) { + return (reqData[this.name] == "1") ? 1 : 0; +}; + +/** + * Validates user input from checkbox. + * @param {Object} reqData request data + * @returns null if everything is ok or string containing error message + * @type String + */ +jala.Form.Component.Checkbox.prototype.checkRequirements = function(reqData) { + if (reqData[this.name] && reqData[this.name] != "1") { + return this.getMessage("invalid", "The value of this checkbox is invalid."); + } + return null; +}; + +/** + * Creates a new File component instance + * @class Subclass of jala.Form.Component.Input which renders and validates a + * file upload. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created File component + * @constructor + */ +jala.Form.Component.File = function File(name) { + jala.Form.Component.File.superConstructor.apply(this, arguments); + + this.containsFileUpload = function() { + return true; + }; + + return this; +}; +// extend jala.Form.Component.Input +jala.Form.extend(jala.Form.Component.File, jala.Form.Component.Input); + +/** + * Renders a file input tag to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.File.prototype.renderControls = function(attr, value, reqData) { + var contentType = this.getRequirement(jala.Form.CONTENTTYPE); + if (contentType) { + attr.accept = (contentType instanceof Array) ? contentType.join(",") : contentType; + } + jala.Form.html.file(attr); + return; +}; + +/** + * Validates a file upload by making sure it's there (if REQUIRE is set), + * checking the file size, the content type and by trying to construct an image. + * @param {Object} reqData request data + * @param {jala.Form.Tracker} tracker jala.Form.Tracker object storing possible error messages + * @returns null if everything is ok or string containing error message + * @type String + */ +jala.Form.Component.File.prototype.checkRequirements = function(reqData) { + + if (reqData[this.name].contentLength == 0) { + // no upload + if (this.getRequirement(jala.Form.REQUIRE) == true) { + return this.getMessage(jala.Form.REQUIRE, "File upload is required."); + } else { + // no further checks necessary, exit here + return null; + } + } + + var maxLength = this.getRequirement(jala.Form.MAXLENGTH); + if (maxLength && reqData[this.name].contentLength > maxLength) { + return this.getMessage(jala.Form.MAXLENGTH, "This file is too big ({0} bytes), maximum allowed size {1} bytes.", + reqData[this.name].contentLength, maxLength); + } + + var contentType = this.getRequirement(jala.Form.CONTENTTYPE); + if (contentType) { + var arr = (contentType instanceof Array) ? contentType : [contentType]; + if (arr.indexOf(reqData[this.name].contentType) == -1) { + return this.getMessage(jala.Form.CONTENTTYPE, "The file type {0} is not allowed.", + reqData[this.name].contentType); + } + } + + return null; +}; + + +/** + * Creates a new Image component instance + * @class Subclass of jala.Form.Component.File which renders a file upload + * and validates uploaded files as images. + * @base jala.Form.Component.File + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Image component + * @constructor + */ +// FIXME: see below +jala.Form.Component.Image = function() {}; + +/** + * @ignore + * FIXME: JSDoc has some sever problems with this class. + * It's somehow due to the named method ("Image") that it + * always appears as global static object. + * Wrapping the method in another function which immediately + * is executed seems to solve this problem and could be used + * as a work-around for similar issues. + */ +jala.Form.Component.Image = (function() { + return function Image(name) { + jala.Form.Component.Image.superConstructor.apply(this, arguments); + return this; + }; +})(); + +// extend jala.Form.Component.File +jala.Form.extend(jala.Form.Component.Image, jala.Form.Component.File); + +/** + * Validates an image upload by making sure it's there (if REQUIRE is set), + * checking the file size, the content type and by trying to construct an image. + * If the file is an image, width and height limitations set by require are + * checked. + * @param {Object} reqData request data + * @type String + */ +jala.Form.Component.Image.prototype.checkRequirements = function(reqData) { + var re = this.constructor.superConstructor.prototype.checkRequirements.call(this, reqData); + if (re) { + return re; + } + + if (reqData[this.name].contentLength > 0) { + var helmaImg = undefined; + try { + helmaImg = new Image(reqData[this.name]); + } catch (imgError) { + return this.getMessage("invalid", "This image file can't be processed."); + } + + var maxWidth = this.getRequirement(jala.Form.MAXWIDTH); + if (maxWidth && helmaImg.getWidth() > maxWidth) { + return this.getMessage("maxwidth", "This image is too wide."); + } + + var minWidth = this.getRequirement(jala.Form.MINWIDTH); + if (minWidth && helmaImg.getWidth() < minWidth) { + return this.getMessage("minwidth", "This image is not wide enough."); + } + + var maxHeight = this.getRequirement(jala.Form.MAXHEIGHT); + if (maxHeight && helmaImg.getHeight() > maxHeight) { + return this.getMessage("maxheight", "This image is too tall."); + } + + var minHeight = this.getRequirement(jala.Form.MINHEIGHT); + if (minHeight && helmaImg.getHeight() < minHeight) { + return this.getMessage("minheight", "This image is not tall enough."); + } + } + + return null; +}; + + + +/** + * Creates a new Button component instance + * @class Subclass of jala.Form.Component.Input which renders a button. + * @base jala.Form.Component.Input + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Button component + * @constructor + */ +jala.Form.Component.Button = function Button(name) { + jala.Form.Component.Button.superConstructor.apply(this, arguments); + + /** + * Private field containing the value of the button (ie. the visible text) + * @type String + */ + var value; + + /** + * Returns the value set for this button. + * @returns value + * @type String + */ + this.getValue = function() { + return value; + }; + + /** + * Sets the value for this button. + * @param {String} newValue new value + */ + this.setValue = function(newValue) { + value = newValue; + return; + }; + + return this; +}; +// extend jala.Form.Component +jala.Form.extend(jala.Form.Component.Button, jala.Form.Component.Input); + +/** + * Renders a button to the response. + * @param {Object} attr Basic attributes for this element. + * @param {Object} value Value to be used for rendering this element. + * @param {Object} reqData Request data for the whole form. This argument is + * passed only if the form is re-rendered after an error occured. + */ +jala.Form.Component.Button.prototype.render = function(attr, value, reqData) { + var classStr = (this.getClassName()) ? " " + this.getClassName() : ""; + var attr = { + id: this.createDomId(), + "class": "component" + classStr + }; + jala.Form.html.openTag("div", attr); + res.write("\n "); + + this.renderControls(this.getControlAttributes(), this.getValue()); + res.write("\n"); + + jala.Form.html.closeTag("div"); + res.write("\n"); + return; +}; + +/** + * Creates a new attribute object for this button. + * @returns Object with all attributes set for this button. + * @type Object + */ +jala.Form.Component.Button.prototype.renderControls = function(attr, value) { + if (value) { + attr.value = value; + } + jala.Form.html.button(attr); + return; +}; + + +/** + * Creates a new Submit component instance + * @class Subclass of jala.Form.Component.Button which renders a submit button. + * @base jala.Form.Component.Button + * @param {String} name Name of the component, used as name of the html controls. + * @returns A newly created Submit component + * @constructor + */ +jala.Form.Component.Submit = function Submit(name) { + jala.Form.Component.Submit.superConstructor.apply(this, arguments); + + return this; +}; +// extend jala.Form.Component.Button +jala.Form.extend(jala.Form.Component.Submit, jala.Form.Component.Button); + +/** + * Creates a new attribute object for this button. + * @returns Object with all attributes set for this button. + * @type Object + */ +jala.Form.Component.Submit.prototype.renderControls = function(attr, value) { + if (value) { + attr.value = value; + } + jala.Form.html.submit(attr); + return; +}; + + +/** + * static default getter function used to return a field + * from the data object. + * @param {String} name Name of the property. + * @type Object + */ +jala.Form.propertyGetter = function(name, value) { + return this[name]; +}; + +/** + * static default setter function used to change a field + * of the data object. + * @param {String} name Name of the property. + * @param {Object} value New value of the property. + */ +jala.Form.propertySetter = function(name, value) { + this[name] = value; +}; + + +/** + * A generic container for error-messages and values + * @class Instances of this class can contain error-messages and values + * @constructor + * @type jala.Form.Tracker + */ +jala.Form.Tracker = function(reqData) { + + /** + * A map containing input from request data + * @type Object + */ + this.reqData = reqData; + + /** + * A map containing parsed values (only for those fields that didn't + * fail during checkRequirements method). + * @type Object + */ + this.values = {}; + + /** + * A map containing error messages + * @type Object + */ + this.errors = {}; + + return this; +}; + +/** @ignore */ +jala.Form.Tracker.toString = function() { + return "[jala.Form.Tracker]"; +}; + +/** @ignore */ +jala.Form.Tracker.prototype.toString = jala.Form.Tracker.toString; + +/** + * Returns true if an error has been set for at least one component. + * @returns true if form encountered an error. + * @type Boolean + */ +jala.Form.Tracker.prototype.hasError = function() { + for (var keys in this.errors) { + return true; + } + return false; +}; + +/** + * Returns the number of components for which this instance has + * tracked an error. + * @returns Number of components that did not validate. + * @type Number + */ +jala.Form.Tracker.prototype.countErrors = function() { + var ct = 0; + for (var keys in this.errors) { + ct++; + } + return ct; +}; + +/** + * Helper method. + * @private + */ +jala.Form.Tracker.prototype.debug = function() { + for (var key in this.errors) { + res.debug(key + ":" + this.errors[key]); + } + return; +}; + + diff --git a/modules/jala/code/Global.js b/modules/jala/code/Global.js new file mode 100644 index 00000000..0c75f031 --- /dev/null +++ b/modules/jala/code/Global.js @@ -0,0 +1,130 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the Global prototype. + */ + + +/** + * Returns true if the value passed as argument is either a string literal, + * an instance of String or of java.lang.String. + * @param {Object} val The value to test + * @returns True if the value is a string, false otherwise + * @type Boolean + */ +function isString(val) { + return typeof(val) == "string" || + val instanceof java.lang.String || + val instanceof String; +}; + +/** + * Returns true if the value passed as argument is either a boolean + * literal or an instance of Boolean. + * @param {Object} val The value to test + * @returns True if the value is a boolean, false otherwise + * @type Boolean + */ +function isBoolean(val) { + return typeof(val) == "boolean" || + val instanceof Boolean; +}; + +/** + * Returns true if the value passed as argument is either a number, + * an instance of Number or of java.lang.Number. + * @param {Object} val The value to test + * @returns True if the value is a number, false otherwise + * @type Boolean + */ +function isNumber(val) { + return typeof(val) == "number" || + val instanceof java.lang.Number || + val instanceof Number; +}; + +/** + * Returns true if the value passed as argument is null. + * @param {Object} val The value to test + * @returns True if the value is null, false otherwise + * @type Boolean + */ +function isNull(val) { + return val === null; +}; + +/** + * Returns true if the value passed as argument is undefined. + * @param {Object} val The value to test + * @returns True if the value is undefined, false otherwise + * @type Boolean + */ +function isUndefined(val) { + return val === undefined; +}; + +/** + * Returns true if the value passed as argument is an array. + * @param {Object} val The value to test + * @returns True if the value is an array, false otherwise + * @type Boolean + */ +function isArray(val) { + return val instanceof Array; +}; + +/** + * Returns true if the value passed as argument is either a Javascript date + * or an instance of java.util.Date. + * @param {Object} val The value to test + * @returns True if the value is a date, false otherwise + * @type Boolean + */ +function isDate(val) { + return val instanceof Date || + val instanceof java.util.Date; +}; + +/** + * Returns true if the value passed as argument is either a Javascript + * object or an instance of java.lang.Object. + * @param {Object} val The value to test + * @returns True if the value is an object, false otherwise + * @type Boolean + */ +function isObject(val) { + return val instanceof Object || + val instanceof java.lang.Object; +}; + +/** + * Returns true if the value passed as argument is a function. + * @param {Object} val The value to test + * @returns True if the argument is a function, false otherwise + * @type Boolean + */ +function isFunction(val) { + return val instanceof Function; +}; \ No newline at end of file diff --git a/modules/jala/code/History.js b/modules/jala/code/History.js new file mode 100644 index 00000000..215166ac --- /dev/null +++ b/modules/jala/code/History.js @@ -0,0 +1,253 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.History class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Constructs a new History object. + * @class This class is an implementation of a Browser-like history + * stack suitable to use in any Helma application. The difference + * to a Browser's history is that this implementation ignores + * POST requests and checks if Urls in the stack are still valid to + * prevent eg. redirections to a HopObject's url that has been deleted. + * Plus it is capable to create new "intermediate" history-stacks + * and this way maintain a "history of histories" which is needed for + * eg. editing sessions in a popup window that should use their own + * request history without interfering with the history of the + * main window. + * @constructor + */ +jala.History = function() { + var MAX = 40; + + /** + * Stack constructor + * @private + */ + var Stack = function(id) { + this.items = []; + this.id = id; + return this; + }; + + /** + * Returns the current url including query string + * @private + */ + var getUrl = function() { + var query; + var url = path.href(req.action); + try { + if (query = req.getServletRequest().getQueryString()) + url += "?" + query; + } catch (e) { + // ignore + } + return url; + } + + /** + * Checks if a request is valid for being added + * to the history stack. This method returns false + * for all POST-requests or requests whose action name + * contains a dot (to prevent requests for external stylesheets + * or the like from being recorded). + * @private + * @type Boolean + */ + var isValid = function() { + // FIXME: we should check for mimetype of response instead + // of assuming that requests containing a dot aren't worth + // being put into history stack ... + if (req.isPost() || (req.action && req.action.contains("."))) + return false; + return true; + }; + + /** + * returns a single Stack instance + * @private + */ + var getStack = function() { + if (history.length < 1) + history.push(new Stack(getUrl())); + return history[history.length -1]; + }; + + /** + * Variable containing the history-stacks + * @private + */ + var history = []; + + /** + * Initializes a new history stack, adds + * it to the array of stacks (which makes it + * the default one to use for further requests) + * and records the current request Url. + */ + this.add = function() { + if (!isValid()) + return; + var url = getUrl(); + if (getStack().id != url) { + history.push(new Stack(url)); + this.push(); + } + return; + }; + + /** + * Removes the current history stack + */ + this.remove = function() { + history.pop(); + return; + }; + + /** + * Records a request Url in the currently active + * history stack. + */ + this.push = function() { + if (isValid()) { + var obj = path[path.length-1]; + var url = getUrl(); + var stack = getStack(); + if (stack.items.length < 1 || stack.items[stack.items.length -1].url != url) { + if (stack.items.length >= MAX) + stack.items.shift(); + stack.items.push({ + url: url, + path: path.href().substring(root.href().length).replace(/\+/g, " ") + }); + } + } + return; + }; + + /** + * Clears the currently active history stack + */ + this.clear = function() { + getStack().items.length = 0; + return; + }; + + /** + * Redirects the client back to the first valid + * request in history. Please mind that searching for + * a valid Url starts at history.length - 2. + * @param {Number} offset The index position in the stack to start + * searching at + */ + this.redirect = function(offset) { + res.redirect(this.pop(offset)); + return; + }; + + /** + * Retrieves the first valid request Url in history + * stack starting with a given offset. The default offset is 1. + * Any valid Url found is removed from the stack, therefor + * this method alters the contents of the history stack. + * @param {Number} offset The index position in history stack to start + * searching at + * @return The Url of the request + * @type String + */ + this.pop = function(offset) { + /** + * checks if a referrer is stil valid + * @private + */ + var isValidPath = function(p) { + var arr = p.split("/"); + var obj = root; + for (var i=0;i 0) { + while (cut-- > 0) { + obj = stack.items.pop(); + } + } + while (stack.items.length > 0) { + obj = stack.items.pop(); + // check if url is valid + if (isValidPath(obj.path)) { + return obj.url; + } + } + return path.href(); + }; + + /** + * Retrieves the request Url at the given position + * in the current history stack. If no offset is given + * the last Url in the stack is returned. This method + * does not alter the stack contents! + * @param {Number} offset The index position in history stack to start + * searching at + * @return The Url of the request + * @type String + */ + this.peek = function(offset) { + var stack = getStack(); + return stack.items[stack.items.length - (offset != null ? offset : 1)]; + }; + + /** + * Returns the contents of all history stacks + * as string + * @return The history stacks as string + * @type String + */ + this.dump = function() { + return history.toSource(); + }; + + /** @ignore */ + this.toString = function() { + return "[History " + getStack().toSource() + "]"; + }; + + return this; +} diff --git a/modules/jala/code/HopObject.js b/modules/jala/code/HopObject.js new file mode 100644 index 00000000..657a24c7 --- /dev/null +++ b/modules/jala/code/HopObject.js @@ -0,0 +1,177 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Additional fields and methods of the HopObject class. + */ + +/** + * HelmaLib dependencies + */ +app.addRepository("modules/core/String.js"); +app.addRepository("modules/helma/File.js"); + +/** + * Constructs a name from an object which + * is unique in the underlying HopObject collection. + * @param {Object} obj The object representing or containing + * the alias name. Possible object types include: + *
      + *
    • File
    • + *
    • helma.File
    • + *
    • java.io.File
    • + *
    • String
    • + *
    • java.lang.String
    • + *
    • Packages.helma.util.MimePart
    • + *
    + * @param {Number} maxLength The maximum length of the alias + * @returns The resulting alias + * @type String + */ +HopObject.prototype.getAccessName = function(obj, maxLength) { + /** + * Private method checking if the key passed as argument is already + * existing in this object + * @param {String} key The key string to test + * @returns True in case the key is already in use, false otherwise + * @type Boolean + */ + var isReserved = function(obj, key) { + return key === "." || + key === ".." || + obj[key] != null || + obj[key + "_action"] != null || + obj.get(key) != null + }; + + // prepare name depending on argument + var name; + var clazz = obj.constructor || obj.getClass(); + switch (clazz) { + case File: + case helma.File: + case java.io.File: + case Packages.helma.util.MimePart: + // first fix bloody ie/win file paths containing backslashes + name = obj.getName().split(/[\\\/]/).pop(); + if (name.contains(".")) + name = name.substring(0, name.lastIndexOf(".")); + break; + case String: + case java.lang.String: + name = obj; + break; + default: + name = obj.toString(); + } + + // remove all (back)slashes + var accessName = name.replace(/[\\\/]/g, ""); + // remove all plus signs + accessName = accessName.replace("+",""); + if (accessName.length > maxLength) { + accessName = accessName.substring(0, maxLength); + } + var result = accessName; + if (isReserved(this, result)) { + var len = result.length; + var counter = 1; + var overflow; + while (isReserved(this, result)) { + result = accessName + "-" + counter.toString(); + if ((overflow = result.length - maxLength) > 0) { + result = accessName.substring(0, accessName.length - overflow) + + "-" + counter.toString(); + if (result.length > maxLength) { + throw "Unable to create accessname due to limit restriction"; + } + } + counter += 1; + } + } + return result; +}; + + +/** + * Returns true if the internal state of this HopObject is TRANSIENT. + * @returns True if this HopObject is marked as transient, false otherwise. + * @type Boolean + */ +HopObject.prototype.isTransient = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.TRANSIENT; +}; + +/** + * Returns true if the internal state of this HopObject is VIRTUAL. + * @returns True if this HopObject is marked as virtual, false otherwise. + * @type Boolean + */ +HopObject.prototype.isVirtual = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.VIRTUAL; +}; + +/** + * Returns true if the internal state of this HopObject is INVALID. + * @returns True if this HopObject is marked as invalid, false otherwise. + * @type Boolean + */ +HopObject.prototype.isInvalid = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.INVALID; +}; + +/** + * Returns true if the internal state of this HopObject is CLEAN. + * @returns True if this HopObject is marked as clean, false otherwise. + * @type Boolean + */ +HopObject.prototype.isClean = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.CLEAN; +}; + +/** + * Returns true if the internal state of this HopObject is NEW. + * @returns True if this HopObject is marked as new, false otherwise. + * @type Boolean + */ +HopObject.prototype.isNew = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.NEW; +}; + +/** + * Returns true if the internal state of this HopObject is MODIFIED. + * @returns True if this HopObject is marked as modified, false otherwise. + * @type Boolean + */ +HopObject.prototype.isModified = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.MODIFIED; +}; + +/** + * Returns true if the internal state of this HopObject is DELETED. + * @returns True if this HopObject is marked as deleted, false otherwise. + * @type Boolean + */ +HopObject.prototype.isDeleted = function() { + return this.__node__.getState() === Packages.helma.objectmodel.INodeState.DELETED; +}; diff --git a/modules/jala/code/HtmlDocument.js b/modules/jala/code/HtmlDocument.js new file mode 100644 index 00000000..ae5626cf --- /dev/null +++ b/modules/jala/code/HtmlDocument.js @@ -0,0 +1,156 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Fields and methods of the jala.HtmlDocument class. + */ + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + +/** + * Jala dependencies + */ +(function() { + var jalaDir = getProperty("jala.dir", "modules/jala"); + app.addRepository(jalaDir + "/lib/dom4j-1.6.1.jar"); + app.addRepository(jalaDir + "/lib/jaxen-1.1-beta-8.jar"); +})(); + +/** + * Construct a new HTML document. + * @class This class provides easy access to the elements of + * an arbitrary HTML document. By using TagSoup, Dom4J and Jaxen + * even invalid HTML can be parsed, turned into an object tree + * and easily be processed with XPath expressions. + * @param {String} source The HTML source code. + * @returns A new HTML document. + * @constructor + */ +jala.HtmlDocument = function(source) { + var REQUIREMENTS = { + "dom4j-1.6.1": "http://www.dom4j.org", + "jaxen-1.1-beta-8": "http://www.jaxen.org" + }; + + var reader = new java.io.StringReader(source); + var dom4j = Packages.org.dom4j; + var tagsoup = "org.ccil.cowan.tagsoup.Parser"; + + try { + var saxReader = new dom4j.io.SAXReader(tagsoup); + var document = saxReader.read(reader); + document.normalize(); + } catch(e) { + res.push(); + res.write("\njala.HtmlDocument requires the following Java "); + res.write("packages in ext/lib or application directory:\n"); + for (var i in REQUIREMENTS) { + res.write(i); + res.write(".jar"); + res.write(" ["); + res.write(REQUIREMENTS[i]); + res.write("]\n"); + } + throw (e + res.pop()); + } + + /** + * Get all document nodes from an XPath expression. + * @param {String} xpathExpr An XPath expression. + * @returns A list of HTML elements. + * @type org.dom4j.tree.DefaultElement + */ + this.scrape = function(xpathExpr) { + return document.selectNodes(xpathExpr); + }; + + /** + * Get all link elements of the HTML document. + * @returns A list of link elements. + * @type Array + */ + this.getLinks = function() { + var result = []; + var list = this.scrape("//html:a"); + for (var i=0; i 0) { + object.attributes = new Array; + for (n=0; nlanguage[_COUNTRY][_variant], where language + * is a valid ISO Language Code (eg. "de"), COUNTRY a valid ISO + * Country Code (eg. "AT"), and variant an identifier for the variant to use. + * @returns The locale for the given id + * @type java.util.Locale + */ +jala.I18n.prototype.getLocale = function(localeId) { + if (localeId) { + if (localeId.indexOf("_") > -1) { + var arr = localeId.split("_"); + if (arr.length == 3) { + return new java.util.Locale(arr[0], arr[1], arr[2]); + } else { + return new java.util.Locale(arr[0], arr[1]); + } + } else { + return new java.util.Locale(localeId); + } + } + return java.util.Locale.getDefault(); +} + +/** + * Tries to "translate" the given message key into a localized + * message. + * @param {String} key The message to translate (required) + * @param {String} plural The plural form of the message to translate + * @param {Number} amount A number to determine whether to use the + * singular or plural form of the message + * @returns The localized message or the appropriate key if no + * localized message was found + * @type String + */ +jala.I18n.prototype.translate = function(singularKey, pluralKey, amount) { + var translation = null; + if (singularKey) { + // use the getter method for retrieving the locale + var locale = this.getLocaleGetter()(); + var catalog, key; + if ((catalog = jala.i18n.getCatalog(locale))) { + if (arguments.length == 3 && amount != 1) { // is plural + key = pluralKey; + } else { + key = singularKey; + } + if (!(translation = catalog[key])) { + translation = key; + app.logger.debug("jala.i18n.translate(): Can't find message '" + + key + "' for locale '" + locale + "'"); + } + } else { + app.logger.debug("jala.i18n.translate(): Can't find message catalog for locale '" + locale + "'"); + if (!pluralKey || amount == 1) { + translation = singularKey; + } else { + translation = pluralKey; + } + } + } + return translation; +}; + +/** + * Helper method to get the message catalog + * corresponding to the actual locale. + * @params {java.util.Locale} locale + * @returns The message catalog. + */ +jala.I18n.prototype.getCatalog = function(locale) { + if (!jala.I18n.catalogs) { + jala.I18n.catalogs = {}; + } + + var catalog = jala.I18n.catalogs[locale]; + + if (catalog) return catalog; + + var messages = this.getMessages(); + + if (locale && messages) { + catalog = messages[locale.toLanguageTag()]; + jala.I18n.catalogs[locale] = catalog; + } + + return catalog; +}; + +/** + * Converts the message passed as argument into an instance + * of java.text.MessageFormat, and formats it using the + * replacement values passed. + * @param {String} message The message to format + * @param {Array} values An optional array containing replacement values + * @returns The formatted message or, if the formatting fails, the + * message passed as argument. + * @type String + * @see http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html + */ +jala.I18n.prototype.formatMessage = function(message, values) { + if (message) { + var args = null; + if (values != null && values.length > 0) { + args = java.lang.reflect.Array.newInstance(java.lang.Object, values.length); + var arg; + for (var i=0;inumber must + * match the number of the additional argument (starting with zero). + * @param {String} key The message to localize + * @returns The translated message + * @type String + * @see #translate + * @see #formatMessage + */ +jala.I18n.prototype.gettext = function(key /** [value 0][, value 1][, ...] */) { + return this.formatMessage(this.translate(key), + Array.prototype.splice.call(arguments, 1)); +}; + +/** + * Returns a localized message for the message key passed as + * argument. In contrast to gettext() this method + * can handle plural forms based on the amount passed as argument. + * If no localization is found, the appropriate message key is + * returned. Any additional arguments passed to this function + * will be used as replacement values during message rendering. + * To reference these values the message can contain placeholders + * following "{number}" notation, where number must + * match the number of the additional argument (starting with zero). + * @param {String} singularKey The singular message to localize + * @param {String} pluralKey The plural form of the message to localize + * @param {Number} amount The amount which is used to determine + * whether the singular or plural form of the message should be returned. + * @returns The translated message + * @type String + * @see #translate + * @see #formatMessage + */ +jala.I18n.prototype.ngettext = function(singularKey, pluralKey, amount /** [value 0][, value 1][, ...] */) { + return this.formatMessage(this.translate(singularKey, pluralKey, amount || 0), + Array.prototype.splice.call(arguments, 2)); +}; + +/** + * A simple proxy method which is used to mark a message string + * for the i18n parser as to be translated. + * @param {String} key The message that should be seen by the + * i18n parser as to be translated. + * @returns The message in unmodified form + * @type String + */ +jala.I18n.prototype.markgettext = function(key) { + return key; +}; + +/** + * Returns a translated message. The following macro attributes + * are accepted: + *
      + *
    • text: The message to translate (required)
    • + *
    • plural: The plural form of the message
    • + *
    • values: A list of replacement values. Use a comma to separate more + * than one value. Each value is either interpreted as a global property + * (if it doesn't containg a dot) or as a property name of the given macro + * handler object (eg. "user.name"). If the value of the property is a + * HopObject or an Array this macro uses the size() resp. length of the + * object, otherwise the string representation of the object will be used.
    • + *
    + * @returns The translated message + * @type String + * @see #gettext + * @see #ngettext + */ +jala.I18n.prototype.message_macro = function(param) { + if (param.text) { + var args = [param.text]; + if (param.plural) { + args[args.length] = param.plural; + } + if (param.values != null) { + var arr = param.values.split(/\s*,\s*/g); + // convert replacement values: if the value name doesn't contain + // a dot, look for a global property with that name, otherwise + // for a property of the specified macro handler object. + var propName, dotIdx, handlerName, handler; + for (var i=0;i 0) { + var handlerName = propName.substring(0, dotIdx); + if (handlerName == "request") { + handler = req.data; + } else if (handlerName == "response") { + handler = res.data; + } else if (!(handler = res.handlers[handlerName])) { + continue; + } + propName = propName.substring(dotIdx + 1); + // primitive security: don't allow access to internal properties + // and a property named "password" + if (propName.charAt(0) != "_" && propName.toLowerCase() != "password") { + value = handler[propName]; + } + } else { + value = global[propName]; + } + if (value != null) { + // if its a HopObject collection or Array, use its size/length + // as value + if (value instanceof HopObject) { + value = value.size(); + } else if (value instanceof Array) { + value = value.length; + } + } + args[args.length] = value; + } + } + } + if (param.plural) { + return this.ngettext.apply(this, args); + } else { + return this.gettext.apply(this, args); + } + } + return; +}; + +/** + * Default i18n class instance. + * @type jala.I18n + * @final + */ +jala.i18n = new jala.I18n(); + +/** + * For convenience reasons the public methods and macros are + * put into global scope too + */ +var gettext = function() { + return jala.i18n.gettext.apply(jala.i18n, arguments); +}; +var ngettext = function() { + return jala.i18n.ngettext.apply(jala.i18n, arguments); +}; +var markgettext = function() { + return jala.i18n.markgettext.apply(jala.i18n, arguments); +}; +var message_macro = function() { + return jala.i18n.message_macro.apply(jala.i18n, arguments); +}; diff --git a/modules/jala/code/ImageFilter.js b/modules/jala/code/ImageFilter.js new file mode 100644 index 00000000..d20ff9b2 --- /dev/null +++ b/modules/jala/code/ImageFilter.js @@ -0,0 +1,362 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.ImageFilter class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Constructs a new ImageFilter object + * @class This class provides several image manipulating + * methods. Most of this filter library is based on filters created + * by Janne Kipinä for JAlbum. For more information have a look + * at http://www.ratol.fi/~jakipina/java/ + * @param {Object} img Either +
      +
    • an instance of helma.image.ImageWrapper
    • +
    • the path to the image file as String
    • +
    • an instance of helma.File representing the image file
    • +
    • an instance of java.io.File representing the image file
    • +
    + * @constructor + */ +jala.ImageFilter = function(img) { + /** + * The buffered image to work on + * @type java.awt.image.BufferedImage + * @private + */ + var bi; + + /** + * Perfoms a gaussian operation (unsharp masking or blurring) + * on the image using the kernelFactory passed as argument + * @param {Number} radius The radius + * @param {Number} amount The amount + * @param {Function} kernelFactory Factory method to call for building the kernel + * @private + */ + var gaussianOp = function(radius, amount, kernelFactory) { + var DEFAULT_RADIUS = 2; + var MINIMUM_RADIUS = 1; + var MAXIMUM_RADIUS = 10; + var DEFAULT_AMOUNT = 15; + var MINIMUM_AMOUNT = 1; + var MAXIMUM_AMOUNT = 100; + + // correct arguments if necessary + if (isNaN(radius = Math.min(Math.max(radius, MINIMUM_RADIUS), MAXIMUM_RADIUS))) + radius = DEFAULT_RADIUS; + if (isNaN(amount = Math.min(Math.max(amount, MINIMUM_AMOUNT), MAXIMUM_AMOUNT))) + amount = DEFAULT_AMOUNT; + + if ((bi.getWidth() < bi.getHeight()) && (radius > bi.getWidth())) { + radius = bi.getWidth(); + } else if ((bi.getHeight() < bi.getWidth()) && (radius > bi.getHeight())) { + radius = bi.getHeight(); + } + + var size = (radius * 2) + 1; + var deviation = amount / 20; + var elements = kernelFactory(size, deviation); + var large = jala.ImageFilter.getEnlargedImageWithMirroring(bi, radius); + var resultImg = new java.awt.image.BufferedImage(large.getWidth(), large.getHeight(), large.getType()); + var kernel = new java.awt.image.Kernel(size, size, elements); + var cop = new java.awt.image.ConvolveOp(kernel, java.awt.image.ConvolveOp.EDGE_NO_OP, null); + cop.filter(large, resultImg); + // replace the wrapped buffered image with the modified one + bi = resultImg.getSubimage(radius, radius, bi.getWidth(), bi.getHeight()); + return; + }; + + /** + * Sharpens the image using a plain sharpening kernel. + * @param {Number} amount The amount of sharpening to apply + */ + this.sharpen = function(amount) { + var DEFAULT = 20; + var MINIMUM = 1; + var MAXIMUM = 100; + // correct argument if necessary + if (isNaN(Math.min(Math.max(amount, MINIMUM), MAXIMUM))) + amount = DEFAULT; + var sharpened = new java.awt.image.BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType()); + var kernel = new java.awt.image.Kernel(3, 3, jala.ImageFilter.getSharpeningKernel(amount)); + var cop = new java.awt.image.ConvolveOp(kernel, java.awt.image.ConvolveOp.EDGE_NO_OP, null); + cop.filter(bi, sharpened); + bi = sharpened; + return; + }; + + /** + * Performs an unsharp mask operation on the image + * @param {Number} radius The radius + * @param {Number} amount The amount + */ + this.unsharpMask = function(radius, amount) { + gaussianOp(radius, amount, jala.ImageFilter.getUnsharpMaskKernel); + return; + }; + + /** + * Performs a gaussian blur operation on the image + * @param {Number} radius The radius + * @param {Number} amount The amount + */ + this.gaussianBlur = function(radius, amount) { + gaussianOp(radius, amount, jala.ImageFilter.getGaussianBlurKernel); + return; + }; + + + /** + * Returns the image that has been worked on + * @return An instance of helma.image.ImageWrapper + * @type helma.image.ImageWrapper + */ + this.getImage = function() { + var generator = Packages.helma.image.ImageGenerator.getInstance(); + return new Packages.helma.image.ImageWrapper(bi, + bi.getWidth(), + bi.getHeight(), + generator); + }; + + /** + * Returns the wrapped image as byte array, to use eg. in conjunction + * with res.writeBinary() + * @returns The wrapped image as byte array + * @type byte[] + */ + this.getBytes = function() { + var outStream = new java.io.ByteArrayOutputStream(); + Packages.javax.imageio.ImageIO.write(bi, "jpeg", outStream); + var bytes = outStream.toByteArray(); + outStream.close(); + return bytes; + }; + + /** + * constructor body + * @ignore + */ + if (arguments.length == 0 || img == null) { + throw "jala.ImageFilter: insufficient arguments"; + } else if (img instanceof Packages.helma.image.ImageWrapper) { + bi = img.getBufferedImage(); + } else { + if (typeof(img) == "string") { + var inStream = new java.io.FileInputStream(new java.io.File(img)); + } else { + var inStream = new java.io.FileInputStream(img); + } + var decoder = Packages.com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(inStream); + bi = decoder.decodeAsBufferedImage(); + } + + return this; +}; + +/** @ignore */ +jala.ImageFilter.prototype.toString = function() { + return "[jala.ImageFilter]"; +}; + +/** + * Transforms an image into a bigger one while mirroring the edges + * This method is used to apply the filtering up to the edges + * of an image (otherwise the image would keep an unmodified + * border). + * @param {java.awt.image.BufferedImage} bi The buffered image to transform + * @param {Number} size The size of the border area + * @returns The transformed image + * @type java.awt.image.BufferedImage + * @private + */ +jala.ImageFilter.getEnlargedImageWithMirroring = function(bi, size) { + + var doFlip = function(bi, sx, sy, dist) { + var out = new java.awt.image.BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType()); + var transform = java.awt.geom.AffineTransform.getScaleInstance(sx, sy); + (sx < sy) ? transform.translate(-dist, 0) : transform.translate(0, -dist); + var atop = new java.awt.image.AffineTransformOp(transform, + java.awt.image.AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + out = atop["filter(java.awt.image.BufferedImage,java.awt.image.BufferedImage)"](bi, null); + return out; + } + + var doHorizontalFlip = function(bi) { + return doFlip(bi, -1, 1, bi.getWidth()); + } + + var doVerticalFlip = function(bi) { + return doFlip(bi, 1, -1, bi.getHeight()); + } + + var width = bi.getWidth() + 2 * size; + var height = bi.getHeight() + 2 * size; + var out = new java.awt.image.BufferedImage(width, height, bi.getType()); + var g = out.createGraphics(); + // due to method overloading exactly define the method to be called + var func = "drawImage(java.awt.Image,int,int,java.awt.image.ImageObserver)"; + g[func](bi, size, size, null); + + var part; + //top-left corner + part = bi.getSubimage(0, 0, size, size); + part = doHorizontalFlip(part); + part = doVerticalFlip(part); + g[func](part, 0, 0, null); + //top-right corner + part = bi.getSubimage(bi.getWidth()-size, 0, size, size); + part = doHorizontalFlip(part); + part = doVerticalFlip(part); + g[func](part, width-size, 0, null); + //bottom-left corner + part = bi.getSubimage(0, bi.getHeight()-size, size, size); + part = doHorizontalFlip(part); + part = doVerticalFlip(part); + g[func](part, 0, height-size, null); + //bottom-right corner + part = bi.getSubimage(bi.getWidth()-size, bi.getHeight()-size, size, size); + part = doHorizontalFlip(part); + part = doVerticalFlip(part); + g[func](part, width-size, height-size, null); + //left border + part = bi.getSubimage(0, 0, size, bi.getHeight()); + part = doHorizontalFlip(part); + g[func](part, 0, size, null); + //right border + part = bi.getSubimage(bi.getWidth()-size, 0, size, bi.getHeight()); + part = doHorizontalFlip(part); + g[func](part, width-size, size, null); + //top border + part = bi.getSubimage(0, 0, bi.getWidth(), size); + part = doVerticalFlip(part); + g[func](part, size, 0, null); + //bottom border + part = bi.getSubimage(0, bi.getHeight()-size, bi.getWidth(), size); + part = doVerticalFlip(part); + g[func](part, size, height-size, null); + return out; +}; + +/** + * Factory method for a gaussian blur kernel + * @returns The gaussian blur kernel + * @param {Number} size The size of the kernel + * @param {Number} deviation The deviation to use + * @returns The gaussian blur kernel + * @type float[] + * @private + */ +jala.ImageFilter.getGaussianBlurKernel = function(size, deviation) { + var nominator = 2 * deviation * deviation; + var kernel = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE, size*size); + var center = (size - 1) / 2; + var limit = size - 1; + var xx, yy; + var sum = 0; + var value = 0; + for (var y=0; y= y) { + //calculate new value + xx = center - x; + yy = center - y; + value = Math.exp(-(xx*xx + yy*yy) / nominator); + kernel[(y*size)+x] = value; + sum += value; + } else { + //copy existing value + value = kernel[(x*size)+y]; + kernel[(y*size)+x] = value; + sum += value; + } + } else { + xx = x; + yy = y; + if (yy > center) + yy = limit - yy; + if (xx > center) + xx = limit - xx; + value = kernel[(yy*size)+xx]; + kernel[(y*size)+x] = value; + sum += value; + } + } + } + for (var i=0; i 0) { + // convert the array with sortfields to a java array + var arr = java.lang.reflect.Array.newInstance(pkg.search.SortField, sortFields.length); + sortFields.forEach(function(sortField, idx) { + arr[idx] = sortField; + }); + var sort = pkg.search.Sort(arr); + if (filter) { + hits = searcher.search(query, filter, sort); + } else { + hits = searcher.search(query, sort); + } + } else if (filter) { + hits = searcher.search(query, filter); + } else { + hits = searcher.search(query); + } + this.log("debug", "Query: " + query.toString()); + return new helma.Search.HitCollection(hits); +}; + +/** + * Parses the query string passed as argument into a lucene Query instance + * @param {String} queryStr The query string to parse + * @param {Array} fields An array containing the names of the files to search in + * @param {Object} boostMap An optional object containing properties whose name denotes + * the name of the field to boost in the query, and the value the boost value. + * @returns The query + * @type org.apache.lucene.search.Query + */ +jala.IndexManager.prototype.parseQuery = function(queryStr, fields, boostMap) { + if (queryStr == null || typeof(queryStr) !== "string") { + throw "IndexManager.parseQuery(): missing or invalid query string"; + } + if (fields == null || fields.constructor !== Array || fields.length < 1) { + throw "IndexManager.parseQuery(): missing fields argument"; + } + var query = null; + var analyzer = this.getIndex().getAnalyzer(); + var pkg = Packages.org.apache.lucene; + var map = null; + if (boostMap != null) { + // convert the javascript object into a HashMap + map = new java.util.HashMap(); + for (var name in boostMap) { + map.put(name, new java.lang.Float(boostMap[name])); + } + } + var parser; + try { + if (fields.length > 1) { + parser = new pkg.queryParser.MultiFieldQueryParser(fields, analyzer, map); + } else { + parser = new pkg.queryParser.QueryParser(fields, analyzer); + } + query = parser.parse(queryStr); + } catch (e) { + // ignore, but write a message to debug log + app.logger.debug("Unable to construct search query '" + queryStr + + "', reason: " + e); + } + return query; +}; + +/** + * Parses the query passed as argument and returns a caching filter. If an array + * with more than one query strings is passed as argument, this method constructs + * a boolean query filter where all queries in the array must match. + * @param {String|Array} query Either a query string, or an array containing + * one or more query strings + * @param {org.apache.lucene.analysis.Analyzer} analyzer Optional analyzer + * to use when parsing the filter query + * @returns A caching query filter + * @type org.apache.lucene.search.CachingWrapperFilter + */ +jala.IndexManager.prototype.parseQueryFilter = function(query, analyzer) { + var filter = null; + if (query != null) { + var pkg = Packages.org.apache.lucene; + // use the index' analyzer if none has been specified + if (analyzer == null) { + analyzer = this.getIndex().getAnalyzer(); + } + var parser = new pkg.queryParser.QueryParser("", analyzer); + var filterQuery; + try { + if (query.constructor === Array) { + if (query.length > 1) { + filterQuery = new pkg.search.BooleanQuery(); + query.forEach(function(queryStr){ + filterQuery.add(parser.parse(queryStr), pkg.search.BooleanClause.Occur.MUST); + }, this); + } else { + filterQuery = parser.parse(query[0]); + } + } else { + filterQuery = parser.parse(query); + } + filter = new pkg.search.CachingWrapperFilter(new pkg.search.QueryWrapperFilter(filterQuery)); + } catch (e) { + app.logger.debug("Unable to parse query filter '" + query + "', reason: " + e); + } + } + return filter; +}; + + + +/********************* + ***** J O B ***** + *********************/ + + +/** + * Creates a new Job instance. + * @class Instances of this class represent a single index + * manipulation job to be processed by the index manager. + * @param {Number} id The Id of the job + * @param {Number} type The type of job, which can be either + * jala.IndexManager.Job.ADD, jala.IndexManager.Job.REMOVE + * or jala.IndexManager.Job.OPTIMIZE. + * @param {Object} data The data needed to process the job. + * @returns A newly created Job instance. + * @constructor + * @see jala.IndexManager.Job + */ +jala.IndexManager.Job = function(type, callback) { + /** + * The type of the job + * @type Number + */ + this.type = type; + + /** + * The data needed to process this job. For adding jobs this property + * must contain the {@link helma.Search.Document} instance to add to + * the index. For removal job this property must contain the unique identifier + * of the document that should be removed from the index. For optimizing + * jobs this property is null. + */ + this.callback = callback; + + /** + * An internal error counter which is increased whenever processing + * the job failed. + * @type Number + * @see jala.IndexManager.MAXTRIES + */ + this.errors = 0; + + /** + * The date and time at which this job was created. + * @type Date + */ + this.createtime = new Date(); + + return this; +}; + +/** @ignore */ +jala.IndexManager.Job.prototype.toString = function() { + return "[Job (type: " + this.type + ")]"; +}; + +/** + * Constant defining an add job + * @type Number + * @final + */ +jala.IndexManager.Job.ADD = "add"; + +/** + * Constant defining a removal job + * @type Number + * @final + */ +jala.IndexManager.Job.REMOVE = "remove"; + +/** + * Constant defining an optimizing job + * @type Number + * @final + */ +jala.IndexManager.Job.OPTIMIZE = "optimize"; diff --git a/modules/jala/code/ListRenderer.js b/modules/jala/code/ListRenderer.js new file mode 100644 index 00000000..215237cc --- /dev/null +++ b/modules/jala/code/ListRenderer.js @@ -0,0 +1,1130 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.ListRenderer class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * HelmaLib dependencies + */ +app.addRepository("modules/helma/Html.js"); + +/** + * @class + * @param {HopObject|ArrayList|Array} coll The collection this ListRenderer + * operates on, or - for backwards compatibility only - a parameter object containing + * the collection and any other optional configuration parameters. + * @param {Object} renderer An optional renderer to use. If this is set, + * any rendering method defined in this renderer overrides the default renderer. + * @constructor + */ +jala.ListRenderer = function(coll, renderer) { + + /** + * The collection this ListRenderer operates on + * @type HopObject|ArrayList + * @private + */ + var collection = null; + + /** + * Private variable containing the number of items to display + * on one page. Defaults to 10. + * @type Number + * @private + */ + var pageSize = 10; + + /** + * Private variable containing the maximum number of pages to display + * within this ListRenderer instance + * @type Number + * @private + */ + var maxPages = Number.MAX_VALUE; + + /** + * Private variable containing the maximum number of days to display + * within this ListRenderer instance. If set to null this check + * is not used. + * @type Number + * @private + */ + var maxDays = null; + + /** + * Private variable containing the base href of this ListRenderer + * @type String + * @private + */ + var baseHref = null; + + /** + * Private variable containing the name of the skin to render for + * a single list item + * @type String + * @private + */ + var itemSkin = null; + + /** + * Private variable containing any optional url parameters to append to + * every navigation link rendered by this ListRenderer instance. + * @type String + * @private + */ + var urlParameters = null; + + /** + * Private variable containing the name of the url parameter containing + * the page number to display. Defaults to "page". + * @type String + * @private + */ + var urlParameterName = "page"; + + /** + * Internal cache for rendered navigation elements + * @private + */ + this.cache = { + pageNavigation: null, + prevLink: null, + nextLink: null, + maxDayDate: null, + nextItem: null + }; + + /** + * Returns the collection this ListRenderer instance operates on + * @returns The collection of this ListRenderer + * @type HopObject|Array + */ + this.getCollection = function() { + return collection; + }; + + /** + * Sets the collection of this ListRenderer + * @param {HopObject|ArrayList|Array} coll The collection this ListRenderer instance + * should operate on + */ + this.setCollection = function(coll) { + if (coll != null) { + if (coll instanceof Array) { + // wrap array in an ArrayList instance + collection = new jala.ListRenderer.ArrayList(coll); + } else { + collection = coll; + } + } + return; + }; + + /** + * Returns the number of items displayed on one page + * @returns The number of items displayed on a single page + * @type Number + */ + this.getPageSize = function() { + return pageSize; + }; + + /** + * Sets the number of items to display on a single page + * @param {Number} size The number of items to display on one page + */ + this.setPageSize = function(size) { + if (size != null && !isNaN(size)) { + pageSize = parseInt(size, 10); + } + return; + }; + + /** + * Returns the current page index. This is either the page url parameter + * or the page number 1. + * @returns The current page number (starts with 1). + * @type Number + * @see #setUrlParameterName + */ + this.getCurrentPage = function() { + var pageNr = parseInt(req.data[this.getUrlParameterName()], 10); + if (!pageNr || isNaN(pageNr)) { + pageNr = 1; + } + return Math.min(Math.max(1, pageNr), this.getTotalPages()); + }; + + /** + * Returns the maximum number of pages handled by this ListRenderer instance + * @returns The maximum number of pages + * @type Number + */ + this.getMaxPages = function() { + return maxPages; + }; + + /** + * Sets the maximum number of pages to display + * @param {Number} pages The maximum number of pages to display + */ + this.setMaxPages = function(pages) { + if (pages != null && !isNaN(pages)) { + maxPages = parseInt(pages, 10); + } + return; + }; + + /** + * Returns the maximum number of days handled by this ListRenderer instance + * @returns The maximum number of days + * @type Number + */ + this.getMaxDays = function() { + return maxDays; + }; + + /** + * Sets the maximum number of days to display + * @param {Number} days The maximum number of days to display + */ + this.setMaxDays = function(days) { + if (days != undefined && !isNaN(days)) { + maxDays = parseInt(days, 10); + } + return; + }; + + /** + * Gets the Date offset indicated by parameter maxDays as Number for runtime efficent comparison + * @type Number + */ + this.getMaxDayDate = function() { + if (this.cache.maxDayDate != null) { + return this.cache.maxDayDate; + } + this.cache.maxDayDate = parseInt((new Date((new Date()).getTime() - (maxDays * Date.ONEDAY))).format("yyyyMMdd"), 10); + return this.cache.maxDayDate; + }; + + /** + * @returns {Object} the next Item + */ + this.getNextItem = function() { + if (this.cache.nextItem !== null) { + return this.cache.nextItem; + } + var nextItemIndex = this.getEndIndex() + 1; + this.cache.nextItem = "none"; + if (collection.size() > nextItemIndex) { + this.cache.nextItem = collection.get(nextItemIndex); + } + return this.cache.nextItem; + }; + + /** + * @returns {Boolean} wether there is a next item + */ + this.hasNext = function() { + var nextItem = this.getNextItem(); + var nextIsDisplayable = false; + var collection = this.getCollection(); + if (maxDays != undefined) { + if (nextItem != "none" && nextItem.getDayDate() >= this.getMaxDayDate()) { + nextIsDisplayable = true; + } + } else { + if (nextItem != "none") { + nextIsDisplayable = true; + } + } + if (collection.size() && + nextIsDisplayable === true) { + return true; + } + return false; + }; + + /** + * Returns the total number of pages handled by this ListRenderer instance + * (which is the collection size divided by the page size). + * @returns The total number of pages + * @type Number + */ + this.getTotalPages = function() { + var collectionSize = collection.size(); + var pages = Math.ceil(collectionSize / pageSize); + if (maxPages > 0) { + return Math.min(maxPages, pages); + } + return pages; + }; + + /** + * Returns the base href of this ListRenderer instance + * @returns The base href of this ListRenderer instance + * @type String + */ + this.getBaseHref = function() { + return baseHref; + }; + + /** + * Sets the base href of this ListRenderer instance. All links rendered + * will start with the href passed as argument + * @param {String} href The base href to use for rendering links + */ + this.setBaseHref = function(href) { + if (href != null) { + baseHref = href; + } + return; + }; + + /** + * Returns the name of the skin rendered for a single list item + * @returns The name of the list item skin + * @type Number + */ + this.getItemSkin = function() { + return itemSkin; + }; + + /** + * Sets the name of the skin to render for every list item + * @param {String} name The name of the skin to render for every list item + */ + this.setItemSkin = function(name) { + if (name != null) { + itemSkin = name; + } + return; + }; + + /** + * Returns the name of the URL parameter name containing the index + * of the page to display + * @returns The name of the page URL parameter name + * @type String + */ + this.getUrlParameterName = function() { + return urlParameterName; + }; + + /** + * Sets the name of the URL parameter name containing the index of the page + * to display + * @param {String} name The name of the page URL parameter + */ + this.setUrlParameterName = function(name) { + if (name != null) { + urlParameterName = name; + } + return; + }; + + /** + * Returns any additional URL parameters included in every navigation link + * rendered by this ListRenderer instance. + * @returns A string containing additional URL parameters + * @type String + */ + this.getUrlParameters = function() { + return urlParameters; + }; + + /** + * Sets additional parameters to include in every navigation link + * @param {String} params A string to append to every navigation URL + */ + this.setUrlParameters = function(params) { + if (params != null) { + urlParameters = params; + } + return; + }; + + /** + * Returns the renderer used by this ListRenderer instance + */ + this.getRenderer = function() { + return renderer; + }; + + /** + * Sets the renderer to be used by this ListRenderer instance + * @param {Object} r The renderer to use + */ + this.setRenderer = function(r) { + if (r != null) { + renderer = r; + } + return; + }; + + /** + * Main constructor body + */ + if (!coll) { + throw "jala.ListRenderer: insufficient arguments"; + } else if (coll instanceof jala.ListRenderer.ArrayList || + coll instanceof Array || + coll instanceof HopObject) { + this.setCollection(coll); + } else if (coll.collection != null) { + // this is for backwards compatibility only - the former ListRenderer + // signature allowed just one parameter object as argument + this.setCollection(coll.collection); + this.setBaseHref(coll.href); + this.setUrlParameters(coll.urlParams); + this.setUrlParameterName(coll.urlParamName); + this.setPageSize(coll.itemsPerPage); + this.setMaxPages(coll.maxPages); + this.setMaxDays(coll.maxDays); + this.setItemSkin(coll.itemSkin); + } else { + throw "jala.ListRenderer: invalid argument " + coll; + } + return this; +}; + +/** + * Static instance of helma.Html + * @type helma.Html + * @private + */ +jala.ListRenderer.html = new helma.Html(); + +/** @ignore */ +jala.ListRenderer.prototype.toString = function() { + return "[jala.ListRenderer]"; +}; + +/** + * Returns the href of a page. If no argument is given, the href + * of the current page is returned. Any URL parameters set with + * {@link #setUrlParameters} are added to the href. + * @param {Number} page The optional page number to include in the href. + * @returns The href of the page + * @type String + * @see #setUrlParameters + * @see #setUrlParameterName + */ +jala.ListRenderer.prototype.getPageHref = function(page) { + var pageNr = (page != null && !isNaN(page)) ? page : this.getCurrentPage(); + var urlParams = this.getUrlParameters(); + res.push(); + res.write(this.getBaseHref()); + if (pageNr || urlParams) { + res.write("?"); + if (urlParams) { + res.write(urlParams); + res.write("&"); + } + if (pageNr) { + res.write(this.getUrlParameterName()); + res.write("="); + res.write(pageNr); + } + } + return res.pop(); +}; + +/** + * Returns the zero-based index position of the first item of the current page + * in the collection this ListRenderer operates on. + * @returns The index position of the first item in the list + * @type Number + */ +jala.ListRenderer.prototype.getStartIndex = function() { + return (this.getCurrentPage() -1) * this.getPageSize(); +}; + +/** + * Returns the zero-based index position of the last item of the current page + * in the collection this ListRenderer operates on. + * @returns The index position of the last item in the list + * @type Number + */ +jala.ListRenderer.prototype.getEndIndex = function() { + var start = this.getStartIndex(); + return Math.min(start + this.getPageSize(), this.getCollection().size()) - 1; +}; + +/** + * Returns the render function to use for a given part of the list. If this + * ListRenderer doesn't have a renderer attached, or if the renderer doesn't + * have the appropriate rendering function, the default renderer is used. + * @param {String} part The part of the page. Valid arguments are + * "list", "pageNavigation" and "pageLink". + * @param {String} fName The name of the rendering function to return + * @returns The function to call for rendering the desired part of the list + * @type Function + * @private + * @see jala.ListRenderer#defaultRenderer + */ +jala.ListRenderer.prototype.getRenderFunction = function(part, fName) { + + var getFunction = function(renderer, name) { + var handler; + if ((handler = renderer[part]) != null) { + if (handler[name] instanceof Function) { + return handler[name]; + } + } + return null; + }; + + var result; + var renderer = this.getRenderer(); + if (renderer != null) { + if (!fName || !(result = getFunction(renderer, fName))) { + result = getFunction(renderer, "default"); + } + } + if (!result) { + result = getFunction(jala.ListRenderer.defaultRenderer, "default"); + } + return result; +}; + +/** + * Renders the list of items for one page directly to response. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @see #getList + */ +jala.ListRenderer.prototype.renderList = function(param) { + var collection = this.getCollection(); + var totalPages = this.getTotalPages(); + var currentPage = this.getCurrentPage(); + var pageSize = this.getPageSize(); + var maxDays = this.getMaxDays(); + var itemSkin = this.getItemSkin(); + + if (totalPages > 0) { + if (!param) { + param = {}; + } + var idx = this.getStartIndex(); + var stop = this.getEndIndex(); + // preload objects if collection is a HopObject one + if (collection instanceof HopObject) { + collection.prefetchChildren(idx, stop - idx); + } + // add various item and list related properties to the parameter object + param.counter = 1; + param.index = idx + 1; + param.stop = stop; + param.pageSize = pageSize; + param.itemsPerPage = pageSize; // for backwards compatibility only + param.collectionSize = collection.size(); + if (!param.skin && itemSkin) { + param.skin = itemSkin; + } + + var renderFunc = this.getRenderFunction("list", param.type); + var item, prevItem; + while (idx <= stop) { + item = collection.get(idx++); + if ((maxDays != undefined) && (item.getDayDate() < this.getMaxDayDate())) { + idx = stop; + break; + } + renderFunc(item, prevItem, param); + prevItem = item; + param.counter += 1; + param.index += 1; + } + } + return; +}; + +/** + * Returns the rendered list of collection items as string + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns The rendered list + * @type String + * @see #renderList + */ +jala.ListRenderer.prototype.getList = function(param) { + res.push(); + this.renderList(param); + return res.pop() || null; +}; + +/** + * Returns the rendered list of collection items as string + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns The rendered list + * @type String + * @see #renderList + * @deprecated Use {@link #getList} instead + */ +jala.ListRenderer.prototype.renderListAsString = function(param) { + return this.getList(param); +}; + +/** + * Renders a link to the previous page directly to response. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @see #getPrevLink + */ +jala.ListRenderer.prototype.renderPrevLink = function(param) { + res.write(this.getPrevLink(param)); + return; +}; + +/** + * Returns a rendered link to the previous page as string. For performance + * reasons this method caches the rendered link in the local cache of this + * ListRenderer instance. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns A rendered link to the previous page + * @type String + * @see #renderPrevLink + */ +jala.ListRenderer.prototype.getPrevLink = function(param) { + if (!this.cache.prevLink) { + res.push(); + var collection = this.getCollection(); + var currentPage = this.getCurrentPage(); + if (collection.size() && currentPage > 1) { + param.index = currentPage - 1; + param.href = this.getPageHref(param.index); + this.getRenderFunction("pageLink", param.type)("prev", param); + } + this.cache.prevLink = res.pop(); + } + return this.cache.prevLink || null; +}; + +/** + * Returns a rendered link to the previous page as string + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns A rendered link to the previous page + * @type String + * @deprecated Use {@link #getPrevLink} instead + */ +jala.ListRenderer.prototype.renderPrevLinkAsString = function(param) { + return this.getPrevLink(param); +}; + +/** + * Renders a link to the next page directly to response. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @see #getNextLink + */ +jala.ListRenderer.prototype.renderNextLink = function(param) { + res.write(this.getNextLink(param)); + return; +}; + +/** + * Returns a rendered link to the previous page as string. For performance + * reasons this method caches the rendered link in the local cache of this + * ListRenderer instance. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns A rendered link to the previous page + * @type String + * @see #renderNextLink + */ +jala.ListRenderer.prototype.getNextLink = function(param) { + if (!this.cache.nextLink) { + res.push(); + var collection = this.getCollection(); + var currentPage = this.getCurrentPage(); + var totalPages = this.getTotalPages(); + var nextItem = this.getNextItem(); + var nextIsDisplayable = false; + if (this.getMaxDays() != undefined) { + if (nextItem != "none" && nextItem.getDayDate() >= this.getMaxDayDate()) { + nextIsDisplayable = true; + } + } else { + if (nextItem != "none") { + nextIsDisplayable = true; + } + } + if (collection.size() && currentPage < totalPages && nextIsDisplayable === true) { + param.index = currentPage + 1; + param.href = this.getPageHref(param.index); + this.getRenderFunction("pageLink", param.type)("next", param); + } + this.cache.nextLink = res.pop(); + } + return this.cache.nextLink || null; +}; + +/** + * Returns a rendered link to the previous page as string + * @returns A rendered link to the next page + * @type String + * @deprecated Use {@link #getNextLink} instead + */ +jala.ListRenderer.prototype.renderNextLinkAsString = function(param) { + return this.getNextLink(param); +}; + +/** + * Renders the page navigation bar directly to response. For performance reasons + * this method caches the rendered page navigation in the local cache of this + * ListRenderer instance. + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @see #getPageNavigation + */ +jala.ListRenderer.prototype.renderPageNavigation = function(param) { + if (!this.cache.pageNavigation) { + var collection = this.getCollection(); + var totalPages = this.getTotalPages(); + var currentPage = this.getCurrentPage(); + var pageSize = this.getPageSize(); + + if (totalPages > 1) { + var renderFunc = this.getRenderFunction("pageNavigation", param.type); + if (!renderFunc) { + return "[Render function missing]"; + } + + // render the navigation-bar + res.push(); + if (currentPage > 1) { + renderFunc("item", { + text: param.previous || "prev", + url: this.getPageHref(currentPage -1), + }); + } + var navLength = parseInt(param.length, 10) || 10; + var pageNr = 1 + Math.floor((currentPage -1) / navLength) * navLength; + if (pageNr > 1) { + renderFunc("item", { + text: param.previousN || "[..]", + url: this.getPageHref(pageNr - navLength), + }); + } + var stop = Math.min(pageNr + navLength, totalPages +1); + do { + renderFunc("item", { + text: (param.itemPrefix || "") + pageNr + (param.itemSuffix || ""), + url: this.getPageHref(pageNr), + selected: pageNr == currentPage + }); + } while ((pageNr += 1) < stop); + + if (pageNr <= totalPages) { + renderFunc("item", { + text: param.nextN || "[..]", + url: this.getPageHref(pageNr), + }); + } + if (currentPage < totalPages) { + renderFunc("item", { + text: param.next || "next", + url: this.getPageHref(currentPage +1), + }); + } + var navigation = res.pop(); + res.push(); + renderFunc("navigation", { + from: ((currentPage -1) * pageSize) +1, + to: Math.min(((currentPage -1) * pageSize) + pageSize, collection.size()), + total: collection.size(), + pageNavigation: navigation, + }); + this.cache.pageNavigation = res.pop(); + } + } + res.write(this.cache.pageNavigation); + return; +}; + +/** + * Returns the rendered page navigation bar as string + * @param {Object} param Object containing extra parameters (e.g. from a macro call). + * @returns The rendered page navigation + * @type String + * @see #renderPageNavigation + */ +jala.ListRenderer.prototype.getPageNavigation = function(param) { + res.push(); + this.renderPageNavigation(param); + return res.pop() || null; +}; + +/** + * Returns the rendered page navigation bar as string + * @returns The rendered page navigation bar + * @type String + * @deprecated Use {@link #getPageNavigation} instead + */ +jala.ListRenderer.prototype.renderPageNavigationAsString = function(param) { + return this.getPageNavigation(param); +}; + + + +/********************************* + ********** M A C R O S ********** + *********************************/ + + +/** + * Either renders the maximum number of items per page, or + * sets the limit to a given number. + * @param {Object} param Extra macro parameters: + *
      + *
    • to - The maximum number of items per page to be set. + *
    + * If no limit is set, this macro returns the current number + * of items per page. + * @returns The current maximum number of items per page + * @type Number + */ +jala.ListRenderer.prototype.limit_macro = function(param) { + if (param.to) { + this.setPageSize(param.to); + return; + } else { + return this.getPageSize(); + } +}; + +/** + * Returns a rendered link to the previous page. + * @param {Object} param Extra macro parameters: + *
      + *
    • type - The type of renderer to be applied.
    • + *
    + * @returns A rendered link to the previous page + * @type String + * @see #renderPrevLink + */ +jala.ListRenderer.prototype.prevLink_macro = function(param) { + return this.getPrevLink(param); +}; + +/** + * Returns a rendered link to the next page. + * @param {Object} param Extra macro parameters: + *
      + *
    • type - The type of renderer to be applied.
    • + *
    + * @returns A rendered link to the next page + * @type String + * @see #renderNextLink + */ +jala.ListRenderer.prototype.nextLink_macro = function(param) { + return this.getNextLink(param); +}; + +/** + * Returns the rendered page navigation bar. + * @param {Object} param Extra macro parameters: + *
      + *
    • type - The type of renderer to be applied.
    • + *
    + * @returns The rendered page navigation bar + * @type String + * @see #getPageNavigation + */ +jala.ListRenderer.prototype.pageNavigation_macro = function(param) { + return this.getPageNavigation(param); +}; + +/** + * Returns the total number of items + * @returns The total number of items in the collection this ListRenderer + * instance is working on + * @type Number + */ +jala.ListRenderer.prototype.size_macro = function() { + return Math.min(this.getMaxPages() * this.getPageSize(), + this.getCollection().size()); +}; + +/** + * Returns the total number of pages + * @returns The total number of pages available + * @type Number + */ +jala.ListRenderer.prototype.totalPages_macro = function() { + return this.getTotalPages(); +}; + +/** + * Returns the current page number + * @returns The current page number + * @type Number + */ +jala.ListRenderer.prototype.currentPage_macro = function() { + return this.getCurrentPage(); +}; + +/** + * Returns the start item number in the current page + * @returns The start item number in the current page + * @type Number + */ +jala.ListRenderer.prototype.currentStart_macro = function() { + return this.getStartIndex() + 1; +}; + +/** + * Returns the end item number in the current page + * @returns The end item number in the current page + * @type Number + */ +jala.ListRenderer.prototype.currentEnd_macro = function() { + return this.getEndIndex() + 1; +}; + +/** + * Renders the current page of this list. + * @param {Object} param Extra macro parameters: + *
      + *
    • skin - The name of the list skin to render for each item in the list.
    • + *
    • type - The type of renderer to be applied.
    • + *
    + * @see #renderList + */ +jala.ListRenderer.prototype.render_macro = function(param) { + var skinName; + if (!(skinName = param.skin || this.getItemSkin())) { + res.write("[Name of skin missing]"); + } else { + this.renderList(param); + } + return; +}; + + + +/***************************************************** + ********** D E F A U L T R E N D E R E R ********** + *****************************************************/ + + +/** + * Default Renderer object containing functions + * used for rendering different list items (eg. page navigation, + * prev/next links and list items). + * @final + */ +jala.ListRenderer.defaultRenderer = {}; + +/** + * List renderer object + */ +jala.ListRenderer.defaultRenderer.list = {}; + +/** + * Default renderer method for a list + * @param {Object} item The current list item to render. + * @param {Object} prevItem The previous list item + * @param {Object} param A parameter object containing macro attributes + * and some parameters set by the ListRenderer. + */ +jala.ListRenderer.defaultRenderer.list["default"] = function(item, prevItem, param) { + var p = {"class": (param.index % 2 == 0 ? "even" : "odd")}; + item.renderSkin(param.skin, p); + return; +}; + +/** + * Pagenavigation renderer object + */ +jala.ListRenderer.defaultRenderer.pageNavigation = {}; + +/** + * Default renderer method for a page navigation bar. + * @param {String} what A string indicating what should be rendered. Can be + * either "item" or "navigation" (the former is a single page link, the latter + * is the whole navigation. + * @param {Object} A parameter object containing the macro attributes and some + * attributes set by the ListRenderer. + */ +jala.ListRenderer.defaultRenderer.pageNavigation["default"] = function(what, param) { + var skin; + switch (what) { + case "item": + if (param.selected == true) { + param["class"] = "selected"; + } else { + delete param["class"]; + } + param.text = jala.ListRenderer.html.linkAsString({href: param.url}, param.text); + if (param.skin != null) { + renderSkin(param.skin, param); + } else if ((skin = app.getSkin("Global", "pageNavigationItem", res.skinpath)) != null) { + renderSkin(skin, param); + } else { + if (param["class"]) { + res.write(''); + } else { + res.write(""); + } + res.write(param.text); + res.write(''); + } + break; + + case "navigation": + if (param.skin != null) { + renderSkin(param.skin, param); + } else if ((skin = app.getSkin("Global", "pageNavigation", res.skinpath)) != null) { + renderSkin(skin, param); + } else { + res.write('"); + } + break; + } + return; +}; + +/** + * Pagelink renderer object + */ +jala.ListRenderer.defaultRenderer.pageLink = {}; + +/** + * Default rendering method for a page link (aka "prev/next" link) + * @param {String} what A string indicating what should be rendered. Can be + * either "prev" or "next" + * @param {Object} param A parameter object containing macro attributes and + * some set by the ListRenderer. + */ +jala.ListRenderer.defaultRenderer.pageLink["default"] = function(what, param) { + delete param.index; + if (param.skin) { + renderSkin(param.skin, param); + } else { + jala.ListRenderer.html.link(param, param.text || what); + } + return; +}; + + + +/***************************************** + ********** A R R A Y L I S T ********** + *****************************************/ + + +/** + * Creates a new ArrayList instance. + * @class A simple wrapper around an array to use in conjunction + * with jala.ListRenderer. This wrapper can either handle complete arrays + * or subsections of an array. In the latter case the wrapper needs offset + * and total size information as argument to mimick a complete array. + * @param {Array} arr The array (or a subsection of an array) to wrap + * @param {Number} offset An optional offset to use (mandatory if the array + * is just a subsection). + * @param {Number} total An optional total size of the array. This argument is + * mandatory if the wrapped array is just a subsection. + * @returns A newly created ArrayList instance + * @constructor + */ +jala.ListRenderer.ArrayList = function(arr, offset, total) { + /** + * The offset of this ArrayList instance. This might be > zero for + * ArrayList instances wrapping just a subsection, that is + * mimicking a bigger list. + * @type Number + */ + this.offset = offset || 0; + + /** + * The length of this ArrayList instance. + * @type Number + */ + this.length = total || arr.length; + + /** + * Returns the element at the index position passed + * as argument. If the wrapped array is just a subsection + * the index position passed will be corrected using + * the offset. + * @param {Number} idx The index position of the element + * to return + * @returns The element at the given index position + */ + this.get = function(idx) { + return arr[(this.offset > 0) ? idx - offset : idx]; + }; + + /** + * Returns the size of this ArrayList, which is either + * the length of the wrapped array or the total size + * passed as argument to the constructor (in case the wrapped + * array is just a subsection). + * @returns The size of this ArrayList instance + * @type Number + */ + this.size = function() { + return this.length; + }; + + /** + * Returns true if this ArrayList is a subsection of a bigger array + * @returns True if this ArrayList is a subsection of a bigger array + * @type Boolean + */ + this.isSubset = function() { + return offset || total ? true : false; + }; + + /** + * Returns the actual size of this ArrayList's wrapped array. + * @returns The actual size of this ArrayList's wrapped array. + * @type Number + */ + this.subsetSize = function() { + return arr.length; + }; + + return this; +}; + +/** @ignore */ +jala.ListRenderer.ArrayList.prototype.toString = function() { + return "[jala.ListRenderer.ArrayList]"; +}; diff --git a/modules/jala/code/Mp3.js b/modules/jala/code/Mp3.js new file mode 100644 index 00000000..2a8cfcd9 --- /dev/null +++ b/modules/jala/code/Mp3.js @@ -0,0 +1,1521 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Fields and methods of the jala.audio package. + */ + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + +// Load java libraries +(function() { + var jalaDir = getProperty("jala.dir", "modules/jala"); + // JavaMusicTag (org.farng.mp3.*) + app.addRepository(jalaDir + "/lib/jid3lib-0.5.4.jar"); + // Mp3Info (de.ueberdosis.mp3info.*, required for parseDuration) + app.addRepository(jalaDir + "/lib/id3-1.6.0d9.jar"); +})(); + +// Resolve HelmaLib dependencies +app.addRepository("modules/helma/File.js"); + +/** + * Constructs a new jala.Mp3 wrapper and + * parses the header data of the MP3 file. + * The standard fields for a tag are accessible + * as properties of the new object. + * + * @class This is a class representing an MP3 file + * providing methods to access its metadata. + * + * @param {String|File} file The mp3 file to be parsed, either as + * path string or as any kind of file object + * + * @constructor + */ +jala.Mp3 = function(file) { + + // check and normalize file argument + if (!file) { + throw "jala.Mp3: missing argument"; + } else { + file = new helma.File(file); + } + + try { + var clazz = java.lang.Class.forName("org.farng.mp3.MP3File", + false, app.getClassLoader()) + } catch (e) { + throw "jala.Mp3 requires jid3lib-0.5.4.jar" + + " in lib/ext or modules/jala/lib directory " + + "[http://javamusictag.sourceforge.net/]"; + } + + if (file.getLength() < 128) { + throw "file too short to be an MP3 file (< 128 bytes)"; + } + try { + var mp3File = new Packages.org.farng.mp3.MP3File(file.getAbsolutePath()); + } catch (e) { + throw "error parsing mp3 file: " + e.toString(); + } + + /** + * Returns a helma.File reference to the wrapped file. + * @type helma.File + */ + this.getFile = function() { + return file; + }; + + /** + * Returns the underlying java object + * @type org.farng.mp3.MP3File + */ + this.getJavaObject = function() { + return mp3File; + }; + + + // map to remember tag objects + var tagObjects = {}; + + if (mp3File.hasID3v1Tag()) { + tagObjects[jala.Mp3.Id3v1] = new jala.Mp3.Id3v1(this); + } + + if (mp3File.hasID3v2Tag()) { + tagObjects[jala.Mp3.Id3v2] = new jala.Mp3.Id3v2(this); + } + + /** + * This method creates a new tag object, attaches it + * to the file (thereby replacing an existing tag of + * this type) and returns it. Type is specified using + * the class name in jala.Mp3.*. If a second + * argument is provided, its values are copied into + * the new tag. + * + * @param {Object} tagClass + * @param {Object} tagObject optional tag whose standard + * properties are copied to the new tag. + * @type Object + */ + this.createTag = function(tagClass, tagObject) { + + this.removeTag(tagClass); + tagObjects[tagClass] = new tagClass(this); + // we use zero as default value for empty track numbers. + // this is the same behaviour as with winamp and tag&rename. + tagObjects[tagClass].setTrackNumber("0"); + + if (tagObject) { + tagObjects[tagClass].copyFrom(tagObject); + } + return tagObjects[tagClass]; + }; + + /** + * Returns a tag object, type is specified using the class name + * in jala.Mp3.*. + * @type Object + */ + this.getTag = function(tagClass) { + return tagObjects[tagClass]; + }; + + /** + * Tells if the file contains a certain tag, type is specified + * using the class name in jala.Mp3.* + */ + this.hasTag = function(tagClass) { + return (tagObjects[tagClass]) ? true : false; + }; + + + // field to remember a v2 tag that has to be deleted from the file in save() + var v2JavaTagToDelete = null; + + /** + * Removes a tag from the file, type is specified using the + * class name in jala.Mp3.* + */ + this.removeTag = function(tagClass) { + if (!tagObjects[tagClass]) { + return; + } + + // remember v2 tag here to explicitly delete it from + // the audio file if save() is called ... + // this is a workaround for a bug in JavaMusicTag! + v2JavaTagToDelete = tagObjects[tagClass].getJavaObject(); + + tagObjects[tagClass].removeFromAudio(); + tagObjects[tagClass] = null; + return; + }; + + + /** + * Writes changed metadata back to the source file or to a new file. + * @param {String|helma.File} outFile (optional) save the modified file + * to a different file + * @returns true on success, false if the file contains tags that cannot be saved (Id3v2_2). + * @type Boolean + */ + this.save = function(outFile) { + var tagOptions = Packages.org.farng.mp3.TagOptionSingleton.getInstance(); + // (robert) this appearently fixes the problem that Windows Media Player cannot play files + // anymore if the size of an Id3v2 tag changed + tagOptions.setId3v2PaddingCopyTag(false); + // turn off saving of backup-files: + tagOptions.setOriginalSavedAfterAdjustingID3v2Padding(false); + + if (v2JavaTagToDelete) { + // this is a workaround for a bug in JavaMusicTag: + // MP3File.save() just tries to delete an ID3v2_4 tag, + // but omits 2_3 or 2_2 tags. To be on the safe side + // we have to explicitly remove the deleted v2 tag. + var raf = new java.io.RandomAccessFile(mp3File.getMp3file(), "rw"); + v2JavaTagToDelete["delete"](raf); + v2JavaTagToDelete = null; + raf.close(); + } + + if(tagObjects[jala.Mp3.Id3v2] && tagObjects[jala.Mp3.Id3v2].getSubtype() == 2) { + app.log("Error in jala.Mp3#save: Can't save a tag of version Id3v2_2. Please remove the tag and add a new Id3v2 tag of sub type 3 or 4!"); + return false; + } + + if(outFile) { + var outFile = new helma.File(outFile); + // MP3File.save(file) only saves the tags! + // Thus, we make a hardcopy first. + file.hardCopy(outFile); + } else { + outFile = file; + } + mp3File.save(outFile, + Packages.org.farng.mp3.TagConstant.MP3_FILE_SAVE_OVERWRITE + ); + return true; + }; + + + + // flag to remember if mp3 header has been read + var mp3HeaderRead = false; + + /** + * Makes sure that the mp3 header is read only once + * This takes a few milliseconds, so we only do it when a + * function that depends on header data is called. + * @private + */ + this.readMp3Header = function() { + if (!mp3HeaderRead) { + mp3File.seekMP3Frame(); + mp3HeaderRead = true; + } + return; + }; + + + /** @type String */ + this.album; + + /** @type String */ + this.artist; + + /** @type String */ + this.comment; + + /** @type String */ + this.genre; + + /** @type String */ + this.title; + + /** @type String */ + this.trackNumber; + + /** @type String */ + this.year; + + return this; +}; + +// define getter for standard fields: +try { + jala.Mp3.prototype.__defineGetter__("album", function() { return this.getField("album"); }); + jala.Mp3.prototype.__defineGetter__("artist", function() { return this.getField("artist"); }); + jala.Mp3.prototype.__defineGetter__("comment", function() { return this.getField("comment"); }); + jala.Mp3.prototype.__defineGetter__("genre", function() { return this.getField("genre"); }); + jala.Mp3.prototype.__defineGetter__("title", function() { return this.getField("title"); }); + jala.Mp3.prototype.__defineGetter__("trackNumber", function() { return this.getField("trackNumber"); }); + jala.Mp3.prototype.__defineGetter__("year", function() { return this.getField("year"); }); +} catch (e) { + // older helma versions can't handle __defineGetter__ +} + + +/** + * Array defining valid genres in ID3v1 + * @type Array + * @final + */ +jala.Mp3.GENRES = ["Blues", "Classic Rock", "Country", "Dance", "Disco", + "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", + "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", + "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", + "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", + "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", + "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", + "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", + "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", + "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", + "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", + "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", + "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock", + "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", + "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", + "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", + "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", + "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", + "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", + "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", + "Acapella", "Euro-House", "Dance Hall"]; + + +/** + * Array defining mp3 modes. + * @type Array + * @final + */ +jala.Mp3.MODES = ["Stereo", "Joint stereo", "Dual channel", "Mono"]; + + +/** + * Array defining valid text encodings. Note: UTF-8 is valid for v2.4 only. + * UTF-16 with BOM doesn't work with Winamp etc - use UTF-16BE instead! + * The index position within the array defines the number used in the mp3 file. + * @type Array + * @final + */ +jala.Mp3.TEXT_ENCODINGS = ["ISO-8859-1", "UTF-16", "UTF-16BE", "UTF-8"]; + + +/** + * Array defining valid picture types. Note: Most image tagged files come with + * one picture of picture type null! + * The index position within the array defines the number used in the mp3 file. + * @type Array + * @final + */ +jala.Mp3.PICTURE_TYPES = ["Other", "32x32 pixels 'file icon' (PNG only)", + "Other file icon", "Cover (front)", "Cover (back)", "Leaflet page", + "Media (e.g. label side of CD)", "Lead artist/lead performer/soloist", + "Artist/performer", "Conductor", "Band/Orchestra", "Composer", + "Lyricist/text writer", "Recording Location", "During recording", + "During performance", "Movie/video screen capture", "A bright coloured fish", + "Illustration", "Band/artist logotype", "Publisher/Studio logotype"]; + + +/** + * Maps the name of the standard fields to frame ids in the different versions + * of ID3v2. + * @type Object + * @private + * @final + */ +jala.Mp3.FIELD_MAPPING = { + "album": ["", "", "TALB", "TALB", "TALB"], + "artist": ["", "", "TPE1", "TPE1", "TPE1"], + "comment": ["", "", "COMM", "COMM", "COMM"], + "genre": ["", "", "TCON", "TCON", "TCON"], + "title": ["", "", "TIT2", "TIT2", "TIT2"], + "subtitle": ["", "", "TIT3", "TIT3", "TIT3"], + "trackNumber": ["", "", "TRCK", "TRCK", "TRCK"], + "year": ["", "", "TYER", "TYER", "TDRC"], + "author": ["", "", "TCOM", "TCOM", "TCOM"], + "copyright": ["", "", "TCOP", "TCOP", "TCOP"], + "url": ["", "", "WXXX", "WXXX", "WXXX"], + "image": ["", "", "APIC", "APIC", "APIC"] +}; + + +/** + * Helper method to copy the standard fields from one tag + * to another + * @param {Object} src object with setter methods for fields album, artist, + * comment, title, trackNumber, genre and year. + * @param {Object} dest object with getter methods for fields album, artist, + * comment, title, trackNumber, genre and year. + * @returns changed object + * @type Object + * @private + */ +jala.Mp3.copyFields = function(src, dest) { + dest.setAlbum(src.getAlbum()); + dest.setArtist(src.getArtist()); + dest.setComment(src.getComment()); + dest.setTitle(src.getTitle()); + dest.setTrackNumber(src.getTrackNumber()); + dest.setGenre(src.getGenre()); + dest.setYear(src.getYear()); + return dest; +}; + + +/** + * Helper function to handle arguments that may either be a + * number or an object that matches a value in an array. + * In the first case the number itself is returned, in the latter + * case the index position within the array is returned. + * @param {Number|Object} arg argument as number or object + * @param {Array} values Array of objects. + * @returns The number the argument represents + * @type Number + * @private + */ +jala.Mp3.normalizeArg = function(arg, values, defaultValue) { + if (arg == null) { + return defaultValue; + } else if (!isNaN(arg)) { + return parseInt(arg); + } else { + var idx = values.indexOf(arg); + if (idx > 0) { + return idx; + } + } + return null; +}; + + +/** + * The audio length of the file in seconds at best estimate + * from the file info (method returns immediately). + * This method calculates based on the bitrate. Therefore it + * has to produce wrong results for files encoded with variable + * bitrate (vbr). For these files parseDuration() can be used. + * @returns length in seconds + * @type Number + * @see #parseDuration + */ +jala.Mp3.prototype.getDuration = function() { + var bitrate = this.getBitRate(); + if (bitrate != 0) { + return Math.round(this.getSize() / (bitrate * 1000 / 8)); + } + return 0; +}; + + +/** + * Parses the audio file to extract the precise duration of the audio. + * The upside is that it works fine for files with variable bitrates. + * The downside is that this action may take a few seconds depending on + * the size of the audio file. + * @returns length in seconds + * @type Number + * @see #getDuration + */ +jala.Mp3.prototype.parseDuration = function() { + try { + Packages.de.ueberdosis.util.OutputCtr.setLevel(0); // turn off debug output + var reader = Packages.de.ueberdosis.mp3info.ID3Reader(this.getFile().getAbsolutePath()); + var tag = reader.getExtendedID3Tag(); + return tag.getRuntime(); + } catch (e) { + throw "jala.Mp3#parseDuration requires id3-1.6.0d9.jar" + + " in lib/ext or modules/jala/lib directory " + + "[http://sourceforge.net/projects/mp3info/]"; + } +}; + + +/** + * Returns the file size in bytes. + * @type Number + */ +jala.Mp3.prototype.getSize = function() { + return this.getFile().getLength(); +}; + + +/** + * Returns the bit rate the file was encoded with. + * @type Number + */ +jala.Mp3.prototype.getBitRate = function() { + this.readMp3Header() + return this.getJavaObject().getBitRate(); +}; + + +/** + * Returns the channel mode the file was encoded with. + * @type String + */ +jala.Mp3.prototype.getChannelMode = function() { + this.readMp3Header() + return jala.Mp3.MODES[this.getJavaObject().getMode()]; +}; + + +/** + * Returns the frequency the file was encoded with. + * @type Number + */ +jala.Mp3.prototype.getFrequency = function() { + this.readMp3Header() + return this.getJavaObject().getFrequency(); +}; + + +/** + * Returns true if the file is (or seems to be) encoded with + * variable bit rate. FIXME: The current implementation returned + * true for all test files. + * @type Boolean + */ +jala.Mp3.prototype.isVariableBitRate = function() { + this.readMp3Header() + return this.getJavaObject().isVariableBitRate(); +}; + + +/** + * Returns the information for a field from the tags: At first the ID3v2 + * tag is checked. If it isn't present or doesn't contain the field, + * the ID3v1 tag is checked. + * @type {String} + * @private + */ +jala.Mp3.prototype.getField = function(fieldName) { + var funcName = "get" + fieldName.charAt(0).toUpperCase() + fieldName.substring(1); + var tag, value; + var getValue = function() { + if (tag[funcName] != null && tag[funcName] instanceof Function) { + return tag[funcName](); + } + return null; + }; + + if ((tag = this.getV2Tag()) != null && (value = getValue()) != null) { + return value; + } + if ((tag = this.getV1Tag()) != null && (value = getValue()) != null) { + return value; + } + return null; +}; + +/** + * Sets the value of the field with the given name to the value specified, + * in both ID3v1 and ID3v2 tags, but only if the appropriate setter method + * exists. + * @param {String} fieldName The name of the field to set + * @param {String} value The value of the field + * @private + */ +jala.Mp3.prototype.setField = function(fieldName, value) { + if (value != null) { + var funcName = "set" + fieldName.charAt(0).toUpperCase() + fieldName.substring(1); + var setValue = function(tag) { + if (tag[funcName] != null && tag[funcName] instanceof Function) { + tag[funcName](value); + } + return; + }; + + setValue(this.getV2Tag() || this.createV2Tag()); + setValue(this.getV1Tag() || this.createV1Tag()); + } + return; +}; + + +/** + * If the file doesn't contain an ID3v1 tag, this method + * creates a new ID3v1 tag object, attaches it to the file + * and returns it. If a second argument is provided, its + * values are copied into the new tag. + * + * @param {Object} tagObject optional tag whose standard + * properties are copied to the new tag. + * @type jala.Mp3.Id3v1 + */ +jala.Mp3.prototype.createV1Tag = function(tagObject) { + return this.createTag(jala.Mp3.Id3v1, tagObject); +}; + + +/** + * If the file doesn't contain an ID3v2 tag, this method + * creates a new ID3v2 tag object, attaches it to the file + * and returns it. If a second argument is provided, its + * values are copied into the new tag. + * + * @param {Object} tagObject optional tag whose standard + * properties are copied to the new tag. + * @type jala.Mp3.Id3v2 + */ +jala.Mp3.prototype.createV2Tag = function(tagObject) { + return this.createTag(jala.Mp3.Id3v2, tagObject); +}; + + +/** + * @type jala.Mp3.Id3v1 + */ +jala.Mp3.prototype.getV1Tag = function() { + return this.getTag(jala.Mp3.Id3v1); +}; + + +/** + * @type jala.Mp3.Id3v2 + */ +jala.Mp3.prototype.getV2Tag = function() { + return this.getTag(jala.Mp3.Id3v2); +}; + + +/** + * Returns true if the file contains a ID3v1 tag. + * @type Boolean + */ +jala.Mp3.prototype.hasV1Tag = function() { + return this.hasTag(jala.Mp3.Id3v1); +}; + + +/** + * Returns true if the file contains a ID3v2 tag. + * @type Boolean + */ +jala.Mp3.prototype.hasV2Tag = function() { + return this.hasTag(jala.Mp3.Id3v2); +}; + + +/** + * Removes the ID3v1 tag from the file. + */ +jala.Mp3.prototype.removeV1Tag = function() { + this.removeTag(jala.Mp3.Id3v1); +}; + + +/** + * Removes the ID3v2 tag from the file. + */ +jala.Mp3.prototype.removeV2Tag = function() { + return this.removeTag(jala.Mp3.Id3v2); +}; + + +/** @ignore */ +jala.Mp3.prototype.toString = function() { + return "[jala.Mp3 " + this.getFile() + "]"; +}; + +/** + * Returns a plain JavaScript object containing the values of + * all fields stored in either the Id3 V1 or V2 tag + * @returns An object containing the values of all fields + */ +jala.Mp3.prototype.getMetadata = function() { + var result = {}; + // generic metadata values + result.size = this.getSize(); + result.isVariableBitRate = this.isVariableBitRate(); + result.bitrate = this.getBitRate(); + result.frequency = this.getFrequency(); + result.channelMode = this.getChannelMode(); + result.duration = this.parseDuration(); + // Id3 tag values + var fields = [ + "title", + "subtitle", + "author", + "url", + "trackNumber", + "year", + "album", + "artist", + "comment", + "genre", + "copyright", + ]; + var fieldName; + for (var i=0; i get the correct encoding string from constant + encoding = jala.Mp3.TEXT_ENCODINGS[encoding]; + } + return new java.lang.String(new java.lang.String(str).getBytes(encoding)); +}; + + +/** + * Decodes a string using the given encoding. + * @param {String} str string to decode + * @param {String} encoding encoding to use + * @returns decoded string + * @type String + * @private + */ +jala.Mp3.Id3v2.prototype.decodeText = function(str, encoding) { + if (!isNaN(encoding)) { + // if encoding is the byte value -> get the correct encoding string from constant + encoding = jala.Mp3.TEXT_ENCODINGS[encoding] + } + var rawStr = new java.lang.String(str); + return "" + new java.lang.String(rawStr.getBytes(), encoding); +}; + + +/** + * This method can be used to retrieve an arbitrary text frame + * of the underlying tag. For the list of valid identifiers + * and their meaning see http://www.id3.org/ + * The identifiers vary across the sub versions of id3v2 tags, + * use getSubtype to make sure you use the correct version. + * @param {String} id Frame identifier according to Id3v2 specification + * or shortcut as defined in jala.Mp3.FIELD_MAPPING. + * @returns String contained in the frame + * @type String + * @see #getSubtype + */ +jala.Mp3.Id3v2.prototype.getTextContent = function(idStr) { + var id = idStr; + if (jala.Mp3.FIELD_MAPPING[idStr]) { + id = jala.Mp3.FIELD_MAPPING[idStr][this.getSubtype()]; + } + var frame = this.getJavaObject().getFrame(id); + if (frame) { + var body = frame.getBody(); + if (!(body instanceof Packages.org.farng.mp3.id3.FrameBodyUnsupported)) { + return this.decodeText(body.getText(), body.getObject("Text Encoding")); + } + } + return null; +} + + +/** + * This method can be used to set an arbitrary field + * of the underlying tag. For the list of valid identifiers + * and their meaning see http://www.id3.org/ + * The identifiers vary across the sub versions of id3v2 tags, + * use getSubtype to make sure you use the correct version. + * @param {String} id Frame identifier according to Id3v2 specification + * @param {String} value + * @type String + * @see #getSubtype + */ +jala.Mp3.Id3v2.prototype.setTextContent = function(idStr, val) { + var id = idStr; + if (jala.Mp3.FIELD_MAPPING[idStr]) { + id = jala.Mp3.FIELD_MAPPING[idStr][this.getSubtype()]; + } + var frame = this.getJavaObject().getFrame(id); + if (frame) { + var body = frame.getBody(); + // frame already exists, use its encoding: + body.setText(this.encodeText(val, body.getObject("Text Encoding"))); + } else { + // new frame is created, use our own encoding: + var body = new Packages.org.farng.mp3.id3["FrameBody" + id]( + this.getTextEncoding(), this.encodeText(val, this.getTextEncoding()) + ); + this.getJavaObject().setFrame(this.createFrameObject(body)); + } + return; +}; + + +/** + * Creates a new frame object that fits to the tag version. + * @param {org.farng.mp3.id3.AbstractID3v2FrameBody} body frame body object + * @returns new frame object + * @type org.farng.mp3.id.ID3v2_2 + * @private + */ +jala.Mp3.Id3v2.prototype.createFrameObject = function(body) { + var subtype = this.getSubtype(); + if (subtype == 2) { + return new Packages.org.farng.mp3.id3.ID3v2_2Frame(body); + } else if (subtype == 3) { + return new Packages.org.farng.mp3.id3.ID3v2_3Frame(body); + } else if (subtype == 4 || subtype == 0) { + return new Packages.org.farng.mp3.id3.ID3v2_4Frame(body); + } + return null; +}; + + +/** + * Returns the version number of this id3v2 (values 2 to 4 for id3v2.2 to id3v2.4) + * @returns The version number of this Id3v2 tag + * @type Number + */ +jala.Mp3.Id3v2.prototype.getSubtype = function() { + // AbstractID3v2#getRevision() only works for newly constructed tag objects, + // but not for tag objects that have been read from a file. + // so we make a class comparison to find out the subtype: + var obj = this.getJavaObject(); + if (obj instanceof Packages.org.farng.mp3.id3.ID3v2_4) { + return 4; + } else if (obj instanceof Packages.org.farng.mp3.id3.ID3v2_3) { + return 3; + } else if (obj instanceof Packages.org.farng.mp3.id3.ID3v2_2) { + return 2; + } + return 0; +}; + + +/** + * Returns the album information of the tag. + * @returns string containing album name + * @type String + */ +jala.Mp3.Id3v2.prototype.getAlbum = function() { + return this.getTextContent("album"); +}; + + +/** + * Returns the artist information of the tag. + * @returns string containing artist name + * @type String + */ +jala.Mp3.Id3v2.prototype.getArtist = function() { + return this.getTextContent("artist"); +}; + + +/** + * Returns the comment information of the tag. + * @returns string containing comment + * @type String + */ +jala.Mp3.Id3v2.prototype.getComment = function() { + var frame = this.getFrame("comment", "eng", ""); + if (frame) { + var str = frame.getBody().getText(); + return this.decodeText(str, frame.getBody().getObject("Text Encoding")); + } + return null; +}; + + +/** + * Returns the title information of the tag. + * @returns string containing title + * @type String + */ +jala.Mp3.Id3v2.prototype.getTitle = function() { + return this.getTextContent("title"); +}; + + +/** + * Returns the subtitle information of the tag. + * @returns string containing subtitle + * @type String + */ +jala.Mp3.Id3v2.prototype.getSubtitle = function() { + return this.getTextContent("subtitle"); +}; + + +/** + * Returns the track number information of the tag. + * @returns string representing track number + * @type String + */ +jala.Mp3.Id3v2.prototype.getTrackNumber = function() { + return this.getTextContent("trackNumber"); +}; + + +/** + * Returns the genre information of the tag. + * @returns string containing genre name + * @type String + */ +jala.Mp3.Id3v2.prototype.getGenre = function() { + return this.getTextContent("genre"); +}; + + +/** + * Returns the year information of the tag. + * @returns string representing year + * @type String + */ +jala.Mp3.Id3v2.prototype.getYear = function() { + return this.getTextContent("year"); +}; + + +/** + * Returns the author information of the tag. + * @returns string containing author information + * @type String + */ +jala.Mp3.Id3v2.prototype.getAuthor = function() { + return this.getTextContent("author"); +}; + + +/** + * Returns the copyright information of the tag. + * @returns The copyright information of the tag + * @type String + */ +jala.Mp3.Id3v2.prototype.getCopyright = function() { + return this.getTextContent("copyright"); +}; + + +/** + * Returns the Url stored in this tag + * @returns The url stored in this tag + * @type String + */ +jala.Mp3.Id3v2.prototype.getUrl = function() { + var frame = this.getFrame("url", ""); + if (frame) { + return frame.getBody().getUrlLink(); + } + return null; +}; + + +/** + * Sets the album information. + * @param {String} album + */ +jala.Mp3.Id3v2.prototype.setAlbum = function(album) { + this.setTextContent("album", album); + return; +}; + + +/** + * Sets the artist information. + * @param {String} artist + */ +jala.Mp3.Id3v2.prototype.setArtist = function(artist) { + this.setTextContent("artist", artist); + return; +}; + + +/** + * Sets the comment + * @param {String} comment + */ +jala.Mp3.Id3v2.prototype.setComment = function(comment) { + // comment (COMM) isn't a text frame. it supports the getText() + // method but its constructor has a different signature. + var frame = this.getFrame("comment", "eng", ""); + if (frame) { + frame.getBody().setText(this.encodeText(comment, frame.getBody().getObject("Text Encoding"))); + } else { + var body = new Packages.org.farng.mp3.id3.FrameBodyCOMM( + this.getTextEncoding(), "eng", "", this.encodeText(comment, this.getTextEncoding()) + ); + this.getJavaObject().setFrame(this.createFrameObject(body)); + } + return; +}; + + +/** + * Sets the title information + * @param {String} title + */ +jala.Mp3.Id3v2.prototype.setTitle = function(title) { + this.setTextContent("title", title); + return; +}; + + +/** + * Sets the subtitle information + * @param {String} title + */ +jala.Mp3.Id3v2.prototype.setSubtitle = function(title) { + this.setTextContent("subtitle", title); + return; +}; + + +/** + * Sets the track number information. + * @param {Number} trackNumber + */ +jala.Mp3.Id3v2.prototype.setTrackNumber = function(trackNumber) { + this.setTextContent("trackNumber", trackNumber); + return; +}; + + +/** + * Sets the genre information. A list of genre names that are compatible + * with ID3v1 tags is located in jala.Mp3.GENRES. + * @param {String} genre + */ +jala.Mp3.Id3v2.prototype.setGenre = function(genre) { + this.setTextContent("genre", genre); + return; +}; + + +/** + * Sets the year information. + * @param {Number} year + */ +jala.Mp3.Id3v2.prototype.setYear = function(year) { + this.setTextContent("year", year); + return; +}; + + +/** + * Sets the author information in this tag + * @param {String} author The author information to set + */ +jala.Mp3.Id3v2.prototype.setAuthor = function(author) { + this.setTextContent("author", author); + return; +}; + + +/** + * Sets the copyright information in this tag + * @param {String} copyright The copyright information to set + */ +jala.Mp3.Id3v2.prototype.setCopyright = function(copyright) { + this.setTextContent("copyright", copyright); + return; +}; + + +/** + * Stores the Url passed as argument in this tag. + * @param {String} url The url to store in this tag + * @param {String} desc An optiona description of the Url + */ +jala.Mp3.Id3v2.prototype.setUrl = function(url, desc) { + var frame = this.getFrame("url", ""); + if (frame) { + frame.getBody().setUrlLink(url); + } else { + var body = new Packages.org.farng.mp3.id3.FrameBodyWXXX( + this.getTextEncoding(), desc, url + ); + this.getJavaObject().setFrame(this.createFrameObject(body)); + } + return; +}; + + +/** + * Extracts the image from the tag + * @param {String} pictureType number describing picture type + * (default is 3, describing a front cover). + * @returns image as mime object + * @type helma.util.MimePart + */ +jala.Mp3.Id3v2.prototype.getImage = function(pictureType) { + // FIXME: maybe add description to arguments of getFrame? + // more testing needed... + pictureType = jala.Mp3.normalizeArg(pictureType, + jala.Mp3.PICTURE_TYPES, 3); + + var frame = this.getFrame("image", new java.lang.Character(pictureType)); + if (frame) { + var body = frame.getBody(); + var mimeType = body.getObject("MIME Type"); + var imageType = mimeType.substring(6); + var imageName = this.getAudio().getFile().getName().replace(/\.[^\.]+$/i, "") + "." + imageType; + return new Packages.helma.util.MimePart( + imageName, + body.getObject("Picture Data"), + mimeType + ); + } + return null; +}; + + +/** + * adds an image to the file. + * @param {Number} pictureType number determining picture type + * @param {String} mimeType mime type of image + * @param {Array} byteArray image binary data + * @param {String} desc optional description + * @see jala.Mp3 + */ +jala.Mp3.Id3v2.prototype.setImage = function(pictureType, mimeType, byteArray) { + pictureType = jala.Mp3.normalizeArg(pictureType, + jala.Mp3.PICTURE_TYPES, 3); + + var frame = this.getFrame("image", new java.lang.Character(pictureType)); + if (frame) { + if (mimeType && byteArray) { + // set new image data + frame.getBody().setObject("MIME Type", mimeType); + frame.getBody().setObject("Picture Data", byteArray); + } + } else { + // add new image to tag + var body = new Packages.org.farng.mp3.id3.FrameBodyAPIC( + this.getTextEncoding(), + mimeType, + new java.lang.Long(pictureType), + new java.lang.Character(pictureType), + byteArray + ); + this.getJavaObject().setFrame(this.createFrameObject(body)); + } + return; +}; + + +/** @ignore */ +jala.Mp3.Id3v2.prototype.debug = function() { + return "
    " + this.getJavaObject().toString() + "
    "; +}; + + +/** @ignore */ +jala.Mp3.Id3v2.toString = function() { + return "[jala.Mp3.Id3v2]"; +}; + +/** @ignore */ +jala.Mp3.Id3v2.prototype.toString = jala.Mp3.Id3v2.toString; + + +// FIXME: report bug in JavaMusicTag: +// if you delete a v2 tag and call save() JMT calls the delete method of an ID3v2_4 tag. +// this way a 2_2 or 2_3 tag in the file isn't found and not deleted. +// Mp3.save() has a workaround for this. + diff --git a/modules/jala/code/PodcastWriter.js b/modules/jala/code/PodcastWriter.js new file mode 100644 index 00000000..906215b5 --- /dev/null +++ b/modules/jala/code/PodcastWriter.js @@ -0,0 +1,129 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.PodcastWriter class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Jala dependencies + */ +app.addRepository(getProperty("jala.dir", "modules/jala") + + "/code/Rss20Writer.js"); + +/** + * @class Class to create, modify and render standard-compliant + * RSS 2.0 feeds including support for Apple's Podcast specification. + * @constructor + * @extends jala.Rss20Writer + * @param {String} header Optional XML header. + */ +jala.PodcastWriter = function(header) { + jala.Rss20Writer.apply(this, arguments); + + var CATEGORY = { + name: "itunes:category", + attributes: { + name: "text" + } + }; + + var OWNER = { + name: "itunes:owner", + value: [{ + name: "itunes:name" + }, { + name: "itunes:email" + }] + }; + + this.addNamespace("itunes", "http://www.itunes.com/dtds/podcast-1.0.dtd"); + + this.extendChannel([{ + name: "itunes:author" + }, { + name: "itunes:subtitle" + }, { + name: "itunes:summary" + }, { + name: "itunes:new-feed-url" + }, { + name: "itunes:image", + attributes: [{ + name: "href" + }] + }, { + name: "itunes:link", + attributes: [{ + name: "rel" + }, { + name: "type" + }, { + name: "href" + }] + }]); + + this.getChannel().setValue(this.createElement(OWNER)); + + this.extendItem([{ + name: "itunes:duration" + }, { + name: "itunes:subtitle" + }]); + + /** + * Add an iTunes Podcast category. + * @param {String} name The category's name. + * @param {String} subName The (optional) sub-category's name. + * @param {jala.XmlWriter.XmlElement} parent Optional parent + * element to add the category to. + */ + this.addItunesCategory = function(name, subName, parent) { + if (!parent) + parent = this.getChannel(); + var cat = this.createElement(CATEGORY); + cat.populate({attributes: {text: name}}); + if (subName) { + var subCat = this.createElement(CATEGORY); + subCat.populate({attributes: {text: subName}}); + cat.addValue(subCat); + } + parent.addValue(cat); + return; + }; + + return this; +}; + + +/** A typical XML header as default. + @type String @final */ +jala.PodcastWriter.XMLHEADER = ''; diff --git a/modules/jala/code/RemoteContent.js b/modules/jala/code/RemoteContent.js new file mode 100644 index 00000000..6106413d --- /dev/null +++ b/modules/jala/code/RemoteContent.js @@ -0,0 +1,307 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Fields and methods of the jala.RemoteContent class. + */ + +// HelmaLib dependencies +app.addRepository("modules/core/String.js"); +app.addRepository("modules/core/Object.js"); +app.addRepository("modules/core/Date.js"); +app.addRepository("modules/helma/Http.js"); + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + +/** + * Construct a new remote content handler. + * @class API to define, fetch and update content + * from a remote site. + * @param {String} url The URL string of the remote site. + * @param {Integer} method The method to retrieve the remote content. + * @param {File} storage The cache directory. + * @returns A new remote content handler. + * @extends helma.Http + * @constructor + */ +jala.RemoteContent = function(url, method, storage) { + if (typeof PropertyMgr == "undefined") + var PropertyMgr = {}; + + var NULLSTR = ""; + var key = url.md5(); + var fname = key + jala.RemoteContent.SUFFIX; + var cache; + method = (method != null ? method.toLowerCase() : null); + + // depending on the method argument the instance + // becomes extent of the appropriate remote client + switch (method) { + case jala.RemoteContent.XMLRPC: + break; + default: + helma.Http.call(this); + break; + } + + if (!storage) { + storage = jala.RemoteContent.CACHEDIR; + if (!storage.exists() || !storage.isDirectory()) + storage.mkdir(storage.getAbsolutePath()); + } + + var getCache = function() { + switch (storage.constructor) { + case HopObject: + cache = storage; + break; + + case PropertyMgr: + cache = storage.getAll(); + break; + + default: + var f = new File(storage, fname); + cache = f.exists() ? Xml.read(f) : new HopObject(); + } + return cache; + }; + + var setCache = function() { + cache.url = url; + cache.method = method; + if (!cache.interval) { + cache.interval = Date.ONEHOUR; + } + cache.lastUpdate = new Date(); + cache = cache.clone(new HopObject()); + + switch (storage.constructor) { + case HopObject: + for (var i in cache) + storage[i] = cache[i]; + break; + + case PropertyMgr: + storage.setAll(cache); + break; + + default: + var f = new File(storage, fname); + Xml.write(cache, f); + } + return; + }; + + cache = getCache(); + + /** + * Set the interval the remote content's + * cache is bound to be updated. + * @param {Number} interval The interval value in milliseconds. + */ + this.setInterval = function(interval) { + cache.interval = parseInt(interval, 10); + return; + }; + + /** + * Get an arbitrary property of the remote content. + * @param {String} key The name of the property. + * @returns The value of the property. + */ + this.get = function(key) { + return cache[key]; + } + + /** + * Get all available property names. + * @returns The list of property names. + * @type Array + */ + this.getKeys = function() { + var keys = []; + for (var i in cache) { + keys.push(i); + } + return keys.sort(); + }; + + /** + * Tests whether the remote content needs to be updated. + * @returns True if the remote content needs to be updated. + * @type Boolean + */ + this.needsUpdate = function() { + if (!cache.lastUpdate) { + return true; + } else { + var max = new Date() - cache.interval; + if (max - cache.lastUpdate > 0) { + return true; + } + } + return false; + }; + + /** + * Get the updated and cached remote content. + * @returns The content as retrieved from the remote site. + * @type String + */ + this.update = function() { + app.debug("[jala.RemoteContent] Retrieving " + url); + var result; + switch (method) { + case jala.RemoteContent.XMLRPC: + break; + default: + result = this.getUrl(url, cache.lastModified || cache.eTag); + if (result.code != 200 && cache.content) { + // preserve the content received before + result.content = cache.content; + } + result.interval = cache.interval; + cache = result; + } + setCache(); + return cache.content; + }; + + /** + * Flushes (empties) the cached remote content. + */ + this.clear = function() { + switch (storage.constructor) { + case HopObject: + for (var i in storage) + delete storage[i]; + break; + + case PropertyMgr: + storage.reset(); + break; + + default: + var f = new File(storage, fname); + f.remove(); + } + return; + }; + + /** + * Get a string representation of the remote content. + * @returns The remote content as string. + * @type String + */ + this.toString = function() { + return cache.content || NULLSTR; + }; + + /** + * Get the value of the remote content. + * @returns The remote content including response header data. + * @type Object + */ + this.valueOf = function() { + return cache; + }; + + return this; +}; + +/** + * A constant representing the HTTP retrieval method. + * @type int + * @final + */ +jala.RemoteContent.HTTP = 1; + +/** + * A constant representing the XML-RPC retrieval method. + * @type int + * @final + */ +jala.RemoteContent.XMLRPC = 2; + +/** + * The default name of the cache directory. + * @type String + * @final + */ +jala.RemoteContent.SUFFIX = ".cache"; + +/** + * The default cache directory. + * @type File + * @final + */ +jala.RemoteContent.CACHEDIR = new File(app.dir, jala.RemoteContent.SUFFIX); + +/** + * Remove all remote content from a file-based cache. + * @param {File} cache An optional target directory. + */ +jala.RemoteContent.flush = function(cache) { + jala.RemoteContent.forEach(function(rc) { + rc.clear(); + return; + }); + return; +}; + +/** + * Apply a custom method on all remote content in a file-based cache. + * @param {Function} callback The callback method to be executed + * for each remote content file. + * @param {File} cache An optional target directory. + */ +jala.RemoteContent.forEach = function(callback, cache) { + if (!cache) + cache = jala.RemoteContent.CACHEDIR; + var f, rc; + var files = cache.list(); + for (var i in files) { + f = new File(cache, files[i]); + if (!files[i].endsWith(jala.RemoteContent.SUFFIX)) + continue; + rc = new jala.RemoteContent(Xml.read(f).url); + if (callback && callback.constructor == Function) + callback(rc); + } + return; +}; + +/** + * Apply a custom method on all remote content in a file-based cache. + * @param {Function} callback The callback method to be executed + * for each remote content file. + * @param {File} cache An optional target directory. + * @deprecated Use {@link #forEach} instead. + */ +jala.RemoteContent.exec = function() { + jala.RemoteContent.forEach.apply(this, arguments); +}; diff --git a/modules/jala/code/Rss20Writer.js b/modules/jala/code/Rss20Writer.js new file mode 100644 index 00000000..6edc0137 --- /dev/null +++ b/modules/jala/code/Rss20Writer.js @@ -0,0 +1,334 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.Rss20Writer class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * Jala dependencies + */ +app.addRepository(getProperty("jala.dir", "modules/jala") + + "/code/XmlWriter.js"); + +/** + * @class Class to create, modify and render standard-compliant + * RSS 2.0 feeds. + * @constructor + * @extends jala.XmlWriter + * @param {String} header Optional XML header. + */ +jala.Rss20Writer = function(header) { + // defines the prototype of this constructor + jala.XmlWriter.apply(this, arguments); + + // this should do the same but alas, helma throws + // an error the very first time it is executed: + //arguments.callee.prototype = new jala.XmlWriterInterface(); + + var DATEFMT = "EEE, dd MMM yyyy HH:mm:ss Z"; + + var CATEGORY = { + name: "category", + amount: Infinity, + attributes: { + name: "domain", + } + }; + + var ITEM = { + name: "item", + amount: Infinity, + value: [{ + name: "title", + required: true + }, { + name: "link", + }, { + name: "description", + }, { + name: "author", + }, { + name: "comments", + }, { + name: "enclosure", + attributes: [{ + name: "url", + required: true + }, { + name: "length", + required: true + }, { + name: "type", + required: true + }] + }, { + name: "guid", + attributes: [{ + name: "isPermaLink", + type: Boolean + }] + }, { + name: "pubDate", + type: Date, + format: DATEFMT + }, { + name: "source", + attributes: [{ + name: "url", + required: true + }] + }] + }; + + var CHANNEL = { + name: "channel", + value: [{ + name: "title", + required: true + }, { + name: "link", + required: true + }, { + name: "description", + required: true + }, { + name: "language", + }, { + name: "copyright", + }, { + name: "managingEditor", + }, { + name: "webMaster", + }, { + name: "pubDate", + type: Date, + format: DATEFMT + }, { + name: "lastBuildDate", + type: Date, + format: DATEFMT + }, { + name: "generator", + }, { + name: "docs", + }, { + name: "cloud", + attributes: [{ + name: "domain", + }, { + name: "port", + type: Number, + format: "#" + }, { + name: "path", + }, { + name: "registerProcedure", + }, { + name: "protocol", + }] + }, { + name: "ttl", + type: Number, + format: "#" + }, { + name: "rating", + }, { + name: "skipHours", + }, { + name: "skipDays", + }] + }; + + var IMAGE = { + name: "image", + value: [{ + name: "url", + required: true + }, { + name: "title", + required: true + }, { + name: "link", + required: true + }, { + name: "width", + type: Number, + format: "#" + }, { + name: "height", + type: Number, + format: "#" + }, { + name: "description", + }] + }; + + var TEXTINPUT = { + name: "textinput", + value: [{ + name: "title", + required: true + }, { + name: "description", + required: true + }, { + name: "name", + required: true + }, { + name: "link", + required: true + }] + }; + + var ROOT = { + name: "rss", + attributes: [{ + name: "version", + value: "2.0" + }] + }; + + var xmlroot = this.createElement(ROOT); + var channel = this.createElement(CHANNEL); + xmlroot.setValue(channel); + + /** + * Get the writer's root element. + * @returns The writer's root element. + * @type jala.XmlWriter.XmlElement + */ + this.getRoot = function() { + return xmlroot; + }; + + /** + * Add child elements to the channel template. + * @param {Array} ext List of additional child elements. + */ + this.extendChannel = function(ext) { + this.extend(CHANNEL, ext); + channel = this.createElement(CHANNEL); + xmlroot.setValue(channel); + return; + }; + + /** + * Get the writer's channel element. + * @returns The writer's channel element. + * @type jala.XmlWriter.XmlElement + */ + this.getChannel = function() { + return channel; + }; + + /** + * Populate the channel element with data. + * @param {Object} data An XmlWriter-compliant object structure. + * @returns The populated channel element. + * @type jala.XmlWriter.XmlElement + */ + this.setChannel = function(data) { + return channel.populate(data); + }; + + /** + * Add child elements to the item template. + * @param {Array} ext List of additional child elements. + */ + this.extendItem = function(ext) { + this.extend(ITEM, ext); + return; + }; + + /** + * Get a new and innocent item element. + * @param {Object} data An XmlWriter-compliant object structure. + * @returns A new and innocent item element. + * @type jala.XmlWriter.XmlElement + */ + this.createItem = function(data) { + var item = this.createElement(ITEM); + item.populate(data); + return item; + }; + + /** + * Add an item element to the channel element. + * @param {jala.XmlWriter.XmlElement} item The item element to add. + */ + this.addItem = function(item) { + channel.addValue(item); + return; + }; + + /** + * Add a category element to an arbitrary element. + * @param {String} name The name of the category. + * @param {String} domain The domain of the category. + * @param {jala.XmlWriter.XmlElement} parent The optional parent element. + */ + this.addCategory = function(name, domain, parent) { + if (!parent) + parent = channel; + var cat = this.createElement(CATEGORY); + cat.populate({ + value: name, + attributes: {domain: domain} + }); + parent.addValue(cat); + return; + }; + + /** + * Populate the image element with data. + * @param {Object} data An XmlWriter-compliant object structure. + */ + this.setImage = function(data) { + var image = this.createElement(IMAGE); + image.populate(data); + channel.setValue(image); + return; + }; + + /** + * Populate the textInput element with data. + * @param {Object} data An XmlWriter-compliant object structure. + */ + this.setTextInput = function(data) { + var textInput = this.createElement(TEXTINPUT); + textInput.populate(data); + channel.setValue(textInput); + return; + }; + + return this; +}; diff --git a/modules/jala/code/Utilities.js b/modules/jala/code/Utilities.js new file mode 100644 index 00000000..506a34b9 --- /dev/null +++ b/modules/jala/code/Utilities.js @@ -0,0 +1,247 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * @fileoverview Fields and methods of the jala.Utilities class. + */ + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + +/** + * HelmaLib dependencies + */ +app.addRepository("modules/core/Number.js"); + +/** + * Construct a utility object. + * @class This class contains various convenience methods + * which do not fit in any other class. + * @returns A new utitilty object. + * @constructor + */ +jala.Utilities = function() { + return this; +}; + +/** + * Return a string representation of the utitility class. + * @returns [jala.Utilities] + * @type String + * @ignore FIXME: JSDoc bug + */ +jala.Utilities.toString = function() { + return "[jala.Utilities]"; +}; + +/** + * Return a string representation of the utitility object. + * @returns [jala.Utilities Object] + * @type String + */ +jala.Utilities.prototype.toString = function() { + return "[jala.Utilities Object]"; +}; + +/** + * Default utility class instance. + * @type jala.Utilities + * @final + */ +jala.util = new jala.Utilities(); + +/** + * Creates a random password with different levels of security. + * @param {Number} len The length of the password (default: 8) + * @param {Number} level The security level + *
      + *
    • 0 - containing only vowels or consonants (default)
    • + *
    • 1 - throws in a number at random position
    • + *
    • 2 - throws in a number and a special character at random position
    • + *
    + * @returns The resulting password + * @type String + */ +jala.Utilities.prototype.createPassword = function(len, level) { + len = len || 8; + level = level || 0; + + var LETTERSONLY = 0; + var WITHNUMBERS = 1; + var WITHSPECIALS = 2; + + var vowels = ['a', 'e', 'i', 'o', 'u']; + var consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']; + var specials = ['.', '#', '!', '$', '%', '&', '?']; + + var posNum = level > LETTERSONLY ? Math.floor(Math.random() * (len - 2)) : -1; + var posSpecial = level > WITHNUMBERS ? Math.floor(Math.random() * (len - 3)) : -2; + if (posNum == posSpecial) { + posSpecial += 1; + } + + res.push(); + // loop to create characters: + var i, rnd; + for (i=0; i<(len-level); i+=1) { + if(i % 2 == 0) { + // every 2nd one is a vowel + rnd = Math.floor(Math.random() * vowels.length); + res.write(vowels[rnd]); + } else { + // every 2nd one is a consonant + rnd = Math.floor(Math.random() * consonants.length); + res.write(consonants[rnd]); + } + if (i == posNum) { + // increased password security: + // throw in a number at random + rnd = Math.floor(Math.random() * specials.length); + res.write(String(rnd + 1)); + } + if (i == posSpecial) { + // increased password security: + // throw in a number at random + rnd = Math.floor(Math.random() * specials.length); + res.write(specials[rnd]); + } + } + return res.pop(); +}; + +/** + * Static field indicating a removed object property. + * @type Number + * @final + */ +jala.Utilities.VALUE_REMOVED = -1; + +/** + * Static field indicating ad added object property. + * @type Number + * @final + */ +jala.Utilities.VALUE_ADDED = 1; + +/** + * Static field indicating a modified object property. + * @type Number + * @final + */ +jala.Utilities.VALUE_MODIFIED = 2; + +/** + * Returns an array containing the properties that are + * added, removed or modified in one object compared to another. + * @param {Object} obj1 The first of two objects which should be compared + * @param {Object} obj2 The second of two objects which should be compared + * @returns An Object containing all properties that are added, removed + * or modified in the second object compared to the first. + * Each property contains a status field with an integer value + * which can be checked against the static jala.Utility fields + * VALUE_ADDED, VALUE_MODIFIED and VALUE_REMOVED. + * @type Object + */ +jala.Utilities.prototype.diffObjects = function(obj1, obj2) { + var childDiff, value1, value2; + var diff = {}; + var foundDiff = false; + + for (var propName in obj1) { + if (obj2[propName] === undefined || obj2[propName] === "" || obj2[propName] === null) { + diff[propName] = {status: jala.Utilities.VALUE_REMOVED}; + foundDiff = true; + } + } + for (var propName in obj2) { + value1 = obj1[propName]; + value2 = obj2[propName]; + if (value1 == null) { + diff[propName] = {status: jala.Utilities.VALUE_ADDED, + value: value2}; + foundDiff = true; + } else { + switch (value2.constructor) { + case HopObject: + case Object: + if (childDiff = this.diffObjects(value1, value2)) { + diff[propName] = childDiff; + foundDiff = true; + } + break; + default: + if (value2 != null && value2 !== "") { + if (value1 === null || value1 === undefined || value1 === "") { + diff[propName] = {status: jala.Utilities.VALUE_ADDED, + value: value2}; + foundDiff = true; + } else if (value1 != value2) { + diff[propName] = {status: jala.Utilities.VALUE_MODIFIED, + value: value2}; + foundDiff = true; + } + } + break; + } + } + } + return foundDiff ? diff : null; +}; + +/** + * Patches an object with a "diff" object created by the + * {@link #diffObjects} method. + * Please mind that this method is recursive, it descends + * along the "diff" object structure. + * @param {Object} obj The Object the diff should be applied to + * @param {Object} diff A "diff" object created by the {@link #diffObjects} method + * @returns The patched Object with all differences applied + * @type Object + */ +jala.Utilities.prototype.patchObject = function(obj, diff) { + var propDiff, value1; + for (var propName in diff) { + propDiff = diff[propName]; + value1 = obj[propName]; + if (propDiff.status != null) { + switch (propDiff.status) { + case jala.Utilities.VALUE_REMOVED: + // app.debug("applyDiff(): removing property " + propName); + delete obj[propName]; + break; + case jala.Utilities.VALUE_ADDED: + case jala.Utilities.VALUE_MODIFIED: + default: + // app.debug("applyDiff(): changing property " + propName + " to " + propDiff.value); + obj[propName] = propDiff.value; + break; + } + } else { + // app.debug("applyDiff(): descending to child object " + propName); + this.patchObject(value1, propDiff); + } + } + return obj; +}; diff --git a/modules/jala/code/XmlRpcRequest.js b/modules/jala/code/XmlRpcRequest.js new file mode 100644 index 00000000..575a12aa --- /dev/null +++ b/modules/jala/code/XmlRpcRequest.js @@ -0,0 +1,461 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.XmlRpcRequest class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +/** + * A constructor for XmlRpc request objects + * @class Instances of this class provide the necessary functionality + * for issueing XmlRpc requests to a remote service. + * @param {String} url The url of the XmlRpc entry point + * @param {String} methodName The name of the method to call + * @returns A newly created jala.XmlRpcRequest instance + * @constructor + */ +jala.XmlRpcRequest = function(url, methodName) { + /** @ignore */ + var proxy = null; + /** @ignore */ + var timeout = { + "connect": 0, + "socket": 0 + }; + /** @ignore */ + var debug = false; + /** @ignore */ + var credentials = null; + // default input and output encoding + /** @ignore */ + var inputEncoding = "UTF-8"; + /** @ignore */ + var outputEncoding = "UTF-8"; + + /** + * Returns the URL of this request + * @returns The URL of this request + * @type java.net.URL + */ + this.getUrl = function() { + return new java.net.URL(url); + }; + + /** + * Sets the proxy host and port. For Java runtimes < 1.5 this method + * sets the appropriate system properties (so this has an effect on + * all requests based on java.net.URL), for all others the proxy + * is only set for this request. + * @param {String} proxyString The proxy string in the form 'fqdn:port' + * (eg. my.proxy.com:3128) + */ + this.setProxy = function(proxyString) { + if (proxyString && proxyString.trim()) { + var idx = proxyString.indexOf(":"); + if (idx > 0) { + var host = proxyString.substring(0, idx); + var port = proxyString.substring(idx+1); + if (host != null && port != null) { + if (java.lang.Class.forName("java.net.Proxy") != null) { + // construct a proxy instance + var socket = new java.net.InetSocketAddress(host, port); + proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, socket); + } else { + // the pre jdk1.5 way: set the system properties + var sys = java.lang.System.getProperties(); + if (host) { + app.log("[Jala XmlRpc Client] WARNING: setting system http proxy to " + + host + ":" + port); + sys.put("http.proxySet", "true"); + sys.put("http.proxyHost", host); + sys.put("http.proxyPort", port); + } + } + } + } + } + return; + }; + + /** + * Returns the proxy object. This method will only return + * a value if using a java runtime > 1.5 + * @returns The proxy to use for this request + * @type java.net.Proxy + * @see #setProxy + */ + this.getProxy = function() { + return proxy; + }; + + /** + * Sets the credentials for basic http authentication to + * use with this request. + * @param {String} username The username + * @param {String} password The password + */ + this.setCredentials = function(username, password) { + var str = new java.lang.String(username + ":" + password); + credentials = (new Packages.sun.misc.BASE64Encoder()).encode(str.getBytes()); + return; + }; + + /** + * Returns the credentials of this request + * @returns The base46 encoded credentials of this request + * @type String + */ + this.getCredentials = function() { + return credentials; + }; + + /** + * Sets the connection timeout to the specified milliseconds. + * @param {Number} millis The timeout to use as connection timeout + */ + this.setTimeout = function(millis) { + timeout.connect = millis; + return; + }; + + /** + * Sets the socket timeout to the specified milliseconds. + * @param {Number} millis The timeout to use as socket timeout + */ + this.setReadTimeout = function(millis) { + timeout.socket = millis; + return; + }; + + /** + * Returns the connection timeout of this request + * @returns The connection timeout value in milliseconds + * @type Number + */ + this.getTimeout = function() { + return timeout.connect; + }; + + /** + * Returns the socket timeout of this request + * @returns The socket timeout value in milliseconds + * @type Number + */ + this.getReadTimeout = function() { + return timeout.socket; + }; + + /** + * Returns the name of the remote function to call + * @returns The name of the remote function + * @type String + */ + this.getMethodName = function() { + return methodName; + }; + + /** + * Sets both input and output encoding to the + * specified encoding string + * @param {String} enc The encoding to use for + * both input and output. This must be a valid + * java encoding string. + */ + this.setEncoding = function(enc) { + inputEncoding = enc; + outputEncoding = enc; + return; + }; + + /** + * Sets the input encoding to the specified encoding string + * @param {String} enc The encoding to use for input. This must be a valid + * java encoding string. + */ + this.setInputEncoding = function(enc) { + inputEncoding = enc; + return; + }; + + /** + * Sets the output encoding to the specified encoding string + * @param {String} enc The encoding to use for output. This must be a valid + * java encoding string. + */ + this.setOutputEncoding = function(enc) { + outputEncoding = enc; + return; + }; + + /** + * Returns the input encoding + * @returns The input encoding used by this request + * @type String + */ + this.getInputEncoding = function() { + return inputEncoding; + }; + + /** + * Returns the output encoding + * @returns The output encoding used by this request + * @type String + */ + this.getOutputEncoding = function() { + return outputEncoding; + }; + + /** + * Enables or disables the debug mode. If enabled the xml source + * of both request and response is included in the result properties + * 'requestXml' and 'responseXml' + * @param {Boolean} flag True or false. + */ + this.setDebug = function(flag) { + debug = flag; + return; + }; + + /** + * Returns true if debug is enabled for this request, false otherwise + * @returns True if debugging is enabled, false otherwise + * @type Boolean + */ + this.debug = function() { + return debug == true; + }; + + return this; +}; + +/** @ignore */ +jala.XmlRpcRequest.prototype.toString = function() { + return "[Jala XmlRpc Request]"; +}; + +/** + * Calling this method executes the remote method using + * the arguments specified. + * @returns The result of this XmlRpc request + * @type Object + */ +jala.XmlRpcRequest.prototype.execute = function(/** [arg1][, arg2][, ...] */) { + // if in debug mode, log the time the request took to event log + if (app.__app__.debug() == true) { + var start = new Date(); + } + + var tz = java.util.TimeZone.getDefault(); + var reqProcessor = new Packages.org.apache.xmlrpc.XmlRpcClientRequestProcessor(tz); + var resProcessor = new Packages.org.apache.xmlrpc.XmlRpcClientResponseProcessor(tz); + // create the result object + var result = { + error: null, + result: null, + requestXml: null, + responseXml: null + }; + + // convert arguments into their appropriate java representations + var params = new java.util.Vector(); + for (var i=0;i= 1.5) { + conn.setConnectTimeout(this.getTimeout()); + conn.setReadTimeout(this.getReadTimeout()); + } else { + app.logger.debug("WARNING: timeouts can only be using a Java runtime >= 1.5"); + } + // set authentication credentials if defined + if (this.getCredentials() != null) { + conn.setRequestProperty("Authorization", "Basic " + this.getCredentials()); + } + + try { + conn.setDoOutput(true); + var outStream = conn.getOutputStream(); + outStream["write(byte[])"](requestBytes); + outStream.flush(); + outStream.close(); + + if (conn.getContentLength() > 0) { + var inStream = conn.getInputStream(); + if (this.debug() == true) { + inStream = new java.io.BufferedInputStream(conn.getInputStream()); + var outStream = new java.io.ByteArrayOutputStream(); + var buf = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024); + var bytes; + while ((bytes = inStream.read(buf)) > -1) { + outStream.write(buf, 0, bytes); + } + result.responseXml = outStream.toString(this.getInputEncoding()); + inStream.close(); + // change the inStream and don't set the input encoding of + // the response processor, since the conversion already happened above + inStream = new java.io.ByteArrayInputStream(outStream.toByteArray()); + } + resProcessor.setInputEncoding(this.getInputEncoding()); + var parsedResult = resProcessor.decodeResponse(inStream); + if (parsedResult instanceof java.lang.Exception) { + result.error = parsedResult; + } else { + result.result = jala.XmlRpcRequest.convertResult(parsedResult); + } + } + } catch (e) { + result.error = "[Jala XmlRpc Request] Error executing " + this.getMethodName() + + " with arguments " + jala.XmlRpcRequest.argumentsToString(arguments) + + ", the error is: " + e.toString(); + } + if (app.__app__.debug() == true) { + app.logger.debug("[Jala XmlRpc Request] (" + ((new Date()) - start) + " ms): executed '" + + this.getMethodName() + "' with arguments: " + + jala.XmlRpcRequest.argumentsToString(arguments)); + } + return result; +}; + +/** + * Helper method for converting a Javascript object into + * its appropriate Java object. + * @param {Object} obj The Javascript object to convert + * @returns The appropriate Java representation of the object + * @type java.lang.Object + */ +jala.XmlRpcRequest.convertArgument = function(obj) { + var result; + if (obj instanceof Array) { + // convert into Vector + result = new java.util.Vector(obj.length); + for (var i=0;i 0) { + result = new java.lang.Double(obj); + } else { + result = new java.lang.Integer(obj); + } + } else if (obj instanceof Object) { + // convert into Hashtable + result = new java.util.Hashtable(); + for (var key in obj) { + if (obj[key] != null) { + result.put(key, jala.XmlRpcRequest.convertArgument(obj[key])); + } + } + } else { + result = obj; + } + return result; +}; + +/** + * Converts a Java object into its appropriate Javascript representation. + * @param {java.lang.Object} obj The Java object to convert + * @returns The appropriate Javascript representation of the Java object + * @type Object + */ +jala.XmlRpcRequest.convertResult = function(obj) { + var result; + if (obj instanceof java.util.Vector) { + // convert into Array + result = []; + var e = obj.elements(); + while (e.hasMoreElements()) { + result.push(jala.XmlRpcRequest.convertResult(e.nextElement())); + } + } else if (obj instanceof java.util.Hashtable) { + // convert into Object + result = {}; + var e = obj.keys(); + var key; + while (e.hasMoreElements()) { + key = e.nextElement(); + result[key] = jala.XmlRpcRequest.convertResult(obj.get(key)); + } + } else if (obj instanceof java.lang.String) { + result = String(obj); + } else if (obj instanceof java.lang.Number) { + result = Number(obj); + } else if (obj instanceof java.lang.Boolean) { + result = Boolean(obj); + } else if (obj instanceof java.lang.Date) { + result = new Date(obj.getTime()); + } else { + result = obj; + } + return result; +}; + +/** + * Helper method to format an arguments array into + * a string useable for debugging output. + * @param {Object} args An arguments array + * @returns The arguments array formatted as string + * @type String + */ +jala.XmlRpcRequest.argumentsToString = function(args) { + var arr = []; + for (var i=0;i'; + var LOCALE = java.util.Locale.ENGLISH; + + /** @ignore FIXME: JSDoc bug */ + var write = function(str) { + return res.write(str); + }; + + var writeln = function(str) { + res.write(str); + res.write("\n"); + return; + }; + + var getString = function(data, format) { + if (data == null) + return; + switch (data.constructor) { + case String: + return encodeXml(data); + case Number: + case Date: + if (format && data.format) + return encodeXml(data.format(format, LOCALE)); + else if (data.toUTCString) + return encodeXml(data.toUTCString()); + else + return encodeXml(data.toString()); + break; + case Object: + return null; + } + return encodeXml(data.toString()); + }; + + /** @ignore */ + var XmlElement = function(data) { + if (!data) + throw Error("Insufficient arguments to create XmlElement"); + + var children = {}; + var properties = [ + "name", + "attributes", + "type", + "required", + "format", + "readonly" + ]; + + if (data.value) { + if (data.value.constructor == Object) { + this.value = [new XmlElement(data.value)]; + } else if (data.value.constructor == Array) { + this.value = []; + for (var i in data.value) { + this.value[i] = new XmlElement(data.value[i]); + } + } else + throw Error("Cannot handle unknown type of template value"); + } + + for (var i in properties) { + var key = properties[i]; + this[key] = data[key] || null; + } + + if (this.attributes) { + this.attributes = self.clone(this.attributes); + if (this.attributes.constructor == Object) + this.attributes = [this.attributes]; + } else { + this.attributes = []; + } + + return this; + }; + + /** @ignore */ + XmlElement.toString = function() { + return "[XmlElement constructor]"; + }; + + /** @ignore */ + XmlElement.prototype.setValue = function(element) { + if (element.constructor != this.constructor) + throw Error("Invalid type for XmlElement addition"); + if (!this.value) + this.value = []; + else { + var pos = this.contains(element); + if (pos > -1) + this.value.splice(pos, 1); + } + this.addValue(element); + return this; + }; + + /** @ignore */ + XmlElement.prototype.addValue = function(element) { + if (element.constructor != this.constructor) + throw Error("Invalid type for XmlElement addition"); + if (!this.value) + this.value = []; + this.value.push(element); + return this; + }; + + /** @ignore */ + XmlElement.prototype.contains = function(element) { + if (!this.value || !element) + return -1; + for (var i in this.value) { + if (this.value[i].name == element.name) + return i; + } + return -1; + }; + + /** @ignore */ + XmlElement.prototype.populate = function(data) { + if (this.attributes) { + var value; + for (var i in this.attributes) { + var attr = this.attributes[i]; + if (!attr.name) + throw Error("Cannot populate unnamed attribute entry"); + if (data && data.attributes) + value = data.attributes[attr.name]; + if (data && (data.value || data.attributes) && !value && attr.required) { + throw Error('Missing required ' + (attr.type || Object).name + ' attribute "' + + attr.name + '" in element <' + this.name + '> (' + value + ")"); + } + if (value && attr.type && attr.type != value.constructor) { + throw Error('Type mismatch in attribute "' + + this.name + ":" + attr.name + '"'); + } + if (value) { + app.debug("populating attribute " + attr.name + + " with " + value.constructor.name + ": " + value.toSource()); + } + if (!attr.readonly) { + attr.value = getString(value, attr.format) || attr.value ; + } + } + } + + if (data && data.value) // && data.value.constructor == Object) + data = data.value; + + if (this.value && data) { + for (var i in this.value) { + var element = this.value[i]; + element.populate(data[element.name]); + } + } else { + if (!data && this.required) + throw Error('Missing required element "' + this.name + '"'); + if (data && this.type && this.type != data.constructor) { + throw Error('Type mismatch in element "' + this.name + '"'); + } + if (data) { + app.debug("populating element <" + this.name + "> with " + + (this.type || Object).name + ": " + data.toSource()); + } + if (!this.readonly) + this.value = getString(data, this.format) || this.value; + } + + return; + }; + + /** @ignore */ + XmlElement.prototype.write = function(path) { + if (!path) + path = ""; + + if (!this.value && !this.attributes) + return; + + var attrBuffer = new java.lang.StringBuffer(); + if (this.attributes) { + for (var a in this.attributes) { + var attr = this.attributes[a]; + if (attr.value) { + attrBuffer.append(" " + attr.name + '="'); + attrBuffer.append(attr.value); + attrBuffer.append('"'); + } + } + } + + var attrSize = attrBuffer.length(); + if (!this.value && attrSize < 1) + return; + + write("<" + this.name); + if (attrSize > 0) { + display = true; + write(attrBuffer.toString()); + } + if (this.value) { + write(">"); + if (this.value && this.value.constructor == Array) { + for (var i in this.value) + this.value[i].write(path+"/"+this.name); + } else + write(this.value); + write("\n"); + } else + write("/>\n"); + return; + }; + + /** @ignore */ + XmlElement.prototype.toString = function() { + return "[XmlElement: " + this.toSource() + "]"; + }; + + /** + * Get a newly created XML element. + * @param {Object} data The XML data as object tree. + * @returns The resulting XML element. + * @type jala.XmlWriter.XmlElement + */ + this.createElement = function(data) { + return new XmlElement(data); + }; + + /** + * Get the root XML element of this writer. + * @returns The root XML element. + * @type jala.XmlWriter.XmlElement + */ + this.getRoot = function() { + return new XmlElement({}); + }; + + /** + * Extend a template object. + * @param {Object} template The template object. + * @param {Object} ext The extension object. + * @returns The XML writer. + * @type jala.XmlWriter + */ + this.extend = function(template, ext) { + if (ext.constructor == Object) + ext = [ext]; + if (ext.constructor == Array) { + for (var i in ext) + template.value.push(ext[i]); + } + return this; + }; + + /** + * Add a namespace to this writer. + * @param {String} name The name of the namespace. + * @param {String} url The URL string of the namespace. + * @returns The XML root element. + * @type jala.XmlWriter.XmlElement + */ + this.addNamespace = function(name, url) { + var ref = this.getRoot(); + ref.attributes.push({ + name: "xmlns:" + name, + value: url + }); + return ref; + }; + + /** + * Write the XML to the response buffer. + */ + this.write = function() { + res.contentType = "text/xml"; + writeln(XMLHEADER); + this.getRoot().write(); + return; + }; + + /** + * Get the XML output as string. + * @returns The XML output. + * @type String + */ + this.toString = function() { + res.push(); + this.write(); + return res.pop(); + }; + + /** + * Clone this XML writer. + * @param {Object} The clone templare. + * @returns The cloned XML writer. + * @type jala.XmlWriter + */ + this.clone = function(obj) { + if (!obj || typeof obj != "object") + return obj; + var copy = new obj.constructor; + for (var i in obj) { + if (obj[i].constructor == Object || + obj[i].constructor == Array) + copy[i]= this.clone(obj[i]); + else + copy[i] = obj[i]; + } + return copy; + }; + + return this; +}; + diff --git a/modules/jala/code/all.js b/modules/jala/code/all.js new file mode 100644 index 00000000..1b7b9564 --- /dev/null +++ b/modules/jala/code/all.js @@ -0,0 +1,74 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Wrapper for automatic inclusion of all Jala modules. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + + +(function() { + var packages = [ + "AsyncRequest", + "BitTorrent", + "Date", + "DnsClient", + "Captcha", + "Form", + "History", + "HtmlDocument", + "HopObject", + "I18n", + "ImageFilter", + "IndexManager", + "ListRenderer", + "Mp3", + "PodcastWriter", + "RemoteContent", + "Rss20Writer", + "Utilities", + "XmlRpcRequest", + "XmlWriter" + ]; + var jalaDir = getProperty("jala.dir", "modules/jala"); + for (var i in packages) { + app.addRepository(jalaDir + "/code/" + packages[i] + ".js"); + } + return; +})(); + + +/** + * Get a string representation of the Jala library. + * @returns [Jala JavaScript Application Library] + * @type String + */ +jala.toString = function() { + return "[Jala JavaScript Application Library]"; +}; diff --git a/modules/jala/docs/Global.html b/modules/jala/docs/Global.html new file mode 100644 index 00000000..bc9833cc --- /dev/null +++ b/modules/jala/docs/Global.html @@ -0,0 +1,692 @@ + + + + + +Global + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class Global

    +
    Object
    +   |
    +   +--Global
    +
    + + +
    +
    + +
    class + Global + + +
    + +
    + + + + + + + + + + + + + + + + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + + <static> Boolean + + + + + isArray(<Object> val) + +
    +            + Returns true if the value passed as argument is an array. +
    + + <static> Boolean + + + + + isBoolean(<Object> val) + +
    +            + Returns true if the value passed as argument is either a boolean + literal or an instance of Boolean. +
    + + <static> Boolean + + + + + isDate(<Object> val) + +
    +            + Returns true if the value passed as argument is either a Javascript date + or an instance of java.util.Date. +
    + + <static> Boolean + + + + + isFunction(<Object> val) + +
    +            + Returns true if the value passed as argument is a function. +
    + + <static> Boolean + + + + + isNull(<Object> val) + +
    +            + Returns true if the value passed as argument is null. +
    + + <static> Boolean + + + + + isNumber(<Object> val) + +
    +            + Returns true if the value passed as argument is either a number, + an instance of Number or of java.lang.Number. +
    + + <static> Boolean + + + + + isObject(<Object> val) + +
    +            + Returns true if the value passed as argument is either a Javascript + object or an instance of java.lang.Object. +
    + + <static> Boolean + + + + + isString(<Object> val) + +
    +            + Returns true if the value passed as argument is either a string literal, + an instance of String or of java.lang.String. +
    + + <static> Boolean + + + + + isUndefined(<Object> val) + +
    +            + Returns true if the value passed as argument is undefined. +
    + + + +

    + + + + + + + + + + + + + + + + + +


    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    isArray

    +
    <static> Boolean isArray(<Object> val)
    + +
      Returns true if the value passed as argument is an array.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is an array, false otherwise +
      +
    + + + + + +
    + + +

    isBoolean

    +
    <static> Boolean isBoolean(<Object> val)
    + +
      Returns true if the value passed as argument is either a boolean + literal or an instance of Boolean.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is a boolean, false otherwise +
      +
    + + + + + +
    + + +

    isDate

    +
    <static> Boolean isDate(<Object> val)
    + +
      Returns true if the value passed as argument is either a Javascript date + or an instance of java.util.Date.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is a date, false otherwise +
      +
    + + + + + +
    + + +

    isFunction

    +
    <static> Boolean isFunction(<Object> val)
    + +
      Returns true if the value passed as argument is a function.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the argument is a function, false otherwise +
      +
    + + + + + +
    + + +

    isNull

    +
    <static> Boolean isNull(<Object> val)
    + +
      Returns true if the value passed as argument is null.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is null, false otherwise +
      +
    + + + + + +
    + + +

    isNumber

    +
    <static> Boolean isNumber(<Object> val)
    + +
      Returns true if the value passed as argument is either a number, + an instance of Number or of java.lang.Number.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is a number, false otherwise +
      +
    + + + + + +
    + + +

    isObject

    +
    <static> Boolean isObject(<Object> val)
    + +
      Returns true if the value passed as argument is either a Javascript + object or an instance of java.lang.Object.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is an object, false otherwise +
      +
    + + + + + +
    + + +

    isString

    +
    <static> Boolean isString(<Object> val)
    + +
      Returns true if the value passed as argument is either a string literal, + an instance of String or of java.lang.String.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is a string, false otherwise +
      +
    + + + + + +
    + + +

    isUndefined

    +
    <static> Boolean isUndefined(<Object> val)
    + +
      Returns true if the value passed as argument is undefined.
    + + + + +
      + Parameters: + +
        val - The value to test +
      + +
    + + + + +
      + Returns: +
        + True if the value is undefined, false otherwise +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/HopObject.html b/modules/jala/docs/HopObject.html new file mode 100644 index 00000000..96486a2f --- /dev/null +++ b/modules/jala/docs/HopObject.html @@ -0,0 +1,581 @@ + + + + + +HopObject + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class HopObject

    +
    Object
    +   |
    +   +--HopObject
    +
    + + +
    +
    + +
    class + HopObject + + +
    + +
    + + + + + + + + + + + + + + + + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + getAccessName(<Object> obj, <Number> maxLength) + +
    +            + Constructs a name from an object which + is unique in the underlying HopObject collection. +
    + +  Boolean + + + + + isClean() + +
    +            + Returns true if the internal state of this HopObject is CLEAN. +
    + +  Boolean + + + + + isDeleted() + +
    +            + Returns true if the internal state of this HopObject is DELETED. +
    + +  Boolean + + + + + isInvalid() + +
    +            + Returns true if the internal state of this HopObject is INVALID. +
    + +  Boolean + + + + + isModified() + +
    +            + Returns true if the internal state of this HopObject is MODIFIED. +
    + +  Boolean + + + + + isNew() + +
    +            + Returns true if the internal state of this HopObject is NEW. +
    + +  Boolean + + + + + isTransient() + +
    +            + Returns true if the internal state of this HopObject is TRANSIENT. +
    + +  Boolean + + + + + isVirtual() + +
    +            + Returns true if the internal state of this HopObject is VIRTUAL. +
    + + + +

    + + + + + + + + + + + + + + + + + +


    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getAccessName

    +
    String getAccessName(<Object> obj, <Number> maxLength)
    + +
      Constructs a name from an object which + is unique in the underlying HopObject collection.
    + + + + +
      + Parameters: + +
        obj - The object representing or containing the alias name. Possible object types include:
        • File
        • helma.File
        • java.io.File
        • String
        • java.lang.String
        • Packages.helma.util.MimePart
        +
      + +
        maxLength - The maximum length of the alias +
      + +
    + + + + +
      + Returns: +
        + The resulting alias +
      +
    + + + + + +
    + + +

    isClean

    +
    Boolean isClean()
    + +
      Returns true if the internal state of this HopObject is CLEAN.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as clean, false otherwise. +
      +
    + + + + + +
    + + +

    isDeleted

    +
    Boolean isDeleted()
    + +
      Returns true if the internal state of this HopObject is DELETED.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as deleted, false otherwise. +
      +
    + + + + + +
    + + +

    isInvalid

    +
    Boolean isInvalid()
    + +
      Returns true if the internal state of this HopObject is INVALID.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as invalid, false otherwise. +
      +
    + + + + + +
    + + +

    isModified

    +
    Boolean isModified()
    + +
      Returns true if the internal state of this HopObject is MODIFIED.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as modified, false otherwise. +
      +
    + + + + + +
    + + +

    isNew

    +
    Boolean isNew()
    + +
      Returns true if the internal state of this HopObject is NEW.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as new, false otherwise. +
      +
    + + + + + +
    + + +

    isTransient

    +
    Boolean isTransient()
    + +
      Returns true if the internal state of this HopObject is TRANSIENT.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as transient, false otherwise. +
      +
    + + + + + +
    + + +

    isVirtual

    +
    Boolean isVirtual()
    + +
      Returns true if the internal state of this HopObject is VIRTUAL.
    + + + + + + + +
      + Returns: +
        + True if this HopObject is marked as virtual, false otherwise. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/allclasses-frame.html b/modules/jala/docs/allclasses-frame.html new file mode 100644 index 00000000..34273ae9 --- /dev/null +++ b/modules/jala/docs/allclasses-frame.html @@ -0,0 +1,323 @@ + + + + + + All Classes + + + + + + +

    + +All Classes +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Global +
    +
    HopObject +
    +
    jala +
    +
    jala.AsyncRequest +
    +
    jala.BitTorrent +
    +
    jala.Captcha +
    +
    jala.Date +
    +
    jala.Date.Calendar +
    +
    jala.Date.Calendar.Renderer +
    +
    jala.db +
    +
    jala.db.FileDatabase +
    +
    jala.db.RamDatabase +
    +
    jala.db.Server +
    +
    jala.DnsClient +
    +
    jala.DnsClient.Record +
    +
    jala.Form +
    +
    jala.Form.Component +
    +
    jala.Form.Component.Button +
    +
    jala.Form.Component.Checkbox +
    +
    jala.Form.Component.Date +
    +
    jala.Form.Component.Fieldset +
    +
    jala.Form.Component.File +
    +
    jala.Form.Component.Hidden +
    +
    jala.Form.Component.Image +
    +
    jala.Form.Component.Input +
    +
    jala.Form.Component.Password +
    +
    jala.Form.Component.Radio +
    +
    jala.Form.Component.Select +
    +
    jala.Form.Component.Skin +
    +
    jala.Form.Component.Submit +
    +
    jala.Form.Component.Textarea +
    +
    jala.Form.Tracker +
    +
    jala.History +
    +
    jala.HtmlDocument +
    +
    jala.I18n +
    +
    jala.ImageFilter +
    +
    jala.IndexManager +
    +
    jala.IndexManager.Job +
    +
    jala.ListRenderer +
    +
    jala.ListRenderer.ArrayList +
    +
    jala.Mp3 +
    +
    jala.Mp3.Id3v1 +
    +
    jala.Mp3.Id3v2 +
    +
    jala.PodcastWriter +
    +
    jala.RemoteContent +
    +
    jala.Rss20Writer +
    +
    jala.Utilities +
    +
    jala.XmlRpcRequest +
    +
    jala.XmlWriter +
    +
    + + + diff --git a/modules/jala/docs/allclasses-noframe.html b/modules/jala/docs/allclasses-noframe.html new file mode 100644 index 00000000..d26edc54 --- /dev/null +++ b/modules/jala/docs/allclasses-noframe.html @@ -0,0 +1,322 @@ + + + + +Jala 1.3 All Classes + + + + + + +

    Jala 1.3

    + +All Classes +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Global +
    +
    HopObject +
    +
    jala +
    +
    jala.AsyncRequest +
    +
    jala.BitTorrent +
    +
    jala.Captcha +
    +
    jala.Date +
    +
    jala.Date.Calendar +
    +
    jala.Date.Calendar.Renderer +
    +
    jala.db +
    +
    jala.db.FileDatabase +
    +
    jala.db.RamDatabase +
    +
    jala.db.Server +
    +
    jala.DnsClient +
    +
    jala.DnsClient.Record +
    +
    jala.Form +
    +
    jala.Form.Component +
    +
    jala.Form.Component.Button +
    +
    jala.Form.Component.Checkbox +
    +
    jala.Form.Component.Date +
    +
    jala.Form.Component.Fieldset +
    +
    jala.Form.Component.File +
    +
    jala.Form.Component.Hidden +
    +
    jala.Form.Component.Image +
    +
    jala.Form.Component.Input +
    +
    jala.Form.Component.Password +
    +
    jala.Form.Component.Radio +
    +
    jala.Form.Component.Select +
    +
    jala.Form.Component.Skin +
    +
    jala.Form.Component.Submit +
    +
    jala.Form.Component.Textarea +
    +
    jala.Form.Tracker +
    +
    jala.History +
    +
    jala.HtmlDocument +
    +
    jala.I18n +
    +
    jala.ImageFilter +
    +
    jala.IndexManager +
    +
    jala.IndexManager.Job +
    +
    jala.ListRenderer +
    +
    jala.ListRenderer.ArrayList +
    +
    jala.Mp3 +
    +
    jala.Mp3.Id3v1 +
    +
    jala.Mp3.Id3v2 +
    +
    jala.PodcastWriter +
    +
    jala.RemoteContent +
    +
    jala.Rss20Writer +
    +
    jala.Utilities +
    +
    jala.XmlRpcRequest +
    +
    jala.XmlWriter +
    +
    + + + diff --git a/modules/jala/docs/constant-values.html b/modules/jala/docs/constant-values.html new file mode 100644 index 00000000..8ec35f01 --- /dev/null +++ b/modules/jala/docs/constant-values.html @@ -0,0 +1,331 @@ + + + + +Jala 1.3 Constant Values + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +
    +

    Constant Field Values

    +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + jala.Form +
    MINLENGTH"minlength"
    MAXLENGTH"maxlength"
    REQUIRE"require"
    CHECKOPTIONS"checkoptions"
    CONTENTTYPE"contenttype"
    MAXWIDTH"maxwidth"
    MINWIDTH"minwidth"
    MAXHEIGHT"maxheight"
    MINHEIGHT"minheight"
    +

    + +

    + + + + + + + + + + + + + + + + + + + + + + + +
    + jala.IndexManager +
    MAXTRIES10
    NORMAL1
    REBUILDING2
    +

    + +

    + + + + + + + + + + + + + + + + + + + + + + + +
    + jala.IndexManager.Job +
    ADD"add"
    REMOVE"remove"
    OPTIMIZE"optimize"
    +

    + +

    + + + + + + + + + + + + + +
    + jala.PodcastWriter +
    XMLHEADER''
    +

    + +

    + + + + + + + + + + + + + + + + + + + + + + + +
    + jala.RemoteContent +
    HTTP1
    XMLRPC2
    SUFFIX".cache"
    +

    + +

    + + + + + + + + + + + + + + + + + + +
    + jala.Utilities +
    VALUE_ADDED1
    VALUE_MODIFIED2
    +

    + +

    + + +


    + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/help-doc.html b/modules/jala/docs/help-doc.html new file mode 100644 index 00000000..f52b22c1 --- /dev/null +++ b/modules/jala/docs/help-doc.html @@ -0,0 +1,160 @@ + + + + +Jala 1.3 API Help + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +
    +
    +

    +How This API Document Is Organized

    +
    +This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

    +Class

    +
    + +

    +Each class has its own separate page. Each of these pages has three sections consisting of a class description, summary tables, and detailed member descriptions:

      +
    • Class inheritance diagram
    • Direct Subclasses
    • Class declaration
    • Class description +

      +

    • Field Summary
    • Constructor Summary
    • Method Summary +

      +

    • Field Detail
    • Constructor Detail
    • Method Detail
    +Each summary entry contains the first sentence from the detailed description for that item.
    + + +

    +Index

    +
    +The Index contains an alphabetic list of all classes, constructors, methods, and fields.
    +

    +Prev/Next

    +These links take you to the next or previous class, interface, package, or related page.

    +Frames/No Frames

    +These links show and hide the HTML frames. All pages are available with or without frames. +

    + + +This help file applies to API documentation generated using the standard doclet. + +
    +


    + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/index-all.html b/modules/jala/docs/index-all.html new file mode 100644 index 00000000..e7b51bcf --- /dev/null +++ b/modules/jala/docs/index-all.html @@ -0,0 +1,3562 @@ + + + + + +Index () + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +A B C D E F G H I J K L M N O P Q R S T U V W X Y +
    + + +

    +A

    + +
    +
    ADD - +Class field in class jala.IndexManager.Job +
      +
    + +
    +
    add() - +Instance method in class jala.History +
      +
    + +
    +
    add(doc) - +Instance method in class jala.IndexManager +
      +
    + +
    +
    addCategory(name, domain, parent) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    addComponent(component) - +Instance method in class jala.Form +
      +
    + +
    +
    addItem(item) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    addItunesCategory(name, subName, parent) - +Instance method in class jala.PodcastWriter +
      +
    + +
    +
    addNamespace(name, url) - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    album - +Instance field in class jala.Mp3 +
      +
    + +
    +
    argumentsToString(args) - +Class method in class jala.XmlRpcRequest +
      +
    + +
    +
    artist - +Instance field in class jala.Mp3 +
      +
    + +
    + +

    +B

    + +
    +
    backup(file) - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    bdecode(code) - +Class method in class jala.BitTorrent +
      +
    + +
    +
    bencode(obj) - +Class method in class jala.BitTorrent +
      +
    + +
    + +

    +C

    + +
    +
    CACHEDIR - +Class field in class jala.RemoteContent +
      +
    + +
    +
    calendar - +Instance field in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    callback - +Instance field in class jala.IndexManager.Job +
      +
    + +
    +
    checkLength(reqData) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    CHECKOPTIONS - +Class field in class jala.Form +
      +
    + +
    +
    checkOptions(reqData) - +Instance method in class jala.Form.Component.Select +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Checkbox +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Date +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.File +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Image +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Radio +
      +
    + +
    +
    checkRequirements(reqData) - +Instance method in class jala.Form.Component.Select +
      +
    + +
    +
    class_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    class_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    clear() - +Instance method in class jala.History +
      +
    + +
    +
    clear() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    clone(obj) - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    close_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    cname - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    comment - +Instance field in class jala.Mp3 +
      +
    + +
    +
    componentSkin - +Instance field in class jala.Form +
      +
    + +
    +
    containsFileUpload() - +Instance method in class jala.Form +
      +
    + +
    +
    CONTENTTYPE - +Class field in class jala.Form +
      +
    + +
    +
    controls_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    convertArgument(obj) - +Class method in class jala.XmlRpcRequest +
      +
    + +
    +
    convertResult(obj) - +Class method in class jala.XmlRpcRequest +
      +
    + +
    +
    copyFrom(tag) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    copyFrom(tag) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    copyTables(database, tables) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    countErrors() - +Instance method in class jala.Form +
      +
    + +
    +
    countErrors() - +Instance method in class jala.Form.Tracker +
      +
    + +
    +
    create(config, dataObj) - +Class method in class jala.Form +
      +
    + +
    +
    createDomId() - +Instance method in class jala.Form +
      +
    + +
    +
    createDomId(idPart) - +Instance method in class jala.Form.Component +
      +
    + +
    +
    createElement(data) - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    createItem(data) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    createOnDemand(bool) - +Instance method in class jala.db.Server +
      +
    + +
    +
    createPassword(len, level) - +Instance method in class jala.Utilities +
      +
    + +
    +
    createTag(tagClass, tagObject) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    createtime - +Instance field in class jala.IndexManager.Job +
      +
    + +
    +
    createV1Tag(tagObject) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    createV2Tag(tagObject) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    currentEnd_macro() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    currentPage_macro() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    currentStart_macro() - +Instance method in class jala.ListRenderer +
      +
    + +
    + +

    +D

    + +
    +
    date - +Class field in class jala +
      +
    + +
    +
    db - +Class field in class jala +
      +
    + +
    +
    debug() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    defaultRenderer - +Class field in class jala.ListRenderer +
      +
    + +
    +
    diffObjects(obj1, obj2) - +Instance method in class jala.Utilities +
      +
    + +
    +
    dropTable(tableName) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    dump() - +Instance method in class jala.History +
      +
    + +
    +
    dump(file, props) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    + +

    +E

    + +
    +
    email - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    error_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    errors - +Instance field in class jala.Form.Tracker +
      +
    + +
    +
    errors - +Instance field in class jala.IndexManager.Job +
      +
    + +
    +
    evaluate() - +Instance method in class jala.AsyncRequest +
      +
    + +
    +
    exec() - +Class method in class jala.RemoteContent +
      +
    + +
    +
    execute() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    extend(subClass, superClass) - +Class method in class jala.Form +
      +
    + +
    +
    extend(template, ext) - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    extendChannel(ext) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    extendItem(ext) - +Instance method in class jala.Rss20Writer +
      +
    + +
    + +

    +F

    + +
    +
    flush(cache) - +Class method in class jala.RemoteContent +
      +
    + +
    +
    forEach(callback, cache) - +Class method in class jala.RemoteContent +
      +
    + +
    +
    formatMessage(message, values) - +Instance method in class jala.I18n +
      +
    + +
    + +

    +G

    + +
    +
    gaussianBlur(radius, amount) - +Instance method in class jala.ImageFilter +
      +
    + +
    +
    genre - +Instance field in class jala.Mp3 +
      +
    + +
    +
    GENRES - +Class field in class jala.Mp3 +
      +
    + +
    +
    get(idx) - +Instance method in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    get(key) - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    get(name) - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    getAccessName(obj, maxLength) - +Instance method in class HopObject +
      +
    + +
    +
    getAccessNameFormat() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getAlbum() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getAlbum() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getAll(elementName) - +Instance method in class jala.HtmlDocument +
      +
    + +
    +
    getArtist() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getArtist() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getAudio() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getAudio() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getAuthor() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getBaseHref() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getBitRate() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getBytes() - +Instance method in class jala.ImageFilter +
      +
    + +
    +
    getCalendar(today) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getCaptcha() - +Instance method in class jala.Captcha +
      +
    + +
    +
    getCatalog(locale) - +Instance method in class jala.I18n +
      +
    + +
    +
    getChannel() - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    getChannelMode() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getClassName() - +Instance method in class jala.Form +
      +
    + +
    +
    getCollection() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getCollection() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getComment() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getComment() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getConnection(name, username, password, props) - +Instance method in class jala.db.Server +
      +
    + +
    +
    getConnection(props) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getControlAttributes() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    getCopyright() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getCreationDate() - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    getCredentials() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getCurrentPage() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getData() - +Instance method in class jala.DnsClient.Record +
      +
    + +
    +
    getDataObject() - +Instance method in class jala.Form +
      +
    + +
    +
    getDirectory() - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    getDirectory() - +Instance method in class jala.db.Server +
      +
    + +
    +
    getDuration() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getEndIndex() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getErrorMessage() - +Instance method in class jala.Form +
      +
    + +
    +
    getFile() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getFrequency() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getGenre() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getGenre() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getHrefFormat() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getImage() - +Instance method in class jala.ImageFilter +
      +
    + +
    +
    getImage(pictureType) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getInputEncoding() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getItemSkin() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getJavaObject() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getJavaObject() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getJavaObject() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getKeys() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    getLinks() - +Instance method in class jala.HtmlDocument +
      +
    + +
    +
    getList(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getLocale() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getLocale(localeId) - +Instance method in class jala.I18n +
      +
    + +
    +
    getLocaleGetter() - +Instance method in class jala.I18n +
      +
    + +
    +
    getMaxPages() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getMessages() - +Instance method in class jala.I18n +
      +
    + +
    +
    getMetadata() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getMethodName() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getName() - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    getName() - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getNextLink(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getOutputEncoding() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getPageHref(page) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getPageNavigation(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getPageSize() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getPassword() - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    getPassword() - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getPieceLength() - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    getPort() - +Instance method in class jala.db.Server +
      +
    + +
    +
    getPrevLink(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getProperties(name, username, password, props) - +Instance method in class jala.db.Server +
      +
    + +
    +
    getProperties(props) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getProxy() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getReadTimeout() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getRenderer() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getRenderer() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getRoot() - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    getRoot() - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    getSize() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getSourceFile() - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    getStartIndex() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getSubtitle() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getSubtype() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getTag(tagClass) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    gettext(key ) - +Instance method in class jala.I18n +
      +
    + +
    +
    getTextContent(id) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getTextContent(idStr) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getTextEncoding() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getTimeout() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getTimeZone() - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    getTitle() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getTitle() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getTorrentFile() - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    getTotalPages() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getTracker() - +Instance method in class jala.Form +
      +
    + +
    +
    getTrackNumber() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getTrackNumber() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getUrl() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    getUrl() - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    getUrl(name, props) - +Instance method in class jala.db.Server +
      +
    + +
    +
    getUrl(props) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getUrlParameterName() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getUrlParameters() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    getUsername() - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    getUsername() - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    getV1Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getV2Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    getValue() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    getYear() - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    getYear() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    Global - + class Global +
      +
    + +
    + +

    +H

    + +
    +
    handle(reqData, destObj) - +Instance method in class jala.Form +
      +
    + +
    +
    hasError() - +Instance method in class jala.Form +
      +
    + +
    +
    hasError() - +Instance method in class jala.Form.Tracker +
      +
    + +
    +
    hasTag(tagClass) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    hasV1Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    hasV2Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    help_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    HopObject - + class HopObject +
      +
    + +
    +
    host - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    html - +Instance field in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    html - +Class field in class jala.Form +
      +
    + +
    +
    HTTP - +Class field in class jala.RemoteContent +
      +
    + +
    + +

    +I

    + +
    +
    i18n - +Class field in class jala +
      +
    + +
    +
    id_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    id_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    ipAddress - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    isAlive() - +Instance method in class jala.AsyncRequest +
      +
    + +
    +
    isArray(val) - +Class method in class Global +
      +
    + +
    +
    isBoolean(val) - +Class method in class Global +
      +
    + +
    +
    isClean() - +Instance method in class HopObject +
      +
    + +
    +
    isDate(val) - +Class method in class Global +
      +
    + +
    +
    isDeleted() - +Instance method in class HopObject +
      +
    + +
    +
    isEmail(name, value, reqData, formObj) - +Class method in class jala.Form +
      +
    + +
    +
    isFunction(val) - +Class method in class Global +
      +
    + +
    +
    isInvalid() - +Instance method in class HopObject +
      +
    + +
    +
    isModified() - +Instance method in class HopObject +
      +
    + +
    +
    isNew() - +Instance method in class HopObject +
      +
    + +
    +
    isNull(val) - +Class method in class Global +
      +
    + +
    +
    isNumber(val) - +Class method in class Global +
      +
    + +
    +
    isObject(val) - +Class method in class Global +
      +
    + +
    +
    isPublic(bool) - +Instance method in class jala.db.Server +
      +
    + +
    +
    isRunning() - +Instance method in class jala.db.Server +
      +
    + +
    +
    isString(val) - +Class method in class Global +
      +
    + +
    +
    isSubset() - +Instance method in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    isTransient() - +Instance method in class HopObject +
      +
    + +
    +
    isUndefined(val) - +Class method in class Global +
      +
    + +
    +
    isUrl(name, value, reqData, formObj) - +Class method in class jala.Form +
      +
    + +
    +
    isVariableBitRate() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    isVirtual() - +Instance method in class HopObject +
      +
    + +
    + +

    +J

    + +
    +
    jala - + class jala +
      +
    + +
    +
    jala.AsyncRequest - + class jala.AsyncRequest +
      +
    + +
    +
    jala.AsyncRequest(obj, funcName, args) - +Constructor in class jala.AsyncRequest +
      +
    + +
    +
    jala.BitTorrent - + class jala.BitTorrent +
      +
    + +
    +
    jala.BitTorrent(filePath, trackerUrl) - +Constructor in class jala.BitTorrent +
      +
    + +
    +
    jala.Captcha - + class jala.Captcha +
      +
    + +
    +
    jala.Captcha() - +Constructor in class jala.Captcha +
      +
    + +
    +
    jala.Date - + class jala.Date +
      +
    + +
    +
    jala.Date() - +Constructor in class jala.Date +
      +
    + +
    +
    jala.Date.Calendar - + class jala.Date.Calendar +
      +
    + +
    +
    jala.Date.Calendar(collection) - +Constructor in class jala.Date.Calendar +
      +
    + +
    +
    jala.Date.Calendar.Renderer - + class jala.Date.Calendar.Renderer +
      +
    + +
    +
    jala.Date.Calendar.Renderer(calendar) - +Constructor in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    jala.db - + class jala.db +
      +
    + +
    +
    jala.db.FileDatabase - + class jala.db.FileDatabase +
      +
    + +
    +
    jala.db.FileDatabase(name, directory, username, password) - +Constructor in class jala.db.FileDatabase +
      +
    + +
    +
    jala.db.RamDatabase - + class jala.db.RamDatabase +
      +
    + +
    +
    jala.db.RamDatabase(name, username, password) - +Constructor in class jala.db.RamDatabase +
      +
    + +
    +
    jala.db.Server - + class jala.db.Server +
      +
    + +
    +
    jala.db.Server(baseDir, port) - +Constructor in class jala.db.Server +
      +
    + +
    +
    jala.DnsClient - + class jala.DnsClient +
      +
    + +
    +
    jala.DnsClient(nameServer) - +Constructor in class jala.DnsClient +
      +
    + +
    +
    jala.DnsClient.Record - + class jala.DnsClient.Record +
      +
    + +
    +
    jala.DnsClient.Record(data) - +Constructor in class jala.DnsClient.Record +
      +
    + +
    +
    jala.Form - + class jala.Form +
      +
    + +
    +
    jala.Form(name, dataObj) - +Constructor in class jala.Form +
      +
    + +
    +
    jala.Form.Component - + class jala.Form.Component +
      +
    + +
    +
    jala.Form.Component(name) - +Constructor in class jala.Form.Component +
      +
    + +
    +
    jala.Form.Component.Button - + class jala.Form.Component.Button +
      +
    + +
    +
    jala.Form.Component.Button(name) - +Constructor in class jala.Form.Component.Button +
      +
    + +
    +
    jala.Form.Component.Checkbox - + class jala.Form.Component.Checkbox +
      +
    + +
    +
    jala.Form.Component.Checkbox(name) - +Constructor in class jala.Form.Component.Checkbox +
      +
    + +
    +
    jala.Form.Component.Date - + class jala.Form.Component.Date +
      +
    + +
    +
    jala.Form.Component.Date(name) - +Constructor in class jala.Form.Component.Date +
      +
    + +
    +
    jala.Form.Component.Fieldset - + class jala.Form.Component.Fieldset +
      +
    + +
    +
    jala.Form.Component.Fieldset(name) - +Constructor in class jala.Form.Component.Fieldset +
      +
    + +
    +
    jala.Form.Component.File - + class jala.Form.Component.File +
      +
    + +
    +
    jala.Form.Component.File(name) - +Constructor in class jala.Form.Component.File +
      +
    + +
    +
    jala.Form.Component.Hidden - + class jala.Form.Component.Hidden +
      +
    + +
    +
    jala.Form.Component.Hidden(name) - +Constructor in class jala.Form.Component.Hidden +
      +
    + +
    +
    jala.Form.Component.Image - + class jala.Form.Component.Image +
      +
    + +
    +
    jala.Form.Component.Image() - +Constructor in class jala.Form.Component.Image +
      +
    + +
    +
    jala.Form.Component.Input - + class jala.Form.Component.Input +
      +
    + +
    +
    jala.Form.Component.Input(name) - +Constructor in class jala.Form.Component.Input +
      +
    + +
    +
    jala.Form.Component.Password - + class jala.Form.Component.Password +
      +
    + +
    +
    jala.Form.Component.Password(name) - +Constructor in class jala.Form.Component.Password +
      +
    + +
    +
    jala.Form.Component.Radio - + class jala.Form.Component.Radio +
      +
    + +
    +
    jala.Form.Component.Radio(name) - +Constructor in class jala.Form.Component.Radio +
      +
    + +
    +
    jala.Form.Component.Select - + class jala.Form.Component.Select +
      +
    + +
    +
    jala.Form.Component.Select(name) - +Constructor in class jala.Form.Component.Select +
      +
    + +
    +
    jala.Form.Component.Skin - + class jala.Form.Component.Skin +
      +
    + +
    +
    jala.Form.Component.Skin(name) - +Constructor in class jala.Form.Component.Skin +
      +
    + +
    +
    jala.Form.Component.Submit - + class jala.Form.Component.Submit +
      +
    + +
    +
    jala.Form.Component.Submit(name) - +Constructor in class jala.Form.Component.Submit +
      +
    + +
    +
    jala.Form.Component.Textarea - + class jala.Form.Component.Textarea +
      +
    + +
    +
    jala.Form.Component.Textarea(name) - +Constructor in class jala.Form.Component.Textarea +
      +
    + +
    +
    jala.Form.Tracker - + class jala.Form.Tracker +
      +
    + +
    +
    jala.Form.Tracker(reqData) - +Constructor in class jala.Form.Tracker +
      +
    + +
    +
    jala.History - + class jala.History +
      +
    + +
    +
    jala.History() - +Constructor in class jala.History +
      +
    + +
    +
    jala.HtmlDocument - + class jala.HtmlDocument +
      +
    + +
    +
    jala.HtmlDocument(source) - +Constructor in class jala.HtmlDocument +
      +
    + +
    +
    jala.I18n - + class jala.I18n +
      +
    + +
    +
    jala.I18n() - +Constructor in class jala.I18n +
      +
    + +
    +
    jala.ImageFilter - + class jala.ImageFilter +
      +
    + +
    +
    jala.ImageFilter(img) - +Constructor in class jala.ImageFilter +
      +
    + +
    +
    jala.IndexManager - + class jala.IndexManager +
      +
    + +
    +
    jala.IndexManager(name, dir, lang) - +Constructor in class jala.IndexManager +
      +
    + +
    +
    jala.IndexManager.Job - + class jala.IndexManager.Job +
      +
    + +
    +
    jala.IndexManager.Job(type, callback) - +Constructor in class jala.IndexManager.Job +
      +
    + +
    +
    jala.ListRenderer - + class jala.ListRenderer +
      +
    + +
    +
    jala.ListRenderer(coll, renderer) - +Constructor in class jala.ListRenderer +
      +
    + +
    +
    jala.ListRenderer.ArrayList - + class jala.ListRenderer.ArrayList +
      +
    + +
    +
    jala.ListRenderer.ArrayList(arr, offset, total) - +Constructor in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    jala.Mp3 - + class jala.Mp3 +
      +
    + +
    +
    jala.Mp3(file) - +Constructor in class jala.Mp3 +
      +
    + +
    +
    jala.Mp3.Id3v1 - + class jala.Mp3.Id3v1 +
      +
    + +
    +
    jala.Mp3.Id3v1(audioObj) - +Constructor in class jala.Mp3.Id3v1 +
      +
    + +
    +
    jala.Mp3.Id3v2 - + class jala.Mp3.Id3v2 +
      +
    + +
    +
    jala.Mp3.Id3v2(audioObj) - +Constructor in class jala.Mp3.Id3v2 +
      +
    + +
    +
    jala.PodcastWriter - + class jala.PodcastWriter +
      +
    + +
    +
    jala.PodcastWriter(header) - +Constructor in class jala.PodcastWriter +
      +
    + +
    +
    jala.RemoteContent - + class jala.RemoteContent +
      +
    + +
    +
    jala.RemoteContent(url, method, storage) - +Constructor in class jala.RemoteContent +
      +
    + +
    +
    jala.Rss20Writer - + class jala.Rss20Writer +
      +
    + +
    +
    jala.Rss20Writer(header) - +Constructor in class jala.Rss20Writer +
      +
    + +
    +
    jala.Utilities - + class jala.Utilities +
      +
    + +
    +
    jala.Utilities() - +Constructor in class jala.Utilities +
      +
    + +
    +
    jala.XmlRpcRequest - + class jala.XmlRpcRequest +
      +
    + +
    +
    jala.XmlRpcRequest(url, methodName) - +Constructor in class jala.XmlRpcRequest +
      +
    + +
    +
    jala.XmlWriter - + class jala.XmlWriter +
      +
    + +
    +
    jala.XmlWriter(header) - +Constructor in class jala.XmlWriter +
      +
    + +
    + +

    +K

    + +
    +
    keys() - +Instance method in class jala.BitTorrent +
      +
    + +
    + +

    +L

    + +
    +
    label_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    length - +Instance field in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    limit_macro(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    listComponents() - +Instance method in class jala.Form +
      +
    + +
    +
    log() - +Instance method in class jala.IndexManager +
      +
    + +
    + +

    +M

    + +
    +
    markgettext(key) - +Instance method in class jala.I18n +
      +
    + +
    +
    MAXHEIGHT - +Class field in class jala.Form +
      +
    + +
    +
    MAXLENGTH - +Class field in class jala.Form +
      +
    + +
    +
    MAXTRIES - +Class field in class jala.IndexManager +
      +
    + +
    +
    MAXWIDTH - +Class field in class jala.Form +
      +
    + +
    +
    message_macro(param) - +Instance method in class jala.I18n +
      +
    + +
    +
    MINHEIGHT - +Class field in class jala.Form +
      +
    + +
    +
    MINLENGTH - +Class field in class jala.Form +
      +
    + +
    +
    MINWIDTH - +Class field in class jala.Form +
      +
    + +
    +
    MODES - +Class field in class jala.Mp3 +
      +
    + +
    +
    mx - +Instance field in class jala.DnsClient.Record +
      +
    + +
    + +

    +N

    + +
    +
    name - +Instance field in class jala.Form +
      +
    + +
    +
    name_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    name_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    nameServer - +Instance field in class jala.DnsClient +
      +
    + +
    +
    needsUpdate() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    nextLink_macro(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    ngettext(singularKey, pluralKey, amount ) - +Instance method in class jala.I18n +
      +
    + +
    +
    NORMAL - +Class field in class jala.IndexManager +
      +
    + +
    + +

    +O

    + +
    +
    offset - +Instance field in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    open_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    OPTIMIZE - +Class field in class jala.IndexManager.Job +
      +
    + +
    +
    optimize() - +Instance method in class jala.IndexManager +
      +
    + +
    + +

    +P

    + +
    +
    pageNavigation_macro(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    parseDuration() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    parseOptions() - +Instance method in class jala.Form.Component.Select +
      +
    + +
    +
    parseValue(reqData) - +Instance method in class jala.Form.Component.Checkbox +
      +
    + +
    +
    parseValue(reqData) - +Instance method in class jala.Form.Component.Date +
      +
    + +
    +
    parseValue(reqData) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    patchObject(obj, diff) - +Instance method in class jala.Utilities +
      +
    + +
    +
    peek(offset) - +Instance method in class jala.History +
      +
    + +
    +
    PICTURE_TYPES - +Class field in class jala.Mp3 +
      +
    + +
    +
    pop(offset) - +Instance method in class jala.History +
      +
    + +
    +
    prevLink_macro(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    propertyGetter(name, value) - +Class method in class jala.Form +
      +
    + +
    +
    propertySetter(name, value) - +Class method in class jala.Form +
      +
    + +
    +
    push() - +Instance method in class jala.History +
      +
    + +
    + +

    +Q

    + +
    +
    query(dName, queryType) - +Instance method in class jala.DnsClient +
      +
    + +
    +
    queryMailHost(dName) - +Instance method in class jala.DnsClient +
      +
    + +
    + +

    +R

    + +
    +
    REBUILDING - +Class field in class jala.IndexManager +
      +
    + +
    +
    redirect(offset) - +Instance method in class jala.History +
      +
    + +
    +
    REMOVE - +Class field in class jala.IndexManager.Job +
      +
    + +
    +
    remove() - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    remove() - +Instance method in class jala.History +
      +
    + +
    +
    remove(id) - +Instance method in class jala.IndexManager +
      +
    + +
    +
    removeFromAudio() - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    removeTag(tagClass) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    removeV1Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    removeV2Tag() - +Instance method in class jala.Mp3 +
      +
    + +
    +
    render() - +Instance method in class jala.Form +
      +
    + +
    +
    render() - +Instance method in class jala.Form.Component +
      +
    + +
    +
    render() - +Instance method in class jala.Form.Component.Fieldset +
      +
    + +
    +
    render() - +Instance method in class jala.Form.Component.Hidden +
      +
    + +
    +
    render() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    render() - +Instance method in class jala.Form.Component.Skin +
      +
    + +
    +
    render(attr, value, reqData) - +Instance method in class jala.Form.Component.Button +
      +
    + +
    +
    render(today) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    render_macro() - +Instance method in class jala.Form +
      +
    + +
    +
    render_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    render_macro(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderAsString(param) - +Instance method in class jala.Form +
      +
    + +
    +
    renderCalendar(date, body, prevMonth, nextMonth) - +Instance method in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    renderControls(attr, value) - +Instance method in class jala.Form.Component.Button +
      +
    + +
    +
    renderControls(attr, value) - +Instance method in class jala.Form.Component.Radio +
      +
    + +
    +
    renderControls(attr, value) - +Instance method in class jala.Form.Component.Submit +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Checkbox +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Date +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.File +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Hidden +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Password +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Select +
      +
    + +
    +
    renderControls(attr, value, reqData) - +Instance method in class jala.Form.Component.Textarea +
      +
    + +
    +
    renderDay(date, isExisting, isSelected) - +Instance method in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    renderDayHeader(text) - +Instance method in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    renderEditor(prefix, date, fmt) - +Instance method in class jala.Date +
      +
    + +
    +
    renderEditorAsString(prefix, date, pattern) - +Instance method in class jala.Date +
      +
    + +
    +
    renderError() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    renderHelp() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    renderImage() - +Instance method in class jala.Captcha +
      +
    + +
    +
    renderLabel() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    renderList(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderListAsString(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderNextLink(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderNextLinkAsString(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderPageNavigation(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderPageNavigationAsString(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderPrevLink(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderPrevLinkAsString(param) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    renderPrevNextLink(date) - +Instance method in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    renderRow(row) - +Instance method in class jala.Date.Calendar.Renderer +
      +
    + +
    +
    reqData - +Instance field in class jala.Form.Tracker +
      +
    + +
    +
    REQUIRE - +Class field in class jala.Form +
      +
    + +
    +
    restore(backupFile) - +Instance method in class jala.db.FileDatabase +
      +
    + +
    +
    run() - +Instance method in class jala.AsyncRequest +
      +
    + +
    +
    runScript(file, props, charset, continueOnError) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    + +

    +S

    + +
    +
    save(destObj, val) - +Instance method in class jala.Form.Component +
      +
    + +
    +
    save(filename) - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    save(outFile) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    save(tracker, destObj) - +Instance method in class jala.Form +
      +
    + +
    +
    save(tracker, destObj) - +Instance method in class jala.Form.Component.Fieldset +
      +
    + +
    +
    save(tracker, destObj) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    scrape(xpathExpr) - +Instance method in class jala.HtmlDocument +
      +
    + +
    +
    set(name, value) - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    setAccessNameFormat(fmt) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    setAlbum(album) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setAlbum(album) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setArtist(artist) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setArtist(artist) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setAuthor(author) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setBaseHref(href) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setChannel(data) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    setClassName(newClassName) - +Instance method in class jala.Form +
      +
    + +
    +
    setCollection(coll) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setComment(comment) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setComment(comment) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setCopyright(copyright) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setCreationDate(date) - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    setCredentials(username, password) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setDataObject(newDataObj) - +Instance method in class jala.Form +
      +
    + +
    +
    setDebug(flag) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setDelay(millis) - +Instance method in class jala.AsyncRequest +
      +
    + +
    +
    setEncoding(enc) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setErrorMessage(newErrorMessage) - +Instance method in class jala.Form +
      +
    + +
    +
    setGenre(genre) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setGenre(genre) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setHandler(handler) - +Instance method in class jala.I18n +
      +
    + +
    +
    setHrefFormat(fmt) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    setImage(data) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    setImage(pictureType, mimeType, byteArray) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setInputEncoding(enc) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setInterval(interval) - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    setItemSkin(name) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setLocale(loc) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    setLocaleGetter(func) - +Instance method in class jala.I18n +
      +
    + +
    +
    setMaxPages(pages) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setMessages(msgObject) - +Instance method in class jala.I18n +
      +
    + +
    +
    setMetadata(metadata) - +Instance method in class jala.Mp3 +
      +
    + +
    +
    setOutputEncoding(enc) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setPageSize(size) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setPieceLength(length) - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    setProxy(proxyString) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setReadTimeout(millis) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setRenderer(r) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    setRenderer(r) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setSubtitle(title) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setTextContent(id, val) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setTextContent(idStr, val) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setTextEncoding(encType) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setTextInput(data) - +Instance method in class jala.Rss20Writer +
      +
    + +
    +
    setTimeout(millis) - +Instance method in class jala.XmlRpcRequest +
      +
    + +
    +
    setTimeout(seconds) - +Instance method in class jala.AsyncRequest +
      +
    + +
    +
    setTimeZone(tz) - +Instance method in class jala.Date.Calendar +
      +
    + +
    +
    setTitle(title) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setTitle(title) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setTracker(newTracker) - +Instance method in class jala.Form +
      +
    + +
    +
    setTrackNumber(trackNumber) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setTrackNumber(trackNumber) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setUrl(url, desc) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    setUrlParameterName(name) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setUrlParameters(params) - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    setValue(destObj, value) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    setYear(year) - +Instance method in class jala.Mp3.Id3v1 +
      +
    + +
    +
    setYear(year) - +Instance method in class jala.Mp3.Id3v2 +
      +
    + +
    +
    sharpen(amount) - +Instance method in class jala.ImageFilter +
      +
    + +
    +
    shutdown() - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    size() - +Instance method in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    size_macro() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    start() - +Instance method in class jala.db.Server +
      +
    + +
    +
    stop() - +Instance method in class jala.db.Server +
      +
    + +
    +
    subsetSize() - +Instance method in class jala.ListRenderer.ArrayList +
      +
    + +
    +
    SUFFIX - +Class field in class jala.RemoteContent +
      +
    + +
    + +

    +T

    + +
    +
    tableExists(name) - +Instance method in class jala.db.RamDatabase +
      +
    + +
    +
    text - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    TEXT_ENCODINGS - +Class field in class jala.Mp3 +
      +
    + +
    +
    title - +Instance field in class jala.Mp3 +
      +
    + +
    +
    toString() - +Instance method in class jala.BitTorrent +
      +
    + +
    +
    toString() - +Instance method in class jala.Captcha +
      +
    + +
    +
    toString() - +Instance method in class jala.HtmlDocument +
      +
    + +
    +
    toString() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    toString() - +Instance method in class jala.Utilities +
      +
    + +
    +
    toString() - +Instance method in class jala.XmlWriter +
      +
    + +
    +
    totalPages_macro() - +Instance method in class jala.ListRenderer +
      +
    + +
    +
    trackNumber - +Instance field in class jala.Mp3 +
      +
    + +
    +
    translate(singularKey, pluralKey, amount) - +Instance method in class jala.I18n +
      +
    + +
    +
    type - +Instance field in class jala.DnsClient.Record +
      +
    + +
    +
    type - +Instance field in class jala.IndexManager.Job +
      +
    + +
    +
    TYPE_A - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_CNAME - +Class field in class jala.DnsClient +
      +
    + +
    +
    type_macro() - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    TYPE_MX - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_NS - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_PTR - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_SOA - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_TXT - +Class field in class jala.DnsClient +
      +
    + +
    +
    TYPE_WKS - +Class field in class jala.DnsClient +
      +
    + +
    + +

    +U

    + +
    +
    unsharpMask(radius, amount) - +Instance method in class jala.ImageFilter +
      +
    + +
    +
    update() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    useSsl(bool) - +Instance method in class jala.db.Server +
      +
    + +
    +
    util - +Class field in class jala +
      +
    + +
    + +

    +V

    + +
    +
    validate(input) - +Instance method in class jala.Captcha +
      +
    + +
    +
    validate(reqData) - +Instance method in class jala.Form +
      +
    + +
    +
    validate(tracker) - +Instance method in class jala.Form.Component +
      +
    + +
    +
    validate(tracker) - +Instance method in class jala.Form.Component.Fieldset +
      +
    + +
    +
    validate(tracker) - +Instance method in class jala.Form.Component.Input +
      +
    + +
    +
    VALUE_ADDED - +Class field in class jala.Utilities +
      +
    + +
    +
    VALUE_MODIFIED - +Class field in class jala.Utilities +
      +
    + +
    +
    VALUE_REMOVED - +Class field in class jala.Utilities +
      +
    + +
    +
    valueOf() - +Instance method in class jala.RemoteContent +
      +
    + +
    +
    values - +Instance field in class jala.Form.Tracker +
      +
    + +
    + +

    +W

    + +
    +
    write() - +Instance method in class jala.XmlWriter +
      +
    + +
    + +

    +X

    + +
    +
    XMLHEADER - +Class field in class jala.PodcastWriter +
      +
    + +
    +
    XMLRPC - +Class field in class jala.RemoteContent +
      +
    + +
    + +

    +Y

    + +
    +
    year - +Instance field in class jala.Mp3 +
      +
    + +
    + +A B C D E F G H I J K L M N O P Q R S T U V W X Y + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/index.html b/modules/jala/docs/index.html new file mode 100644 index 00000000..8a7b7ade --- /dev/null +++ b/modules/jala/docs/index.html @@ -0,0 +1,27 @@ + + + + +Generated Javascript Documentation + + + + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to <A HREF="allclasses-frame.html">Non-frame version.</A> + diff --git a/modules/jala/docs/jala.AsyncRequest.html b/modules/jala/docs/jala.AsyncRequest.html new file mode 100644 index 00000000..5b8f5c3d --- /dev/null +++ b/modules/jala/docs/jala.AsyncRequest.html @@ -0,0 +1,510 @@ + + + + + +jala.AsyncRequest + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.AsyncRequest

    +
    Object
    +   |
    +   +--jala.AsyncRequest
    +
    + + +
    +
    + +
    class + jala.AsyncRequest + + +
    + +

    +
    This class is used to create requests of type "INTERNAL" + (like cron-jobs) that are processed in a separate thread and + therefor asynchronous. +
    Deprecated Use the app.invokeAsync method instead (built-in into Helma as of version 1.6)

    Defined in AsyncRequest.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.AsyncRequest + + (<Object> obj, <String> funcName, <Array> args) + +
    +             + Creates a new AsyncRequest instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + evaluate() + +
    +            + Starts this asynchronous request. +
    + +  Boolean + + + + + isAlive() + +
    +            + Returns true if the underlying thread is alive +
    + +  void + + + + + run() + +
    +            + Starts this asynchronous request. +
    + +  void + + + + + setDelay(<Number> millis) + +
    +            + Defines the delay to wait before evaluating this asynchronous request. +
    + +  void + + + + + setTimeout(<Number> seconds) + +
    +            + Sets the timeout of this asynchronous request. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.AsyncRequest

    +
    jala.AsyncRequest(<Object> obj, <String> funcName, <Array> args)
    + + +
      + Creates a new AsyncRequest instance. +
    + + + +
      + Parameters: + +
        obj - Object in whose context the method should be called +
      + +
        funcName - Name of the function to call +
      + +
        args - Array containing the arguments that should be passed to the function (optional). This option is deprecated, instead pass the arguments directly to the run() method. +
      + + +
    + + + + +
      + Returns: +
        + A new instance of AsyncRequest +
      +
    + + + + + +
      +Deprecated Use the app.invokeAsync method instead (built-in into Helma as of version 1.6)

      +
    + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    evaluate

    +
    void evaluate()
    + +
      Starts this asynchronous request.
    + + + + + + + + + + +
      + Deprecated Use run() instead

      +
    + + +
    + + +

    isAlive

    +
    Boolean isAlive()
    + +
      Returns true if the underlying thread is alive
    + + + + + + + +
      + Returns: +
        + True if the underlying thread is alive, false otherwise. +
      +
    + + + + + +
    + + +

    run

    +
    void run()
    + +
      Starts this asynchronous request. Any arguments passed to + this method will be passed to the method executed by + this AsyncRequest instance.
    + + + + + + + + + + + +
    + + +

    setDelay

    +
    void setDelay(<Number> millis)
    + +
      Defines the delay to wait before evaluating this asynchronous request.
    + + + + +
      + Parameters: + +
        millis - Milliseconds to wait +
      + +
    + + + + + + + + +
    + + +

    setTimeout

    +
    void setTimeout(<Number> seconds)
    + +
      Sets the timeout of this asynchronous request.
    + + + + +
      + Parameters: + +
        seconds - Thread-timeout. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.BitTorrent.html b/modules/jala/docs/jala.BitTorrent.html new file mode 100644 index 00000000..71bed863 --- /dev/null +++ b/modules/jala/docs/jala.BitTorrent.html @@ -0,0 +1,879 @@ + + + + + +jala.BitTorrent + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.BitTorrent

    +
    Object
    +   |
    +   +--jala.BitTorrent
    +
    + + +
    +
    + +
    class + jala.BitTorrent + + +
    + +

    +
    This class provides methods to create a BitTorrent + metadata file from any desired file. +
    Defined in BitTorrent.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.BitTorrent + + (<String> filePath, <String> trackerUrl) + +
    +             + Constructs a new BitTorrent file. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Object + + + + + get(<String> name) + +
    +            + Get a torrent property. +
    + +  Date + + + + + getCreationDate() + +
    +            + Get the creation date of the torrent. +
    + +  Number + + + + + getPieceLength() + +
    +            + Get the piece length of the torrent. +
    + +  helma.File + + + + + getSourceFile() + +
    +            + Returns the underlying source file. +
    + +  helma.File + + + + + getTorrentFile() + +
    +            + Returns the underlying torrent file. +
    + +  Array + + + + + keys() + +
    +            + Get all available property names. +
    + +  void + + + + + save(<String> filename) + +
    +            + Saves the torrent as file. +
    + +  void + + + + + set(<String> name, <Object> value) + +
    +            + Set a torrent property. +
    + +  void + + + + + setCreationDate(<Date> date) + +
    +            + Set the creation date of the torrent. +
    + +  void + + + + + setPieceLength(<Number> length) + +
    +            + Set the piece length of the torrent. +
    + +  String + + + + + toString() + +
    +            + Get a string representation of the torrent. +
    + + <static> Object + + + + + bdecode(<String> code) + +
    +            + The bdecode method. +
    + + <static> String + + + + + bencode(<Object> obj) + +
    +            + The bencode method. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.BitTorrent

    +
    jala.BitTorrent(<String> filePath, <String> trackerUrl)
    + + +
      + Constructs a new BitTorrent file. +
    + + + +
      + Parameters: + +
        filePath - The path to the original file. +
      + +
        trackerUrl - The URL string of the tracker. +
      + + +
    + + + + +
      + Returns: +
        + A new BitTorrent file. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    get

    +
    Object get(<String> name)
    + +
      Get a torrent property.
    + + + + +
      + Parameters: + +
        name - The name of the property. +
      + +
    + + + + +
      + Returns: +
        + The value of the property. +
      +
    + + + + + +
    + + +

    getCreationDate

    +
    Date getCreationDate()
    + +
      Get the creation date of the torrent.
    + + + + + + + +
      + Returns: +
        + The torrent's creation date. +
      +
    + + + + + +
    + + +

    getPieceLength

    +
    Number getPieceLength()
    + +
      Get the piece length of the torrent.
    + + + + + + + +
      + Returns: +
        + The torrent's piece length. +
      +
    + + + + + +
    + + +

    getSourceFile

    +
    helma.File getSourceFile()
    + +
      Returns the underlying source file.
    + + + + + + + +
      + Returns: +
        + The source file. +
      +
    + + + + + +
    + + +

    getTorrentFile

    +
    helma.File getTorrentFile()
    + +
      Returns the underlying torrent file.
    + + + + + + + +
      + Returns: +
        + The torrent file. +
      +
    + + + + + +
    + + +

    keys

    +
    Array keys()
    + +
      Get all available property names.
    + + + + + + + +
      + Returns: +
        + The list of property names. +
      +
    + + + + + +
    + + +

    save

    +
    void save(<String> filename)
    + +
      Saves the torrent as file.
    + + + + +
      + Parameters: + +
        filename - An optional name for the torrent file. If no name is given it will be composed from name of source file as defined in the torrent plus the ending ".torrent". +
      + +
    + + + + + + + + +
    + + +

    set

    +
    void set(<String> name, <Object> value)
    + +
      Set a torrent property.
    + + + + +
      + Parameters: + +
        name - The name of the property. +
      + +
        value - The property's value. +
      + +
    + + + + + + + + +
    + + +

    setCreationDate

    +
    void setCreationDate(<Date> date)
    + +
      Set the creation date of the torrent.
    + + + + +
      + Parameters: + +
        date - The desired creation date. +
      + +
    + + + + + + + + +
    + + +

    setPieceLength

    +
    void setPieceLength(<Number> length)
    + +
      Set the piece length of the torrent.
    + + + + +
      + Parameters: + +
        length - The desired piece length. +
      + +
    + + + + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Get a string representation of the torrent.
    + + + + + + + +
      + Returns: +
        + The torrent as string. +
      +
    + + + + + +
    + + +

    bdecode

    +
    <static> Object bdecode(<String> code)
    + +
      The bdecode method. Turns an encoded string into + a corresponding JavaScript object structure. + FIXME: Handle with caution...
    + + + + +
      + Parameters: + +
        code - The encoded string. +
      + +
    + + + + +
      + Returns: +
        + The decoded JavaScript structure. +
      +
    + + + + + +
    + + +

    bencode

    +
    <static> String bencode(<Object> obj)
    + +
      The bencode method. Turns an arbitrary JavaScript + object structure into a corresponding encoded + string.
    + + + + +
      + Parameters: + +
        obj - The target JavaScript object. +
      + +
    + + + + +
      + Returns: +
        + The encoded string. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Captcha.html b/modules/jala/docs/jala.Captcha.html new file mode 100644 index 00000000..742e675b --- /dev/null +++ b/modules/jala/docs/jala.Captcha.html @@ -0,0 +1,461 @@ + + + + + +jala.Captcha + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Captcha

    +
    Object
    +   |
    +   +--jala.Captcha
    +
    + + +
    +
    + +
    class + jala.Captcha + + +
    + +

    +
    Wrapper class for the + JCaptcha library. + A captcha (an acronym for "completely automated public + Turing test to tell computers and humans apart") is a + type of challenge-response test used in computing to + determine whether or not the user is human. +
    Defined in Captcha.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Captcha + + () + +
    +             + Construct a new captcha. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  com.octo.captcha.Captcha + + + + + getCaptcha() + +
    +            + Get a new captcha object. +
    + +  void + + + + + renderImage() + +
    +            + Render a new captcha image. +
    + +  String + + + + + toString() + +
    +            + Get a string representation of the captcha object. +
    + +  Boolean + + + + + validate(<String> input) + +
    +            + Validate a user's input with the prompted captcha. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Captcha

    +
    jala.Captcha()
    + + +
      + Construct a new captcha. +
    + + + + + + + + +
      + Returns: +
        + A new captcha. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getCaptcha

    +
    com.octo.captcha.Captcha getCaptcha()
    + +
      Get a new captcha object.
    + + + + + + + +
      + Returns: +
        + A new captcha object. +
      +
    + + + + + +
    + + +

    renderImage

    +
    void renderImage()
    + +
      Render a new captcha image.
    + + + + + + + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Get a string representation of the captcha object.
    + + + + + + + +
      + Returns: +
        + A string representation of the captcha object. +
      +
    + + + + + +
    + + +

    validate

    +
    Boolean validate(<String> input)
    + +
      Validate a user's input with the prompted captcha.
    + + + + +
      + Parameters: + +
        input - The user's input. +
      + +
    + + + + +
      + Returns: +
        + True if the user's input matches the captcha. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Date.Calendar.Renderer.html b/modules/jala/docs/jala.Date.Calendar.Renderer.html new file mode 100644 index 00000000..25121432 --- /dev/null +++ b/modules/jala/docs/jala.Date.Calendar.Renderer.html @@ -0,0 +1,580 @@ + + + + + +jala.Date.Calendar.Renderer + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Date.Calendar.Renderer

    +
    Object
    +   |
    +   +--jala.Date.Calendar.Renderer
    +
    + + +
    +
    + +
    class + jala.Date.Calendar.Renderer + + +
    + +

    +
    A default renderer to use in conjunction with jala.Date.Calendar +
    Defined in Date.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  jala.Date.Calendarcalendar +
    +           The calendar utilizing this renderer instance
    +  helma.Htmlhtml +
    +           An instance of helma.Html used for rendering the calendar
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Date.Calendar.Renderer + + (<jala.Date.Calendar> calendar) + +
    +             + Returns a new instance of the default calendar renderer. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + renderCalendar(<Date> date, <String> body, <Date> prevMonth, <Date> nextMonth) + +
    +            + Renders the calendar directly to response. +
    + +  void + + + + + renderDay(<Date> date, <Boolean> isExisting, <Boolean> isSelected) + +
    +            + Renders a single day within the calendar directly to response. +
    + +  void + + + + + renderDayHeader(<String> text) + +
    +            + Renders a single cell in the calendar day header row directly to response. +
    + +  void + + + + + renderPrevNextLink(<Date> date) + +
    +            + Renders a link to the previous or next month's calendar directly to response. +
    + +  void + + + + + renderRow(<String> row) + +
    +            + Renders a single calendar row directly to response. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    calendar

    +
    jala.Date.Calendar calendar
    +
      + The calendar utilizing this renderer instance + +
    +
    + + +

    html

    +
    helma.Html html
    +
      + An instance of helma.Html used for rendering the calendar + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Date.Calendar.Renderer

    +
    jala.Date.Calendar.Renderer(<jala.Date.Calendar> calendar)
    + + +
      + Returns a new instance of the default calendar renderer. +
    + + + +
      + Parameters: + +
        calendar - The calendar utilizing this renderer +
      + + +
    + + + + +
      + Returns: +
        + A newly created instance of jala.Date.Calendar.Renderer +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    renderCalendar

    +
    void renderCalendar(<Date> date, <String> body, <Date> prevMonth, <Date> nextMonth)
    + +
      Renders the calendar directly to response.
    + + + + +
      + Parameters: + +
        date - A date object representing this calendar's month and year. Please mind that the day will be set to the last date in this month. +
      + +
        body - The rendered calendar weeks including the day header (basically the whole kernel of the table). +
      + +
        prevMonth - A date object set to the last available date of the previous month. This can be used to render a navigation link to the previous month. +
      + +
        nextMonth - A date object set to the first available date of the next month. This can be used to render a navigation link to the next month. +
      + +
    + + + + + + + + +
    + + +

    renderDay

    +
    void renderDay(<Date> date, <Boolean> isExisting, <Boolean> isSelected)
    + +
      Renders a single day within the calendar directly to response.
    + + + + +
      + Parameters: + +
        date - A date instance representing the day within the calendar. +
      + +
        isExisting - True if there is a child object in the calendar's collection to which the date cell should link to +
      + +
        isSelected - True if this calendar day should be rendered as selected day. +
      + +
    + + + + + + + + +
    + + +

    renderDayHeader

    +
    void renderDayHeader(<String> text)
    + +
      Renders a single cell in the calendar day header row directly to response.
    + + + + +
      + Parameters: + +
        text - The text to display in the header field. +
      + +
    + + + + + + + + +
    + + +

    renderPrevNextLink

    +
    void renderPrevNextLink(<Date> date)
    + +
      Renders a link to the previous or next month's calendar directly to response.
    + + + + +
      + Parameters: + +
        date - A date object set to the previous or next available month. This can be null in case there is no previous or next month. +
      + +
    + + + + + + + + +
    + + +

    renderRow

    +
    void renderRow(<String> row)
    + +
      Renders a single calendar row directly to response.
    + + + + +
      + Parameters: + +
        row - The body of the calendar row. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Date.Calendar.html b/modules/jala/docs/jala.Date.Calendar.html new file mode 100644 index 00000000..6dde6026 --- /dev/null +++ b/modules/jala/docs/jala.Date.Calendar.html @@ -0,0 +1,911 @@ + + + + + +jala.Date.Calendar + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Date.Calendar

    +
    Object
    +   |
    +   +--jala.Date.Calendar
    +
    + + +
    +
    + +
    class + jala.Date.Calendar + + +
    + +

    +
    This class represents a calendar based based on a grouped + collection of HopObjects. It provides several methods for rendering + the calendar plus defining locale and timezone settings. +
    Defined in Date.js

    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Date.Calendar.Renderer
    +  + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Date.Calendar + + (<HopObject> collection) + +
    +             + Creates a new instance of jala.Data.Calendar +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + getAccessNameFormat() + +
    +            + Returns the format of the access name used by this calendar to access + child group objects of the collection this calendar is operating on. +
    + +  String + + + + + getCalendar(today) + +
    +            + Returns a rendered calendar +
    + +  HopObject + + + + + getCollection() + +
    +            + Returns the collection this calendar object works on +
    + +  String + + + + + getHrefFormat() + +
    +            + Returns the date formatting pattern used to render hrefs. +
    + +  java.util.Locale + + + + + getLocale() + +
    +            + Returns the locale used within this calendar instance. +
    + +  Object + + + + + getRenderer() + +
    +            + Returns the renderer used by this calendar. +
    + +  java.util.Locale + + + + + getTimeZone() + +
    +            + Returns the locale used within this calendar instance. +
    + +  void + + + + + render(today) + +
    +            + Renders the calendar using either a custom renderer defined + using setRenderer() or the default one. +
    + +  void + + + + + setAccessNameFormat(<String> fmt) + +
    +            + Sets the format of the group name to use when trying to access + child objects of the collection this calendar is operating on. +
    + +  void + + + + + setHrefFormat(<String> fmt) + +
    +            + Sets the format of the hrefs to render by this calendar + to the format pattern passed as argument. +
    + +  void + + + + + setLocale(<java.util.Locale> loc) + +
    +            + Sets the locale to use within this calendar object +
    + +  void + + + + + setRenderer(<Object> r) + +
    +            + Sets the renderer to use. +
    + +  void + + + + + setTimeZone(tz) + +
    +            + Sets the locale to use within this calendar object +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Date.Calendar

    +
    jala.Date.Calendar(<HopObject> collection)
    + + +
      + Creates a new instance of jala.Data.Calendar +
    + + + +
      + Parameters: + +
        collection - A grouped HopObject collection to work on +
      + + +
    + + + + +
      + Returns: +
        + A newly created jala.Date.Calendar instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getAccessNameFormat

    +
    String getAccessNameFormat()
    + +
      Returns the format of the access name used by this calendar to access + child group objects of the collection this calendar is operating on. + The default format is "yyyyMMdd".
    + + + + + + + +
      + Returns: +
        + The date formatting pattern used to access child objects +
      +
    + + + + + + + +
    + + +

    getCalendar

    +
    String getCalendar(today)
    + +
      Returns a rendered calendar
    + + + + + + + + + + + + + +
    + + +

    getCollection

    +
    HopObject getCollection()
    + +
      Returns the collection this calendar object works on
    + + + + + + + +
      + Returns: +
        + The HopObject collection of this calendar +
      +
    + + + + + +
    + + +

    getHrefFormat

    +
    String getHrefFormat()
    + +
      Returns the date formatting pattern used to render hrefs. The default + format is "yyyyMMdd".
    + + + + + + + +
      + Returns: +
        + The date formatting pattern +
      +
    + + + + + + + +
    + + +

    getLocale

    +
    java.util.Locale getLocale()
    + +
      Returns the locale used within this calendar instance. By default + the locale used by this calendar is the default locale of the + Java Virtual Machine running Helma.
    + + + + + + + +
      + Returns: +
        + The locale of this calendar +
      +
    + + + + + + + +
    + + +

    getRenderer

    +
    Object getRenderer()
    + +
      Returns the renderer used by this calendar.
    + + + + + + + +
      + Returns: +
        + The calendar renderer +
      +
    + + + + + + + +
    + + +

    getTimeZone

    +
    java.util.Locale getTimeZone()
    + +
      Returns the locale used within this calendar instance. By default + the timezone used by this calendar is the default timezone + of the Java Virtual Machine running Helma.
    + + + + + + + +
      + Returns: +
        + The locale of this calendar +
      +
    + + + + + + + +
    + + +

    render

    +
    void render(today)
    + +
      Renders the calendar using either a custom renderer defined + using setRenderer() or the default one.
    + + + + + + + + + + + + + +
    + + +

    setAccessNameFormat

    +
    void setAccessNameFormat(<String> fmt)
    + +
      Sets the format of the group name to use when trying to access + child objects of the collection this calendar is operating on.
    + + + + +
      + Parameters: + +
        fmt - The date format pattern to use for accessing child objects +
      + +
    + + + + + + + + + + +
    + + +

    setHrefFormat

    +
    void setHrefFormat(<String> fmt)
    + +
      Sets the format of the hrefs to render by this calendar + to the format pattern passed as argument.
    + + + + +
      + Parameters: + +
        fmt - The date format pattern to use for rendering the href +
      + +
    + + + + + + + + + + +
    + + +

    setLocale

    +
    void setLocale(<java.util.Locale> loc)
    + +
      Sets the locale to use within this calendar object
    + + + + +
      + Parameters: + +
        loc - The locale to use +
      + +
    + + + + + + + + + + +
    + + +

    setRenderer

    +
    void setRenderer(<Object> r)
    + +
      Sets the renderer to use.
    + + + + +
      + Parameters: + +
        r - The renderer to use +
      + +
    + + + + + + + + + + +
    + + +

    setTimeZone

    +
    void setTimeZone(tz)
    + +
      Sets the locale to use within this calendar object
    + + + + +
      + Parameters: + +
        loc - The locale to use +
      + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Date.html b/modules/jala/docs/jala.Date.html new file mode 100644 index 00000000..1c371558 --- /dev/null +++ b/modules/jala/docs/jala.Date.html @@ -0,0 +1,389 @@ + + + + + +jala.Date + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Date

    +
    Object
    +   |
    +   +--jala.Date
    +
    + + +
    +
    + +
    class + jala.Date + + +
    + +

    +
    This class provides various convenience + methods for rendering purposes. +
    Defined in Date.js

    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Date.Calendar
    +  + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Date + + () + +
    +             + Constructs a new Renderings object. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + renderEditor(<String> prefix, <Date> date, <Object> fmt) + +
    +            + Renders a timestamp as set of DropDown boxes, following the + format passed as argument. +
    + +  String + + + + + renderEditorAsString(prefix, date, pattern) + +
    +            + Returns a timestamp as set of dropdown-boxes +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Date

    +
    jala.Date()
    + + +
      + Constructs a new Renderings object. +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    renderEditor

    +
    void renderEditor(<String> prefix, <Date> date, <Object> fmt)
    + +
      Renders a timestamp as set of DropDown boxes, following the + format passed as argument. Every <select> + item is prefixed with a string so that it can be retrieved + easily from the values of a submitted POST request.
    + + + + +
      + Parameters: + +
        prefix - The prefix to use for all dropdown boxes, eg. "postdate" +
      + +
        date - A Date object to use as preselection (optional) +
      + +
        fmt - Array containing one parameter object for every single select box that should be rendered, with the following properties set:
        • pattern - The date format pattern that should be rendered. Valid patterns are: "dd", "MM", "yyyy", "HH", "ss".
        • firstOption - The string to use as first option, eg.: "choose a day"
        +
      + +
    + + + + + + + + +
    + + +

    renderEditorAsString

    +
    String renderEditorAsString(prefix, date, pattern)
    + +
      Returns a timestamp as set of dropdown-boxes
    + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.DnsClient.Record.html b/modules/jala/docs/jala.DnsClient.Record.html new file mode 100644 index 00000000..ea3fdd72 --- /dev/null +++ b/modules/jala/docs/jala.DnsClient.Record.html @@ -0,0 +1,484 @@ + + + + + +jala.DnsClient.Record + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.DnsClient.Record

    +
    Object
    +   |
    +   +--jala.DnsClient.Record
    +
    + + +
    +
    + +
    class + jala.DnsClient.Record + + +
    + +

    +
    Instances of this class wrap record data as received + from the nameserver. +
    Defined in DnsClient.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Stringcname +
    +           The CNAME of this record.
    +  Stringemail +
    +           The email address responsible for a name server.
    +  Stringhost +
    +           The name of the host.
    +  StringipAddress +
    +           The IP address of the host.
    +  Stringmx +
    +           The name of the mail exchanging server.
    +  Stringtext +
    +           Descriptive text as received from the nameserver.
    +  Numbertype +
    +           The type of the nameserver record represented by this Answer instance.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.DnsClient.Record + + (<org.wonderly.net.dns.RR> data) + +
    +             + Constructs a new instance of jala.DnsClient.Record. +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  org.wonderly.net.dns.RR + + + + + getData() + +
    +            + Returns the wrapped nameserver record data +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    cname

    +
    String cname
    +
      + The CNAME of this record. This will only be set for records + of type CNAME + +
    +
    + + +

    email

    +
    String email
    +
      + The email address responsible for a name server. This property + will only be set for records of type SOA + +
    +
    + + +

    host

    +
    String host
    +
      + The name of the host. This will only be set for records + of type A, AAAA and NS. + +
    +
    + + +

    ipAddress

    +
    String ipAddress
    +
      + The IP address of the host. This will only be set for records + of type A and AAAA + +
    +
    + + +

    mx

    +
    String mx
    +
      + The name of the mail exchanging server. This is only set for + records of type MX + +
    +
    + + +

    text

    +
    String text
    +
      + Descriptive text as received from the nameserver. This is only + set for records of type TXT + +
    +
    + + +

    type

    +
    Number type
    +
      + The type of the nameserver record represented by this Answer instance. + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.DnsClient.Record

    +
    jala.DnsClient.Record(<org.wonderly.net.dns.RR> data)
    + + +
      + Constructs a new instance of jala.DnsClient.Record. +
    + + + +
      + Parameters: + +
        data - The data as received from the nameserver +
      + + +
    + + + + +
      + Returns: +
        + A newly constructed Record instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getData

    +
    org.wonderly.net.dns.RR getData()
    + +
      Returns the wrapped nameserver record data
    + + + + + + + +
      + Returns: +
        + The wrapped data +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.DnsClient.html b/modules/jala/docs/jala.DnsClient.html new file mode 100644 index 00000000..8f3d752f --- /dev/null +++ b/modules/jala/docs/jala.DnsClient.html @@ -0,0 +1,591 @@ + + + + + +jala.DnsClient + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.DnsClient

    +
    Object
    +   |
    +   +--jala.DnsClient
    +
    + + +
    +
    + +
    class + jala.DnsClient + + +
    + +

    +
    This is a wrapper around the Dns Client by wonderly.org + providing methods for querying Dns servers. For more information + about the Java DNS client visit + https://javadns.dev.java.net/. + Please mind that the nameserver specified must accept queries on port + 53 TCP (the Java DNS client used doesn't support UDP nameserver queries), + and that reverse lookups are not supported. +
    Defined in DnsClient.js

    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.DnsClient.Record
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  StringnameServer +
    +           Contains the IP Adress/FQDN of the name server to query.
    + <static>  <final> NumberTYPE_A +
    +           The "A" record/query type.
    + <static>  <final> NumberTYPE_CNAME +
    +           The "CNAME" record/query type.
    + <static>  <final> NumberTYPE_MX +
    +           The "MX" record/query type.
    + <static>  <final> NumberTYPE_NS +
    +           The "NS" record/query type.
    + <static>  <final> NumberTYPE_PTR +
    +           The "PTR" record/query type.
    + <static>  <final> NumberTYPE_SOA +
    +           The "SOA" record/query type.
    + <static>  <final> NumberTYPE_TXT +
    +           The "TXT" record/query type.
    + <static>  <final> NumberTYPE_WKS +
    +           The "WKS" record/query type.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.DnsClient + + (<String> nameServer) + +
    +             + Constructs a new DnsClient object. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  org.wonderly.net.dns.RR + + + + + query(<String> dName, <Number> queryType) + +
    +            + Queries the nameserver for a specific domain + and the given type of record. +
    + +  org.wonderly.net.dns.RR + + + + + queryMailHost(<String> dName) + +
    +            + Convenience method to query for the MX-records + of the domain passed as argument. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    nameServer

    +
    String nameServer
    +
      + Contains the IP Adress/FQDN of the name server to query. + +
    +
    + + +

    TYPE_A

    +
    <static> <final> Number TYPE_A
    +
      + The "A" record/query type. + +
    +
    + + +

    TYPE_CNAME

    +
    <static> <final> Number TYPE_CNAME
    +
      + The "CNAME" record/query type. + +
    +
    + + +

    TYPE_MX

    +
    <static> <final> Number TYPE_MX
    +
      + The "MX" record/query type. + +
    +
    + + +

    TYPE_NS

    +
    <static> <final> Number TYPE_NS
    +
      + The "NS" record/query type. + +
    +
    + + +

    TYPE_PTR

    +
    <static> <final> Number TYPE_PTR
    +
      + The "PTR" record/query type. + +
    +
    + + +

    TYPE_SOA

    +
    <static> <final> Number TYPE_SOA
    +
      + The "SOA" record/query type. + +
    +
    + + +

    TYPE_TXT

    +
    <static> <final> Number TYPE_TXT
    +
      + The "TXT" record/query type. + +
    +
    + + +

    TYPE_WKS

    +
    <static> <final> Number TYPE_WKS
    +
      + The "WKS" record/query type. + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.DnsClient

    +
    jala.DnsClient(<String> nameServer)
    + + +
      + Constructs a new DnsClient object. +
    + + + +
      + Parameters: + +
        nameServer - IP-Address or FQDN of nameserver to query +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    query

    +
    org.wonderly.net.dns.RR query(<String> dName, <Number> queryType)
    + +
      Queries the nameserver for a specific domain + and the given type of record.
    + + + + +
      + Parameters: + +
        dName - The domain name to query for +
      + +
        queryType - The type of records to retrieve +
      + +
    + + + + +
      + Returns: +
        + The records retrieved from the nameserver +
      +
    + + + + + +
    + + +

    queryMailHost

    +
    org.wonderly.net.dns.RR queryMailHost(<String> dName)
    + +
      Convenience method to query for the MX-records + of the domain passed as argument.
    + + + + +
      + Parameters: + +
        dName - The domain name to query for +
      + +
    + + + + +
      + Returns: +
        + The records retrieved from the nameserver +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Button.html b/modules/jala/docs/jala.Form.Component.Button.html new file mode 100644 index 00000000..b863fff4 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Button.html @@ -0,0 +1,411 @@ + + + + + +jala.Form.Component.Button + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Button

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Button
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Form.Component.Submit +
    +
    + + +
    +
    + +
    class + jala.Form.Component.Button + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders a button. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Button + + (<String> name) + +
    +             + Creates a new Button component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + render(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a button to the response. +
    + +  Object + + + + + renderControls(attr, value) + +
    +            + Creates a new attribute object for this button. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, checkRequirements, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Button

    +
    jala.Form.Component.Button(<String> name)
    + + +
      + Creates a new Button component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Button component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    render

    +
    void render(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a button to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + +

    renderControls

    +
    Object renderControls(attr, value)
    + +
      Creates a new attribute object for this button.
    + + + + + + + +
      + Returns: +
        + Object with all attributes set for this button. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Checkbox.html b/modules/jala/docs/jala.Form.Component.Checkbox.html new file mode 100644 index 00000000..283c7603 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Checkbox.html @@ -0,0 +1,460 @@ + + + + + +jala.Form.Component.Checkbox + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Checkbox

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Checkbox
    +
    + + +
    +
    + +
    class + jala.Form.Component.Checkbox + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + checkbox. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Checkbox + + (<String> name) + +
    +             + Creates a new Checkbox component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates user input from checkbox. +
    + +  Number + + + + + parseValue(<Object> reqData) + +
    +            + Parses the string input from the form. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, reqData) + +
    +            + Renders an checkbox to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Checkbox

    +
    jala.Form.Component.Checkbox(<String> name)
    + + +
      + Creates a new Checkbox component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Checkbox component instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates user input from checkbox.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + null if everything is ok or string containing error message +
      +
    + + + + + +
    + + +

    parseValue

    +
    Number parseValue(<Object> reqData)
    + +
      Parses the string input from the form. For a checked box, the value is 1, + for an unchecked box the value is 0.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + parsed value +
      +
    + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, reqData)
    + +
      Renders an checkbox to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Date.html b/modules/jala/docs/jala.Form.Component.Date.html new file mode 100644 index 00000000..62a7abd3 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Date.html @@ -0,0 +1,463 @@ + + + + + +jala.Form.Component.Date + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Date

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Date
    +
    + + +
    +
    + +
    class + jala.Form.Component.Date + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + date editor. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Date + + (<String> name) + +
    +             + Constructs a new Date component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates user input from a date editor. +
    + +  Date + + + + + parseValue(<Object> reqData) + +
    +            + Parses the string input from the form and converts it to a date object. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a textarea tag to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Date

    +
    jala.Form.Component.Date(<String> name)
    + + +
      + Constructs a new Date component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Date component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates user input from a date editor.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + null if everything is ok or string containing error message +
      +
    + + + + + +
    + + +

    parseValue

    +
    Date parseValue(<Object> reqData)
    + +
      Parses the string input from the form and converts it to a date object. + Throws an error if the string cannot be parsed.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + parsed date value +
      +
    + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a textarea tag to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Fieldset.html b/modules/jala/docs/jala.Form.Component.Fieldset.html new file mode 100644 index 00000000..9f581f95 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Fieldset.html @@ -0,0 +1,419 @@ + + + + + +jala.Form.Component.Fieldset + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Fieldset

    +
    Object
    +   |
    +   +--jala.Form.Component.Fieldset
    +
    + + +
    +
    + +
    class + jala.Form.Component.Fieldset + + +
    + +

    +
    Instances of this class represent a form fieldset containing + numerous form components +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Fieldset + + (<String> name) + +
    +             + Constructs a new Fieldset instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + render() + +
    +            + Renders all components within the fieldset. +
    + +  void + + + + + save(<jala.Form.Tracker> tracker, <Object> destObj) + +
    +            + Saves all components within the fieldset. +
    + +  void + + + + + validate(<jala.Form.Tracker> tracker) + +
    +            + Validates all components within the fieldset. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Fieldset

    +
    jala.Form.Component.Fieldset(<String> name)
    + + +
      + Constructs a new Fieldset instance +
    + + + +
      + Parameters: + +
        name - The name of the fieldset +
      + + +
    + + + + +
      + Returns: +
        + A newly created Fieldset instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    render

    +
    void render()
    + +
      Renders all components within the fieldset.
    + + + + + + + + + + + +
    + + +

    save

    +
    void save(<jala.Form.Tracker> tracker, <Object> destObj)
    + +
      Saves all components within the fieldset.
    + + + + +
      + Parameters: + +
        tracker - +
      + +
        destObj - +
      + +
    + + + + + + + + +
    + + +

    validate

    +
    void validate(<jala.Form.Tracker> tracker)
    + +
      Validates all components within the fieldset.
    + + + + +
      + Parameters: + +
        tracker - +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.File.html b/modules/jala/docs/jala.Form.Component.File.html new file mode 100644 index 00000000..e218bfa9 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.File.html @@ -0,0 +1,425 @@ + + + + + +jala.Form.Component.File + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.File

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.File
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Form.Component.Image +
    +
    + + +
    +
    + +
    class + jala.Form.Component.File + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + file upload. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.File + + (<String> name) + +
    +             + Creates a new File component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates a file upload by making sure it's there (if REQUIRE is set), + checking the file size, the content type and by trying to construct an image. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a file input tag to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.File

    +
    jala.Form.Component.File(<String> name)
    + + +
      + Creates a new File component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created File component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates a file upload by making sure it's there (if REQUIRE is set), + checking the file size, the content type and by trying to construct an image.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
        tracker - jala.Form.Tracker object storing possible error messages +
      + +
    + + + + +
      + Returns: +
        + null if everything is ok or string containing error message +
      +
    + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a file input tag to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Hidden.html b/modules/jala/docs/jala.Form.Component.Hidden.html new file mode 100644 index 00000000..0b2e631f --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Hidden.html @@ -0,0 +1,398 @@ + + + + + +jala.Form.Component.Hidden + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Hidden

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Hidden
    +
    + + +
    +
    + +
    class + jala.Form.Component.Hidden + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + hidden input tag. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Hidden + + (<String> name) + +
    +             + Constructs a newly created Hidden component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + render() + +
    +            + Renders this component directly to response. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a hidden input tag to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, checkRequirements, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Hidden

    +
    jala.Form.Component.Hidden(<String> name)
    + + +
      + Constructs a newly created Hidden component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Hidden component instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    render

    +
    void render()
    + +
      Renders this component directly to response. For a hidden tag, this is + just an input element, no div tag or anything.
    + + + + + + + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a hidden input tag to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Image.html b/modules/jala/docs/jala.Form.Component.Image.html new file mode 100644 index 00000000..bf6833a0 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Image.html @@ -0,0 +1,376 @@ + + + + + +jala.Form.Component.Image + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Image

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.File
    +               |
    +               +--jala.Form.Component.Image
    +
    + + +
    +
    + +
    class + jala.Form.Component.Image + +
    extends jala.Form.Component.File + + +
    + +

    +
    Subclass of jala.Form.Component.File which renders a file upload + and validates uploaded files as images. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Image + + () + +
    +             + Creates a new Image component instance +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates an image upload by making sure it's there (if REQUIRE is set), + checking the file size, the content type and by trying to construct an image. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.File
    + +renderControls +
    +  + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Image

    +
    jala.Form.Component.Image()
    + + +
      + Creates a new Image component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Image component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates an image upload by making sure it's there (if REQUIRE is set), + checking the file size, the content type and by trying to construct an image. + If the file is an image, width and height limitations set by require are + checked.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Input.html b/modules/jala/docs/jala.Form.Component.Input.html new file mode 100644 index 00000000..a0d3131b --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Input.html @@ -0,0 +1,1258 @@ + + + + + +jala.Form.Component.Input + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Input

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Form.Component.Hidden, jala.Form.Component.Checkbox, jala.Form.Component.File, jala.Form.Component.Password, jala.Form.Component.Button, jala.Form.Component.Select, jala.Form.Component.Textarea, jala.Form.Component.Date +
    +
    + + +
    +
    + +
    class + jala.Form.Component.Input + + +
    + +

    +
    Instances of this class represent a single form input field. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Input + + (<String> name) + +
    +             + Creates a new input component instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkLength(<Object> reqData) + +
    +            + Checks user input for maximum length, minimum length and require + if the corresponding options have been set using the require method. +
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Checks user input against options set using the require method. +
    + +  void + + + + + class_macro() + +
    +            + Renders this component's class name. +
    + +  void + + + + + controls_macro() + +
    +            + Renders the control(s) of this component +
    + +  void + + + + + error_macro() + +
    +            + Renders this component's error message (if set) directly to response +
    + +  Object + + + + + getControlAttributes() + +
    +            + Creates a new attribute object for this element. +
    + +  String|Number|Date + + + + + getValue() + +
    +            + Retrieves the property which is edited by this component. +
    + +  void + + + + + help_macro() + +
    +            + Renders this component's help text, if set. +
    + +  void + + + + + id_macro() + +
    +            + Renders this component's id +
    + +  void + + + + + label_macro() + +
    +            + Renders this component's label. +
    + +  void + + + + + name_macro() + +
    +            + Renders this component's name +
    + +  Object + + + + + parseValue(<Object> reqData) + +
    +            + Parses the string input from the form and creates the datatype that + is edited with this component. +
    + +  void + + + + + render() + +
    +            + Renders this component including label, error and help messages directly + to response. +
    + +  void + + + + + render_macro() + +
    +            + Renders this component including label, error and help messages + directly to response +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders the html form elements to the response. +
    + +  String + + + + + renderError() + +
    +            + If the error tracker holds an error message for this component, + it is wrapped in a div-tag and returned as a string. +
    + +  String + + + + + renderHelp() + +
    +            + If this component contains a help message, it is wrapped in + a div-tag and returned as a string. +
    + +  String + + + + + renderLabel() + +
    +            + Returns the rendered label of this component +
    + +  void + + + + + save(<jala.Form.Tracker> tracker, <Object> destObj) + +
    +            + Saves the parsed value using setValue. +
    + +  Object + + + + + setValue(<Object> destObj, <Object> value) + +
    +            + Sets a property of the object passed as argument to the given value. +
    + +  void + + + + + type_macro() + +
    +            + Renders this component's type +
    + +  void + + + + + validate(<jala.Form.Tracker> tracker) + +
    +            + Validates the input provided to this component. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Input

    +
    jala.Form.Component.Input(<String> name)
    + + +
      + Creates a new input component instance. +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html control. +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkLength

    +
    String checkLength(<Object> reqData)
    + +
      Checks user input for maximum length, minimum length and require + if the corresponding options have been set using the require method.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + String containing error message or null if everything is ok. +
      +
    + + + + + + + +
    + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Checks user input against options set using the require method.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + String containing error message or null if everything is ok. +
      +
    + + + + + + + +
    + + +

    class_macro

    +
    void class_macro()
    + +
      Renders this component's class name. + Note that this is just the class name that has been explicitly + assigned using setClassName.
    + + + + + + + + + + + + + +
    + + +

    controls_macro

    +
    void controls_macro()
    + +
      Renders the control(s) of this component
    + + + + + + + + + + + +
    + + +

    error_macro

    +
    void error_macro()
    + +
      Renders this component's error message (if set) directly to response
    + + + + + + + + + + + +
    + + +

    getControlAttributes

    +
    Object getControlAttributes()
    + +
      Creates a new attribute object for this element.
    + + + + + + + +
      + Returns: +
        + Object with properties id, name, class +
      +
    + + + + + +
    + + +

    getValue

    +
    String|Number|Date getValue()
    + +
      Retrieves the property which is edited by this component. +
        +
      • If no getter is given, the method returns the primitive property + of the data object with the same name as the component.
      • +
      • If a getter function is defined, it is executed with the scope + of the data object and the return value is used as default value. + The name of the component is passed to the getter function + as an argument.
      • +
    + + + + + + + +
      + Returns: +
        + The value of the property +
      +
    + + + + + +
    + + +

    help_macro

    +
    void help_macro()
    + +
      Renders this component's help text, if set.
    + + + + + + + + + + + +
    + + +

    id_macro

    +
    void id_macro()
    + +
      Renders this component's id
    + + + + + + + + + + + + + +
    + + +

    label_macro

    +
    void label_macro()
    + +
      Renders this component's label.
    + + + + + + + + + + + +
    + + +

    name_macro

    +
    void name_macro()
    + +
      Renders this component's name
    + + + + + + + + + + + +
    + + +

    parseValue

    +
    Object parseValue(<Object> reqData)
    + +
      Parses the string input from the form and creates the datatype that + is edited with this component. For the input component this method + is not of much use, but subclasses that edit other datatypes may use + it. For example, a date editor should convert the user input from string + to a date object.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + parsed value +
      +
    + + + + + +
    + + +

    render

    +
    void render()
    + +
      Renders this component including label, error and help messages directly + to response.
    + + + + + + + + + + + +
    + + +

    render_macro

    +
    void render_macro()
    + +
      Renders this component including label, error and help messages + directly to response
    + + + + + + + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders the html form elements to the response. + This method shall be overridden by subclasses of input component.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for the html form elements. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + +

    renderError

    +
    String renderError()
    + +
      If the error tracker holds an error message for this component, + it is wrapped in a div-tag and returned as a string.
    + + + + + + + +
      + Returns: +
        + Rendered string +
      +
    + + + + + +
    + + +

    renderHelp

    +
    String renderHelp()
    + +
      If this component contains a help message, it is wrapped in + a div-tag and returned as a string.
    + + + + + + + +
      + Returns: +
        + The rendered help message +
      +
    + + + + + +
    + + +

    renderLabel

    +
    String renderLabel()
    + +
      Returns the rendered label of this component
    + + + + + + + +
      + Returns: +
        + The rendered label of this component +
      +
    + + + + + +
    + + +

    save

    +
    void save(<jala.Form.Tracker> tracker, <Object> destObj)
    + +
      Saves the parsed value using setValue.
    + + + + +
      + Parameters: + +
        tracker - Tracker object collecting request data, error messages and parsed values. +
      + +
        destObj - (optional) object whose values will be changed. +
      + +
    + + + + + + + + + + +
    + + +

    setValue

    +
    Object setValue(<Object> destObj, <Object> value)
    + +
      Sets a property of the object passed as argument to the given value. +
    • If no setter is set at the component, the primitive property + of the data object is changed.
    • +
    • If a setter function is defined it is executed with the data object + as scope and with the name and new value provided as arguments
    • +
    • If the setter is explicitly set to null, no changes are made at all.
    + + + + +
      + Parameters: + +
        destObj - (optional) object whose values will be changed. +
      + +
        value - The value to set the property to +
      + +
    + + + + +
      + Returns: +
        + True in case the update was successful, false otherwise. +
      +
    + + + + + + + +
    + + +

    type_macro

    +
    void type_macro()
    + +
      Renders this component's type
    + + + + + + + + + + + +
    + + +

    validate

    +
    void validate(<jala.Form.Tracker> tracker)
    + +
      Validates the input provided to this component. First, + checkRequirements is called. If no error occurs, the input + is parsed using parseValue and passed on to the validator + function.
    + + + + +
      + Parameters: + +
        tracker - Tracker object collecting request data, error messages and parsed values. +
      + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Password.html b/modules/jala/docs/jala.Form.Component.Password.html new file mode 100644 index 00000000..f450869a --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Password.html @@ -0,0 +1,362 @@ + + + + + +jala.Form.Component.Password + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Password

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Password
    +
    + + +
    +
    + +
    class + jala.Form.Component.Password + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + password input tag. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Password + + (<String> name) + +
    +             + Constructs a newly created Password component instance +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a password input tag to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, checkRequirements, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Password

    +
    jala.Form.Component.Password(<String> name)
    + + +
      + Constructs a newly created Password component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Password component instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a password input tag to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Radio.html b/modules/jala/docs/jala.Form.Component.Radio.html new file mode 100644 index 00000000..117dcd14 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Radio.html @@ -0,0 +1,431 @@ + + + + + +jala.Form.Component.Radio + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Radio

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Select
    +               |
    +               +--jala.Form.Component.Radio
    +
    + + +
    +
    + +
    class + jala.Form.Component.Radio + +
    extends jala.Form.Component.Select + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + set of radio buttons. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Radio + + (<String> name) + +
    +             + Creates a new Radio component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates user input from a set of radio buttons and makes sure that + option value list contains the user input. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value) + +
    +            + Renders a set of radio buttons to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Select
    + +parseOptions, checkOptions +
    +  + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Radio

    +
    jala.Form.Component.Radio(<String> name)
    + + +
      + Creates a new Radio component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Radio component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates user input from a set of radio buttons and makes sure that + option value list contains the user input.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + null if everything is ok or string containing error message +
      +
    + + + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value)
    + +
      Renders a set of radio buttons to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Select.html b/modules/jala/docs/jala.Form.Component.Select.html new file mode 100644 index 00000000..9a4bdeea --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Select.html @@ -0,0 +1,524 @@ + + + + + +jala.Form.Component.Select + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Select

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Select
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Form.Component.Radio +
    +
    + + +
    +
    + +
    class + jala.Form.Component.Select + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + dropdown element. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Select + + (<String> name) + +
    +             + Constructs a new Select component instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + checkOptions(<Object> reqData) + +
    +            + Checks user input for optiongroups: Unless require("checkoptions") + has ben set to false, the user input must exist in the option array. +
    + +  String + + + + + checkRequirements(<Object> reqData) + +
    +            + Validates user input from a dropdown element by making sure that + the option value list contains the user input. +
    + +  Array + + + + + parseOptions() + +
    +            + Creates an array of options for a dropdown element or a + group of radiobuttons. +
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a dropdown element to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Select

    +
    jala.Form.Component.Select(<String> name)
    + + +
      + Constructs a new Select component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Select component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    checkOptions

    +
    String checkOptions(<Object> reqData)
    + +
      Checks user input for optiongroups: Unless require("checkoptions") + has ben set to false, the user input must exist in the option array.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + null if everything is ok or string containing error message +
      +
    + + + + + +
    + + +

    checkRequirements

    +
    String checkRequirements(<Object> reqData)
    + +
      Validates user input from a dropdown element by making sure that + the option value list contains the user input.
    + + + + +
      + Parameters: + +
        reqData - request data +
      + +
    + + + + +
      + Returns: +
        + string containing error message or null if everything is ok. +
      +
    + + + + + + + +
    + + +

    parseOptions

    +
    Array parseOptions()
    + +
      Creates an array of options for a dropdown element or a + group of radiobuttons. If options field of this element's + config is an array, that array is returned. + If options is a function, its return value is returned.
    + + + + + + + +
      + Returns: +
        + array of options +
      +
    + + + + + +
    + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a dropdown element to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Skin.html b/modules/jala/docs/jala.Form.Component.Skin.html new file mode 100644 index 00000000..51fc872b --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Skin.html @@ -0,0 +1,344 @@ + + + + + +jala.Form.Component.Skin + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Skin

    +
    Object
    +   |
    +   +--jala.Form.Component
    +         |
    +         +--jala.Form.Component.Skin
    +
    + + +
    +
    + +
    class + jala.Form.Component.Skin + +
    extends jala.Form.Component + + +
    + +

    +
    Subclass of jala.Form.Component that allows rendering a skin + within a form. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Skin + + (<String> name) + +
    +             + +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + render() + +
    +            + Renders the skin named by this component to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component
    + +createDomId, validate, save +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Skin

    +
    jala.Form.Component.Skin(<String> name)
    + + + + +
      + Parameters: + +
        name - The name of the component, used as the name of the skin +
      + + +
    + + + + +
      + Returns: +
        + A newly created Skin component instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    render

    +
    void render()
    + +
      Renders the skin named by this component to the response.
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Submit.html b/modules/jala/docs/jala.Form.Component.Submit.html new file mode 100644 index 00000000..07452f56 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Submit.html @@ -0,0 +1,370 @@ + + + + + +jala.Form.Component.Submit + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Submit

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Button
    +               |
    +               +--jala.Form.Component.Submit
    +
    + + +
    +
    + +
    class + jala.Form.Component.Submit + +
    extends jala.Form.Component.Button + + +
    + +

    +
    Subclass of jala.Form.Component.Button which renders a submit button. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Submit + + (<String> name) + +
    +             + Creates a new Submit component instance +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Object + + + + + renderControls(attr, value) + +
    +            + Creates a new attribute object for this button. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Button
    + +render +
    +  + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, checkRequirements, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Submit

    +
    jala.Form.Component.Submit(<String> name)
    + + +
      + Creates a new Submit component instance +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Submit component +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    renderControls

    +
    Object renderControls(attr, value)
    + +
      Creates a new attribute object for this button.
    + + + + + + + +
      + Returns: +
        + Object with all attributes set for this button. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.Textarea.html b/modules/jala/docs/jala.Form.Component.Textarea.html new file mode 100644 index 00000000..fd0de8c4 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.Textarea.html @@ -0,0 +1,362 @@ + + + + + +jala.Form.Component.Textarea + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component.Textarea

    +
    Object
    +   |
    +   +--jala.Form.Component.Input
    +         |
    +         +--jala.Form.Component.Textarea
    +
    + + +
    +
    + +
    class + jala.Form.Component.Textarea + +
    extends jala.Form.Component.Input + + +
    + +

    +
    Subclass of jala.Form.Component.Input which renders and validates a + textarea input field. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component.Textarea + + (<String> name) + +
    +             + Constructs a new Textarea component. +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + renderControls(<Object> attr, <Object> value, <Object> reqData) + +
    +            + Renders a textarea input field to the response. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Form.Component.Input
    + +validate, save, getValue, setValue, render, renderError, renderLabel, renderHelp, render_macro, controls_macro, error_macro, label_macro, help_macro, id_macro, name_macro, type_macro, class_macro, getControlAttributes, checkLength, checkRequirements, parseValue +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component.Textarea

    +
    jala.Form.Component.Textarea(<String> name)
    + + +
      + Constructs a new Textarea component. +
    + + + +
      + Parameters: + +
        name - Name of the component, used as name of the html controls. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Textarea component instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    renderControls

    +
    void renderControls(<Object> attr, <Object> value, <Object> reqData)
    + +
      Renders a textarea input field to the response.
    + + + + +
      + Parameters: + +
        attr - Basic attributes for this element. +
      + +
        value - Value to be used for rendering this element. +
      + +
        reqData - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Component.html b/modules/jala/docs/jala.Form.Component.html new file mode 100644 index 00000000..205e8872 --- /dev/null +++ b/modules/jala/docs/jala.Form.Component.html @@ -0,0 +1,550 @@ + + + + + +jala.Form.Component + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Component

    +
    Object
    +   |
    +   +--jala.Form.Component
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Form.Component.Skin +
    +
    + + +
    +
    + +
    class + jala.Form.Component + + +
    + +

    + Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Form.Component.Fieldset
    + <static class>jala.Form.Component.Skin
    + <static class>jala.Form.Component.Input
    + <static class>jala.Form.Component.Password
    + <static class>jala.Form.Component.Hidden
    + <static class>jala.Form.Component.Textarea
    + <static class>jala.Form.Component.Date
    + <static class>jala.Form.Component.Select
    + <static class>jala.Form.Component.Radio
    + <static class>jala.Form.Component.Checkbox
    + <static class>jala.Form.Component.File
    + <static class>jala.Form.Component.Image
    + <static class>jala.Form.Component.Button
    + <static class>jala.Form.Component.Submit
    +  + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Component + + (name) + +
    +             + The abstract base class for all components. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + createDomId(<String> idPart) + +
    +            + Creates a DOM identifier based on the name of the form, + the name of the component and an additional string. +
    + +  void + + + + + render() + +
    +            + Function to render a component. +
    + +  void + + + + + save(destObj, val) + +
    +            + Function to save the data of a component. +
    + +  Object + + + + + validate(<jala.Form.Tracker> tracker) + +
    +            + Function to validate a component. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Component

    +
    jala.Form.Component(name)
    + + +
      + The abstract base class for all components. +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    createDomId

    +
    String createDomId(<String> idPart)
    + +
      Creates a DOM identifier based on the name of the form, + the name of the component and an additional string. + The items will be chained using camel casing.
    + + + + +
      + Parameters: + +
        idPart - Optional string appended to component's id. +
      + +
    + + + + +
      + Returns: +
        + The DOM Id +
      +
    + + + + + +
    + + +

    render

    +
    void render()
    + +
      Function to render a component. + Subclasses of jala.Form.Component may override this function.
    + + + + + + + + + + + +
    + + +

    save

    +
    void save(destObj, val)
    + +
      Function to save the data of a component. + Subclasses of jala.Form.Component may override this function.
    + + + + + + + + + + + +
    + + +

    validate

    +
    Object validate(<jala.Form.Tracker> tracker)
    + +
      Function to validate a component. + Subclasses of jala.Form.Component may override this function.
    + + + + +
      + Parameters: + +
        tracker - object tracking errors and holding parsed values and request data. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.Tracker.html b/modules/jala/docs/jala.Form.Tracker.html new file mode 100644 index 00000000..90cfe375 --- /dev/null +++ b/modules/jala/docs/jala.Form.Tracker.html @@ -0,0 +1,441 @@ + + + + + +jala.Form.Tracker + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form.Tracker

    +
    Object
    +   |
    +   +--jala.Form.Tracker
    +
    + + +
    +
    + +
    class + jala.Form.Tracker + + +
    + +

    +
    Instances of this class can contain error-messages and values +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Objecterrors +
    +           A map containing error messages
    +  ObjectreqData +
    +           A map containing input from request data
    +  Objectvalues +
    +           A map containing parsed values (only for those fields that didn't + fail during checkRequirements method).
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form.Tracker + + (reqData) + +
    +             + A generic container for error-messages and values +
    + + + +  + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Number + + + + + countErrors() + +
    +            + Returns the number of components for which this instance has + tracked an error. +
    + +  Boolean + + + + + hasError() + +
    +            + Returns true if an error has been set for at least one component. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    errors

    +
    Object errors
    +
      + A map containing error messages + +
    +
    + + +

    reqData

    +
    Object reqData
    +
      + A map containing input from request data + +
    +
    + + +

    values

    +
    Object values
    +
      + A map containing parsed values (only for those fields that didn't + fail during checkRequirements method). + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form.Tracker

    +
    jala.Form.Tracker(reqData)
    + + +
      + A generic container for error-messages and values +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    countErrors

    +
    Number countErrors()
    + +
      Returns the number of components for which this instance has + tracked an error.
    + + + + + + + +
      + Returns: +
        + Number of components that did not validate. +
      +
    + + + + + +
    + + +

    hasError

    +
    Boolean hasError()
    + +
      Returns true if an error has been set for at least one component.
    + + + + + + + +
      + Returns: +
        + true if form encountered an error. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Form.html b/modules/jala/docs/jala.Form.html new file mode 100644 index 00000000..2fffb0f8 --- /dev/null +++ b/modules/jala/docs/jala.Form.html @@ -0,0 +1,2034 @@ + + + + + +jala.Form + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Form

    +
    Object
    +   |
    +   +--jala.Form
    +
    + + +
    +
    + +
    class + jala.Form + + +
    + +

    +
    A class that renders forms, validates submitted form data and + stores the data in a specified object. +
    Defined in Form.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Form.Component
    + <static class>jala.Form.Tracker
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  SkincomponentSkin +
    +           Contains the default component skin
    +  Stringname +
    +           Readonly reference to the name of the form
    + <static>  <final> StringCHECKOPTIONS +
    +           Constant used by require function to define that a select or + radio component should validate only if the user input is contained + in the list of options provided.
    + <static>  <final> StringCONTENTTYPE +
    +           Constant used by require function to define that a file upload + component should validate only if the file's content type is + in the list of allowed content types provided.
    + <static>  helma.Htmlhtml +
    +           The HTML renderer used by jala.Form
    + <static>  <final> StringMAXHEIGHT +
    +           Constant used by require function to define that an image upload + component should validate only if the image's height is less than + the value provided.
    + <static>  <final> StringMAXLENGTH +
    +           Constant used by require function to define that a component + should not validate if userinput exceeds a maximum length.
    + <static>  <final> StringMAXWIDTH +
    +           Constant used by require function to define that an image upload + component should validate only if the image's width is less than + the value provided.
    + <static>  <final> StringMINHEIGHT +
    +           Constant used by require function to define that an image upload + component should validate only if the image's height is more than + the value provided.
    + <static>  <final> StringMINLENGTH +
    +           Constant used by require function to define that a component + should not validate if userinput is shorter than a given length.
    + <static>  <final> StringMINWIDTH +
    +           Constant used by require function to define that an image upload + component should validate only if the image's width is more than + the value provided.
    + <static>  <final> StringREQUIRE +
    +           Constant used by require function to define that a component + should validate only if the user did provide input.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Form + + (<String> name, <Object> dataObj) + +
    +             + Constructs a new Form instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + addComponent(<jala.Form.Component.Input> component) + +
    +            + Adds a component to this jala.Form instance +
    + +  String + + + + + class_macro() + +
    +            + Returns the class name of the form +
    + +  void + + + + + close_macro() + +
    +            + Writes the form closing tag to response +
    + +  Boolean + + + + + containsFileUpload() + +
    +            + Returns true if this instance of jala.Form contains at least + one component doing a file upload. +
    + +  Number + + + + + countErrors() + +
    +            + If this instance of jala.Form holds a jala.Form.Tracker + instance it returns the number of components that didn't + validate. +
    + +  String + + + + + createDomId() + +
    +            + Creates a DOM identifier based on the arguments passed. +
    + +  String + + + + + getClassName() + +
    +            + Returns the class name set for this form instance. +
    + +  Object + + + + + getDataObject() + +
    +            + Returns the data object containing the values used + for rendering the form. +
    + +  String + + + + + getErrorMessage() + +
    +            + Returns the general error message printed above the form + if any of the components didn't validate. +
    + +  jala.Form.Tracker + + + + + getTracker() + +
    +            + Returns the tracker object this form instance uses for collecting + error messages and parsed values. +
    + +  Boolean + + + + + handle(<Object> reqData, <Object> destObj) + +
    +            + Parses form input, applies check functions and stores the values + if the form does validate. +
    + +  Boolean + + + + + hasError() + +
    +            + Returns true if this instance of jala.Form holds a jala.Form.Tracker + instance and at least one error has been set on this tracker. +
    + +  String + + + + + id_macro() + +
    +            + Returns the id (equal to the name) of the form +
    + +  Array + + + + + listComponents() + +
    +            + Returns an array containing the components + of this jala.Form instance. +
    + +  String + + + + + name_macro() + +
    +            + Returns the name (equal to the id) of the form +
    + +  void + + + + + open_macro() + +
    +            + Writes the form opening tag to response +
    + +  void + + + + + render() + +
    +            + Renders this form including all components to response. +
    + +  void + + + + + render_macro() + +
    +            + Renders the whole form to response +
    + +  String + + + + + renderAsString(param) + +
    +            + renders the form as a string +
    + +  void + + + + + save(<jala.Form.Tracker> tracker, <Object> destObj) + +
    +            + Sets the parsed values on an object. +
    + +  void + + + + + setClassName(<String> newClassName) + +
    +            + Sets an extra classname for this form instance +
    + +  void + + + + + setDataObject(newDataObj) + +
    +            + Sets the data object which is being edited by this form. +
    + +  void + + + + + setErrorMessage(<String> newErrorMessage) + +
    +            + Sets the general error message printed above the form if any + of the components didn't validate. +
    + +  void + + + + + setTracker(<jala.Form.Tracker> newTracker) + +
    +            + Sets the tracker object this form instance uses for collecting + error messages and parsed values. +
    + +  jala.Form.Tracker + + + + + validate(<Object> reqData) + +
    +            + Validates user input from a submitted form by calling each + component's validate method. +
    + + <static> jala.Form + + + + + create(<Object> config, dataObj) + +
    +            + Parses a plain javascript object tree and configures a + new jala.Form instance according to the properties. +
    + + <static> void + + + + + extend(<Function> subClass, <Function> superClass) + +
    +            + Utility to set up the prototype, constructor, superclass and superconstructor + properties to support an inheritance strategy that can chain constructors and methods. +
    + + <static> String + + + + + isEmail(<String> name, <String> value, <Object> reqData, <jala.Form> formObj) + +
    +            + Static validator function to test values for being a valid email address. +
    + + <static> String + + + + + isUrl(<String> name, <String> value, <Object> reqData, <jala.Form> formObj) + +
    +            + Static validator function to test values for being a valid url. +
    + + <static> Object + + + + + propertyGetter(<String> name, value) + +
    +            + static default getter function used to return a field + from the data object. +
    + + <static> void + + + + + propertySetter(<String> name, <Object> value) + +
    +            + static default setter function used to change a field + of the data object. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    componentSkin

    +
    Skin componentSkin
    +
      + Contains the default component skin + +
    +
    + + +

    name

    +
    String name
    +
      + Readonly reference to the name of the form + +
    +
    + + +

    CHECKOPTIONS

    +
    <static> <final> String CHECKOPTIONS
    +
      + Constant used by require function to define that a select or + radio component should validate only if the user input is contained + in the list of options provided. + Value: "checkoptions" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    CONTENTTYPE

    +
    <static> <final> String CONTENTTYPE
    +
      + Constant used by require function to define that a file upload + component should validate only if the file's content type is + in the list of allowed content types provided. + Value: "contenttype" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    html

    +
    <static> helma.Html html
    +
      + The HTML renderer used by jala.Form + +
    +
    + + +

    MAXHEIGHT

    +
    <static> <final> String MAXHEIGHT
    +
      + Constant used by require function to define that an image upload + component should validate only if the image's height is less than + the value provided. + Value: "maxheight" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    MAXLENGTH

    +
    <static> <final> String MAXLENGTH
    +
      + Constant used by require function to define that a component + should not validate if userinput exceeds a maximum length. + Value: "maxlength" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    MAXWIDTH

    +
    <static> <final> String MAXWIDTH
    +
      + Constant used by require function to define that an image upload + component should validate only if the image's width is less than + the value provided. + Value: "maxwidth" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    MINHEIGHT

    +
    <static> <final> String MINHEIGHT
    +
      + Constant used by require function to define that an image upload + component should validate only if the image's height is more than + the value provided. + Value: "min-height" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    MINLENGTH

    +
    <static> <final> String MINLENGTH
    +
      + Constant used by require function to define that a component + should not validate if userinput is shorter than a given length. + Value: "minlength" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    MINWIDTH

    +
    <static> <final> String MINWIDTH
    +
      + Constant used by require function to define that an image upload + component should validate only if the image's width is more than + the value provided. + Value: "minwidth" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    REQUIRE

    +
    <static> <final> String REQUIRE
    +
      + Constant used by require function to define that a component + should validate only if the user did provide input. + Value: "require" + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Form

    +
    jala.Form(<String> name, <Object> dataObj)
    + + +
      + Constructs a new Form instance +
    + + + +
      + Parameters: + +
        name - The name of the form +
      + +
        dataObj - An optional object used to retrieve values to display in the form input fields contained in this Form instance. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Form instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    addComponent

    +
    void addComponent(<jala.Form.Component.Input> component)
    + +
      Adds a component to this jala.Form instance
    + + + + +
      + Parameters: + +
        component - +
      + +
    + + + + + + + + +
    + + +

    class_macro

    +
    String class_macro()
    + +
      Returns the class name of the form
    + + + + + + + +
      + Returns: +
        + The class name of this Form instance +
      +
    + + + + + +
    + + +

    close_macro

    +
    void close_macro()
    + +
      Writes the form closing tag to response
    + + + + + + + + + + + +
    + + +

    containsFileUpload

    +
    Boolean containsFileUpload()
    + +
      Returns true if this instance of jala.Form contains at least + one component doing a file upload.
    + + + + + + + + + + +
      + See:
        - jala.Form.Component#containsFileUpload
      +
    + + +
    + + +

    countErrors

    +
    Number countErrors()
    + +
      If this instance of jala.Form holds a jala.Form.Tracker + instance it returns the number of components that didn't + validate.
    + + + + + + + +
      + Returns: +
        + Number of components that didn't validate. +
      +
    + + + + + +
    + + +

    createDomId

    +
    String createDomId()
    + +
      Creates a DOM identifier based on the arguments passed. The + resulting Id will be prefixed with the name of the form. + All arguments will be chained using camel casing.
    + + + + + + + +
      + Returns: +
        + The DOM Id +
      +
    + + + + + +
    + + +

    getClassName

    +
    String getClassName()
    + +
      Returns the class name set for this form instance.
    + + + + + + + +
      + Returns: +
        + class name +
      +
    + + + + + +
    + + +

    getDataObject

    +
    Object getDataObject()
    + +
      Returns the data object containing the values used + for rendering the form.
    + + + + + + + +
      + Returns: +
        + The data object of this jala.Form instance +
      +
    + + + + + +
    + + +

    getErrorMessage

    +
    String getErrorMessage()
    + +
      Returns the general error message printed above the form + if any of the components didn't validate.
    + + + + + + + +
      + Returns: +
        + error message +
      +
    + + + + + +
    + + +

    getTracker

    +
    jala.Form.Tracker getTracker()
    + +
      Returns the tracker object this form instance uses for collecting + error messages and parsed values.
    + + + + + + + +
      + Returns: +
        + tracker object +
      +
    + + + + + +
    + + +

    handle

    +
    Boolean handle(<Object> reqData, <Object> destObj)
    + +
      Parses form input, applies check functions and stores the values + if the form does validate. Otherwise this method returns false + without saving so that the form can be reprinted with error messages.
    + + + + +
      + Parameters: + +
        reqData - input from form +
      + +
        destObj - object whose values should be chanegd +
      + +
    + + + + +
      + Returns: +
        + False if one of the checks failed, true if the element was saved correctly. +
      +
    + + + + + +
    + + +

    hasError

    +
    Boolean hasError()
    + +
      Returns true if this instance of jala.Form holds a jala.Form.Tracker + instance and at least one error has been set on this tracker.
    + + + + + + + +
      + Returns: +
        + true if an error has been encountered. +
      +
    + + + + + +
    + + +

    id_macro

    +
    String id_macro()
    + +
      Returns the id (equal to the name) of the form
    + + + + + + + +
      + Returns: +
        + The id of this Form instance +
      +
    + + + + + +
    + + +

    listComponents

    +
    Array listComponents()
    + +
      Returns an array containing the components + of this jala.Form instance.
    + + + + + + + +
      + Returns: +
        + The components of this jala.Form instance. +
      +
    + + + + + +
    + + +

    name_macro

    +
    String name_macro()
    + +
      Returns the name (equal to the id) of the form
    + + + + + + + +
      + Returns: +
        + The name of this Form instance +
      +
    + + + + + +
    + + +

    open_macro

    +
    void open_macro()
    + +
      Writes the form opening tag to response
    + + + + + + + + + + + +
    + + +

    render

    +
    void render()
    + +
      Renders this form including all components to response.
    + + + + + + + + + + + +
    + + +

    render_macro

    +
    void render_macro()
    + +
      Renders the whole form to response
    + + + + + + + + + + + +
    + + +

    renderAsString

    +
    String renderAsString(param)
    + +
      renders the form as a string
    + + + + + + + +
      + Returns: +
        + rendered form +
      +
    + + + + + +
    + + +

    save

    +
    void save(<jala.Form.Tracker> tracker, <Object> destObj)
    + +
      Sets the parsed values on an object. By default the internally + stored tracker and data objects are used, but those may be + overridden here.
    + + + + +
      + Parameters: + +
        tracker - (optional) tracker object holding parsed data from form input. +
      + +
        destObj - (optional) object whose values will be changed. By default the dataObj passed to the constructor or to setDataObject is used. +
      + +
    + + + + + + + + +
    + + +

    setClassName

    +
    void setClassName(<String> newClassName)
    + +
      Sets an extra classname for this form instance
    + + + + +
      + Parameters: + +
        newClassName - new classname +
      + +
    + + + + + + + + +
    + + +

    setDataObject

    +
    void setDataObject(newDataObj)
    + +
      Sets the data object which is being edited by this form. This object + is used to get the default values when first printing the form and + - if no other object is provided - receives the changed values in save.
    + + + + +
      + Parameters: + +
        dataObj - The object which is being edited by this form. +
      + +
    + + + + + + + + + + +
    + + +

    setErrorMessage

    +
    void setErrorMessage(<String> newErrorMessage)
    + +
      Sets the general error message printed above the form if any + of the components didn't validate.
    + + + + +
      + Parameters: + +
        newErrorMessage - error message +
      + +
    + + + + + + + + +
    + + +

    setTracker

    +
    void setTracker(<jala.Form.Tracker> newTracker)
    + +
      Sets the tracker object this form instance uses for collecting + error messages and parsed values.
    + + + + +
      + Parameters: + +
        newTracker - +
      + +
    + + + + + + + + +
    + + +

    validate

    +
    jala.Form.Tracker validate(<Object> reqData)
    + +
      Validates user input from a submitted form by calling each + component's validate method.
    + + + + +
      + Parameters: + +
        reqData - Optional submitted form data. If not specified req.data is used. +
      + +
    + + + + +
      + Returns: +
        + tracker object with error fields set. +
      +
    + + + + + +
    + + +

    create

    +
    <static> jala.Form create(<Object> config, dataObj)
    + +
      Parses a plain javascript object tree and configures a + new jala.Form instance according to the properties. + Propertynames are matched with constants and setter-functions, + the property "type" is used to create new component objects.
    + + + + +
      + Parameters: + +
        config - object tree containing config +
      + +
    + + + + +
      + Returns: +
        + A newly created jala.Form instance based on the config specified +
      +
    + + + + + +
    + + +

    extend

    +
    <static> void extend(<Function> subClass, <Function> superClass)
    + +
      Utility to set up the prototype, constructor, superclass and superconstructor + properties to support an inheritance strategy that can chain constructors and methods.
    + + + + +
      + Parameters: + +
        subClass - the object which inherits superClass' functions +
      + +
        superClass - the object to inherit +
      + +
    + + + + + + + + +
    + + +

    isEmail

    +
    <static> String isEmail(<String> name, <String> value, <Object> reqData, <jala.Form> formObj)
    + +
      Static validator function to test values for being a valid email address.
    + + + + +
      + Parameters: + +
        name - name of the property being validated. +
      + +
        value - value in form input +
      + +
        reqData - the whole request-data-object, in case properties depend on each other +
      + +
        formObj - instance of jala.Form +
      + +
    + + + + +
      + Returns: +
        + Error message or null +
      +
    + + + + + +
    + + +

    isUrl

    +
    <static> String isUrl(<String> name, <String> value, <Object> reqData, <jala.Form> formObj)
    + +
      Static validator function to test values for being a valid url.
    + + + + +
      + Parameters: + +
        name - name of the property being validated. +
      + +
        value - value in form input +
      + +
        reqData - the whole request-data-object, in case properties depend on each other +
      + +
        formObj - instance of jala.Form +
      + +
    + + + + +
      + Returns: +
        + Error message or null +
      +
    + + + + + +
    + + +

    propertyGetter

    +
    <static> Object propertyGetter(<String> name, value)
    + +
      static default getter function used to return a field + from the data object.
    + + + + +
      + Parameters: + +
        name - Name of the property. +
      + +
    + + + + + + + + +
    + + +

    propertySetter

    +
    <static> void propertySetter(<String> name, <Object> value)
    + +
      static default setter function used to change a field + of the data object.
    + + + + +
      + Parameters: + +
        name - Name of the property. +
      + +
        value - New value of the property. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.History.html b/modules/jala/docs/jala.History.html new file mode 100644 index 00000000..75d19aec --- /dev/null +++ b/modules/jala/docs/jala.History.html @@ -0,0 +1,635 @@ + + + + + +jala.History + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.History

    +
    Object
    +   |
    +   +--jala.History
    +
    + + +
    +
    + +
    class + jala.History + + +
    + +

    +
    This class is an implementation of a Browser-like history + stack suitable to use in any Helma application. The difference + to a Browser's history is that this implementation ignores + POST requests and checks if Urls in the stack are still valid to + prevent eg. redirections to a HopObject's url that has been deleted. + Plus it is capable to create new "intermediate" history-stacks + and this way maintain a "history of histories" which is needed for + eg. editing sessions in a popup window that should use their own + request history without interfering with the history of the + main window. +
    Defined in History.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.History + + () + +
    +             + Constructs a new History object. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + add() + +
    +            + Initializes a new history stack, adds + it to the array of stacks (which makes it + the default one to use for further requests) + and records the current request Url. +
    + +  void + + + + + clear() + +
    +            + Clears the currently active history stack +
    + +  String + + + + + dump() + +
    +            + Returns the contents of all history stacks + as string +
    + +  String + + + + + peek(<Number> offset) + +
    +            + Retrieves the request Url at the given position + in the current history stack. +
    + +  String + + + + + pop(<Number> offset) + +
    +            + Retrieves the first valid request Url in history + stack starting with a given offset. +
    + +  void + + + + + push() + +
    +            + Records a request Url in the currently active + history stack. +
    + +  void + + + + + redirect(<Number> offset) + +
    +            + Redirects the client back to the first valid + request in history. +
    + +  void + + + + + remove() + +
    +            + Removes the current history stack +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.History

    +
    jala.History()
    + + +
      + Constructs a new History object. +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    add

    +
    void add()
    + +
      Initializes a new history stack, adds + it to the array of stacks (which makes it + the default one to use for further requests) + and records the current request Url.
    + + + + + + + + + + + +
    + + +

    clear

    +
    void clear()
    + +
      Clears the currently active history stack
    + + + + + + + + + + + +
    + + +

    dump

    +
    String dump()
    + +
      Returns the contents of all history stacks + as string
    + + + + + + + +
      + Returns: +
        + The history stacks as string +
      +
    + + + + + +
    + + +

    peek

    +
    String peek(<Number> offset)
    + +
      Retrieves the request Url at the given position + in the current history stack. If no offset is given + the last Url in the stack is returned. This method + does not alter the stack contents!
    + + + + +
      + Parameters: + +
        offset - The index position in history stack to start searching at +
      + +
    + + + + +
      + Returns: +
        + The Url of the request +
      +
    + + + + + +
    + + +

    pop

    +
    String pop(<Number> offset)
    + +
      Retrieves the first valid request Url in history + stack starting with a given offset. The default offset is 1. + Any valid Url found is removed from the stack, therefor + this method alters the contents of the history stack.
    + + + + +
      + Parameters: + +
        offset - The index position in history stack to start searching at +
      + +
    + + + + +
      + Returns: +
        + The Url of the request +
      +
    + + + + + +
    + + +

    push

    +
    void push()
    + +
      Records a request Url in the currently active + history stack.
    + + + + + + + + + + + +
    + + +

    redirect

    +
    void redirect(<Number> offset)
    + +
      Redirects the client back to the first valid + request in history. Please mind that searching for + a valid Url starts at history.length - 2.
    + + + + +
      + Parameters: + +
        offset - The index position in the stack to start searching at +
      + +
    + + + + + + + + +
    + + +

    remove

    +
    void remove()
    + +
      Removes the current history stack
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.HtmlDocument.html b/modules/jala/docs/jala.HtmlDocument.html new file mode 100644 index 00000000..190b24e8 --- /dev/null +++ b/modules/jala/docs/jala.HtmlDocument.html @@ -0,0 +1,483 @@ + + + + + +jala.HtmlDocument + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.HtmlDocument

    +
    Object
    +   |
    +   +--jala.HtmlDocument
    +
    + + +
    +
    + +
    class + jala.HtmlDocument + + +
    + +

    +
    This class provides easy access to the elements of + an arbitrary HTML document. By using TagSoup, Dom4J and Jaxen + even invalid HTML can be parsed, turned into an object tree + and easily be processed with XPath expressions. +
    Defined in HtmlDocument.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.HtmlDocument + + (<String> source) + +
    +             + Construct a new HTML document. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Array + + + + + getAll(<String> elementName) + +
    +            + Retrieves all elements by name from the document. +
    + +  Array + + + + + getLinks() + +
    +            + Get all link elements of the HTML document. +
    + +  org.dom4j.tree.DefaultElement + + + + + scrape(<String> xpathExpr) + +
    +            + Get all document nodes from an XPath expression. +
    + +  String + + + + + toString() + +
    +            + Get a string representation of the HTML document. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.HtmlDocument

    +
    jala.HtmlDocument(<String> source)
    + + +
      + Construct a new HTML document. +
    + + + +
      + Parameters: + +
        source - The HTML source code. +
      + + +
    + + + + +
      + Returns: +
        + A new HTML document. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getAll

    +
    Array getAll(<String> elementName)
    + +
      Retrieves all elements by name from the document. + The returned object structure is compatible for usage + in jala.XmlWriter.
    + + + + +
      + Parameters: + +
        elementName - The name of the desired element +
      + +
    + + + + +
      + Returns: +
        + The list of available elements in the document +
      +
    + + + + + +
    + + +

    getLinks

    +
    Array getLinks()
    + +
      Get all link elements of the HTML document.
    + + + + + + + +
      + Returns: +
        + A list of link elements. +
      +
    + + + + + +
    + + +

    scrape

    +
    org.dom4j.tree.DefaultElement scrape(<String> xpathExpr)
    + +
      Get all document nodes from an XPath expression.
    + + + + +
      + Parameters: + +
        xpathExpr - An XPath expression. +
      + +
    + + + + +
      + Returns: +
        + A list of HTML elements. +
      +
    + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Get a string representation of the HTML document.
    + + + + + + + +
      + Returns: +
        + A string representation of the HTML document. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.I18n.html b/modules/jala/docs/jala.I18n.html new file mode 100644 index 00000000..633ca818 --- /dev/null +++ b/modules/jala/docs/jala.I18n.html @@ -0,0 +1,951 @@ + + + + + +jala.I18n + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.I18n

    +
    Object
    +   |
    +   +--jala.I18n
    +
    + + +
    +
    + +
    class + jala.I18n + + +
    + +

    +
    This class provides various functions and macros for + internationalization of Helma applications. +
    Defined in I18n.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.I18n + + () + +
    +             + Constructs a new instance of jala.I18n +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + formatMessage(<String> message, <Array> values) + +
    +            + Converts the message passed as argument into an instance + of java.text.MessageFormat, and formats it using the + replacement values passed. +
    + +  Object + + + + + getCatalog(locale) + +
    +            + Helper method to get the message catalog + corresponding to the actual locale. +
    + +  java.util.Locale + + + + + getLocale(localeId) + +
    +            + Returns the locale for the given id, which is expected to follow + the form language[_COUNTRY][_variant], where language + is a valid ISO Language Code (eg. +
    + +  Function + + + + + getLocaleGetter() + +
    +            + Get the method for retrieving the locale. +
    + +  Object + + + + + getMessages() + +
    +            + Get the message object. +
    + +  String + + + + + gettext(<String> key ) + +
    +            + Returns a localized message for the message key passed as + argument. +
    + +  String + + + + + markgettext(<String> key) + +
    +            + A simple proxy method which is used to mark a message string + for the i18n parser as to be translated. +
    + +  String + + + + + message_macro(param) + +
    +            + Returns a translated message. +
    + +  String + + + + + ngettext(<String> singularKey, <String> pluralKey, <Number> amount ) + +
    +            + Returns a localized message for the message key passed as + argument. +
    + +  void + + + + + setHandler(<Object> handler) + +
    +            + Set (overwrite) the default handler containing + the messages (ie. +
    + +  void + + + + + setLocaleGetter(<Function> func) + +
    +            + Set the method for retrieving the locale. +
    + +  void + + + + + setMessages(<Object> msgObject) + +
    +            + Overwrite the default object containing + the messages (ie. +
    + +  String + + + + + translate(singularKey, pluralKey, <Number> amount) + +
    +            + Tries to "translate" the given message key into a localized + message. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.I18n

    +
    jala.I18n()
    + + +
      + Constructs a new instance of jala.I18n +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    formatMessage

    +
    String formatMessage(<String> message, <Array> values)
    + +
      Converts the message passed as argument into an instance + of java.text.MessageFormat, and formats it using the + replacement values passed.
    + + + + +
      + Parameters: + +
        message - The message to format +
      + +
        values - An optional array containing replacement values +
      + +
    + + + + +
      + Returns: +
        + The formatted message or, if the formatting fails, the message passed as argument. +
      +
    + + + + +
      + See:
        - http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html
      +
    + + +
    + + +

    getCatalog

    +
    Object getCatalog(locale)
    + +
      Helper method to get the message catalog + corresponding to the actual locale.
    + + + + + + + +
      + Returns: +
        + The message catalog. +
      +
    + + + + + +
    + + +

    getLocale

    +
    java.util.Locale getLocale(localeId)
    + +
      Returns the locale for the given id, which is expected to follow + the form language[_COUNTRY][_variant], where language + is a valid ISO Language Code (eg. "de"), COUNTRY a valid ISO + Country Code (eg. "AT"), and variant an identifier for the variant to use.
    + + + + + + + +
      + Returns: +
        + The locale for the given id +
      +
    + + + + + +
    + + +

    getLocaleGetter

    +
    Function getLocaleGetter()
    + +
      Get the method for retrieving the locale.
    + + + + + + + +
      + Returns: +
        + The getter method +
      +
    + + + + + +
    + + +

    getMessages

    +
    Object getMessages()
    + +
      Get the message object.
    + + + + + + + +
      + Returns: +
        + The object containing the messages +
      +
    + + + + + +
    + + +

    gettext

    +
    String gettext(<String> key )
    + +
      Returns a localized message for the message key passed as + argument. If no localization is found, the message key + is returned. Any additional arguments passed to this function + will be used as replacement values during message rendering. + To reference these values the message can contain placeholders + following "{number}" notation, where number must + match the number of the additional argument (starting with zero).
    + + + + +
      + Parameters: + +
        key - The message to localize +
      + +
    + + + + +
      + Returns: +
        + The translated message +
      +
    + + + + + + + +
    + + +

    markgettext

    +
    String markgettext(<String> key)
    + +
      A simple proxy method which is used to mark a message string + for the i18n parser as to be translated.
    + + + + +
      + Parameters: + +
        key - The message that should be seen by the i18n parser as to be translated. +
      + +
    + + + + +
      + Returns: +
        + The message in unmodified form +
      +
    + + + + + +
    + + +

    message_macro

    +
    String message_macro(param)
    + +
      Returns a translated message. The following macro attributes + are accepted: +
        +
      • text: The message to translate (required)
      • +
      • plural: The plural form of the message
      • +
      • values: A list of replacement values. Use a comma to separate more + than one value. Each value is either interpreted as a global property + (if it doesn't containg a dot) or as a property name of the given macro + handler object (eg. "user.name"). If the value of the property is a + HopObject or an Array this macro uses the size() resp. length of the + object, otherwise the string representation of the object will be used.
      • +
    + + + + + + + +
      + Returns: +
        + The translated message +
      +
    + + + + + + + +
    + + +

    ngettext

    +
    String ngettext(<String> singularKey, <String> pluralKey, <Number> amount )
    + +
      Returns a localized message for the message key passed as + argument. In contrast to gettext() this method + can handle plural forms based on the amount passed as argument. + If no localization is found, the appropriate message key is + returned. Any additional arguments passed to this function + will be used as replacement values during message rendering. + To reference these values the message can contain placeholders + following "{number}" notation, where number must + match the number of the additional argument (starting with zero).
    + + + + +
      + Parameters: + +
        singularKey - The singular message to localize +
      + +
        pluralKey - The plural form of the message to localize +
      + +
        amount - The amount which is used to determine whether the singular or plural form of the message should be returned. +
      + +
    + + + + +
      + Returns: +
        + The translated message +
      +
    + + + + + + + +
    + + +

    setHandler

    +
    void setHandler(<Object> handler)
    + +
      Set (overwrite) the default handler containing + the messages (ie. a vanilla EcmaScript object).
    + + + + +
      + Parameters: + +
        handler - The handler containing the message object +
      + +
    + + + + + + + + + + +
    + + +

    setLocaleGetter

    +
    void setLocaleGetter(<Function> func)
    + +
      Set the method for retrieving the locale.
    + + + + +
      + Parameters: + +
        func - The getter method +
      + +
    + + + + + + + + +
    + + +

    setMessages

    +
    void setMessages(<Object> msgObject)
    + +
      Overwrite the default object containing + the messages (ie. a vanilla EcmaScript object).
    + + + + +
      + Parameters: + +
        msgObject - The object containing the messages +
      + +
    + + + + + + + + +
    + + +

    translate

    +
    String translate(singularKey, pluralKey, <Number> amount)
    + +
      Tries to "translate" the given message key into a localized + message.
    + + + + +
      + Parameters: + +
        amount - A number to determine whether to use the singular or plural form of the message +
      + +
        key - The message to translate (required) +
      + +
        plural - The plural form of the message to translate +
      + +
    + + + + +
      + Returns: +
        + The localized message or the appropriate key if no localized message was found +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.ImageFilter.html b/modules/jala/docs/jala.ImageFilter.html new file mode 100644 index 00000000..5451df17 --- /dev/null +++ b/modules/jala/docs/jala.ImageFilter.html @@ -0,0 +1,510 @@ + + + + + +jala.ImageFilter + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.ImageFilter

    +
    Object
    +   |
    +   +--jala.ImageFilter
    +
    + + +
    +
    + +
    class + jala.ImageFilter + + +
    + +

    +
    This class provides several image manipulating + methods. Most of this filter library is based on filters created + by Janne Kipinä for JAlbum. For more information have a look + at http://www.ratol.fi/~jakipina/java/ +
    Defined in ImageFilter.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.ImageFilter + + (<Object> img) + +
    +             + Constructs a new ImageFilter object +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + gaussianBlur(<Number> radius, <Number> amount) + +
    +            + Performs a gaussian blur operation on the image +
    + +  byte[] + + + + + getBytes() + +
    +            + Returns the wrapped image as byte array, to use eg. +
    + +  helma.image.ImageWrapper + + + + + getImage() + +
    +            + Returns the image that has been worked on +
    + +  void + + + + + sharpen(<Number> amount) + +
    +            + Sharpens the image using a plain sharpening kernel. +
    + +  void + + + + + unsharpMask(<Number> radius, <Number> amount) + +
    +            + Performs an unsharp mask operation on the image +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.ImageFilter

    +
    jala.ImageFilter(<Object> img)
    + + +
      + Constructs a new ImageFilter object +
    + + + +
      + Parameters: + +
        img - Either
        • an instance of helma.image.ImageWrapper
        • the path to the image file as String
        • an instance of helma.File representing the image file
        • an instance of java.io.File representing the image file
        +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    gaussianBlur

    +
    void gaussianBlur(<Number> radius, <Number> amount)
    + +
      Performs a gaussian blur operation on the image
    + + + + +
      + Parameters: + +
        radius - The radius +
      + +
        amount - The amount +
      + +
    + + + + + + + + +
    + + +

    getBytes

    +
    byte[] getBytes()
    + +
      Returns the wrapped image as byte array, to use eg. in conjunction + with res.writeBinary()
    + + + + + + + +
      + Returns: +
        + The wrapped image as byte array +
      +
    + + + + + +
    + + +

    getImage

    +
    helma.image.ImageWrapper getImage()
    + +
      Returns the image that has been worked on
    + + + + + + + +
      + Returns: +
        + An instance of helma.image.ImageWrapper +
      +
    + + + + + +
    + + +

    sharpen

    +
    void sharpen(<Number> amount)
    + +
      Sharpens the image using a plain sharpening kernel.
    + + + + +
      + Parameters: + +
        amount - The amount of sharpening to apply +
      + +
    + + + + + + + + +
    + + +

    unsharpMask

    +
    void unsharpMask(<Number> radius, <Number> amount)
    + +
      Performs an unsharp mask operation on the image
    + + + + +
      + Parameters: + +
        radius - The radius +
      + +
        amount - The amount +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.IndexManager.Job.html b/modules/jala/docs/jala.IndexManager.Job.html new file mode 100644 index 00000000..a1db9cc8 --- /dev/null +++ b/modules/jala/docs/jala.IndexManager.Job.html @@ -0,0 +1,447 @@ + + + + + +jala.IndexManager.Job + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.IndexManager.Job

    +
    Object
    +   |
    +   +--jala.IndexManager.Job
    +
    + + +
    +
    + +
    class + jala.IndexManager.Job + + +
    + +

    +
    Instances of this class represent a single index + manipulation job to be processed by the index manager. +
    Defined in IndexManager.js

    See:

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Objectcallback +
    +           The data needed to process this job.
    +  Datecreatetime +
    +           The date and time at which this job was created.
    +  Numbererrors +
    +           An internal error counter which is increased whenever processing + the job failed.
    +  Numbertype +
    +           The type of the job
    + <static>  <final> NumberADD +
    +           Constant defining an add job
    + <static>  <final> NumberOPTIMIZE +
    +           Constant defining an optimizing job
    + <static>  <final> NumberREMOVE +
    +           Constant defining a removal job
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.IndexManager.Job + + (<Number> type, callback) + +
    +             + Creates a new Job instance. +
    + + + +  + + + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    callback

    +
    Object callback
    +
      + The data needed to process this job. For adding jobs this property + must contain the helma.Search.Document instance to add to + the index. For removal job this property must contain the unique identifier + of the document that should be removed from the index. For optimizing + jobs this property is null. + +
    +
    + + +

    createtime

    +
    Date createtime
    +
      + The date and time at which this job was created. + +
    +
    + + +

    errors

    +
    Number errors
    +
      + An internal error counter which is increased whenever processing + the job failed. + +
    +
    + + +

    type

    +
    Number type
    +
      + The type of the job + +
    +
    + + +

    ADD

    +
    <static> <final> Number ADD
    + +
    + + +

    OPTIMIZE

    +
    <static> <final> Number OPTIMIZE
    + +
    + + +

    REMOVE

    +
    <static> <final> Number REMOVE
    + +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.IndexManager.Job

    +
    jala.IndexManager.Job(<Number> type, callback)
    + + +
      + Creates a new Job instance. +
    + + + +
      + Parameters: + +
        type - The type of job, which can be either jala.IndexManager.Job.ADD, jala.IndexManager.Job.REMOVE or jala.IndexManager.Job.OPTIMIZE. +
      + +
        id - The Id of the job +
      + +
        data - The data needed to process the job. +
      + + +
    + + + + +
      + Returns: +
        + A newly created Job instance. +
      +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.IndexManager.html b/modules/jala/docs/jala.IndexManager.html new file mode 100644 index 00000000..0c198138 --- /dev/null +++ b/modules/jala/docs/jala.IndexManager.html @@ -0,0 +1,615 @@ + + + + + +jala.IndexManager + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.IndexManager

    +
    Object
    +   |
    +   +--jala.IndexManager
    +
    + + +
    +
    + +
    class + jala.IndexManager + + +
    + +

    +
    This class basically sits on top of a helma.Search.Index instance + and provides methods for adding, removing and optimizing the underlying index. + All methods generate jobs that are put into an internal queue which is + processed asynchronously by a separate worker thread. This means all calls + to add(), remove() and optimize() will return immediately, but the changes to + the index will be done within a short delay. Please keep in mind to change the + status of this IndexManager instance to REBUILDING before starting to rebuild + the index, as this ensures that all add/remove/optimize jobs will stay in the + queue and will only be processed after switching the status back to NORMAL. + This ensures that objects that have been modified during a rebuilding process + are re-indexed properly afterwards. +
    Defined in IndexManager.js

    See:

      - helma.Search.createIndex
    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.IndexManager.Job
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> NumberMAXTRIES +
    +           Constant defining the maximum number of tries to add/remove + an object to/from the underlying index.
    + <static>  <final> NumberNORMAL +
    +           Constant defining normal mode of this index manager.
    + <static>  <final> NumberREBUILDING +
    +           Constant defining rebuilding mode of this index manager.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.IndexManager + + (<String> name, <helma.File> dir, <String> lang) + +
    +             + Constructs a new IndexManager object. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Boolean + + + + + add(<helma.Search.Document> doc) + +
    +            + Queues the document object passed as argument for addition to the underlying + index. +
    + +  void + + + + + log() + +
    +            + Helper function that prefixes every log message with + the name of the IndexManager. +
    + +  Boolean + + + + + optimize() + +
    +            + Queues the optimization of the underlying index. +
    + +  Boolean + + + + + remove(<Number> id) + +
    +            + Queues the removal of all index documents whose identifier value ("id" by default) + matches the number passed as argument. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    MAXTRIES

    +
    <static> <final> Number MAXTRIES
    +
      + Constant defining the maximum number of tries to add/remove + an object to/from the underlying index. + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + +

    NORMAL

    +
    <static> <final> Number NORMAL
    + +
    + + +

    REBUILDING

    +
    <static> <final> Number REBUILDING
    +
      + Constant defining rebuilding mode of this index manager. + +

      +

      +
      See Also:
      Constant Field Values
      + + + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.IndexManager

    +
    jala.IndexManager(<String> name, <helma.File> dir, <String> lang)
    + + +
      + Constructs a new IndexManager object. +
    + + + +
      + Parameters: + +
        name - The name of the index, which is the name of the directory the index already resides or will be created in. +
      + +
        dir - The base directory where this index's directory is already existing or will be created in. +
      + +
        lang - The language of the documents in this index. This leads to the proper Lucene analyzer being used for indexing documents. +
      + + +
    + + + + + + + + +
      +See:
        - helma.Search.createIndex
      +
    + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    add

    +
    Boolean add(<helma.Search.Document> doc)
    + +
      Queues the document object passed as argument for addition to the underlying + index. This includes that all existing documents with the same identifier will + be removed before the object passed as argument is added.
    + + + + +
      + Parameters: + +
        doc - The document object that should be added to the underlying index. +
      + +
    + + + + +
      + Returns: +
        + True if the job was added successfully to the internal queue, false otherwise. +
      +
    + + + + +
      + See:
        - helma.Search.Document
      +
    + + +
    + + +

    log

    +
    void log()
    + +
      Helper function that prefixes every log message with + the name of the IndexManager.
    + + + + +
      + Parameters: + +
        level - An optional logging level. Accepted values +
      + +
        msg - The log message are "debug", "info", "warn" and "error". +
      + +
    + + + + + + + + +
    + + +

    optimize

    +
    Boolean optimize()
    + +
      Queues the optimization of the underlying index.
    + + + + + + + +
      + Returns: +
        + True if the optimizing job was added, false otherwise, which means that there is already an optimizing job waiting in the queue. +
      +
    + + + + + +
    + + +

    remove

    +
    Boolean remove(<Number> id)
    + +
      Queues the removal of all index documents whose identifier value ("id" by default) + matches the number passed as argument.
    + + + + +
      + Parameters: + +
        id - The identifier value +
      + +
    + + + + +
      + Returns: +
        + True if the removal job was added successfully to the queue, false otherwise. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.ListRenderer.ArrayList.html b/modules/jala/docs/jala.ListRenderer.ArrayList.html new file mode 100644 index 00000000..fe0c4af7 --- /dev/null +++ b/modules/jala/docs/jala.ListRenderer.ArrayList.html @@ -0,0 +1,547 @@ + + + + + +jala.ListRenderer.ArrayList + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.ListRenderer.ArrayList

    +
    Object
    +   |
    +   +--jala.ListRenderer.ArrayList
    +
    + + +
    +
    + +
    class + jala.ListRenderer.ArrayList + + +
    + +

    +
    A simple wrapper around an array to use in conjunction + with jala.ListRenderer. This wrapper can either handle complete arrays + or subsections of an array. In the latter case the wrapper needs offset + and total size information as argument to mimick a complete array. +
    Defined in ListRenderer.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Numberlength +
    +           The length of this ArrayList instance.
    +  Numberoffset +
    +           The offset of this ArrayList instance.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.ListRenderer.ArrayList + + (<Array> arr, <Number> offset, <Number> total) + +
    +             + Creates a new ArrayList instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Object + + + + + get(<Number> idx) + +
    +            + Returns the element at the index position passed + as argument. +
    + +  Boolean + + + + + isSubset() + +
    +            + Returns true if this ArrayList is a subsection of a bigger array +
    + +  Number + + + + + size() + +
    +            + Returns the size of this ArrayList, which is either + the length of the wrapped array or the total size + passed as argument to the constructor (in case the wrapped + array is just a subsection). +
    + +  Number + + + + + subsetSize() + +
    +            + Returns the actual size of this ArrayList's wrapped array. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    length

    +
    Number length
    +
      + The length of this ArrayList instance. + +
    +
    + + +

    offset

    +
    Number offset
    +
      + The offset of this ArrayList instance. This might be > zero for + ArrayList instances wrapping just a subsection, that is + mimicking a bigger list. + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.ListRenderer.ArrayList

    +
    jala.ListRenderer.ArrayList(<Array> arr, <Number> offset, <Number> total)
    + + +
      + Creates a new ArrayList instance. +
    + + + +
      + Parameters: + +
        arr - The array (or a subsection of an array) to wrap +
      + +
        offset - An optional offset to use (mandatory if the array is just a subsection). +
      + +
        total - An optional total size of the array. This argument is mandatory if the wrapped array is just a subsection. +
      + + +
    + + + + +
      + Returns: +
        + A newly created ArrayList instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    get

    +
    Object get(<Number> idx)
    + +
      Returns the element at the index position passed + as argument. If the wrapped array is just a subsection + the index position passed will be corrected using + the offset.
    + + + + +
      + Parameters: + +
        idx - The index position of the element to return +
      + +
    + + + + +
      + Returns: +
        + The element at the given index position +
      +
    + + + + + +
    + + +

    isSubset

    +
    Boolean isSubset()
    + +
      Returns true if this ArrayList is a subsection of a bigger array
    + + + + + + + +
      + Returns: +
        + True if this ArrayList is a subsection of a bigger array +
      +
    + + + + + +
    + + +

    size

    +
    Number size()
    + +
      Returns the size of this ArrayList, which is either + the length of the wrapped array or the total size + passed as argument to the constructor (in case the wrapped + array is just a subsection).
    + + + + + + + +
      + Returns: +
        + The size of this ArrayList instance +
      +
    + + + + + +
    + + +

    subsetSize

    +
    Number subsetSize()
    + +
      Returns the actual size of this ArrayList's wrapped array.
    + + + + + + + +
      + Returns: +
        + The actual size of this ArrayList's wrapped array. +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.ListRenderer.html b/modules/jala/docs/jala.ListRenderer.html new file mode 100644 index 00000000..7a9324be --- /dev/null +++ b/modules/jala/docs/jala.ListRenderer.html @@ -0,0 +1,2339 @@ + + + + + +jala.ListRenderer + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.ListRenderer

    +
    Object
    +   |
    +   +--jala.ListRenderer
    +
    + + +
    +
    + +
    class + jala.ListRenderer + + +
    + +

    +

    Defined in ListRenderer.js

    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.ListRenderer.ArrayList
    +  + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> ObjectdefaultRenderer +
    +           Default Renderer object containing functions + used for rendering different list items (eg.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.ListRenderer + + (<HopObject|ArrayList|Array> coll, <Object> renderer) + +
    +             + +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Number + + + + + currentEnd_macro() + +
    +            + Returns the end item number in the current page +
    + +  Number + + + + + currentPage_macro() + +
    +            + Returns the current page number +
    + +  Number + + + + + currentStart_macro() + +
    +            + Returns the start item number in the current page +
    + +  String + + + + + getBaseHref() + +
    +            + Returns the base href of this ListRenderer instance +
    + +  HopObject|Array + + + + + getCollection() + +
    +            + Returns the collection this ListRenderer instance operates on +
    + +  Number + + + + + getCurrentPage() + +
    +            + Returns the current page index. +
    + +  Number + + + + + getEndIndex() + +
    +            + Returns the zero-based index position of the last item of the current page + in the collection this ListRenderer operates on. +
    + +  Number + + + + + getItemSkin() + +
    +            + Returns the name of the skin rendered for a single list item +
    + +  String + + + + + getList(<Object> param) + +
    +            + Returns the rendered list of collection items as string +
    + +  Number + + + + + getMaxPages() + +
    +            + Returns the maximum number of pages handled by this ListRenderer instance +
    + +  String + + + + + getNextLink(<Object> param) + +
    +            + Returns a rendered link to the previous page as string. +
    + +  String + + + + + getPageHref(<Number> page) + +
    +            + Returns the href of a page. +
    + +  String + + + + + getPageNavigation(<Object> param) + +
    +            + Returns the rendered page navigation bar as string +
    + +  Number + + + + + getPageSize() + +
    +            + Returns the number of items displayed on one page +
    + +  String + + + + + getPrevLink(<Object> param) + +
    +            + Returns a rendered link to the previous page as string. +
    + +  Object + + + + + getRenderer() + +
    +            + Returns the renderer used by this ListRenderer instance +
    + +  Number + + + + + getStartIndex() + +
    +            + Returns the zero-based index position of the first item of the current page + in the collection this ListRenderer operates on. +
    + +  Number + + + + + getTotalPages() + +
    +            + Returns the total number of pages handled by this ListRenderer instance + (which is the collection size divided by the page size). +
    + +  String + + + + + getUrlParameterName() + +
    +            + Returns the name of the URL parameter name containing the index + of the page to display +
    + +  String + + + + + getUrlParameters() + +
    +            + Returns any additional URL parameters included in every navigation link + rendered by this ListRenderer instance. +
    + +  Number + + + + + limit_macro(<Object> param) + +
    +            + Either renders the maximum number of items per page, or + sets the limit to a given number. +
    + +  String + + + + + nextLink_macro(<Object> param) + +
    +            + Returns a rendered link to the next page. +
    + +  String + + + + + pageNavigation_macro(<Object> param) + +
    +            + Returns the rendered page navigation bar. +
    + +  String + + + + + prevLink_macro(<Object> param) + +
    +            + Returns a rendered link to the previous page. +
    + +  void + + + + + render_macro(<Object> param) + +
    +            + Renders the current page of this list. +
    + +  void + + + + + renderList(<Object> param) + +
    +            + Renders the list of items for one page directly to response. +
    + +  String + + + + + renderListAsString(<Object> param) + +
    +            + Returns the rendered list of collection items as string +
    + +  void + + + + + renderNextLink(<Object> param) + +
    +            + Renders a link to the next page directly to response. +
    + +  String + + + + + renderNextLinkAsString(param) + +
    +            + Returns a rendered link to the previous page as string +
    + +  Object + + + + + renderPageNavigation(<Object> param) + +
    +            + Renders the page navigation bar directly to response. +
    + +  String + + + + + renderPageNavigationAsString(param) + +
    +            + Returns the rendered page navigation bar as string +
    + +  void + + + + + renderPrevLink(<Object> param) + +
    +            + Renders a link to the previous page directly to response. +
    + +  String + + + + + renderPrevLinkAsString(<Object> param) + +
    +            + Returns a rendered link to the previous page as string +
    + +  void + + + + + setBaseHref(<String> href) + +
    +            + Sets the base href of this ListRenderer instance. +
    + +  void + + + + + setCollection(<HopObject|ArrayList|Array> coll) + +
    +            + Sets the collection of this ListRenderer +
    + +  void + + + + + setItemSkin(<String> name) + +
    +            + Sets the name of the skin to render for every list item +
    + +  void + + + + + setMaxPages(<Number> pages) + +
    +            + Sets the maximum number of pages to display +
    + +  void + + + + + setPageSize(<Number> size) + +
    +            + Sets the number of items to display on a single page +
    + +  void + + + + + setRenderer(<Object> r) + +
    +            + Sets the renderer to be used by this ListRenderer instance +
    + +  void + + + + + setUrlParameterName(<String> name) + +
    +            + Sets the name of the URL parameter name containing the index of the page + to display +
    + +  void + + + + + setUrlParameters(<String> params) + +
    +            + Sets additional parameters to include in every navigation link +
    + +  Number + + + + + size_macro() + +
    +            + Returns the total number of items +
    + +  Number + + + + + totalPages_macro() + +
    +            + Returns the total number of pages +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    defaultRenderer

    +
    <static> <final> Object defaultRenderer
    +
      + Default Renderer object containing functions + used for rendering different list items (eg. page navigation, + prev/next links and list items). + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.ListRenderer

    +
    jala.ListRenderer(<HopObject|ArrayList|Array> coll, <Object> renderer)
    + + + + +
      + Parameters: + +
        coll - The collection this ListRenderer operates on, or - for backwards compatibility only - a parameter object containing the collection and any other optional configuration parameters. +
      + +
        renderer - An optional renderer to use. If this is set, any rendering method defined in this renderer overrides the default renderer. +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    currentEnd_macro

    +
    Number currentEnd_macro()
    + +
      Returns the end item number in the current page
    + + + + + + + +
      + Returns: +
        + The end item number in the current page +
      +
    + + + + + +
    + + +

    currentPage_macro

    +
    Number currentPage_macro()
    + +
      Returns the current page number
    + + + + + + + +
      + Returns: +
        + The current page number +
      +
    + + + + + +
    + + +

    currentStart_macro

    +
    Number currentStart_macro()
    + +
      Returns the start item number in the current page
    + + + + + + + +
      + Returns: +
        + The start item number in the current page +
      +
    + + + + + +
    + + +

    getBaseHref

    +
    String getBaseHref()
    + +
      Returns the base href of this ListRenderer instance
    + + + + + + + +
      + Returns: +
        + The base href of this ListRenderer instance +
      +
    + + + + + +
    + + +

    getCollection

    +
    HopObject|Array getCollection()
    + +
      Returns the collection this ListRenderer instance operates on
    + + + + + + + +
      + Returns: +
        + The collection of this ListRenderer +
      +
    + + + + + +
    + + +

    getCurrentPage

    +
    Number getCurrentPage()
    + +
      Returns the current page index. This is either the page url parameter + or the page number 1.
    + + + + + + + +
      + Returns: +
        + The current page number (starts with 1). +
      +
    + + + + + + + +
    + + +

    getEndIndex

    +
    Number getEndIndex()
    + +
      Returns the zero-based index position of the last item of the current page + in the collection this ListRenderer operates on.
    + + + + + + + +
      + Returns: +
        + The index position of the last item in the list +
      +
    + + + + + +
    + + +

    getItemSkin

    +
    Number getItemSkin()
    + +
      Returns the name of the skin rendered for a single list item
    + + + + + + + +
      + Returns: +
        + The name of the list item skin +
      +
    + + + + + +
    + + +

    getList

    +
    String getList(<Object> param)
    + +
      Returns the rendered list of collection items as string
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + The rendered list +
      +
    + + + + + + + +
    + + +

    getMaxPages

    +
    Number getMaxPages()
    + +
      Returns the maximum number of pages handled by this ListRenderer instance
    + + + + + + + +
      + Returns: +
        + The maximum number of pages +
      +
    + + + + + +
    + + +

    getNextLink

    +
    String getNextLink(<Object> param)
    + +
      Returns a rendered link to the previous page as string. For performance + reasons this method caches the rendered link in the local cache of this + ListRenderer instance.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + A rendered link to the previous page +
      +
    + + + + + + + +
    + + +

    getPageHref

    +
    String getPageHref(<Number> page)
    + +
      Returns the href of a page. If no argument is given, the href + of the current page is returned. Any URL parameters set with + setUrlParameters() are added to the href.
    + + + + +
      + Parameters: + +
        page - The optional page number to include in the href. +
      + +
    + + + + +
      + Returns: +
        + The href of the page +
      +
    + + + + + + + +
    + + +

    getPageNavigation

    +
    String getPageNavigation(<Object> param)
    + +
      Returns the rendered page navigation bar as string
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + The rendered page navigation +
      +
    + + + + + + + +
    + + +

    getPageSize

    +
    Number getPageSize()
    + +
      Returns the number of items displayed on one page
    + + + + + + + +
      + Returns: +
        + The number of items displayed on a single page +
      +
    + + + + + +
    + + +

    getPrevLink

    +
    String getPrevLink(<Object> param)
    + +
      Returns a rendered link to the previous page as string. For performance + reasons this method caches the rendered link in the local cache of this + ListRenderer instance.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + A rendered link to the previous page +
      +
    + + + + + + + +
    + + +

    getRenderer

    +
    Object getRenderer()
    + +
      Returns the renderer used by this ListRenderer instance
    + + + + + + + + + + + +
    + + +

    getStartIndex

    +
    Number getStartIndex()
    + +
      Returns the zero-based index position of the first item of the current page + in the collection this ListRenderer operates on.
    + + + + + + + +
      + Returns: +
        + The index position of the first item in the list +
      +
    + + + + + +
    + + +

    getTotalPages

    +
    Number getTotalPages()
    + +
      Returns the total number of pages handled by this ListRenderer instance + (which is the collection size divided by the page size).
    + + + + + + + +
      + Returns: +
        + The total number of pages +
      +
    + + + + + +
    + + +

    getUrlParameterName

    +
    String getUrlParameterName()
    + +
      Returns the name of the URL parameter name containing the index + of the page to display
    + + + + + + + +
      + Returns: +
        + The name of the page URL parameter name +
      +
    + + + + + +
    + + +

    getUrlParameters

    +
    String getUrlParameters()
    + +
      Returns any additional URL parameters included in every navigation link + rendered by this ListRenderer instance.
    + + + + + + + +
      + Returns: +
        + A string containing additional URL parameters +
      +
    + + + + + +
    + + +

    limit_macro

    +
    Number limit_macro(<Object> param)
    + +
      Either renders the maximum number of items per page, or + sets the limit to a given number.
    + + + + +
      + Parameters: + +
        param - Extra macro parameters:
        • to - The maximum number of items per page to be set.
        If no limit is set, this macro returns the current number of items per page. +
      + +
    + + + + +
      + Returns: +
        + The current maximum number of items per page +
      +
    + + + + + +
    + + +

    nextLink_macro

    +
    String nextLink_macro(<Object> param)
    + +
      Returns a rendered link to the next page.
    + + + + +
      + Parameters: + +
        param - Extra macro parameters:
        • type - The type of renderer to be applied.
        +
      + +
    + + + + +
      + Returns: +
        + A rendered link to the next page +
      +
    + + + + + + + +
    + + +

    pageNavigation_macro

    +
    String pageNavigation_macro(<Object> param)
    + +
      Returns the rendered page navigation bar.
    + + + + +
      + Parameters: + +
        param - Extra macro parameters:
        • type - The type of renderer to be applied.
        +
      + +
    + + + + +
      + Returns: +
        + The rendered page navigation bar +
      +
    + + + + + + + +
    + + +

    prevLink_macro

    +
    String prevLink_macro(<Object> param)
    + +
      Returns a rendered link to the previous page.
    + + + + +
      + Parameters: + +
        param - Extra macro parameters:
        • type - The type of renderer to be applied.
        +
      + +
    + + + + +
      + Returns: +
        + A rendered link to the previous page +
      +
    + + + + + + + +
    + + +

    render_macro

    +
    void render_macro(<Object> param)
    + +
      Renders the current page of this list.
    + + + + +
      + Parameters: + +
        param - Extra macro parameters:
        • skin - The name of the list skin to render for each item in the list.
        • type - The type of renderer to be applied.
        +
      + +
    + + + + + + + + + + +
    + + +

    renderList

    +
    void renderList(<Object> param)
    + +
      Renders the list of items for one page directly to response.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + + + + + + + +
    + + +

    renderListAsString

    +
    String renderListAsString(<Object> param)
    + +
      Returns the rendered list of collection items as string
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + The rendered list +
      +
    + + + + + + + +
    + + +

    renderNextLink

    +
    void renderNextLink(<Object> param)
    + +
      Renders a link to the next page directly to response.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + + + + + + + +
    + + +

    renderNextLinkAsString

    +
    String renderNextLinkAsString(param)
    + +
      Returns a rendered link to the previous page as string
    + + + + + + + +
      + Returns: +
        + A rendered link to the next page +
      +
    + + + + + + + +
    + + +

    renderPageNavigation

    +
    Object renderPageNavigation(<Object> param)
    + +
      Renders the page navigation bar directly to response. For performance reasons + this method caches the rendered page navigation in the local cache of this + ListRenderer instance.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + + + + + + + +
    + + +

    renderPageNavigationAsString

    +
    String renderPageNavigationAsString(param)
    + +
      Returns the rendered page navigation bar as string
    + + + + + + + +
      + Returns: +
        + The rendered page navigation bar +
      +
    + + + + + + + +
    + + +

    renderPrevLink

    +
    void renderPrevLink(<Object> param)
    + +
      Renders a link to the previous page directly to response.
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + + + + + + + +
    + + +

    renderPrevLinkAsString

    +
    String renderPrevLinkAsString(<Object> param)
    + +
      Returns a rendered link to the previous page as string
    + + + + +
      + Parameters: + +
        param - Object containing extra parameters (e.g. from a macro call). +
      + +
    + + + + +
      + Returns: +
        + A rendered link to the previous page +
      +
    + + + + + + + +
    + + +

    setBaseHref

    +
    void setBaseHref(<String> href)
    + +
      Sets the base href of this ListRenderer instance. All links rendered + will start with the href passed as argument
    + + + + +
      + Parameters: + +
        href - The base href to use for rendering links +
      + +
    + + + + + + + + +
    + + +

    setCollection

    +
    void setCollection(<HopObject|ArrayList|Array> coll)
    + +
      Sets the collection of this ListRenderer
    + + + + +
      + Parameters: + +
        coll - The collection this ListRenderer instance should operate on +
      + +
    + + + + + + + + +
    + + +

    setItemSkin

    +
    void setItemSkin(<String> name)
    + +
      Sets the name of the skin to render for every list item
    + + + + +
      + Parameters: + +
        name - The name of the skin to render for every list item +
      + +
    + + + + + + + + +
    + + +

    setMaxPages

    +
    void setMaxPages(<Number> pages)
    + +
      Sets the maximum number of pages to display
    + + + + +
      + Parameters: + +
        pages - The maximum number of pages to display +
      + +
    + + + + + + + + +
    + + +

    setPageSize

    +
    void setPageSize(<Number> size)
    + +
      Sets the number of items to display on a single page
    + + + + +
      + Parameters: + +
        size - The number of items to display on one page +
      + +
    + + + + + + + + +
    + + +

    setRenderer

    +
    void setRenderer(<Object> r)
    + +
      Sets the renderer to be used by this ListRenderer instance
    + + + + +
      + Parameters: + +
        r - The renderer to use +
      + +
    + + + + + + + + +
    + + +

    setUrlParameterName

    +
    void setUrlParameterName(<String> name)
    + +
      Sets the name of the URL parameter name containing the index of the page + to display
    + + + + +
      + Parameters: + +
        name - The name of the page URL parameter +
      + +
    + + + + + + + + +
    + + +

    setUrlParameters

    +
    void setUrlParameters(<String> params)
    + +
      Sets additional parameters to include in every navigation link
    + + + + +
      + Parameters: + +
        params - A string to append to every navigation URL +
      + +
    + + + + + + + + +
    + + +

    size_macro

    +
    Number size_macro()
    + +
      Returns the total number of items
    + + + + + + + +
      + Returns: +
        + The total number of items in the collection this ListRenderer instance is working on +
      +
    + + + + + +
    + + +

    totalPages_macro

    +
    Number totalPages_macro()
    + +
      Returns the total number of pages
    + + + + + + + +
      + Returns: +
        + The total number of pages available +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Mp3.Id3v1.html b/modules/jala/docs/jala.Mp3.Id3v1.html new file mode 100644 index 00000000..21dedf33 --- /dev/null +++ b/modules/jala/docs/jala.Mp3.Id3v1.html @@ -0,0 +1,1102 @@ + + + + + +jala.Mp3.Id3v1 + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Mp3.Id3v1

    +
    Object
    +   |
    +   +--jala.Mp3.Id3v1
    +
    + + +
    +
    + +
    class + jala.Mp3.Id3v1 + + +
    + +

    +
    This class represents an Id3v1 tag. +
    Defined in Mp3.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Mp3.Id3v1 + + (audioObj) + +
    +             + Constructs a new Id3v1 tag from an Mp3 file +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + copyFrom(tag) + +
    +            + Copies standard fields from another tag. +
    + +  String + + + + + getAlbum() + +
    +            + Returns the album information of the tag. +
    + +  String + + + + + getArtist() + +
    +            + Returns the artist information of the tag. +
    + +  jala.Mp3 + + + + + getAudio() + +
    +            + Returns the wrapper for the underlying audio file. +
    + +  String + + + + + getComment() + +
    +            + Returns the comment information of the tag. +
    + +  String + + + + + getGenre() + +
    +            + Returns the genre information of the tag. +
    + +  org.farng.mp3.id3.AbstractID3v1 + + + + + getJavaObject() + +
    +            + Returns the java representation of the tag, + class depends on the actual library used. +
    + +  Object + + + + + getTextContent(<String> id) + +
    +            + This method could be used to retrieve an arbitrary field + of the underlying tag. +
    + +  String + + + + + getTitle() + +
    +            + Returns the title information of the tag. +
    + +  String + + + + + getTrackNumber() + +
    +            + Returns the track number information of the tag. +
    + +  String + + + + + getYear() + +
    +            + Returns the year information of the tag. +
    + +  void + + + + + setAlbum(<String> album) + +
    +            + Sets the album information. +
    + +  void + + + + + setArtist(<String> artist) + +
    +            + Sets the artist information. +
    + +  void + + + + + setComment(<String> comment) + +
    +            + Sets the comment +
    + +  void + + + + + setGenre(<String> genre) + +
    +            + Sets the genre information. +
    + +  void + + + + + setTextContent(<String> id, val) + +
    +            + This method could be used to set an arbitrary field + of the underlying tag. +
    + +  void + + + + + setTitle(<String> title) + +
    +            + Sets the title information +
    + +  void + + + + + setTrackNumber(<Number> trackNumber) + +
    +            + Sets the track number information. +
    + +  void + + + + + setYear(<Number> year) + +
    +            + Sets the year information. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Mp3.Id3v1

    +
    jala.Mp3.Id3v1(audioObj)
    + + +
      + Constructs a new Id3v1 tag from an Mp3 file +
    + + + +
      + Parameters: + +
        mp3File - +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    copyFrom

    +
    void copyFrom(tag)
    + +
      Copies standard fields from another tag.
    + + + + +
      + Parameters: + +
        src - object with getter methods for fields album, artist, comment, title, trackNumber, genre and year. +
      + +
    + + + + + + + + +
    + + +

    getAlbum

    +
    String getAlbum()
    + +
      Returns the album information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing album name +
      +
    + + + + + +
    + + +

    getArtist

    +
    String getArtist()
    + +
      Returns the artist information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing artist name +
      +
    + + + + + +
    + + +

    getAudio

    +
    jala.Mp3 getAudio()
    + +
      Returns the wrapper for the underlying audio file.
    + + + + + + + + + + + +
    + + +

    getComment

    +
    String getComment()
    + +
      Returns the comment information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing comment +
      +
    + + + + + +
    + + +

    getGenre

    +
    String getGenre()
    + +
      Returns the genre information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing genre name +
      +
    + + + + + +
    + + +

    getJavaObject

    +
    org.farng.mp3.id3.AbstractID3v1 getJavaObject()
    + +
      Returns the java representation of the tag, + class depends on the actual library used.
    + + + + + + + + + + + +
    + + +

    getTextContent

    +
    Object getTextContent(<String> id)
    + +
      This method could be used to retrieve an arbitrary field + of the underlying tag. For Id3v1 tags all information + is available through getter and setter methods, so this + implementation always returns null.
    + + + + +
      + Parameters: + +
        id - +
      + +
    + + + + +
      + Returns: +
        + null +
      +
    + + + + + +
    + + +

    getTitle

    +
    String getTitle()
    + +
      Returns the title information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing title +
      +
    + + + + + +
    + + +

    getTrackNumber

    +
    String getTrackNumber()
    + +
      Returns the track number information of the tag.
    + + + + + + + +
      + Returns: +
        + string representing track number or null if tag doesn't contain a track number. +
      +
    + + + + + +
    + + +

    getYear

    +
    String getYear()
    + +
      Returns the year information of the tag.
    + + + + + + + +
      + Returns: +
        + string representing year +
      +
    + + + + + +
    + + +

    setAlbum

    +
    void setAlbum(<String> album)
    + +
      Sets the album information.
    + + + + +
      + Parameters: + +
        album - +
      + +
    + + + + + + + + +
    + + +

    setArtist

    +
    void setArtist(<String> artist)
    + +
      Sets the artist information.
    + + + + +
      + Parameters: + +
        artist - +
      + +
    + + + + + + + + +
    + + +

    setComment

    +
    void setComment(<String> comment)
    + +
      Sets the comment
    + + + + +
      + Parameters: + +
        comment - +
      + +
    + + + + + + + + +
    + + +

    setGenre

    +
    void setGenre(<String> genre)
    + +
      Sets the genre information. A list of genre names that are valid + for ID3v1 tags is located in jala.Mp3.GENRES.
    + + + + +
      + Parameters: + +
        genre - +
      + +
    + + + + + + + + +
    + + +

    setTextContent

    +
    void setTextContent(<String> id, val)
    + +
      This method could be used to set an arbitrary field + of the underlying tag. For Id3v1 tags all information + is available through getter and setter methods, so this + implementation does nothing.
    + + + + +
      + Parameters: + +
        id - +
      + +
        value - +
      + +
    + + + + + + + + +
    + + +

    setTitle

    +
    void setTitle(<String> title)
    + +
      Sets the title information
    + + + + +
      + Parameters: + +
        title - +
      + +
    + + + + + + + + +
    + + +

    setTrackNumber

    +
    void setTrackNumber(<Number> trackNumber)
    + +
      Sets the track number information.
    + + + + +
      + Parameters: + +
        trackNumber - +
      + +
    + + + + + + + + +
    + + +

    setYear

    +
    void setYear(<Number> year)
    + +
      Sets the year information.
    + + + + +
      + Parameters: + +
        year - +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Mp3.Id3v2.html b/modules/jala/docs/jala.Mp3.Id3v2.html new file mode 100644 index 00000000..b2b0bd1a --- /dev/null +++ b/modules/jala/docs/jala.Mp3.Id3v2.html @@ -0,0 +1,1733 @@ + + + + + +jala.Mp3.Id3v2 + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Mp3.Id3v2

    +
    Object
    +   |
    +   +--jala.Mp3.Id3v2
    +
    + + +
    +
    + +
    class + jala.Mp3.Id3v2 + + +
    + +

    +
    This class represents an Id3v2 tag. +
    Defined in Mp3.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Mp3.Id3v2 + + (audioObj) + +
    +             + Constructs a new Id3v2 tag from an Mp3 file +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + copyFrom(tag) + +
    +            + Copies standard fields from another tag. +
    + +  String + + + + + getAlbum() + +
    +            + Returns the album information of the tag. +
    + +  String + + + + + getArtist() + +
    +            + Returns the artist information of the tag. +
    + +  jala.Mp3 + + + + + getAudio() + +
    +            + Returns the wrapper for the underlying audio file. +
    + +  String + + + + + getAuthor() + +
    +            + Returns the author information of the tag. +
    + +  String + + + + + getComment() + +
    +            + Returns the comment information of the tag. +
    + +  String + + + + + getCopyright() + +
    +            + Returns the copyright information of the tag. +
    + +  String + + + + + getGenre() + +
    +            + Returns the genre information of the tag. +
    + +  helma.util.MimePart + + + + + getImage(<String> pictureType) + +
    +            + Extracts the image from the tag +
    + +  org.farng.mp3.id3.AbstractID3v2 + + + + + getJavaObject() + +
    +            + returns the java representation of the tag, + class depends on the actual library used. +
    + +  String + + + + + getSubtitle() + +
    +            + Returns the subtitle information of the tag. +
    + +  Number + + + + + getSubtype() + +
    +            + Returns the version number of this id3v2 (values 2 to 4 for id3v2.2 to id3v2.4) +
    + +  String + + + + + getTextContent(idStr) + +
    +            + This method can be used to retrieve an arbitrary text frame + of the underlying tag. +
    + +  Number + + + + + getTextEncoding() + +
    +            + Returns the text encoding used when setting values. +
    + +  String + + + + + getTitle() + +
    +            + Returns the title information of the tag. +
    + +  String + + + + + getTrackNumber() + +
    +            + Returns the track number information of the tag. +
    + +  String + + + + + getUrl() + +
    +            + Returns the Url stored in this tag +
    + +  String + + + + + getYear() + +
    +            + Returns the year information of the tag. +
    + +  void + + + + + removeFromAudio() + +
    +            + Removes the tag from the audio file and + nulls out the wrapper. +
    + +  void + + + + + setAlbum(<String> album) + +
    +            + Sets the album information. +
    + +  void + + + + + setArtist(<String> artist) + +
    +            + Sets the artist information. +
    + +  void + + + + + setAuthor(<String> author) + +
    +            + Sets the author information in this tag +
    + +  void + + + + + setComment(<String> comment) + +
    +            + Sets the comment +
    + +  void + + + + + setCopyright(<String> copyright) + +
    +            + Sets the copyright information in this tag +
    + +  void + + + + + setGenre(<String> genre) + +
    +            + Sets the genre information. +
    + +  void + + + + + setImage(<Number> pictureType, <String> mimeType, <Array> byteArray) + +
    +            + adds an image to the file. +
    + +  void + + + + + setSubtitle(<String> title) + +
    +            + Sets the subtitle information +
    + +  String + + + + + setTextContent(idStr, val) + +
    +            + This method can be used to set an arbitrary field + of the underlying tag. +
    + +  void + + + + + setTextEncoding(<Number|String> encType) + +
    +            + sets the text encoding used when creating new frames + (the encoding type of old frames can't be changed with + JavaMusicTag) +
    + +  void + + + + + setTitle(<String> title) + +
    +            + Sets the title information +
    + +  void + + + + + setTrackNumber(<Number> trackNumber) + +
    +            + Sets the track number information. +
    + +  void + + + + + setUrl(<String> url, <String> desc) + +
    +            + Stores the Url passed as argument in this tag. +
    + +  void + + + + + setYear(<Number> year) + +
    +            + Sets the year information. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Mp3.Id3v2

    +
    jala.Mp3.Id3v2(audioObj)
    + + +
      + Constructs a new Id3v2 tag from an Mp3 file +
    + + + +
      + Parameters: + +
        mp3File - +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    copyFrom

    +
    void copyFrom(tag)
    + +
      Copies standard fields from another tag.
    + + + + +
      + Parameters: + +
        src - object with getter methods for fields album, artist, comment, title, trackNumber, genre and year. +
      + +
    + + + + + + + + +
    + + +

    getAlbum

    +
    String getAlbum()
    + +
      Returns the album information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing album name +
      +
    + + + + + +
    + + +

    getArtist

    +
    String getArtist()
    + +
      Returns the artist information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing artist name +
      +
    + + + + + +
    + + +

    getAudio

    +
    jala.Mp3 getAudio()
    + +
      Returns the wrapper for the underlying audio file.
    + + + + + + + + + + + +
    + + +

    getAuthor

    +
    String getAuthor()
    + +
      Returns the author information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing author information +
      +
    + + + + + +
    + + +

    getComment

    +
    String getComment()
    + +
      Returns the comment information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing comment +
      +
    + + + + + +
    + + +

    getCopyright

    +
    String getCopyright()
    + +
      Returns the copyright information of the tag.
    + + + + + + + +
      + Returns: +
        + The copyright information of the tag +
      +
    + + + + + +
    + + +

    getGenre

    +
    String getGenre()
    + +
      Returns the genre information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing genre name +
      +
    + + + + + +
    + + +

    getImage

    +
    helma.util.MimePart getImage(<String> pictureType)
    + +
      Extracts the image from the tag
    + + + + +
      + Parameters: + +
        pictureType - number describing picture type (default is 3, describing a front cover). +
      + +
    + + + + +
      + Returns: +
        + image as mime object +
      +
    + + + + + +
    + + +

    getJavaObject

    +
    org.farng.mp3.id3.AbstractID3v2 getJavaObject()
    + +
      returns the java representation of the tag, + class depends on the actual library used.
    + + + + + + + + + + + +
    + + +

    getSubtitle

    +
    String getSubtitle()
    + +
      Returns the subtitle information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing subtitle +
      +
    + + + + + +
    + + +

    getSubtype

    +
    Number getSubtype()
    + +
      Returns the version number of this id3v2 (values 2 to 4 for id3v2.2 to id3v2.4)
    + + + + + + + +
      + Returns: +
        + The version number of this Id3v2 tag +
      +
    + + + + + +
    + + +

    getTextContent

    +
    String getTextContent(idStr)
    + +
      This method can be used to retrieve an arbitrary text frame + of the underlying tag. For the list of valid identifiers + and their meaning see http://www.id3.org/ + The identifiers vary across the sub versions of id3v2 tags, + use getSubtype to make sure you use the correct version.
    + + + + +
      + Parameters: + +
        id - Frame identifier according to Id3v2 specification or shortcut as defined in jala.Mp3.FIELD_MAPPING. +
      + +
    + + + + +
      + Returns: +
        + String contained in the frame +
      +
    + + + + + + + +
    + + +

    getTextEncoding

    +
    Number getTextEncoding()
    + +
      Returns the text encoding used when setting values.
    + + + + + + + +
      + Returns: +
        + The text encoding +
      +
    + + + + + +
    + + +

    getTitle

    +
    String getTitle()
    + +
      Returns the title information of the tag.
    + + + + + + + +
      + Returns: +
        + string containing title +
      +
    + + + + + +
    + + +

    getTrackNumber

    +
    String getTrackNumber()
    + +
      Returns the track number information of the tag.
    + + + + + + + +
      + Returns: +
        + string representing track number +
      +
    + + + + + +
    + + +

    getUrl

    +
    String getUrl()
    + +
      Returns the Url stored in this tag
    + + + + + + + +
      + Returns: +
        + The url stored in this tag +
      +
    + + + + + +
    + + +

    getYear

    +
    String getYear()
    + +
      Returns the year information of the tag.
    + + + + + + + +
      + Returns: +
        + string representing year +
      +
    + + + + + +
    + + +

    removeFromAudio

    +
    void removeFromAudio()
    + +
      Removes the tag from the audio file and + nulls out the wrapper.
    + + + + + + + + + + + +
    + + +

    setAlbum

    +
    void setAlbum(<String> album)
    + +
      Sets the album information.
    + + + + +
      + Parameters: + +
        album - +
      + +
    + + + + + + + + +
    + + +

    setArtist

    +
    void setArtist(<String> artist)
    + +
      Sets the artist information.
    + + + + +
      + Parameters: + +
        artist - +
      + +
    + + + + + + + + +
    + + +

    setAuthor

    +
    void setAuthor(<String> author)
    + +
      Sets the author information in this tag
    + + + + +
      + Parameters: + +
        author - The author information to set +
      + +
    + + + + + + + + +
    + + +

    setComment

    +
    void setComment(<String> comment)
    + +
      Sets the comment
    + + + + +
      + Parameters: + +
        comment - +
      + +
    + + + + + + + + +
    + + +

    setCopyright

    +
    void setCopyright(<String> copyright)
    + +
      Sets the copyright information in this tag
    + + + + +
      + Parameters: + +
        copyright - The copyright information to set +
      + +
    + + + + + + + + +
    + + +

    setGenre

    +
    void setGenre(<String> genre)
    + +
      Sets the genre information. A list of genre names that are compatible + with ID3v1 tags is located in jala.Mp3.GENRES.
    + + + + +
      + Parameters: + +
        genre - +
      + +
    + + + + + + + + +
    + + +

    setImage

    +
    void setImage(<Number> pictureType, <String> mimeType, <Array> byteArray)
    + +
      adds an image to the file.
    + + + + +
      + Parameters: + +
        pictureType - number determining picture type +
      + +
        mimeType - mime type of image +
      + +
        byteArray - image binary data +
      + +
        desc - optional description +
      + +
    + + + + + + + + + + +
    + + +

    setSubtitle

    +
    void setSubtitle(<String> title)
    + +
      Sets the subtitle information
    + + + + +
      + Parameters: + +
        title - +
      + +
    + + + + + + + + +
    + + +

    setTextContent

    +
    String setTextContent(idStr, val)
    + +
      This method can be used to set an arbitrary field + of the underlying tag. For the list of valid identifiers + and their meaning see http://www.id3.org/ + The identifiers vary across the sub versions of id3v2 tags, + use getSubtype to make sure you use the correct version.
    + + + + +
      + Parameters: + +
        id - Frame identifier according to Id3v2 specification +
      + +
        value - +
      + +
    + + + + + + + + + + +
    + + +

    setTextEncoding

    +
    void setTextEncoding(<Number|String> encType)
    + +
      sets the text encoding used when creating new frames + (the encoding type of old frames can't be changed with + JavaMusicTag)
    + + + + +
      + Parameters: + +
        encType - the new encoding type as number or string +
      + +
    + + + + + + + + + + +
    + + +

    setTitle

    +
    void setTitle(<String> title)
    + +
      Sets the title information
    + + + + +
      + Parameters: + +
        title - +
      + +
    + + + + + + + + +
    + + +

    setTrackNumber

    +
    void setTrackNumber(<Number> trackNumber)
    + +
      Sets the track number information.
    + + + + +
      + Parameters: + +
        trackNumber - +
      + +
    + + + + + + + + +
    + + +

    setUrl

    +
    void setUrl(<String> url, <String> desc)
    + +
      Stores the Url passed as argument in this tag.
    + + + + +
      + Parameters: + +
        url - The url to store in this tag +
      + +
        desc - An optiona description of the Url +
      + +
    + + + + + + + + +
    + + +

    setYear

    +
    void setYear(<Number> year)
    + +
      Sets the year information.
    + + + + +
      + Parameters: + +
        year - +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Mp3.html b/modules/jala/docs/jala.Mp3.html new file mode 100644 index 00000000..0132fa7f --- /dev/null +++ b/modules/jala/docs/jala.Mp3.html @@ -0,0 +1,1481 @@ + + + + + +jala.Mp3 + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Mp3

    +
    Object
    +   |
    +   +--jala.Mp3
    +
    + + +
    +
    + +
    class + jala.Mp3 + + +
    + +

    +
    This is a class representing an MP3 file + providing methods to access its metadata. + +
    Defined in Mp3.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Mp3.Id3v1
    + <static class>jala.Mp3.Id3v2
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Objectalbum +
    +           
    +  Objectartist +
    +           
    +  Objectcomment +
    +           
    +  Objectgenre +
    +           
    +  Objecttitle +
    +           
    +  ObjecttrackNumber +
    +           
    +  Objectyear +
    +           
    + <static>  <final> ArrayGENRES +
    +           Array defining valid genres in ID3v1
    + <static>  <final> ArrayMODES +
    +           Array defining mp3 modes.
    + <static>  <final> ArrayPICTURE_TYPES +
    +           Array defining valid picture types.
    + <static>  <final> ArrayTEXT_ENCODINGS +
    +           Array defining valid text encodings.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Mp3 + + (<String|File> file) + +
    +             + Constructs a new jala.Mp3 wrapper and + parses the header data of the MP3 file. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Object + + + + + createTag(<Object> tagClass, <Object> tagObject) + +
    +            + This method creates a new tag object, attaches it + to the file (thereby replacing an existing tag of + this type) and returns it. +
    + +  jala.Mp3.Id3v1 + + + + + createV1Tag(<Object> tagObject) + +
    +            + If the file doesn't contain an ID3v1 tag, this method + creates a new ID3v1 tag object, attaches it to the file + and returns it. +
    + +  jala.Mp3.Id3v2 + + + + + createV2Tag(<Object> tagObject) + +
    +            + If the file doesn't contain an ID3v2 tag, this method + creates a new ID3v2 tag object, attaches it to the file + and returns it. +
    + +  Number + + + + + getBitRate() + +
    +            + Returns the bit rate the file was encoded with. +
    + +  String + + + + + getChannelMode() + +
    +            + Returns the channel mode the file was encoded with. +
    + +  Number + + + + + getDuration() + +
    +            + The audio length of the file in seconds at best estimate + from the file info (method returns immediately). +
    + +  helma.File + + + + + getFile() + +
    +            + Returns a helma.File reference to the wrapped file. +
    + +  Number + + + + + getFrequency() + +
    +            + Returns the frequency the file was encoded with. +
    + +  org.farng.mp3.MP3File + + + + + getJavaObject() + +
    +            + Returns the underlying java object +
    + +  Object + + + + + getMetadata() + +
    +            + Returns a plain JavaScript object containing the values of + all fields stored in either the Id3 V1 or V2 tag +
    + +  Number + + + + + getSize() + +
    +            + Returns the file size in bytes. +
    + +  Object + + + + + getTag(tagClass) + +
    +            + Returns a tag object, type is specified using the class name + in jala.Mp3.*. +
    + +  jala.Mp3.Id3v1 + + + + + getV1Tag() + +
    +            + +
    + +  jala.Mp3.Id3v2 + + + + + getV2Tag() + +
    +            + +
    + +  Object + + + + + hasTag(tagClass) + +
    +            + Tells if the file contains a certain tag, type is specified + using the class name in jala.Mp3. +
    + +  Boolean + + + + + hasV1Tag() + +
    +            + Returns true if the file contains a ID3v1 tag. +
    + +  Boolean + + + + + hasV2Tag() + +
    +            + Returns true if the file contains a ID3v2 tag. +
    + +  Boolean + + + + + isVariableBitRate() + +
    +            + Returns true if the file is (or seems to be) encoded with + variable bit rate. +
    + +  Number + + + + + parseDuration() + +
    +            + Parses the audio file to extract the precise duration of the audio. +
    + +  void + + + + + removeTag(tagClass) + +
    +            + Removes a tag from the file, type is specified using the + class name in jala.Mp3.* +
    + +  void + + + + + removeV1Tag() + +
    +            + Removes the ID3v1 tag from the file. +
    + +  Object + + + + + removeV2Tag() + +
    +            + Removes the ID3v2 tag from the file. +
    + +  Boolean + + + + + save(<String|helma.File> outFile) + +
    +            + Writes changed metadata back to the source file or to a new file. +
    + +  void + + + + + setMetadata(<Object> metadata) + +
    +            + Stores the metadata passed as argument in the ID2 v1 and v2 tags + of the wrapped MP3 file. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    album

    +
    Object album
    +
      + + +
    +
    + + +

    artist

    +
    Object artist
    +
      + + +
    +
    + + +

    comment

    +
    Object comment
    +
      + + +
    +
    + + +

    genre

    +
    Object genre
    +
      + + +
    +
    + + +

    title

    +
    Object title
    +
      + + +
    +
    + + +

    trackNumber

    +
    Object trackNumber
    +
      + + +
    +
    + + +

    year

    +
    Object year
    +
      + + +
    +
    + + +

    GENRES

    +
    <static> <final> Array GENRES
    +
      + Array defining valid genres in ID3v1 + +
    +
    + + +

    MODES

    +
    <static> <final> Array MODES
    +
      + Array defining mp3 modes. + +
    +
    + + +

    PICTURE_TYPES

    +
    <static> <final> Array PICTURE_TYPES
    +
      + Array defining valid picture types. Note: Most image tagged files come with + one picture of picture type null! + The index position within the array defines the number used in the mp3 file. + +
    +
    + + +

    TEXT_ENCODINGS

    +
    <static> <final> Array TEXT_ENCODINGS
    +
      + Array defining valid text encodings. Note: UTF-8 is valid for v2.4 only. + UTF-16 with BOM doesn't work with Winamp etc - use UTF-16BE instead! + The index position within the array defines the number used in the mp3 file. + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Mp3

    +
    jala.Mp3(<String|File> file)
    + + +
      + Constructs a new jala.Mp3 wrapper and + parses the header data of the MP3 file. + The standard fields for a tag are accessible + as properties of the new object. +
    + + + +
      + Parameters: + +
        file - The mp3 file to be parsed, either as path string or as any kind of file object +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    createTag

    +
    Object createTag(<Object> tagClass, <Object> tagObject)
    + +
      This method creates a new tag object, attaches it + to the file (thereby replacing an existing tag of + this type) and returns it. Type is specified using + the class name in jala.Mp3.*. If a second + argument is provided, its values are copied into + the new tag.
    + + + + +
      + Parameters: + +
        tagClass - +
      + +
        tagObject - optional tag whose standard properties are copied to the new tag. +
      + +
    + + + + + + + + +
    + + +

    createV1Tag

    +
    jala.Mp3.Id3v1 createV1Tag(<Object> tagObject)
    + +
      If the file doesn't contain an ID3v1 tag, this method + creates a new ID3v1 tag object, attaches it to the file + and returns it. If a second argument is provided, its + values are copied into the new tag.
    + + + + +
      + Parameters: + +
        tagObject - optional tag whose standard properties are copied to the new tag. +
      + +
    + + + + + + + + +
    + + +

    createV2Tag

    +
    jala.Mp3.Id3v2 createV2Tag(<Object> tagObject)
    + +
      If the file doesn't contain an ID3v2 tag, this method + creates a new ID3v2 tag object, attaches it to the file + and returns it. If a second argument is provided, its + values are copied into the new tag.
    + + + + +
      + Parameters: + +
        tagObject - optional tag whose standard properties are copied to the new tag. +
      + +
    + + + + + + + + +
    + + +

    getBitRate

    +
    Number getBitRate()
    + +
      Returns the bit rate the file was encoded with.
    + + + + + + + + + + + +
    + + +

    getChannelMode

    +
    String getChannelMode()
    + +
      Returns the channel mode the file was encoded with.
    + + + + + + + + + + + +
    + + +

    getDuration

    +
    Number getDuration()
    + +
      The audio length of the file in seconds at best estimate + from the file info (method returns immediately). + This method calculates based on the bitrate. Therefore it + has to produce wrong results for files encoded with variable + bitrate (vbr). For these files parseDuration() can be used.
    + + + + + + + +
      + Returns: +
        + length in seconds +
      +
    + + + + + + + +
    + + +

    getFile

    +
    helma.File getFile()
    + +
      Returns a helma.File reference to the wrapped file.
    + + + + + + + + + + + +
    + + +

    getFrequency

    +
    Number getFrequency()
    + +
      Returns the frequency the file was encoded with.
    + + + + + + + + + + + +
    + + +

    getJavaObject

    +
    org.farng.mp3.MP3File getJavaObject()
    + +
      Returns the underlying java object
    + + + + + + + + + + + +
    + + +

    getMetadata

    +
    Object getMetadata()
    + +
      Returns a plain JavaScript object containing the values of + all fields stored in either the Id3 V1 or V2 tag
    + + + + + + + +
      + Returns: +
        + An object containing the values of all fields +
      +
    + + + + + +
    + + +

    getSize

    +
    Number getSize()
    + +
      Returns the file size in bytes.
    + + + + + + + + + + + +
    + + +

    getTag

    +
    Object getTag(tagClass)
    + +
      Returns a tag object, type is specified using the class name + in jala.Mp3.*.
    + + + + + + + + + + + +
    + + +

    getV1Tag

    +
    jala.Mp3.Id3v1 getV1Tag()
    + + + + + + + + + + + +
    + + +

    getV2Tag

    +
    jala.Mp3.Id3v2 getV2Tag()
    + + + + + + + + + + + +
    + + +

    hasTag

    +
    Object hasTag(tagClass)
    + +
      Tells if the file contains a certain tag, type is specified + using the class name in jala.Mp3.
    + + + + + + + + + + + +
    + + +

    hasV1Tag

    +
    Boolean hasV1Tag()
    + +
      Returns true if the file contains a ID3v1 tag.
    + + + + + + + + + + + +
    + + +

    hasV2Tag

    +
    Boolean hasV2Tag()
    + +
      Returns true if the file contains a ID3v2 tag.
    + + + + + + + + + + + +
    + + +

    isVariableBitRate

    +
    Boolean isVariableBitRate()
    + +
      Returns true if the file is (or seems to be) encoded with + variable bit rate. FIXME: The current implementation returned + true for all test files.
    + + + + + + + + + + + +
    + + +

    parseDuration

    +
    Number parseDuration()
    + +
      Parses the audio file to extract the precise duration of the audio. + The upside is that it works fine for files with variable bitrates. + The downside is that this action may take a few seconds depending on + the size of the audio file.
    + + + + + + + +
      + Returns: +
        + length in seconds +
      +
    + + + + + + + +
    + + +

    removeTag

    +
    void removeTag(tagClass)
    + +
      Removes a tag from the file, type is specified using the + class name in jala.Mp3.*
    + + + + + + + + + + + +
    + + +

    removeV1Tag

    +
    void removeV1Tag()
    + +
      Removes the ID3v1 tag from the file.
    + + + + + + + + + + + +
    + + +

    removeV2Tag

    +
    Object removeV2Tag()
    + +
      Removes the ID3v2 tag from the file.
    + + + + + + + + + + + +
    + + +

    save

    +
    Boolean save(<String|helma.File> outFile)
    + +
      Writes changed metadata back to the source file or to a new file.
    + + + + +
      + Parameters: + +
        outFile - (optional) save the modified file to a different file +
      + +
    + + + + +
      + Returns: +
        + true on success, false if the file contains tags that cannot be saved (Id3v2_2). +
      +
    + + + + + +
    + + +

    setMetadata

    +
    void setMetadata(<Object> metadata)
    + +
      Stores the metadata passed as argument in the ID2 v1 and v2 tags + of the wrapped MP3 file.
    + + + + +
      + Parameters: + +
        metadata - An object containing the fields to set and their values. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.PodcastWriter.html b/modules/jala/docs/jala.PodcastWriter.html new file mode 100644 index 00000000..e0c9f295 --- /dev/null +++ b/modules/jala/docs/jala.PodcastWriter.html @@ -0,0 +1,416 @@ + + + + + +jala.PodcastWriter + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.PodcastWriter

    +
    Object
    +   |
    +   +--jala.XmlWriter
    +         |
    +         +--jala.Rss20Writer
    +               |
    +               +--jala.PodcastWriter
    +
    + + +
    +
    + +
    class + jala.PodcastWriter + +
    extends jala.Rss20Writer + + +
    + +

    +
    Class to create, modify and render standard-compliant + RSS 2.0 feeds including support for Apple's Podcast specification. +
    Defined in PodcastWriter.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> StringXMLHEADER +
    +           A typical XML header as default.
    +   + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.PodcastWriter + + (<String> header) + +
    +             + +
    + + + +  + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + addItunesCategory(<String> name, <String> subName, <jala.XmlWriter.XmlElement> parent) + +
    +            + Add an iTunes Podcast category. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.Rss20Writer
    + +getRoot, extendChannel, getChannel, setChannel, extendItem, createItem, addItem, addCategory, setImage, setTextInput +
    +  + +  + + + + + + + +
    Methods inherited from class jala.XmlWriter
    + +createElement, extend, addNamespace, write, toString, clone +
    +  + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    XMLHEADER

    +
    <static> <final> String XMLHEADER
    + +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.PodcastWriter

    +
    jala.PodcastWriter(<String> header)
    + + + + +
      + Parameters: + +
        header - Optional XML header. +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    addItunesCategory

    +
    void addItunesCategory(<String> name, <String> subName, <jala.XmlWriter.XmlElement> parent)
    + +
      Add an iTunes Podcast category.
    + + + + +
      + Parameters: + +
        name - The category's name. +
      + +
        subName - The (optional) sub-category's name. +
      + +
        parent - Optional parent element to add the category to. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.RemoteContent.html b/modules/jala/docs/jala.RemoteContent.html new file mode 100644 index 00000000..71fd9a62 --- /dev/null +++ b/modules/jala/docs/jala.RemoteContent.html @@ -0,0 +1,892 @@ + + + + + +jala.RemoteContent + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.RemoteContent

    +
    Object
    +   |
    +   +--helma.Http
    +         |
    +         +--jala.RemoteContent
    +
    + + +
    +
    + +
    class + jala.RemoteContent + +
    extends helma.Http + + +
    + +

    +
    API to define, fetch and update content + from a remote site. +
    Defined in RemoteContent.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> FileCACHEDIR +
    +           The default cache directory.
    + <static>  <final> intHTTP +
    +           A constant representing the HTTP retrieval method.
    + <static>  <final> StringSUFFIX +
    +           The default name of the cache directory.
    + <static>  <final> intXMLRPC +
    +           A constant representing the XML-RPC retrieval method.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.RemoteContent + + (<String> url, <Integer> method, <File> storage) + +
    +             + Construct a new remote content handler. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + clear() + +
    +            + Flushes (empties) the cached remote content. +
    + +  Object + + + + + get(<String> key) + +
    +            + Get an arbitrary property of the remote content. +
    + +  Array + + + + + getKeys() + +
    +            + Get all available property names. +
    + +  Boolean + + + + + needsUpdate() + +
    +            + Tests whether the remote content needs to be updated. +
    + +  void + + + + + setInterval(<Number> interval) + +
    +            + Set the interval the remote content's + cache is bound to be updated. +
    + +  String + + + + + toString() + +
    +            + Get a string representation of the remote content. +
    + +  String + + + + + update() + +
    +            + Get the updated and cached remote content. +
    + +  Object + + + + + valueOf() + +
    +            + Get the value of the remote content. +
    + + <static> void + + + + + exec() + +
    +            + Apply a custom method on all remote content in a file-based cache. +
    + + <static> void + + + + + flush(<File> cache) + +
    +            + Remove all remote content from a file-based cache. +
    + + <static> void + + + + + forEach(<Function> callback, <File> cache) + +
    +            + Apply a custom method on all remote content in a file-based cache. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    CACHEDIR

    +
    <static> <final> File CACHEDIR
    +
      + The default cache directory. + +
    +
    + + +

    HTTP

    +
    <static> <final> int HTTP
    + +
    + + +

    SUFFIX

    +
    <static> <final> String SUFFIX
    + +
    + + +

    XMLRPC

    +
    <static> <final> int XMLRPC
    + +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.RemoteContent

    +
    jala.RemoteContent(<String> url, <Integer> method, <File> storage)
    + + +
      + Construct a new remote content handler. +
    + + + +
      + Parameters: + +
        url - The URL string of the remote site. +
      + +
        method - The method to retrieve the remote content. +
      + +
        storage - The cache directory. +
      + + +
    + + + + +
      + Returns: +
        + A new remote content handler. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    clear

    +
    void clear()
    + +
      Flushes (empties) the cached remote content.
    + + + + + + + + + + + +
    + + +

    get

    +
    Object get(<String> key)
    + +
      Get an arbitrary property of the remote content.
    + + + + +
      + Parameters: + +
        key - The name of the property. +
      + +
    + + + + +
      + Returns: +
        + The value of the property. +
      +
    + + + + + +
    + + +

    getKeys

    +
    Array getKeys()
    + +
      Get all available property names.
    + + + + + + + +
      + Returns: +
        + The list of property names. +
      +
    + + + + + +
    + + +

    needsUpdate

    +
    Boolean needsUpdate()
    + +
      Tests whether the remote content needs to be updated.
    + + + + + + + +
      + Returns: +
        + True if the remote content needs to be updated. +
      +
    + + + + + +
    + + +

    setInterval

    +
    void setInterval(<Number> interval)
    + +
      Set the interval the remote content's + cache is bound to be updated.
    + + + + +
      + Parameters: + +
        interval - The interval value in milliseconds. +
      + +
    + + + + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Get a string representation of the remote content.
    + + + + + + + +
      + Returns: +
        + The remote content as string. +
      +
    + + + + + +
    + + +

    update

    +
    String update()
    + +
      Get the updated and cached remote content.
    + + + + + + + +
      + Returns: +
        + The content as retrieved from the remote site. +
      +
    + + + + + +
    + + +

    valueOf

    +
    Object valueOf()
    + +
      Get the value of the remote content.
    + + + + + + + +
      + Returns: +
        + The remote content including response header data. +
      +
    + + + + + +
    + + +

    exec

    +
    <static> void exec()
    + +
      Apply a custom method on all remote content in a file-based cache.
    + + + + +
      + Parameters: + +
        callback - The callback method to be executed for each remote content file. +
      + +
        cache - An optional target directory. +
      + +
    + + + + + + + + + + +
    + + +

    flush

    +
    <static> void flush(<File> cache)
    + +
      Remove all remote content from a file-based cache.
    + + + + +
      + Parameters: + +
        cache - An optional target directory. +
      + +
    + + + + + + + + +
    + + +

    forEach

    +
    <static> void forEach(<Function> callback, <File> cache)
    + +
      Apply a custom method on all remote content in a file-based cache.
    + + + + +
      + Parameters: + +
        callback - The callback method to be executed for each remote content file. +
      + +
        cache - An optional target directory. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Rss20Writer.html b/modules/jala/docs/jala.Rss20Writer.html new file mode 100644 index 00000000..5ceca0e8 --- /dev/null +++ b/modules/jala/docs/jala.Rss20Writer.html @@ -0,0 +1,760 @@ + + + + + +jala.Rss20Writer + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Rss20Writer

    +
    Object
    +   |
    +   +--jala.XmlWriter
    +         |
    +         +--jala.Rss20Writer
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.PodcastWriter +
    +
    + + +
    +
    + +
    class + jala.Rss20Writer + +
    extends jala.XmlWriter + + +
    + +

    +
    Class to create, modify and render standard-compliant + RSS 2.0 feeds. +
    Defined in Rss20Writer.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Rss20Writer + + (<String> header) + +
    +             + +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + addCategory(<String> name, <String> domain, <jala.XmlWriter.XmlElement> parent) + +
    +            + Add a category element to an arbitrary element. +
    + +  void + + + + + addItem(<jala.XmlWriter.XmlElement> item) + +
    +            + Add an item element to the channel element. +
    + +  jala.XmlWriter.XmlElement + + + + + createItem(<Object> data) + +
    +            + Get a new and innocent item element. +
    + +  void + + + + + extendChannel(<Array> ext) + +
    +            + Add child elements to the channel template. +
    + +  void + + + + + extendItem(<Array> ext) + +
    +            + Add child elements to the item template. +
    + +  jala.XmlWriter.XmlElement + + + + + getChannel() + +
    +            + Get the writer's channel element. +
    + +  jala.XmlWriter.XmlElement + + + + + getRoot() + +
    +            + Get the writer's root element. +
    + +  jala.XmlWriter.XmlElement + + + + + setChannel(<Object> data) + +
    +            + Populate the channel element with data. +
    + +  void + + + + + setImage(<Object> data) + +
    +            + Populate the image element with data. +
    + +  void + + + + + setTextInput(<Object> data) + +
    +            + Populate the textInput element with data. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.XmlWriter
    + +createElement, extend, addNamespace, write, toString, clone +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Rss20Writer

    +
    jala.Rss20Writer(<String> header)
    + + + + +
      + Parameters: + +
        header - Optional XML header. +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    addCategory

    +
    void addCategory(<String> name, <String> domain, <jala.XmlWriter.XmlElement> parent)
    + +
      Add a category element to an arbitrary element.
    + + + + +
      + Parameters: + +
        name - The name of the category. +
      + +
        domain - The domain of the category. +
      + +
        parent - The optional parent element. +
      + +
    + + + + + + + + +
    + + +

    addItem

    +
    void addItem(<jala.XmlWriter.XmlElement> item)
    + +
      Add an item element to the channel element.
    + + + + +
      + Parameters: + +
        item - The item element to add. +
      + +
    + + + + + + + + +
    + + +

    createItem

    +
    jala.XmlWriter.XmlElement createItem(<Object> data)
    + +
      Get a new and innocent item element.
    + + + + +
      + Parameters: + +
        data - An XmlWriter-compliant object structure. +
      + +
    + + + + +
      + Returns: +
        + A new and innocent item element. +
      +
    + + + + + +
    + + +

    extendChannel

    +
    void extendChannel(<Array> ext)
    + +
      Add child elements to the channel template.
    + + + + +
      + Parameters: + +
        ext - List of additional child elements. +
      + +
    + + + + + + + + +
    + + +

    extendItem

    +
    void extendItem(<Array> ext)
    + +
      Add child elements to the item template.
    + + + + +
      + Parameters: + +
        ext - List of additional child elements. +
      + +
    + + + + + + + + +
    + + +

    getChannel

    +
    jala.XmlWriter.XmlElement getChannel()
    + +
      Get the writer's channel element.
    + + + + + + + +
      + Returns: +
        + The writer's channel element. +
      +
    + + + + + +
    + + +

    getRoot

    +
    jala.XmlWriter.XmlElement getRoot()
    + +
      Get the writer's root element.
    + + + + + + + +
      + Returns: +
        + The writer's root element. +
      +
    + + + + + +
    + + +

    setChannel

    +
    jala.XmlWriter.XmlElement setChannel(<Object> data)
    + +
      Populate the channel element with data.
    + + + + +
      + Parameters: + +
        data - An XmlWriter-compliant object structure. +
      + +
    + + + + +
      + Returns: +
        + The populated channel element. +
      +
    + + + + + +
    + + +

    setImage

    +
    void setImage(<Object> data)
    + +
      Populate the image element with data.
    + + + + +
      + Parameters: + +
        data - An XmlWriter-compliant object structure. +
      + +
    + + + + + + + + +
    + + +

    setTextInput

    +
    void setTextInput(<Object> data)
    + +
      Populate the textInput element with data.
    + + + + +
      + Parameters: + +
        data - An XmlWriter-compliant object structure. +
      + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.Utilities.html b/modules/jala/docs/jala.Utilities.html new file mode 100644 index 00000000..cd58c6e3 --- /dev/null +++ b/modules/jala/docs/jala.Utilities.html @@ -0,0 +1,586 @@ + + + + + +jala.Utilities + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.Utilities

    +
    Object
    +   |
    +   +--jala.Utilities
    +
    + + +
    +
    + +
    class + jala.Utilities + + +
    + +

    +
    This class contains various convenience methods + which do not fit in any other class. +
    Defined in Utilities.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> NumberVALUE_ADDED +
    +           Static field indicating ad added object property.
    + <static>  <final> NumberVALUE_MODIFIED +
    +           Static field indicating a modified object property.
    + <static>  <final> NumberVALUE_REMOVED +
    +           Static field indicating a removed object property.
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Utilities + + () + +
    +             + Construct a utility object. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + createPassword(<Number> len, <Number> level) + +
    +            + Creates a random password with different levels of security. +
    + +  Object + + + + + diffObjects(<Object> obj1, <Object> obj2) + +
    +            + Returns an array containing the properties that are + added, removed or modified in one object compared to another. +
    + +  Object + + + + + patchObject(<Object> obj, <Object> diff) + +
    +            + Patches an object with a "diff" object created by the + diffObjects() method. +
    + +  String + + + + + toString() + +
    +            + Return a string representation of the utitility object. +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    VALUE_ADDED

    +
    <static> <final> Number VALUE_ADDED
    + +
    + + +

    VALUE_MODIFIED

    +
    <static> <final> Number VALUE_MODIFIED
    + +
    + + +

    VALUE_REMOVED

    +
    <static> <final> Number VALUE_REMOVED
    + +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Utilities

    +
    jala.Utilities()
    + + +
      + Construct a utility object. +
    + + + + + + + + +
      + Returns: +
        + A new utitilty object. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    createPassword

    +
    String createPassword(<Number> len, <Number> level)
    + +
      Creates a random password with different levels of security.
    + + + + +
      + Parameters: + +
        len - The length of the password (default: 8) +
      + +
        level - The security level
        • 0 - containing only vowels or consonants (default)
        • 1 - throws in a number at random position
        • 2 - throws in a number and a special character at random position
        +
      + +
    + + + + +
      + Returns: +
        + The resulting password +
      +
    + + + + + +
    + + +

    diffObjects

    +
    Object diffObjects(<Object> obj1, <Object> obj2)
    + +
      Returns an array containing the properties that are + added, removed or modified in one object compared to another.
    + + + + +
      + Parameters: + +
        obj1 - The first of two objects which should be compared +
      + +
        obj2 - The second of two objects which should be compared +
      + +
    + + + + +
      + Returns: +
        + An Object containing all properties that are added, removed or modified in the second object compared to the first. Each property contains a status field with an integer value which can be checked against the static jala.Utility fields VALUE_ADDED, VALUE_MODIFIED and VALUE_REMOVED. +
      +
    + + + + + +
    + + +

    patchObject

    +
    Object patchObject(<Object> obj, <Object> diff)
    + +
      Patches an object with a "diff" object created by the + diffObjects() method. + Please mind that this method is recursive, it descends + along the "diff" object structure.
    + + + + +
      + Parameters: + +
        obj - The Object the diff should be applied to +
      + + + +
    + + + + +
      + Returns: +
        + The patched Object with all differences applied +
      +
    + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Return a string representation of the utitility object.
    + + + + + + + +
      + Returns: +
        + [jala.Utilities Object] +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.XmlRpcRequest.html b/modules/jala/docs/jala.XmlRpcRequest.html new file mode 100644 index 00000000..c52e8de2 --- /dev/null +++ b/modules/jala/docs/jala.XmlRpcRequest.html @@ -0,0 +1,1235 @@ + + + + + +jala.XmlRpcRequest + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.XmlRpcRequest

    +
    Object
    +   |
    +   +--jala.XmlRpcRequest
    +
    + + +
    +
    + +
    class + jala.XmlRpcRequest + + +
    + +

    +
    Instances of this class provide the necessary functionality + for issueing XmlRpc requests to a remote service. +
    Defined in XmlRpcRequest.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.XmlRpcRequest + + (<String> url, <String> methodName) + +
    +             + A constructor for XmlRpc request objects +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Boolean + + + + + debug() + +
    +            + Returns true if debug is enabled for this request, false otherwise +
    + +  Object + + + + + execute() + +
    +            + Calling this method executes the remote method using + the arguments specified. +
    + +  String + + + + + getCredentials() + +
    +            + Returns the credentials of this request +
    + +  String + + + + + getInputEncoding() + +
    +            + Returns the input encoding +
    + +  String + + + + + getMethodName() + +
    +            + Returns the name of the remote function to call +
    + +  String + + + + + getOutputEncoding() + +
    +            + Returns the output encoding +
    + +  java.net.Proxy + + + + + getProxy() + +
    +            + Returns the proxy object. +
    + +  Number + + + + + getReadTimeout() + +
    +            + Returns the socket timeout of this request +
    + +  Number + + + + + getTimeout() + +
    +            + Returns the connection timeout of this request +
    + +  java.net.URL + + + + + getUrl() + +
    +            + Returns the URL of this request +
    + +  void + + + + + setCredentials(<String> username, <String> password) + +
    +            + Sets the credentials for basic http authentication to + use with this request. +
    + +  void + + + + + setDebug(<Boolean> flag) + +
    +            + Enables or disables the debug mode. +
    + +  void + + + + + setEncoding(<String> enc) + +
    +            + Sets both input and output encoding to the + specified encoding string +
    + +  void + + + + + setInputEncoding(<String> enc) + +
    +            + Sets the input encoding to the specified encoding string +
    + +  void + + + + + setOutputEncoding(<String> enc) + +
    +            + Sets the output encoding to the specified encoding string +
    + +  void + + + + + setProxy(<String> proxyString) + +
    +            + Sets the proxy host and port. +
    + +  void + + + + + setReadTimeout(<Number> millis) + +
    +            + Sets the socket timeout to the specified milliseconds. +
    + +  void + + + + + setTimeout(<Number> millis) + +
    +            + Sets the connection timeout to the specified milliseconds. +
    + + <static> String + + + + + argumentsToString(<Object> args) + +
    +            + Helper method to format an arguments array into + a string useable for debugging output. +
    + + <static> java.lang.Object + + + + + convertArgument(<Object> obj) + +
    +            + Helper method for converting a Javascript object into + its appropriate Java object. +
    + + <static> Object + + + + + convertResult(<java.lang.Object> obj) + +
    +            + Converts a Java object into its appropriate Javascript representation. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.XmlRpcRequest

    +
    jala.XmlRpcRequest(<String> url, <String> methodName)
    + + +
      + A constructor for XmlRpc request objects +
    + + + +
      + Parameters: + +
        url - The url of the XmlRpc entry point +
      + +
        methodName - The name of the method to call +
      + + +
    + + + + +
      + Returns: +
        + A newly created jala.XmlRpcRequest instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    debug

    +
    Boolean debug()
    + +
      Returns true if debug is enabled for this request, false otherwise
    + + + + + + + +
      + Returns: +
        + True if debugging is enabled, false otherwise +
      +
    + + + + + +
    + + +

    execute

    +
    Object execute()
    + +
      Calling this method executes the remote method using + the arguments specified.
    + + + + + + + +
      + Returns: +
        + The result of this XmlRpc request +
      +
    + + + + + +
    + + +

    getCredentials

    +
    String getCredentials()
    + +
      Returns the credentials of this request
    + + + + + + + +
      + Returns: +
        + The base46 encoded credentials of this request +
      +
    + + + + + +
    + + +

    getInputEncoding

    +
    String getInputEncoding()
    + +
      Returns the input encoding
    + + + + + + + +
      + Returns: +
        + The input encoding used by this request +
      +
    + + + + + +
    + + +

    getMethodName

    +
    String getMethodName()
    + +
      Returns the name of the remote function to call
    + + + + + + + +
      + Returns: +
        + The name of the remote function +
      +
    + + + + + +
    + + +

    getOutputEncoding

    +
    String getOutputEncoding()
    + +
      Returns the output encoding
    + + + + + + + +
      + Returns: +
        + The output encoding used by this request +
      +
    + + + + + +
    + + +

    getProxy

    +
    java.net.Proxy getProxy()
    + +
      Returns the proxy object. This method will only return + a value if using a java runtime > 1.5
    + + + + + + + +
      + Returns: +
        + The proxy to use for this request +
      +
    + + + + + + + +
    + + +

    getReadTimeout

    +
    Number getReadTimeout()
    + +
      Returns the socket timeout of this request
    + + + + + + + +
      + Returns: +
        + The socket timeout value in milliseconds +
      +
    + + + + + +
    + + +

    getTimeout

    +
    Number getTimeout()
    + +
      Returns the connection timeout of this request
    + + + + + + + +
      + Returns: +
        + The connection timeout value in milliseconds +
      +
    + + + + + +
    + + +

    getUrl

    +
    java.net.URL getUrl()
    + +
      Returns the URL of this request
    + + + + + + + +
      + Returns: +
        + The URL of this request +
      +
    + + + + + +
    + + +

    setCredentials

    +
    void setCredentials(<String> username, <String> password)
    + +
      Sets the credentials for basic http authentication to + use with this request.
    + + + + +
      + Parameters: + +
        username - The username +
      + +
        password - The password +
      + +
    + + + + + + + + +
    + + +

    setDebug

    +
    void setDebug(<Boolean> flag)
    + +
      Enables or disables the debug mode. If enabled the xml source + of both request and response is included in the result properties + 'requestXml' and 'responseXml'
    + + + + +
      + Parameters: + +
        flag - True or false. +
      + +
    + + + + + + + + +
    + + +

    setEncoding

    +
    void setEncoding(<String> enc)
    + +
      Sets both input and output encoding to the + specified encoding string
    + + + + +
      + Parameters: + +
        enc - The encoding to use for both input and output. This must be a valid java encoding string. +
      + +
    + + + + + + + + +
    + + +

    setInputEncoding

    +
    void setInputEncoding(<String> enc)
    + +
      Sets the input encoding to the specified encoding string
    + + + + +
      + Parameters: + +
        enc - The encoding to use for input. This must be a valid java encoding string. +
      + +
    + + + + + + + + +
    + + +

    setOutputEncoding

    +
    void setOutputEncoding(<String> enc)
    + +
      Sets the output encoding to the specified encoding string
    + + + + +
      + Parameters: + +
        enc - The encoding to use for output. This must be a valid java encoding string. +
      + +
    + + + + + + + + +
    + + +

    setProxy

    +
    void setProxy(<String> proxyString)
    + +
      Sets the proxy host and port. For Java runtimes < 1.5 this method + sets the appropriate system properties (so this has an effect on + all requests based on java.net.URL), for all others the proxy + is only set for this request.
    + + + + +
      + Parameters: + +
        proxyString - The proxy string in the form 'fqdn:port' (eg. my.proxy.com:3128) +
      + +
    + + + + + + + + +
    + + +

    setReadTimeout

    +
    void setReadTimeout(<Number> millis)
    + +
      Sets the socket timeout to the specified milliseconds.
    + + + + +
      + Parameters: + +
        millis - The timeout to use as socket timeout +
      + +
    + + + + + + + + +
    + + +

    setTimeout

    +
    void setTimeout(<Number> millis)
    + +
      Sets the connection timeout to the specified milliseconds.
    + + + + +
      + Parameters: + +
        millis - The timeout to use as connection timeout +
      + +
    + + + + + + + + +
    + + +

    argumentsToString

    +
    <static> String argumentsToString(<Object> args)
    + +
      Helper method to format an arguments array into + a string useable for debugging output.
    + + + + +
      + Parameters: + +
        args - An arguments array +
      + +
    + + + + +
      + Returns: +
        + The arguments array formatted as string +
      +
    + + + + + +
    + + +

    convertArgument

    +
    <static> java.lang.Object convertArgument(<Object> obj)
    + +
      Helper method for converting a Javascript object into + its appropriate Java object.
    + + + + +
      + Parameters: + +
        obj - The Javascript object to convert +
      + +
    + + + + +
      + Returns: +
        + The appropriate Java representation of the object +
      +
    + + + + + +
    + + +

    convertResult

    +
    <static> Object convertResult(<java.lang.Object> obj)
    + +
      Converts a Java object into its appropriate Javascript representation.
    + + + + +
      + Parameters: + +
        obj - The Java object to convert +
      + +
    + + + + +
      + Returns: +
        + The appropriate Javascript representation of the Java object +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.XmlWriter.html b/modules/jala/docs/jala.XmlWriter.html new file mode 100644 index 00000000..7ce2fdda --- /dev/null +++ b/modules/jala/docs/jala.XmlWriter.html @@ -0,0 +1,633 @@ + + + + + +jala.XmlWriter + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.XmlWriter

    +
    Object
    +   |
    +   +--jala.XmlWriter
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Rss20Writer +
    +
    + + +
    +
    + +
    class + jala.XmlWriter + + +
    + +

    +
    This class defines a generic interface to write + arbitrary and validating XML source code. This is done + by first applying data objects onto template objects, + both in a specified format. Then, the resulting object + tree is transformed into XML. Moreover, template objects + can be extended with other template objects to provide + full flexibility in inheriting subclasses. +
    Defined in XmlWriter.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.XmlWriter + + (<String> header) + +
    +             + Construct a new XML writer. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  jala.XmlWriter.XmlElement + + + + + addNamespace(<String> name, <String> url) + +
    +            + Add a namespace to this writer. +
    + +  jala.XmlWriter + + + + + clone(obj) + +
    +            + Clone this XML writer. +
    + +  jala.XmlWriter.XmlElement + + + + + createElement(<Object> data) + +
    +            + Get a newly created XML element. +
    + +  jala.XmlWriter + + + + + extend(<Object> template, <Object> ext) + +
    +            + Extend a template object. +
    + +  jala.XmlWriter.XmlElement + + + + + getRoot() + +
    +            + Get the root XML element of this writer. +
    + +  String + + + + + toString() + +
    +            + Get the XML output as string. +
    + +  void + + + + + write() + +
    +            + Write the XML to the response buffer. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.XmlWriter

    +
    jala.XmlWriter(<String> header)
    + + +
      + Construct a new XML writer. +
    + + + +
      + Parameters: + +
        header - An optional XML header. +
      + + +
    + + + + +
      + Returns: +
        + A new XML writer. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    addNamespace

    +
    jala.XmlWriter.XmlElement addNamespace(<String> name, <String> url)
    + +
      Add a namespace to this writer.
    + + + + +
      + Parameters: + +
        name - The name of the namespace. +
      + +
        url - The URL string of the namespace. +
      + +
    + + + + +
      + Returns: +
        + The XML root element. +
      +
    + + + + + +
    + + +

    clone

    +
    jala.XmlWriter clone(obj)
    + +
      Clone this XML writer.
    + + + + +
      + Parameters: + +
        The - clone templare. +
      + +
    + + + + +
      + Returns: +
        + The cloned XML writer. +
      +
    + + + + + +
    + + +

    createElement

    +
    jala.XmlWriter.XmlElement createElement(<Object> data)
    + +
      Get a newly created XML element.
    + + + + +
      + Parameters: + +
        data - The XML data as object tree. +
      + +
    + + + + +
      + Returns: +
        + The resulting XML element. +
      +
    + + + + + +
    + + +

    extend

    +
    jala.XmlWriter extend(<Object> template, <Object> ext)
    + +
      Extend a template object.
    + + + + +
      + Parameters: + +
        template - The template object. +
      + +
        ext - The extension object. +
      + +
    + + + + +
      + Returns: +
        + The XML writer. +
      +
    + + + + + +
    + + +

    getRoot

    +
    jala.XmlWriter.XmlElement getRoot()
    + +
      Get the root XML element of this writer.
    + + + + + + + +
      + Returns: +
        + The root XML element. +
      +
    + + + + + +
    + + +

    toString

    +
    String toString()
    + +
      Get the XML output as string.
    + + + + + + + +
      + Returns: +
        + The XML output. +
      +
    + + + + + +
    + + +

    write

    +
    void write()
    + +
      Write the XML to the response buffer.
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.db.DataType.html b/modules/jala/docs/jala.db.DataType.html new file mode 100644 index 00000000..e319ed22 --- /dev/null +++ b/modules/jala/docs/jala.db.DataType.html @@ -0,0 +1,475 @@ + + + + + +jala.db.DataType + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.0 + +
    + +
    + + +

    Class jala.db.DataType

    +
    Object
    +   |
    +   +--jala.db.DataType
    +
    + + +
    +
    + +
    class + jala.db.DataType + + +
    + +

    +
    Instances of this class represent a data type. Each instance + contains the code number as defined in java.sql.Types, the name of + the data type as defined in java.sql.Types and optional creation parameters + allowed for this data type. +
    Defined in Database.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.db.DataType + + (<Number> type, <String> typeName, <String> params) + +
    +             + Returns a newly created DataType instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  String + + + + + getParams() + +
    +            + Returns the creation parameter string of this data type +
    + +  Number + + + + + getType() + +
    +            + Returns the sql type code number as defined in java.sql.Types +
    + +  String + + + + + getTypeName() + +
    +            + Returns the type name of this data type, which can be + used in sql queries. +
    + +  Boolean + + + + + needsQuotes() + +
    +            + Returns true if values for this data type should be surrounded + by (single) quotes. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.db.DataType

    +
    jala.db.DataType(<Number> type, <String> typeName, <String> params)
    + + +
      + Returns a newly created DataType instance. +
    + + + +
      + Parameters: + +
        type - The sql code number of this data type +
      + +
        typeName - The type name of this data type, as used within sql statements +
      + +
        params - Optional creation parameters allowed for this data type. +
      + + +
    + + + + +
      + Returns: +
        + A newly created instance of DataType. +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getParams

    +
    String getParams()
    + +
      Returns the creation parameter string of this data type
    + + + + + + + +
      + Returns: +
        + The creation parameter string of this data type +
      +
    + + + + + +
    + + +

    getType

    +
    Number getType()
    + +
      Returns the sql type code number as defined in java.sql.Types
    + + + + + + + +
      + Returns: +
        + The sql type code number of this data type +
      +
    + + + + + +
    + + +

    getTypeName

    +
    String getTypeName()
    + +
      Returns the type name of this data type, which can be + used in sql queries.
    + + + + + + + +
      + Returns: +
        + The type name of this data type +
      +
    + + + + + +
    + + +

    needsQuotes

    +
    Boolean needsQuotes()
    + +
      Returns true if values for this data type should be surrounded + by (single) quotes.
    + + + + + + + +
      + Returns: +
        + True if values for this data type should be surrounded by quotes, false if not +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.0 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Wed Apr 4 17:06:49 2007
    + + diff --git a/modules/jala/docs/jala.db.FileDatabase.html b/modules/jala/docs/jala.db.FileDatabase.html new file mode 100644 index 00000000..bde70a26 --- /dev/null +++ b/modules/jala/docs/jala.db.FileDatabase.html @@ -0,0 +1,637 @@ + + + + + +jala.db.FileDatabase + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.db.FileDatabase

    +
    Object
    +   |
    +   +--jala.db.RamDatabase
    +         |
    +         +--jala.db.FileDatabase
    +
    + + +
    +
    + +
    class + jala.db.FileDatabase + +
    extends jala.db.RamDatabase + + +
    + +

    +
    Instances of this class represent a file based in-process database +
    Important: You need the h2.jar in directory "lib/ext" + of your helma installation for this library to work, which you can get + at http://www.h2database.com/. +
    Defined in Database.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.db.FileDatabase + + (<String> name, <helma.File> directory, <String> username, <String> password) + +
    +             + Returns a newly created instance of FileDatabase. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Boolean + + + + + backup(<helma.File> file) + +
    +            + Creates a backup of this database, using the file passed as argument. +
    + +  helma.File + + + + + getDirectory() + +
    +            + Returns the directory where the database files are stored. +
    + +  String + + + + + getName() + +
    +            + Returns the name of the database. +
    + +  String + + + + + getPassword() + +
    +            + Returns the password of this database +
    + +  String + + + + + getUsername() + +
    +            + Returns the username of this database +
    + +  Boolean + + + + + remove() + +
    +            + Deletes all files of this database on disk. +
    + +  Boolean + + + + + restore(<helma.File> backupFile) + +
    +            + Restores this database using a backup on disk. +
    + + + +  + + + + + + + +
    Methods inherited from class jala.db.RamDatabase
    + +getUrl, getProperties, getConnection, shutdown, dropTable, tableExists, copyTables, runScript, dump +
    +  + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.db.FileDatabase

    +
    jala.db.FileDatabase(<String> name, <helma.File> directory, <String> username, <String> password)
    + + +
      + Returns a newly created instance of FileDatabase. +
    + + + +
      + Parameters: + +
        name - The name of the database. This name is used as prefix for all database files +
      + +
        directory - The directory where the database files should be stored in. +
      + +
        username - Optional username (defaults to "sa"). This username is used when creating the database, so the same should be used when creating subsequent instances of jala.db.FileDatabase pointing to the same database +
      + +
        password - Optional password (defaults to ""). +
      + + +
    + + + + +
      + Returns: +
        + A newly created FileDatabase instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    backup

    +
    Boolean backup(<helma.File> file)
    + +
      Creates a backup of this database, using the file passed as argument. The + result will be a zipped file containing the database files
    + + + + +
      + Parameters: + +
        file - The file to write the backup to +
      + +
    + + + + +
      + Returns: +
        + True if the database backup was created successfully, false otherwise +
      +
    + + + + + +
    + + +

    getDirectory

    +
    helma.File getDirectory()
    + +
      Returns the directory where the database files are stored.
    + + + + + + + +
      + Returns: +
        + The directory where this database is stored. +
      +
    + + + + + +
    + + +

    getName

    +
    String getName()
    + +
      Returns the name of the database. This name is used as prefix + for all files of this database in the specified directory
    + + + + + + + +
      + Returns: +
        + The name of the database +
      +
    + + + + + +
    + + +

    getPassword

    +
    String getPassword()
    + +
      Returns the password of this database
    + + + + + + + +
      + Returns: +
        + The password of this database +
      +
    + + + + + +
    + + +

    getUsername

    +
    String getUsername()
    + +
      Returns the username of this database
    + + + + + + + +
      + Returns: +
        + The username of this database +
      +
    + + + + + +
    + + +

    remove

    +
    Boolean remove()
    + +
      Deletes all files of this database on disk. Note that this also + closes the database before removing it.
    + + + + + + + +
      + Returns: +
        + True in case the database was removed successfully, false otherwise +
      +
    + + + + + +
    + + +

    restore

    +
    Boolean restore(<helma.File> backupFile)
    + +
      Restores this database using a backup on disk.
    + + + + +
      + Parameters: + +
        backupFile - The backup file to use for restore +
      + +
    + + + + +
      + Returns: +
        + True if the database was successfully restored, false otherwise +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.db.RamDatabase.html b/modules/jala/docs/jala.db.RamDatabase.html new file mode 100644 index 00000000..da22e63e --- /dev/null +++ b/modules/jala/docs/jala.db.RamDatabase.html @@ -0,0 +1,886 @@ + + + + + +jala.db.RamDatabase + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.db.RamDatabase

    +
    Object
    +   |
    +   +--jala.db.RamDatabase
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.db.FileDatabase +
    +
    + + +
    +
    + +
    class + jala.db.RamDatabase + + +
    + +

    +
    Instances of this class represent an in-memory sql database. +
    Important: You need the h2.jar in directory "lib/ext" + of your helma installation for this library to work, which you can get + at http://www.h2database.com/. +
    Defined in Database.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.db.RamDatabase + + (<String> name, <String> username, <String> password) + +
    +             + Returns a newly created RamDatabase instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + copyTables(<helma.Database> database, <Array> tables) + +
    +            + Copies all tables in the database passed as argument into this embedded database. +
    + +  Boolean + + + + + dropTable(<String> tableName) + +
    +            + Drops the table with the given name +
    + +  Boolean + + + + + dump(<helma.File> file, <Object> props) + +
    +            + Dumps the database schema and data into a file +
    + +  helma.Database + + + + + getConnection(props) + +
    +            + Returns a connection to this database +
    + +  String + + + + + getName() + +
    +            + Returns the name of the database +
    + +  String + + + + + getPassword() + +
    +            + Returns the password of this database +
    + +  helma.util.ResourceProperties + + + + + getProperties(<Object> props) + +
    +            + Returns a properties object containing the connection properties + for this database. +
    + +  String + + + + + getUrl(<Object> props) + +
    +            + Returns the JDBC Url to connect to this database +
    + +  String + + + + + getUsername() + +
    +            + Returns the username of this database +
    + +  Boolean + + + + + runScript(<helma.File> file, <Object> props, <String> charset, <Boolean> continueOnError) + +
    +            + Runs the script file passed as argument in the context of this database. +
    + +  void + + + + + shutdown() + +
    +            + Stops this in-process database by issueing a "SHUTDOWN" sql command. +
    + +  Boolean + + + + + tableExists(<String> name) + +
    +            + Returns true if the table exists already in the database +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.db.RamDatabase

    +
    jala.db.RamDatabase(<String> name, <String> username, <String> password)
    + + +
      + Returns a newly created RamDatabase instance. +
    + + + +
      + Parameters: + +
        name - The name of the database. If not given a private un-named database is created, that can only be accessed through this instance of jala.db.RamDatabase +
      + +
        username - Optional username (defaults to "sa"). This username is used when creating the database, so the same should be used when creating subsequent instances of jala.db.RamDatabase pointing to a named database. +
      + +
        password - Optional password (defaults to ""). +
      + + +
    + + + + +
      + Returns: +
        + A newly created instance of RamDatabase +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    copyTables

    +
    void copyTables(<helma.Database> database, <Array> tables)
    + +
      Copies all tables in the database passed as argument into this embedded database. + If any of the tables already exists in this database, they will be removed before + re-created. Please mind that this method ignores any indexes in the source database, + but respects the primary key settings.
    + + + + +
      + Parameters: + +
        database - The database to copy the tables from +
      + +
        tables - An optional array containing the names of the tables to copy. If not given all tables are copied +
      + +
    + + + + + + + + +
    + + +

    dropTable

    +
    Boolean dropTable(<String> tableName)
    + +
      Drops the table with the given name
    + + + + +
      + Parameters: + +
        tableName - The name of the table +
      + +
    + + + + +
      + Returns: +
        + True if the table was successfully dropped, false otherwise +
      +
    + + + + + +
    + + +

    dump

    +
    Boolean dump(<helma.File> file, <Object> props)
    + +
      Dumps the database schema and data into a file
    + + + + +
      + Parameters: + +
        file - The file where the database dump will be +
      + +
        props - Optional object containing connection properties +
      + +
    + + + + +
      + Returns: +
        + True in case the database was successfully dumped, false otherwise +
      +
    + + + + + +
    + + +

    getConnection

    +
    helma.Database getConnection(props)
    + +
      Returns a connection to this database
    + + + + +
      + Parameters: + +
        An - optional parameter object containing connection properties to add to the connection Url. +
      + +
    + + + + +
      + Returns: +
        + A connection to this database +
      +
    + + + + + +
    + + +

    getName

    +
    String getName()
    + +
      Returns the name of the database
    + + + + + + + +
      + Returns: +
        + The name of the database +
      +
    + + + + + +
    + + +

    getPassword

    +
    String getPassword()
    + +
      Returns the password of this database
    + + + + + + + +
      + Returns: +
        + The password of this database +
      +
    + + + + + +
    + + +

    getProperties

    +
    helma.util.ResourceProperties getProperties(<Object> props)
    + +
      Returns a properties object containing the connection properties + for this database.
    + + + + +
      + Parameters: + +
        props - An optional parameter object containing connection properties to add to the connection Url. +
      + +
    + + + + +
      + Returns: +
        + A properties object containing the connection properties +
      +
    + + + + + +
    + + +

    getUrl

    +
    String getUrl(<Object> props)
    + +
      Returns the JDBC Url to connect to this database
    + + + + +
      + Parameters: + +
        props - Optional connection properties to add +
      + +
    + + + + +
      + Returns: +
        + The JDBC url to use for connecting to this database +
      +
    + + + + + +
    + + +

    getUsername

    +
    String getUsername()
    + +
      Returns the username of this database
    + + + + + + + +
      + Returns: +
        + The username of this database +
      +
    + + + + + +
    + + +

    runScript

    +
    Boolean runScript(<helma.File> file, <Object> props, <String> charset, <Boolean> continueOnError)
    + +
      Runs the script file passed as argument in the context of this database. + Use this method to eg. create and/or populate a database.
    + + + + +
      + Parameters: + +
        file - The script file to run +
      + +
        props - Optional object containing connection properties +
      + +
        charset - Optional character set to use (defaults to "UTF-8") +
      + +
        continueOnError - Optional flag indicating whether to continue on error or not (defaults to false) +
      + +
    + + + + +
      + Returns: +
        + True in case the script was executed successfully, false otherwise +
      +
    + + + + + +
    + + +

    shutdown

    +
    void shutdown()
    + +
      Stops this in-process database by issueing a "SHUTDOWN" sql command.
    + + + + + + + + + + + +
    + + +

    tableExists

    +
    Boolean tableExists(<String> name)
    + +
      Returns true if the table exists already in the database
    + + + + +
      + Parameters: + +
        name - The name of the table +
      + +
    + + + + +
      + Returns: +
        + True if the table exists, false otherwise +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.db.Server.html b/modules/jala/docs/jala.db.Server.html new file mode 100644 index 00000000..5ba94fb1 --- /dev/null +++ b/modules/jala/docs/jala.db.Server.html @@ -0,0 +1,850 @@ + + + + + +jala.db.Server + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.db.Server

    +
    Object
    +   |
    +   +--jala.db.Server
    +
    + + +
    +
    + +
    class + jala.db.Server + + +
    + +

    +
    Instances of this class represent a H2 database listener that + allows multiple databases to be accessed via tcp. +
    Important: You need the h2.jar in directory "lib/ext" + of your helma installation for this library to work, which you can get + at http://www.h2database.com/. +
    Defined in Database.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.db.Server + + (<helma.File> baseDir, <Number> port) + +
    +             + Returns a new Server instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Boolean + + + + + createOnDemand(<Boolean> bool) + +
    +            + If called with boolean true as argument, this server creates databases + on-the-fly, otherwise it only accepts connections to already existing + databases. +
    + +  helma.Database + + + + + getConnection(<String> name, <String> username, <String> password, <Object> props) + +
    +            + Returns a connection to a database within this server. +
    + +  helma.File + + + + + getDirectory() + +
    +            + Returns the directory used by this server instance +
    + +  Number + + + + + getPort() + +
    +            + Returns the port this server listens on +
    + +  helma.util.ResourceProperties + + + + + getProperties(<String> name, <String> username, <String> password, <Object> props) + +
    +            + Returns a properties object containing the connection properties + of the database with the given name. +
    + +  String + + + + + getUrl(<String> name, <Object> props) + +
    +            + Returns the JDBC Url to use for connections to a given database. +
    + +  Boolean + + + + + isPublic(<Boolean> bool) + +
    +            + If called with boolean true as argument, this server accepts connections + from outside localhost. +
    + +  Boolean + + + + + isRunning() + +
    +            + Returns true if the database server is running. +
    + +  Boolean + + + + + start() + +
    +            + Starts the database server. +
    + +  Boolean + + + + + stop() + +
    +            + Stops the database server. +
    + +  Boolean + + + + + useSsl(<Boolean> bool) + +
    +            + Toggles the use of Ssl encryption within this server. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.db.Server

    +
    jala.db.Server(<helma.File> baseDir, <Number> port)
    + + +
      + Returns a new Server instance. +
    + + + +
      + Parameters: + +
        baseDir - The directory where the database files are located or should be stored +
      + +
        port - The port to listen on (defaults to 9001) +
      + +
        createOnDemand - If true this server will create non-existing databases on-the-fly, if false it only accepts connections to already existing databases in the given base directory +
      + +
        makePublic - If true this database is reachable from outside, if false it's only reachable from localhost +
      + +
        useSsl - If true SSL will be used to encrypt the connection +
      + + +
    + + + + +
      + Returns: +
        + A newly created Server instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    createOnDemand

    +
    Boolean createOnDemand(<Boolean> bool)
    + +
      If called with boolean true as argument, this server creates databases + on-the-fly, otherwise it only accepts connections to already existing + databases. This should be set before starting the server.
    + + + + +
      + Parameters: + +
        bool - If true this server creates non-existing databases on demand, if false it only allows connections to existing databases. If no argument is given, this method returns the current setting. +
      + +
    + + + + +
      + Returns: +
        + The current setting if no argument is given, or void +
      +
    + + + + + +
    + + +

    getConnection

    +
    helma.Database getConnection(<String> name, <String> username, <String> password, <Object> props)
    + +
      Returns a connection to a database within this server.
    + + + + +
      + Parameters: + +
        name - The name of the database running within this server +
      + +
        username - Optional username to use for this connection +
      + +
        password - Optional password to use for this connection +
      + +
        props - An optional parameter object containing connection properties to add to the connection Url. +
      + +
    + + + + +
      + Returns: +
        + A connection to the specified database +
      +
    + + + + + +
    + + +

    getDirectory

    +
    helma.File getDirectory()
    + +
      Returns the directory used by this server instance
    + + + + + + + +
      + Returns: +
        + The directory where the databases used by this server are located in +
      +
    + + + + + +
    + + +

    getPort

    +
    Number getPort()
    + +
      Returns the port this server listens on
    + + + + + + + +
      + Returns: +
        + The port this server listens on +
      +
    + + + + + +
    + + +

    getProperties

    +
    helma.util.ResourceProperties getProperties(<String> name, <String> username, <String> password, <Object> props)
    + +
      Returns a properties object containing the connection properties + of the database with the given name.
    + + + + +
      + Parameters: + +
        name - The name of the database +
      + +
        username - Optional username to use for this connection +
      + +
        password - Optional password to use for this connection +
      + +
        props - An optional parameter object containing connection properties to add to the connection Url. +
      + +
    + + + + +
      + Returns: +
        + A properties object containing the connection properties +
      +
    + + + + + +
    + + +

    getUrl

    +
    String getUrl(<String> name, <Object> props)
    + +
      Returns the JDBC Url to use for connections to a given database.
    + + + + +
      + Parameters: + +
        name - An optional name of a database running +
      + +
        props - Optional connection properties to add +
      + +
    + + + + +
      + Returns: +
        + The JDBC Url to use for connecting to a database within this sever +
      +
    + + + + + +
    + + +

    isPublic

    +
    Boolean isPublic(<Boolean> bool)
    + +
      If called with boolean true as argument, this server accepts connections + from outside localhost. This should be set before starting the server.
    + + + + +
      + Parameters: + +
        bool - If true this server accepts connections from outside localhost. If no argument is given, this method returns the current setting. +
      + +
    + + + + +
      + Returns: +
        + The current setting if no argument is given, or void +
      +
    + + + + + +
    + + +

    isRunning

    +
    Boolean isRunning()
    + +
      Returns true if the database server is running.
    + + + + + + + +
      + Returns: +
        + True if the database server is running +
      +
    + + + + + +
    + + +

    start

    +
    Boolean start()
    + +
      Starts the database server.
    + + + + + + + +
      + Returns: +
        + True in case the server started successfully, false otherwise +
      +
    + + + + + +
    + + +

    stop

    +
    Boolean stop()
    + +
      Stops the database server.
    + + + + + + + +
      + Returns: +
        + True if stopping the server was successful, false otherwise +
      +
    + + + + + +
    + + +

    useSsl

    +
    Boolean useSsl(<Boolean> bool)
    + +
      Toggles the use of Ssl encryption within this server. This should be set + before starting the server.
    + + + + +
      + Parameters: + +
        bool - If true SSL encryption will be used, false otherwise. If no argument is given, this method returns the current setting. +
      + +
    + + + + +
      + Returns: +
        + The current setting if no argument is given, or void +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.db.html b/modules/jala/docs/jala.db.html new file mode 100644 index 00000000..7551bafd --- /dev/null +++ b/modules/jala/docs/jala.db.html @@ -0,0 +1,243 @@ + + + + + +jala.db + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala.db

    +
    Object
    +   |
    +   +--jala.db
    +
    + + +
    +
    + +
    class + jala.db + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.db.Server
    + <static class>jala.db.DataType
    + <static class>jala.db.RamDatabase
    + <static class>jala.db.FileDatabase
    +  + + + + + + + + + + + + + + + + +  + + + + + +

    + + + + + + + + + + + + + + + + + +


    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/jala.html b/modules/jala/docs/jala.html new file mode 100644 index 00000000..eb12207c --- /dev/null +++ b/modules/jala/docs/jala.html @@ -0,0 +1,423 @@ + + + + + +jala + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + +
    + + +

    Class jala

    +
    Object
    +   |
    +   +--jala
    +
    + + +
    +
    + +
    class + jala + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.AsyncRequest
    + <static class>jala.BitTorrent
    + <static class>jala.Captcha
    + <static class>jala.Date
    + <static class>jala.DnsClient
    + <static class>jala.Form
    + <static class>jala.History
    + <static class>jala.HtmlDocument
    + <static class>jala.I18n
    + <static class>jala.ImageFilter
    + <static class>jala.IndexManager
    + <static class>jala.ListRenderer
    + <static class>jala.Mp3
    + <static class>jala.PodcastWriter
    + <static class>jala.RemoteContent
    + <static class>jala.Rss20Writer
    + <static class>jala.Utilities
    + <static class>jala.XmlRpcRequest
    + <static class>jala.XmlWriter
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    + <static>  <final> jala.Datedate +
    +           Default date class instance.
    + <static>  Objectdb +
    +           Namespace declaration
    + <static>  <final> jala.I18ni18n +
    +           Default i18n class instance.
    + <static>  <final> jala.Utilitiesutil +
    +           Default utility class instance.
    +   + + + + + + + + + + + +  + + + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    date

    +
    <static> <final> jala.Date date
    +
      + Default date class instance. + +
    +
    + + +

    db

    +
    <static> Object db
    +
      + Namespace declaration + +
    +
    + + +

    i18n

    +
    <static> <final> jala.I18n i18n
    +
      + Default i18n class instance. + +
    +
    + + +

    util

    +
    <static> <final> jala.Utilities util
    +
      + Default utility class instance. + +
    +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-AsyncRequest.js.html b/modules/jala/docs/overview-AsyncRequest.js.html new file mode 100644 index 00000000..88c84e17 --- /dev/null +++ b/modules/jala/docs/overview-AsyncRequest.js.html @@ -0,0 +1,36 @@ + + + + + + AsyncRequest.js + + + + + + +

    + +AsyncRequest.js +
    + + + + + + + + +
    jala.AsyncRequest +
    +
    + + + diff --git a/modules/jala/docs/overview-BitTorrent.js.html b/modules/jala/docs/overview-BitTorrent.js.html new file mode 100644 index 00000000..40186fe3 --- /dev/null +++ b/modules/jala/docs/overview-BitTorrent.js.html @@ -0,0 +1,36 @@ + + + + + + BitTorrent.js + + + + + + +

    + +BitTorrent.js +
    + + + + + + + + +
    jala.BitTorrent +
    +
    + + + diff --git a/modules/jala/docs/overview-Captcha.js.html b/modules/jala/docs/overview-Captcha.js.html new file mode 100644 index 00000000..a3b39db1 --- /dev/null +++ b/modules/jala/docs/overview-Captcha.js.html @@ -0,0 +1,36 @@ + + + + + + Captcha.js + + + + + + +

    + +Captcha.js +
    + + + + + + + + +
    jala.Captcha +
    +
    + + + diff --git a/modules/jala/docs/overview-Database.js.html b/modules/jala/docs/overview-Database.js.html new file mode 100644 index 00000000..98301afd --- /dev/null +++ b/modules/jala/docs/overview-Database.js.html @@ -0,0 +1,48 @@ + + + + + + Database.js + + + + + + +

    + +Database.js +
    + + + + + + + + + + + + + + + + +
    jala.db.FileDatabase +
    +
    jala.db.RamDatabase +
    +
    jala.db.Server +
    +
    + + + diff --git a/modules/jala/docs/overview-Date.js.html b/modules/jala/docs/overview-Date.js.html new file mode 100644 index 00000000..41d49a7d --- /dev/null +++ b/modules/jala/docs/overview-Date.js.html @@ -0,0 +1,48 @@ + + + + + + Date.js + + + + + + +

    + +Date.js +
    + + + + + + + + + + + + + + + + +
    jala.Date +
    +
    jala.Date.Calendar +
    +
    jala.Date.Calendar.Renderer +
    +
    + + + diff --git a/modules/jala/docs/overview-DnsClient.js.html b/modules/jala/docs/overview-DnsClient.js.html new file mode 100644 index 00000000..cd8cfacb --- /dev/null +++ b/modules/jala/docs/overview-DnsClient.js.html @@ -0,0 +1,42 @@ + + + + + + DnsClient.js + + + + + + +

    + +DnsClient.js +
    + + + + + + + + + + + + +
    jala.DnsClient +
    +
    jala.DnsClient.Record +
    +
    + + + diff --git a/modules/jala/docs/overview-Form.js.html b/modules/jala/docs/overview-Form.js.html new file mode 100644 index 00000000..d95bfab3 --- /dev/null +++ b/modules/jala/docs/overview-Form.js.html @@ -0,0 +1,132 @@ + + + + + + Form.js + + + + + + +

    + +Form.js +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    jala.Form +
    +
    jala.Form.Component +
    +
    jala.Form.Component.Button +
    +
    jala.Form.Component.Checkbox +
    +
    jala.Form.Component.Date +
    +
    jala.Form.Component.Fieldset +
    +
    jala.Form.Component.File +
    +
    jala.Form.Component.Hidden +
    +
    jala.Form.Component.Image +
    +
    jala.Form.Component.Input +
    +
    jala.Form.Component.Password +
    +
    jala.Form.Component.Radio +
    +
    jala.Form.Component.Select +
    +
    jala.Form.Component.Skin +
    +
    jala.Form.Component.Submit +
    +
    jala.Form.Component.Textarea +
    +
    jala.Form.Tracker +
    +
    + + + diff --git a/modules/jala/docs/overview-Global.js.html b/modules/jala/docs/overview-Global.js.html new file mode 100644 index 00000000..0b33ab65 --- /dev/null +++ b/modules/jala/docs/overview-Global.js.html @@ -0,0 +1,30 @@ + + + + + + Global.js + + + + + + +

    + +Global.js +
    + + + + +
    + + + diff --git a/modules/jala/docs/overview-History.js.html b/modules/jala/docs/overview-History.js.html new file mode 100644 index 00000000..f9a292db --- /dev/null +++ b/modules/jala/docs/overview-History.js.html @@ -0,0 +1,36 @@ + + + + + + History.js + + + + + + +

    + +History.js +
    + + + + + + + + +
    jala.History +
    +
    + + + diff --git a/modules/jala/docs/overview-HopObject.js.html b/modules/jala/docs/overview-HopObject.js.html new file mode 100644 index 00000000..5096aa7f --- /dev/null +++ b/modules/jala/docs/overview-HopObject.js.html @@ -0,0 +1,30 @@ + + + + + + HopObject.js + + + + + + +

    + +HopObject.js +
    + + + + +
    + + + diff --git a/modules/jala/docs/overview-HtmlDocument.js.html b/modules/jala/docs/overview-HtmlDocument.js.html new file mode 100644 index 00000000..74abea83 --- /dev/null +++ b/modules/jala/docs/overview-HtmlDocument.js.html @@ -0,0 +1,36 @@ + + + + + + HtmlDocument.js + + + + + + +

    + +HtmlDocument.js +
    + + + + + + + + +
    jala.HtmlDocument +
    +
    + + + diff --git a/modules/jala/docs/overview-I18n.js.html b/modules/jala/docs/overview-I18n.js.html new file mode 100644 index 00000000..30a1f027 --- /dev/null +++ b/modules/jala/docs/overview-I18n.js.html @@ -0,0 +1,36 @@ + + + + + + I18n.js + + + + + + +

    + +I18n.js +
    + + + + + + + + +
    jala.I18n +
    +
    + + + diff --git a/modules/jala/docs/overview-ImageFilter.js.html b/modules/jala/docs/overview-ImageFilter.js.html new file mode 100644 index 00000000..c949f24b --- /dev/null +++ b/modules/jala/docs/overview-ImageFilter.js.html @@ -0,0 +1,36 @@ + + + + + + ImageFilter.js + + + + + + +

    + +ImageFilter.js +
    + + + + + + + + +
    jala.ImageFilter +
    +
    + + + diff --git a/modules/jala/docs/overview-IndexManager.js.html b/modules/jala/docs/overview-IndexManager.js.html new file mode 100644 index 00000000..1b4282eb --- /dev/null +++ b/modules/jala/docs/overview-IndexManager.js.html @@ -0,0 +1,42 @@ + + + + + + IndexManager.js + + + + + + +

    + +IndexManager.js +
    + + + + + + + + + + + + +
    jala.IndexManager +
    +
    jala.IndexManager.Job +
    +
    + + + diff --git a/modules/jala/docs/overview-ListRenderer.js.html b/modules/jala/docs/overview-ListRenderer.js.html new file mode 100644 index 00000000..9da05948 --- /dev/null +++ b/modules/jala/docs/overview-ListRenderer.js.html @@ -0,0 +1,42 @@ + + + + + + ListRenderer.js + + + + + + +

    + +ListRenderer.js +
    + + + + + + + + + + + + +
    jala.ListRenderer +
    +
    jala.ListRenderer.ArrayList +
    +
    + + + diff --git a/modules/jala/docs/overview-Mp3.js.html b/modules/jala/docs/overview-Mp3.js.html new file mode 100644 index 00000000..b20cd0ba --- /dev/null +++ b/modules/jala/docs/overview-Mp3.js.html @@ -0,0 +1,48 @@ + + + + + + Mp3.js + + + + + + +

    + +Mp3.js +
    + + + + + + + + + + + + + + + + +
    jala.Mp3 +
    +
    jala.Mp3.Id3v1 +
    +
    jala.Mp3.Id3v2 +
    +
    + + + diff --git a/modules/jala/docs/overview-PodcastWriter.js.html b/modules/jala/docs/overview-PodcastWriter.js.html new file mode 100644 index 00000000..266115dd --- /dev/null +++ b/modules/jala/docs/overview-PodcastWriter.js.html @@ -0,0 +1,36 @@ + + + + + + PodcastWriter.js + + + + + + +

    + +PodcastWriter.js +
    + + + + + + + + +
    jala.PodcastWriter +
    +
    + + + diff --git a/modules/jala/docs/overview-RemoteContent.js.html b/modules/jala/docs/overview-RemoteContent.js.html new file mode 100644 index 00000000..0d06a163 --- /dev/null +++ b/modules/jala/docs/overview-RemoteContent.js.html @@ -0,0 +1,36 @@ + + + + + + RemoteContent.js + + + + + + +

    + +RemoteContent.js +
    + + + + + + + + +
    jala.RemoteContent +
    +
    + + + diff --git a/modules/jala/docs/overview-Rss20Writer.js.html b/modules/jala/docs/overview-Rss20Writer.js.html new file mode 100644 index 00000000..ef353f62 --- /dev/null +++ b/modules/jala/docs/overview-Rss20Writer.js.html @@ -0,0 +1,36 @@ + + + + + + Rss20Writer.js + + + + + + +

    + +Rss20Writer.js +
    + + + + + + + + +
    jala.Rss20Writer +
    +
    + + + diff --git a/modules/jala/docs/overview-Utilities.js.html b/modules/jala/docs/overview-Utilities.js.html new file mode 100644 index 00000000..df24f343 --- /dev/null +++ b/modules/jala/docs/overview-Utilities.js.html @@ -0,0 +1,36 @@ + + + + + + Utilities.js + + + + + + +

    + +Utilities.js +
    + + + + + + + + +
    jala.Utilities +
    +
    + + + diff --git a/modules/jala/docs/overview-XmlRpcRequest.js.html b/modules/jala/docs/overview-XmlRpcRequest.js.html new file mode 100644 index 00000000..4570873b --- /dev/null +++ b/modules/jala/docs/overview-XmlRpcRequest.js.html @@ -0,0 +1,36 @@ + + + + + + XmlRpcRequest.js + + + + + + +

    + +XmlRpcRequest.js +
    + + + + + + + + +
    jala.XmlRpcRequest +
    +
    + + + diff --git a/modules/jala/docs/overview-XmlWriter.js.html b/modules/jala/docs/overview-XmlWriter.js.html new file mode 100644 index 00000000..e0a6fa19 --- /dev/null +++ b/modules/jala/docs/overview-XmlWriter.js.html @@ -0,0 +1,36 @@ + + + + + + XmlWriter.js + + + + + + +

    + +XmlWriter.js +
    + + + + + + + + +
    jala.XmlWriter +
    +
    + + + diff --git a/modules/jala/docs/overview-all.js.html b/modules/jala/docs/overview-all.js.html new file mode 100644 index 00000000..e2dce5a2 --- /dev/null +++ b/modules/jala/docs/overview-all.js.html @@ -0,0 +1,30 @@ + + + + + + all.js + + + + + + +

    + +all.js +
    + + + + +
    + + + diff --git a/modules/jala/docs/overview-frame.html b/modules/jala/docs/overview-frame.html new file mode 100644 index 00000000..41ebf84b --- /dev/null +++ b/modules/jala/docs/overview-frame.html @@ -0,0 +1,85 @@ + + + + +Overview () + + + + + + +

    Jala 1.3

    + + + + +
    + + + + + +
    All Classes +

    + +Files +
    + +all.js
    + +AsyncRequest.js
    + +BitTorrent.js
    + +Captcha.js
    + +Database.js
    + +Date.js
    + +DnsClient.js
    + +Form.js
    + +Global.js
    + +History.js
    + +HopObject.js
    + +HtmlDocument.js
    + +I18n.js
    + +ImageFilter.js
    + +IndexManager.js
    + +ListRenderer.js
    + +Mp3.js
    + +PodcastWriter.js
    + +RemoteContent.js
    + +Rss20Writer.js
    + +Utilities.js
    + +XmlRpcRequest.js
    + +XmlWriter.js
    + +

    + +

    +  + + diff --git a/modules/jala/docs/overview-summary-AsyncRequest.js.html b/modules/jala/docs/overview-summary-AsyncRequest.js.html new file mode 100644 index 00000000..2e5de3c2 --- /dev/null +++ b/modules/jala/docs/overview-summary-AsyncRequest.js.html @@ -0,0 +1,170 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +


    +
    + +

    AsyncRequest.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.AsyncRequest class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.AsyncRequestThis class is used to create requests of type "INTERNAL" + (like cron-jobs) that are processed in a separate thread and + therefor asynchronous.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-BitTorrent.js.html b/modules/jala/docs/overview-summary-BitTorrent.js.html new file mode 100644 index 00000000..d34bcb31 --- /dev/null +++ b/modules/jala/docs/overview-summary-BitTorrent.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    BitTorrent.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.BitTorrent class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.BitTorrentThis class provides methods to create a BitTorrent + metadata file from any desired file.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Captcha.js.html b/modules/jala/docs/overview-summary-Captcha.js.html new file mode 100644 index 00000000..70dfe35b --- /dev/null +++ b/modules/jala/docs/overview-summary-Captcha.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Captcha.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.Captcha class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.CaptchaWrapper class for the + JCaptcha library.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Database.js.html b/modules/jala/docs/overview-summary-Database.js.html new file mode 100644 index 00000000..d40deebf --- /dev/null +++ b/modules/jala/docs/overview-summary-Database.js.html @@ -0,0 +1,182 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Database.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.db package.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.db.FileDatabaseInstances of this class represent a file based in-process database +
    Important: You need the h2.jar in directory "lib/ext" + of your helma installation for this library to work, which you can get + at http://www.h2database.com/.
    jala.db.RamDatabaseInstances of this class represent an in-memory sql database.
    jala.db.ServerInstances of this class represent a H2 database listener that + allows multiple databases to be accessed via tcp.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Date.js.html b/modules/jala/docs/overview-summary-Date.js.html new file mode 100644 index 00000000..45b3be62 --- /dev/null +++ b/modules/jala/docs/overview-summary-Date.js.html @@ -0,0 +1,181 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Date.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.Date class.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.DateThis class provides various convenience + methods for rendering purposes.
    jala.Date.CalendarThis class represents a calendar based based on a grouped + collection of HopObjects.
    jala.Date.Calendar.RendererA default renderer to use in conjunction with jala.Date.Calendar +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-DnsClient.js.html b/modules/jala/docs/overview-summary-DnsClient.js.html new file mode 100644 index 00000000..8eb16e9b --- /dev/null +++ b/modules/jala/docs/overview-summary-DnsClient.js.html @@ -0,0 +1,175 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    DnsClient.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.DnsClient class.

    + +

    + +
    + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.DnsClientThis is a wrapper around the Dns Client by wonderly.org + providing methods for querying Dns servers.
    jala.DnsClient.RecordInstances of this class wrap record data as received + from the nameserver.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Form.js.html b/modules/jala/docs/overview-summary-Form.js.html new file mode 100644 index 00000000..c85ee5b6 --- /dev/null +++ b/modules/jala/docs/overview-summary-Form.js.html @@ -0,0 +1,264 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Form.js

    + +
    + + + + +

    Summary

    +

    + + This class can be used to render forms and to validate + and store user submits. Further types of form components can be added + by subclassing jala.Form.Component.Input.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.FormA class that renders forms, validates submitted form data and + stores the data in a specified object.
    jala.Form.Component 
    jala.Form.Component.ButtonSubclass of jala.Form.Component.Input which renders a button.
    jala.Form.Component.CheckboxSubclass of jala.Form.Component.Input which renders and validates a + checkbox.
    jala.Form.Component.DateSubclass of jala.Form.Component.Input which renders and validates a + date editor.
    jala.Form.Component.FieldsetInstances of this class represent a form fieldset containing + numerous form components +
    jala.Form.Component.FileSubclass of jala.Form.Component.Input which renders and validates a + file upload.
    jala.Form.Component.HiddenSubclass of jala.Form.Component.Input which renders and validates a + hidden input tag.
    jala.Form.Component.ImageSubclass of jala.Form.Component.File which renders a file upload + and validates uploaded files as images.
    jala.Form.Component.InputInstances of this class represent a single form input field.
    jala.Form.Component.PasswordSubclass of jala.Form.Component.Input which renders and validates a + password input tag.
    jala.Form.Component.RadioSubclass of jala.Form.Component.Input which renders and validates a + set of radio buttons.
    jala.Form.Component.SelectSubclass of jala.Form.Component.Input which renders and validates a + dropdown element.
    jala.Form.Component.SkinSubclass of jala.Form.Component that allows rendering a skin + within a form.
    jala.Form.Component.SubmitSubclass of jala.Form.Component.Button which renders a submit button.
    jala.Form.Component.TextareaSubclass of jala.Form.Component.Input which renders and validates a + textarea input field.
    jala.Form.TrackerInstances of this class can contain error-messages and values +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Global.js.html b/modules/jala/docs/overview-summary-Global.js.html new file mode 100644 index 00000000..a486ca23 --- /dev/null +++ b/modules/jala/docs/overview-summary-Global.js.html @@ -0,0 +1,324 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Global.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the Global prototype.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + Method Summary + +
    + + static Boolean + + + + + isArray(<Object> val) + +
    +            + Returns true if the value passed as argument is an array. +
    + + static Boolean + + + + + isBoolean(<Object> val) + +
    +            + Returns true if the value passed as argument is either a boolean + literal or an instance of Boolean. +
    + + static Boolean + + + + + isDate(<Object> val) + +
    +            + Returns true if the value passed as argument is either a Javascript date + or an instance of java.util.Date. +
    + + static Boolean + + + + + isFunction(<Object> val) + +
    +            + Returns true if the value passed as argument is a function. +
    + + static Boolean + + + + + isNull(<Object> val) + +
    +            + Returns true if the value passed as argument is null. +
    + + static Boolean + + + + + isNumber(<Object> val) + +
    +            + Returns true if the value passed as argument is either a number, + an instance of Number or of java.lang.Number. +
    + + static Boolean + + + + + isObject(<Object> val) + +
    +            + Returns true if the value passed as argument is either a Javascript + object or an instance of java.lang.Object. +
    + + static Boolean + + + + + isString(<Object> val) + +
    +            + Returns true if the value passed as argument is either a string literal, + an instance of String or of java.lang.String. +
    + + static Boolean + + + + + isUndefined(<Object> val) + +
    +            + Returns true if the value passed as argument is undefined. +
    +

    + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +


    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-History.js.html b/modules/jala/docs/overview-summary-History.js.html new file mode 100644 index 00000000..6f521c76 --- /dev/null +++ b/modules/jala/docs/overview-summary-History.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    History.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.History class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.HistoryThis class is an implementation of a Browser-like history + stack suitable to use in any Helma application.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-HopObject.js.html b/modules/jala/docs/overview-summary-HopObject.js.html new file mode 100644 index 00000000..fcf4c14f --- /dev/null +++ b/modules/jala/docs/overview-summary-HopObject.js.html @@ -0,0 +1,151 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    HopObject.js

    + +
    + + + + +

    Summary

    +

    + + Additional fields and methods of the HopObject class.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-HtmlDocument.js.html b/modules/jala/docs/overview-summary-HtmlDocument.js.html new file mode 100644 index 00000000..27b462c1 --- /dev/null +++ b/modules/jala/docs/overview-summary-HtmlDocument.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    HtmlDocument.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.HtmlDocument class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.HtmlDocumentThis class provides easy access to the elements of + an arbitrary HTML document.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-I18n.js.html b/modules/jala/docs/overview-summary-I18n.js.html new file mode 100644 index 00000000..4dc0d79d --- /dev/null +++ b/modules/jala/docs/overview-summary-I18n.js.html @@ -0,0 +1,170 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    I18n.js

    + +
    + + + + +

    Summary

    +

    + + Methods and macros for internationalization + of Helma applications.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.I18nThis class provides various functions and macros for + internationalization of Helma applications.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-ImageFilter.js.html b/modules/jala/docs/overview-summary-ImageFilter.js.html new file mode 100644 index 00000000..a5049352 --- /dev/null +++ b/modules/jala/docs/overview-summary-ImageFilter.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    ImageFilter.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.ImageFilter class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.ImageFilterThis class provides several image manipulating + methods.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-IndexManager.js.html b/modules/jala/docs/overview-summary-IndexManager.js.html new file mode 100644 index 00000000..60a323ab --- /dev/null +++ b/modules/jala/docs/overview-summary-IndexManager.js.html @@ -0,0 +1,175 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    IndexManager.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.IndexManager class.

    + +

    + +
    + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.IndexManagerThis class basically sits on top of a helma.Search.Index instance + and provides methods for adding, removing and optimizing the underlying index.
    jala.IndexManager.JobInstances of this class represent a single index + manipulation job to be processed by the index manager.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-ListRenderer.js.html b/modules/jala/docs/overview-summary-ListRenderer.js.html new file mode 100644 index 00000000..9727f143 --- /dev/null +++ b/modules/jala/docs/overview-summary-ListRenderer.js.html @@ -0,0 +1,174 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    ListRenderer.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.ListRenderer class.

    + +

    + +
    + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.ListRenderer 
    jala.ListRenderer.ArrayListA simple wrapper around an array to use in conjunction + with jala.ListRenderer.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Mp3.js.html b/modules/jala/docs/overview-summary-Mp3.js.html new file mode 100644 index 00000000..21624a71 --- /dev/null +++ b/modules/jala/docs/overview-summary-Mp3.js.html @@ -0,0 +1,179 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Mp3.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.audio package.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.Mp3This is a class representing an MP3 file + providing methods to access its metadata.
    jala.Mp3.Id3v1This class represents an Id3v1 tag.
    jala.Mp3.Id3v2This class represents an Id3v2 tag.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-PodcastWriter.js.html b/modules/jala/docs/overview-summary-PodcastWriter.js.html new file mode 100644 index 00000000..935ed3a0 --- /dev/null +++ b/modules/jala/docs/overview-summary-PodcastWriter.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    PodcastWriter.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.PodcastWriter class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.PodcastWriterClass to create, modify and render standard-compliant + RSS 2.0 feeds including support for Apple's Podcast specification.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-RemoteContent.js.html b/modules/jala/docs/overview-summary-RemoteContent.js.html new file mode 100644 index 00000000..697ab0b0 --- /dev/null +++ b/modules/jala/docs/overview-summary-RemoteContent.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    RemoteContent.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.RemoteContent class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.RemoteContentAPI to define, fetch and update content + from a remote site.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Rss20Writer.js.html b/modules/jala/docs/overview-summary-Rss20Writer.js.html new file mode 100644 index 00000000..3705e4e6 --- /dev/null +++ b/modules/jala/docs/overview-summary-Rss20Writer.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Rss20Writer.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.Rss20Writer class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.Rss20WriterClass to create, modify and render standard-compliant + RSS 2.0 feeds.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-Utilities.js.html b/modules/jala/docs/overview-summary-Utilities.js.html new file mode 100644 index 00000000..98b6fa71 --- /dev/null +++ b/modules/jala/docs/overview-summary-Utilities.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Utilities.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.Utilities class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.UtilitiesThis class contains various convenience methods + which do not fit in any other class.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-XmlRpcRequest.js.html b/modules/jala/docs/overview-summary-XmlRpcRequest.js.html new file mode 100644 index 00000000..3287421a --- /dev/null +++ b/modules/jala/docs/overview-summary-XmlRpcRequest.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    XmlRpcRequest.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.XmlRpcRequest class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.XmlRpcRequestInstances of this class provide the necessary functionality + for issueing XmlRpc requests to a remote service.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-XmlWriter.js.html b/modules/jala/docs/overview-summary-XmlWriter.js.html new file mode 100644 index 00000000..f2f0e31c --- /dev/null +++ b/modules/jala/docs/overview-summary-XmlWriter.js.html @@ -0,0 +1,169 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    XmlWriter.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.XmlWriter class.

    + +

    + +
    + + + + + + + + + + + + +
    + + Class Summary + +
    jala.XmlWriterThis class defines a generic interface to write + arbitrary and validating XML source code.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary-all.js.html b/modules/jala/docs/overview-summary-all.js.html new file mode 100644 index 00000000..b45afdd9 --- /dev/null +++ b/modules/jala/docs/overview-summary-all.js.html @@ -0,0 +1,151 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    all.js

    + +
    + + + + +

    Summary

    +

    + + Wrapper for automatic inclusion of all Jala modules.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-summary.html b/modules/jala/docs/overview-summary.html new file mode 100644 index 00000000..1c059073 --- /dev/null +++ b/modules/jala/docs/overview-summary.html @@ -0,0 +1,286 @@ + + + + +Jala 1.3 Overview + + + + + + + + + + + + + + + + + + +
    + +Jala 1.3 +
    + + +
    +
    + +

    Jala 1.3

    + +
    + + +

    + This document is the API Specification for + Jala 1.3. +

    + + + +

    Summary

    +

    + + Jala is a Helma-based library and utility project initially developed to ease the work at ORF.at's software development department. + + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + File Summary + +
    all.jsWrapper for automatic inclusion of all Jala modules.
    AsyncRequest.jsFields and methods of the jala.AsyncRequest class.
    BitTorrent.jsFields and methods of the jala.BitTorrent class.
    Captcha.jsFields and methods of the jala.Captcha class.
    Database.jsFields and methods of the jala.db package.
    Date.jsFields and methods of the jala.Date class.
    DnsClient.jsFields and methods of the jala.DnsClient class.
    Form.jsThis class can be used to render forms and to validate + and store user submits.
    Global.jsFields and methods of the Global prototype.
    History.jsFields and methods of the jala.History class.
    HopObject.jsAdditional fields and methods of the HopObject class.
    HtmlDocument.jsFields and methods of the jala.HtmlDocument class.
    I18n.jsMethods and macros for internationalization + of Helma applications.
    ImageFilter.jsFields and methods of the jala.ImageFilter class.
    IndexManager.jsFields and methods of the jala.IndexManager class.
    ListRenderer.jsFields and methods of the jala.ListRenderer class.
    Mp3.jsFields and methods of the jala.audio package.
    PodcastWriter.jsFields and methods of the jala.PodcastWriter class.
    RemoteContent.jsFields and methods of the jala.RemoteContent class.
    Rss20Writer.jsFields and methods of the jala.Rss20Writer class.
    Utilities.jsFields and methods of the jala.Utilities class.
    XmlRpcRequest.jsFields and methods of the jala.XmlRpcRequest class.
    XmlWriter.jsFields and methods of the jala.XmlWriter class.
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/overview-tree.html b/modules/jala/docs/overview-tree.html new file mode 100644 index 00000000..52df74e1 --- /dev/null +++ b/modules/jala/docs/overview-tree.html @@ -0,0 +1,316 @@ + + + + + +Jala 1.3 Class Hierarchy + + + + + + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    +

    Class Hierarchy

    + + + +
    + + + + + + + + + + + + + +
    +Jala 1.3 +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008
    + + diff --git a/modules/jala/docs/stylesheet.css b/modules/jala/docs/stylesheet.css new file mode 100644 index 00000000..7a35c0c1 --- /dev/null +++ b/modules/jala/docs/stylesheet.css @@ -0,0 +1,39 @@ +/* JSDoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ +.TableRowColor { background: #FFFFFF } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameHeadingFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } + +/* Example of smaller, sans-serif font in frames */ +/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ +.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} + +.jsdoc_ctime { font-family: Arial, Helvetica, sans-serif; font-size: 9pt; + text-align: right } + +/* Sourcecode view */ +.sourceview { background: #FFFFFF } +.attrib { color: #DD7777 } +.comment { color: #55AA55 } +.reserved { color: #FF5555 } +.literal { color: #5555FF } + diff --git a/modules/jala/lib/dom4j-1.6.1.jar b/modules/jala/lib/dom4j-1.6.1.jar new file mode 100644 index 00000000..c8c4dbb9 Binary files /dev/null and b/modules/jala/lib/dom4j-1.6.1.jar differ diff --git a/modules/jala/lib/id3-1.6.0d9.jar b/modules/jala/lib/id3-1.6.0d9.jar new file mode 100644 index 00000000..7da41c59 Binary files /dev/null and b/modules/jala/lib/id3-1.6.0d9.jar differ diff --git a/modules/jala/lib/javadns.jar b/modules/jala/lib/javadns.jar new file mode 100644 index 00000000..13b2ec77 Binary files /dev/null and b/modules/jala/lib/javadns.jar differ diff --git a/modules/jala/lib/jaxen-1.1-beta-8.jar b/modules/jala/lib/jaxen-1.1-beta-8.jar new file mode 100644 index 00000000..6b007d97 Binary files /dev/null and b/modules/jala/lib/jaxen-1.1-beta-8.jar differ diff --git a/modules/jala/lib/jid3lib-0.5.4.jar b/modules/jala/lib/jid3lib-0.5.4.jar new file mode 100644 index 00000000..c0b8ed94 Binary files /dev/null and b/modules/jala/lib/jid3lib-0.5.4.jar differ diff --git a/modules/jala/licenses/dom4j.txt b/modules/jala/licenses/dom4j.txt new file mode 100644 index 00000000..7cae050c --- /dev/null +++ b/modules/jala/licenses/dom4j.txt @@ -0,0 +1,40 @@ +Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided +that the following conditions are met: + +1. Redistributions of source code must retain copyright + statements and notices. Redistributions must also contain a + copy of this document. + +2. Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. The name "DOM4J" must not be used to endorse or promote + products derived from this Software without prior written + permission of MetaStuff, Ltd. For written permission, + please contact dom4j-info@metastuff.com. + +4. Products derived from this Software may not be called "DOM4J" + nor may "DOM4J" appear in their names without prior written + permission of MetaStuff, Ltd. DOM4J is a registered + trademark of MetaStuff, Ltd. + +5. Due credit should be given to the DOM4J Project - + http://www.dom4j.org + +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +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 OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/modules/jala/licenses/id3.txt b/modules/jala/licenses/id3.txt new file mode 100644 index 00000000..5ab7695a --- /dev/null +++ b/modules/jala/licenses/id3.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/modules/jala/licenses/jala.txt b/modules/jala/licenses/jala.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/modules/jala/licenses/jala.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) 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. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/modules/jala/licenses/javadns.txt b/modules/jala/licenses/javadns.txt new file mode 100644 index 00000000..56e3f124 --- /dev/null +++ b/modules/jala/licenses/javadns.txt @@ -0,0 +1,29 @@ +Copyright (c) 2001-2004, Gregg Wonderly +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +Neither the name of Gregg Wonderly nor the names of contributors to this +software may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/modules/jala/licenses/javamusictag.html b/modules/jala/licenses/javamusictag.html new file mode 100644 index 00000000..487e60aa --- /dev/null +++ b/modules/jala/licenses/javamusictag.html @@ -0,0 +1,613 @@ + + + + GNU Lesser General Public License - GNU Project - Free Software Foundation (FSF) + + + +

    GNU Lesser General Public License

    + +

    + Version 2.1, February 1999 + +

    + +

    +

    Copyright (C) 1991, 1999 Free Software Foundation, Inc.
    +    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    +    Everyone is permitted to copy and distribute verbatim copies
    +    of this license document, but changing it is not allowed.
    +
    +    [This is the first released version of the Lesser GPL. It also counts
    +    as the successor of the GNU Library Public License, version 2, hence
    +    the version number 2.1.]
    +
    + + +

    Preamble

    + +

    + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public + Licenses are intended to guarantee your freedom to share and change + free software--to make sure the software is free for all its users. +

    + +

    + This license, the Lesser General Public License, applies to some + specially designated software packages--typically libraries--of the + Free Software Foundation and other authors who decide to use it. You + can use it too, but we suggest you first think carefully about whether + this license or the ordinary General Public License is the better + strategy to use in any particular case, based on the explanations below. +

    + +

    + When we speak of free software, we are referring to freedom of use, + not price. Our General Public Licenses are designed to make sure that + you have the freedom to distribute copies of free software (and charge + for this service if you wish); that you receive source code or can get + it if you want it; that you can change the software and use pieces of + it in new free programs; and that you are informed that you can do + these things. +

    + +

    + To protect your rights, we need to make restrictions that forbid + distributors to deny you these rights or to ask you to surrender these + rights. These restrictions translate to certain responsibilities for + you if you distribute copies of the library or if you modify it. +

    + +

    + For example, if you distribute copies of the library, whether gratis + or for a fee, you must give the recipients all the rights that we gave + you. You must make sure that they, too, receive or can get the source + code. If you link other code with the library, you must provide + complete object files to the recipients, so that they can relink them + with the library after making changes to the library and recompiling + it. And you must show them these terms so they know their rights. +

    + +

    + We protect your rights with a two-step method: (1) we copyright the + library, and (2) we offer you this license, which gives you legal + permission to copy, distribute and/or modify the library. +

    + +

    + To protect each distributor, we want to make it very clear that + there is no warranty for the free library. Also, if the library is + modified by someone else and passed on, the recipients should know + that what they have is not the original version, so that the original + author's reputation will not be affected by problems that might be + introduced by others. +

    + +

    + Finally, software patents pose a constant threat to the existence of + any free program. We wish to make sure that a company cannot + effectively restrict the users of a free program by obtaining a + restrictive license from a patent holder. Therefore, we insist that + any patent license obtained for a version of the library must be + consistent with the full freedom of use specified in this license. +

    + +

    + Most GNU software, including some libraries, is covered by the + ordinary GNU General Public License. This license, the GNU Lesser + General Public License, applies to certain designated libraries, and + is quite different from the ordinary General Public License. We use + this license for certain libraries in order to permit linking those + libraries into non-free programs. +

    + +

    + When a program is linked with a library, whether statically or using + a shared library, the combination of the two is legally speaking a + combined work, a derivative of the original library. The ordinary + General Public License therefore permits such linking only if the + entire combination fits its criteria of freedom. The Lesser General + Public License permits more lax criteria for linking other code with + the library. +

    + +

    + We call this license the "Lesser" General Public License because it + does Less to protect the user's freedom than the ordinary General + Public License. It also provides other free software developers Less + of an advantage over competing non-free programs. These disadvantages + are the reason we use the ordinary General Public License for many + libraries. However, the Lesser license provides advantages in certain + special circumstances. +

    + +

    + For example, on rare occasions, there may be a special need to + encourage the widest possible use of a certain library, so that it becomes + a de-facto standard. To achieve this, non-free programs must be + allowed to use the library. A more frequent case is that a free + library does the same job as widely used non-free libraries. In this + case, there is little to gain by limiting the free library to free + software only, so we use the Lesser General Public License. +

    + +

    + In other cases, permission to use a particular library in non-free + programs enables a greater number of people to use a large body of + free software. For example, permission to use the GNU C Library in + non-free programs enables many more people to use the whole GNU + operating system, as well as its variant, the GNU/Linux operating + system. +

    + +

    + Although the Lesser General Public License is Less protective of the + users' freedom, it does ensure that the user of a program that is + linked with the Library has the freedom and the wherewithal to run + that program using a modified version of the Library. +

    + +

    + The precise terms and conditions for copying, distribution and + modification follow. Pay close attention to the difference between a + "work based on the library" and a "work that uses the library". The + former contains code derived from the library, whereas the latter must + be combined with the library in order to run. +

    + +

    + +

    + +

    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

    + + +

    + 0. + This License Agreement applies to any software library or other + program which contains a notice placed by the copyright holder or + other authorized party saying it may be distributed under the terms of + this Lesser General Public License (also called "this License"). + Each licensee is addressed as "you". +

    + +

    + A "library" means a collection of software functions and/or data + prepared so as to be conveniently linked with application programs + (which use some of those functions and data) to form executables. +

    + +

    + The "Library", below, refers to any such software library or work + which has been distributed under these terms. A "work based on the + Library" means either the Library or any derivative work under + copyright law: that is to say, a work containing the Library or a + portion of it, either verbatim or with modifications and/or translated + straightforwardly into another language. (Hereinafter, translation is + included without limitation in the term "modification".) +

    + +

    + "Source code" for a work means the preferred form of the work for + making modifications to it. For a library, complete source code means + all the source code for all modules it contains, plus any associated + interface definition files, plus the scripts used to control compilation + and installation of the library. +

    + +

    + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of + running a program using the Library is not restricted, and output from + such a program is covered only if its contents constitute a work based + on the Library (independent of the use of the Library in a tool for + writing it). Whether that is true depends on what the Library does + and what the program that uses the Library does. +

    + +

    + 1. + You may copy and distribute verbatim copies of the Library's + complete source code as you receive it, in any medium, provided that + you conspicuously and appropriately publish on each copy an + appropriate copyright notice and disclaimer of warranty; keep intact + all the notices that refer to this License and to the absence of any + warranty; and distribute a copy of this License along with the + Library. +

    + +

    + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange for a + fee. +

    + +

    + 2. + You may modify your copy or copies of the Library or any portion + of it, thus forming a work based on the Library, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: +

    + +

    +

      +
    • a) + The modified work must itself be a software library. +
    • b) + You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + +
    • c) + You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + +
    • d) + If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. +

      + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) +

      + +

      + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Library, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Library, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote + it. +

      + +

      + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Library. +

      + +

      + In addition, mere aggregation of another work not based on the Library + with the Library (or with a work based on the Library) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. +

    + +

    + 3. + You may opt to apply the terms of the ordinary GNU General Public + License instead of this License to a given copy of the Library. To do + this, you must alter all the notices that refer to this License, so + that they refer to the ordinary GNU General Public License, version 2, + instead of to this License. (If a newer version than version 2 of the + ordinary GNU General Public License has appeared, then you can specify + that version instead if you wish.) Do not make any other change in + these notices. +

    + +

    + Once this change is made in a given copy, it is irreversible for + that copy, so the ordinary GNU General Public License applies to all + subsequent copies and derivative works made from that copy. +

    + +

    + This option is useful when you wish to copy part of the code of + the Library into a program that is not a library. +

    + +

    + 4. + You may copy and distribute the Library (or a portion or + derivative of it, under Section 2) in object code or executable form + under the terms of Sections 1 and 2 above provided that you accompany + it with the complete corresponding machine-readable source code, which + must be distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange. +

    + +

    + If distribution of object code is made by offering access to copy + from a designated place, then offering equivalent access to copy the + source code from the same place satisfies the requirement to + distribute the source code, even though third parties are not + compelled to copy the source along with the object code. +

    + +

    + 5. + A program that contains no derivative of any portion of the + Library, but is designed to work with the Library by being compiled or + linked with it, is called a "work that uses the Library". Such a + work, in isolation, is not a derivative work of the Library, and + therefore falls outside the scope of this License. +

    + +

    + However, linking a "work that uses the Library" with the Library + creates an executable that is a derivative of the Library (because it + contains portions of the Library), rather than a "work that uses the + library". The executable is therefore covered by this License. + Section 6 states terms for distribution of such executables. +

    + +

    + When a "work that uses the Library" uses material from a header file + that is part of the Library, the object code for the work may be a + derivative work of the Library even though the source code is not. + Whether this is true is especially significant if the work can be + linked without the Library, or if the work is itself a library. The + threshold for this to be true is not precisely defined by law. +

    + +

    + If such an object file uses only numerical parameters, data + structure layouts and accessors, and small macros and small inline + functions (ten lines or less in length), then the use of the object + file is unrestricted, regardless of whether it is legally a derivative + work. (Executables containing this object code plus portions of the + Library will still fall under Section 6.) +

    + +

    + Otherwise, if the work is a derivative of the Library, you may + distribute the object code for the work under the terms of Section 6. + Any executables containing that work also fall under Section 6, + whether or not they are linked directly with the Library itself. +

    + +

    + 6. + As an exception to the Sections above, you may also combine or + link a "work that uses the Library" with the Library to produce a + work containing portions of the Library, and distribute that work + under terms of your choice, provided that the terms permit + modification of the work for the customer's own use and reverse + engineering for debugging such modifications. +

    + +

    + You must give prominent notice with each copy of the work that the + Library is used in it and that the Library and its use are covered by + this License. You must supply a copy of this License. If the work + during execution displays copyright notices, you must include the + copyright notice for the Library among them, as well as a reference + directing the user to the copy of this License. Also, you must do one + of these things: +

    + +

    +

      +
    • a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + +
    • b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + +
    • c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + +
    • d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + +
    • e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. +
    + +

    + For an executable, the required form of the "work that uses the + Library" must include any data and utility programs needed for + reproducing the executable from it. However, as a special exception, + the materials to be distributed need not include anything that is + normally distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system on + which the executable runs, unless that component itself accompanies + the executable. +

    + +

    + It may happen that this requirement contradicts the license + restrictions of other proprietary libraries that do not normally + accompany the operating system. Such a contradiction means you cannot + use both them and the Library together in an executable that you + distribute. +

    + +

    + 7. You may place library facilities that are a work based on the + Library side-by-side in a single library together with other library + facilities not covered by this License, and distribute such a combined + library, provided that the separate distribution of the work based on + the Library and of the other library facilities is otherwise + permitted, and provided that you do these two things: +

    + +

    +

      +
    • a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + +
    • b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. +
    + +

    + 8. You may not copy, modify, sublicense, link with, or distribute + the Library except as expressly provided under this License. Any + attempt otherwise to copy, modify, sublicense, link with, or + distribute the Library is void, and will automatically terminate your + rights under this License. However, parties who have received copies, + or rights, from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. +

    + +

    + 9. + You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Library or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Library (or any work based on the + Library), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Library or works based on it. +

    + +

    + 10. + Each time you redistribute the Library (or any work based on the + Library), the recipient automatically receives a license from the + original licensor to copy, distribute, link with or modify the Library + subject to these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties with + this License. +

    + +

    + 11. + If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Library at all. For example, if a patent + license would not permit royalty-free redistribution of the Library by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Library. +

    + +

    + If any portion of this section is held invalid or unenforceable under any + particular circumstance, the balance of the section is intended to apply, + and the section as a whole is intended to apply in other circumstances. +

    + +

    + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. +

    + +

    + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. +

    + +

    + 12. + If the distribution and/or use of the Library is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Library under this License may add + an explicit geographical distribution limitation excluding those countries, + so that distribution is permitted only in or among countries not thus + excluded. In such case, this License incorporates the limitation as if + written in the body of this License. +

    + +

    + 13. + The Free Software Foundation may publish revised and/or new + versions of the Lesser General Public License from time to time. + Such new versions will be similar in spirit to the present version, + but may differ in detail to address new problems or concerns. +

    + +

    + Each version is given a distinguishing version number. If the Library + specifies a version number of this License which applies to it and + "any later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Library does not specify a + license version number, you may choose any version ever published by + the Free Software Foundation. +

    + +

    + 14. + If you wish to incorporate parts of the Library into other free + programs whose distribution conditions are incompatible with these, + write to the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free + Software Foundation; we sometimes make exceptions for this. Our + decision will be guided by the two goals of preserving the free status + of all derivatives of our free software and of promoting the sharing + and reuse of software generally. +

    + +

    + NO WARRANTY +

    + +

    + 15. + BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE + LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME + THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +

    + +

    + 16. + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU + FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR + CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE + LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING + RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A + FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF + SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. +

    + \ No newline at end of file diff --git a/modules/jala/tests/1meg.reference-win.torrent b/modules/jala/tests/1meg.reference-win.torrent new file mode 100644 index 00000000..bfa6890a --- /dev/null +++ b/modules/jala/tests/1meg.reference-win.torrent @@ -0,0 +1 @@ +d8:announce30:http://tracker.orf.at/announce13:creation datei1172497604e4:infod6:lengthi1048576e4:name4:1meg12:piece lengthi262144e6:pieces80:. §èWYÇôÂTÔÙÃ>ôäY§. §èWYÇôÂTÔÙÃ>ôäY§. §èWYÇôÂTÔÙÃ>ôäY§. §èWYÇôÂTÔÙÃ>ôäY§ee \ No newline at end of file diff --git a/modules/jala/tests/1meg.reference.torrent b/modules/jala/tests/1meg.reference.torrent new file mode 100644 index 00000000..16454c90 Binary files /dev/null and b/modules/jala/tests/1meg.reference.torrent differ diff --git a/modules/jala/tests/AsyncRequest.js b/modules/jala/tests/AsyncRequest.js new file mode 100644 index 00000000..c7033aa2 --- /dev/null +++ b/modules/jala/tests/AsyncRequest.js @@ -0,0 +1,65 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +var result = undefined; + +/** + * A simple test of jala.AsyncRequest. It constructs a new AsyncRequest + * with a test function defined below that sets various properties + * of the global result object above. After evaluating the async request + * the current thread sleeps for a short period of time to wait for + * the other request to finish, and then does the testing of the result. + */ +var testAsyncRequest = function() { + var r = new jala.AsyncRequest(global, "testFunction"); + r.run("jala"); + // wait until the async request started above has finished + // before testing the result, but no longer than 1 second. + var elapsed = 0; + var interval = 5; + while (result === undefined && elapsed < 1000) { + elapsed += interval; + java.lang.Thread.sleep(interval); + } + assertNotUndefined(result); + assertEqual(result.name, "jala"); + assertEqual(result.request, req); + assertEqual(result.response, res); + assertFalse(r.isAlive()); + return; +}; + +/** + * A simple test function that assigns an object to the global + * property "result". + * @param {String} name A string to use as name + */ +var testFunction = function(name) { + result = { + name: name, + request: req, + response: res + }; + return; +}; diff --git a/modules/jala/tests/BitTorrent.js b/modules/jala/tests/BitTorrent.js new file mode 100644 index 00000000..ac1e92bd --- /dev/null +++ b/modules/jala/tests/BitTorrent.js @@ -0,0 +1,59 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * A simple test of jala.BitTorrent. + * FIXME: Needs resolution of issue #33 + */ +var testBitTorrent = function() { + var size = 1024 * 1024; // 1 meg + var file = new java.io.File(jala.Test.getTestFile("1meg")); + var fos = new java.io.FileOutputStream(file, false); + var channel = fos.getChannel(); + var iterations = 0; + while (channel.size() < size) { + channel.write(java.nio.ByteBuffer.allocate(1024)); + } + channel.close(); + fos.close(); + + var torrent = new jala.BitTorrent(file); + // Testing against file generated with BitTorrent.app (OS X) + torrent.set("announce", "http://tracker.orf.at/announce"); + // S3 defines a multitracker list with a single tracker item + //torrent.set("announce-list", [["http://tracker.amazonaws.com:6969/announce"]]); + torrent.setCreationDate(new Date(2007, 1, 26, 14, 46, 44)); + torrent.save(); + file["delete"](); + + try { + var torrentFile = torrent.getTorrentFile(); + var refFile = new helma.File(jala.Test.getTestFile("1meg.reference.torrent")); + assertEqual(torrentFile.readAll().trim(), refFile.readAll().trim()); + } catch (x) { + throw(x); + } finally { + torrentFile.remove(); + } + return; +}; diff --git a/modules/jala/tests/Database.js b/modules/jala/tests/Database.js new file mode 100644 index 00000000..a2b95509 --- /dev/null +++ b/modules/jala/tests/Database.js @@ -0,0 +1,163 @@ +/** + * Contains the system's temporary directory + * @type helma.File + * @private + */ +var tmpDir = new helma.File(java.lang.System.getProperty("java.io.tmpdir")); + +/** + * Contains the server created in testServer method + * @private + */ +var server = null; + +/** + * Basic tests for jala.db.RamDatabase. All of these tests are + * valid for jala.db.FileDatabase too. + */ +var testRamDatabase = function() { + var db = new jala.db.RamDatabase("test"); + assertNotNull(db); + assertEqual(db.getName(), "test"); + assertEqual(db.getDatabasePath(), "mem:test"); + assertEqual(db.getUrl(), "jdbc:h2:mem:test"); + // test connection to database + var conn = db.getConnection(); + assertNotNull(conn); + assertTrue(conn instanceof helma.Database); + + // create a table + db.createTable("test", [ + { + name: "id", + type: java.sql.Types.INTEGER, + nullable: false, + unique: true + }, + { + name: "name", + type: java.sql.Types.VARCHAR, + length: 255 + } + ], "id"); + + // test if the table exists + assertTrue(db.tableExists("test")); + + // dump database + var dumpFile = new helma.File(tmpDir, "backup.test.sql"); + assertTrue(db.dump(dumpFile)); + assertTrue(dumpFile.exists()); + assertTrue(dumpFile.getLength() > 0); + // remove dump file again + dumpFile.remove(); + + // drop table + db.dropTable("test"); + assertFalse(db.tableExists("test")); + + // test db shutdown + db.shutdown(); + assertThrows(function() { + conn.query("select 1 = 1"); + }, Packages.org.h2.jdbc.JdbcSQLException); + return; +}; + +/** + * Basic tests for jala.db.FileDatabase that are different to + * jala.db.RamDatabase + */ +var testFileDatabase = function() { + var db = new jala.db.FileDatabase("test", tmpDir); + assertNotNull(db); + assertEqual(db.getName(), "test"); + assertEqual(db.getDirectory(), tmpDir); + + var dbDir = new helma.File(tmpDir, "test"); + assertEqual(db.getDatabasePath(), "file:" + dbDir.getAbsolutePath()); + assertEqual(db.getUrl(), "jdbc:h2:file:" + dbDir.getAbsolutePath()); + + // execute sql script (need to do that, otherwise the backup won't + // work because the database is empty) + var sqlFile = jala.Test.getTestFile("Database.script.sql"); + assertTrue(db.runScript(sqlFile)); + assertTrue(db.tableExists("test")); + + // test backup + var backupFile = new helma.File(tmpDir, "backup.zip"); + assertTrue(db.backup(backupFile)); + assertTrue(backupFile.exists()); + assertTrue(backupFile.getLength() > 0); + + // remove the database + db.remove(); + assertFalse((new helma.File(db.getDirectory(), db.getName() + ".data.db")).exists()); + assertFalse((new helma.File(db.getDirectory(), db.getName() + ".index.db")).exists()); + assertFalse((new helma.File(db.getDirectory(), db.getName() + ".trace.db")).exists()); + + // test restore + assertTrue(db.restore(backupFile)); + assertTrue(db.tableExists("test")); + + // remove backup file and database + backupFile.remove(); + db.remove(); + + return; +}; + +var testServer = function() { + server = new jala.db.Server(tmpDir); + // test default config + assertEqual(tmpDir, server.getDirectory()); + assertEqual(server.getPort(), 9092); + assertFalse(server.useSsl()); + assertFalse(server.isPublic()); + assertFalse(server.createOnDemand()); + + // test setting config properties + server.useSsl(true); + assertTrue(server.useSsl()); + server.isPublic(true); + assertTrue(server.isPublic()); + server.createOnDemand(true); + assertTrue(server.createOnDemand()); + + // reset back some of them + server.useSsl(false); + assertFalse(server.useSsl()); + server.isPublic(false); + assertFalse(server.isPublic()); + + // start the server + assertTrue(server.start()); + + // test connection properties (this also includes testing + // of server.getUrl()) + var props = server.getProperties("test", "test", "1111"); + assertEqual(props.getProperty("test.url"), "jdbc:h2:tcp://localhost:9092/test"); + assertEqual(props.getProperty("test.driver"), "org.h2.Driver"); + assertEqual(props.getProperty("test.user"), "test"); + assertEqual(props.getProperty("test.password"), "1111"); + + var conn = server.getConnection("test", "test", "1111"); + assertNotNull(conn); + + // stop the server + assertTrue(server.stop()); + // and remove the file database created above + var db = new jala.db.FileDatabase("test", tmpDir, "test", "1111"); + db.remove(); + return; +}; + +/** + * Stuff to do on cleanup + */ +var cleanup = function() { + if (server != null) { + server.stop(); + } + return; +}; diff --git a/modules/jala/tests/Database.script.sql b/modules/jala/tests/Database.script.sql new file mode 100644 index 00000000..7beab74d --- /dev/null +++ b/modules/jala/tests/Database.script.sql @@ -0,0 +1,4 @@ +CREATE TABLE test (id INTEGER NOT NULL, name VARCHAR(255), PRIMARY KEY (id)); +INSERT INTO test (id, name) VALUES (1, 'jala'); +INSERT INTO test (id, name) VALUES (2, 'Database'); +INSERT INTO test (id, name) VALUES (3, 'Test'); diff --git a/modules/jala/tests/DnsClient.js b/modules/jala/tests/DnsClient.js new file mode 100644 index 00000000..19ceb720 --- /dev/null +++ b/modules/jala/tests/DnsClient.js @@ -0,0 +1,66 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +var dnsClient = new jala.DnsClient("68.12.16.25"); +var result; + +/** + * Testing default mode (A records) + */ +var testAQuery = function() { + result = dnsClient.query("nomatic.org"); + assertEqual(result.length, 1); + assertEqual(result[0].ipAddress, "213.129.249.34"); + return; +}; + +/** + * Testing SOA record queries + */ +var testSoaQuery = function() { + result = dnsClient.query("nomatic.org", jala.DnsClient.TYPE_SOA); + assertEqual(result.length, 1); + assertEqual(result[0].email, "hostmaster.nomatic.org"); + return; +}; + +/** + * Testing MX record queries + */ +var testMxQuery = function() { + result = dnsClient.query("nomatic.org", jala.DnsClient.TYPE_MX); + assertEqual(result.length, 1); + assertEqual(result[0].mx, "grace.nomatic.org"); + return; +}; + +/** + * Testing NS record queries + */ +var testNsQuery = function() { + result = dnsClient.query("nomatic.org", jala.DnsClient.TYPE_NS); + assertEqual(result.length, 3); + // can't test single records as their order changes unpredictably + return; +}; diff --git a/modules/jala/tests/Form.fileupload.doc b/modules/jala/tests/Form.fileupload.doc new file mode 100644 index 00000000..40b88854 Binary files /dev/null and b/modules/jala/tests/Form.fileupload.doc differ diff --git a/modules/jala/tests/Form.imageupload.jpg b/modules/jala/tests/Form.imageupload.jpg new file mode 100644 index 00000000..84a3d709 Binary files /dev/null and b/modules/jala/tests/Form.imageupload.jpg differ diff --git a/modules/jala/tests/Form.js b/modules/jala/tests/Form.js new file mode 100644 index 00000000..0fee8358 --- /dev/null +++ b/modules/jala/tests/Form.js @@ -0,0 +1,460 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * a global variable containing the form instance + * @type jala.Form + */ +var form; + + +/** + * Create and configure the form object + */ +var setup = function() { + form = jala.Form.create(getConfig(), new DataObject()); + // form.render(); // show the test form + return; +}; + + +/** + * Test the form rendering mechanism + */ +var testFormRender = function() { + var html = new jala.HtmlDocument(form.renderAsString()); + var list = html.getAll("*"); + + var idx = 2; + assertEqual(list[idx].name, "form"); + assertAttribute(list[idx].attributes, "id", "test"); + assertAttribute(list[idx].attributes, "class", "form"); + assertAttribute(list[idx].attributes, "name", "test"); + assertAttribute(list[idx].attributes, "enctype", "multipart/form-data"); + assertAttribute(list[idx].attributes, "method", "post"); + + + // alias / input + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testAlias"); + assertAttribute(list[idx].attributes, "class", "component require"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testAliasControl"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testAliasControl"); + assertAttribute(list[idx].attributes, "class", "input"); + assertAttribute(list[idx].attributes, "type", "text"); + assertAttribute(list[idx].attributes, "maxlength", "10"); + assertAttribute(list[idx].attributes, "name", "alias"); + assertAttribute(list[idx].attributes, "size", "20"); + + assertEqual(list[++idx].name, "div"); + assertEqual(list[idx].value, "Enter alias."); + assertAttribute(list[idx].attributes, "class", "helpText"); + + + // desc / textarea + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testDesc"); + assertAttribute(list[idx].attributes, "class", "component require"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testDescControl"); + + assertEqual(list[++idx].name, "textarea"); + assertAttribute(list[idx].attributes, "id", "testDescControl"); + assertAttribute(list[idx].attributes, "class", "textarea"); + assertAttribute(list[idx].attributes, "name", "desc"); + assertAttribute(list[idx].attributes, "cols", "30"); + assertAttribute(list[idx].attributes, "rows", "3"); + + + + // pushdate / date + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testPushdate"); + assertAttribute(list[idx].attributes, "class", "component require"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testPushdateControl"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testPushdateControl"); + assertAttribute(list[idx].attributes, "class", "date"); + assertAttribute(list[idx].attributes, "type", "text"); + assertAttribute(list[idx].attributes, "name", "pushdate"); + + + // isonline / checkbox + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testIsonline"); + assertAttribute(list[idx].attributes, "class", "component optional"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testIsonlineControl"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testIsonlineControl"); + assertAttribute(list[idx].attributes, "type", "checkbox"); + assertAttribute(list[idx].attributes, "class", "checkbox"); + assertAttribute(list[idx].attributes, "name", "isonline"); + assertAttribute(list[idx].attributes, "value", "1"); + + + // category / select + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testCategory"); + assertAttribute(list[idx].attributes, "class", "component optional"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testCategoryControl"); + + assertEqual(list[++idx].name, "select"); + assertAttribute(list[idx].attributes, "id", "testCategoryControl"); + assertAttribute(list[idx].attributes, "class", "select"); + assertAttribute(list[idx].attributes, "name", "category"); + assertAttribute(list[idx].attributes, "size", "1"); + + assertEqual(list[++idx].name, "option"); + assertAttribute(list[idx].attributes, "value", "cat0"); + + assertEqual(list[++idx].name, "option"); + assertAttribute(list[idx].attributes, "value", "cat1"); + + assertEqual(list[++idx].name, "option"); + assertAttribute(list[idx].attributes, "value", "cat2"); + + assertEqual(list[++idx].name, "option"); + assertAttribute(list[idx].attributes, "value", "cat3"); + + + // fieldset + assertEqual(list[++idx].name, "fieldset"); + + assertEqual(list[++idx].name, "legend"); + assertEqual(list[idx].value, "a fieldset"); + + + // fileupload + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testFileupload"); + assertAttribute(list[idx].attributes, "class", "component optional"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testFileuploadControl"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testFileuploadControl"); + assertAttribute(list[idx].attributes, "class", "file"); + assertAttribute(list[idx].attributes, "type", "file"); + assertAttribute(list[idx].attributes, "accept", "application/msword"); + assertAttribute(list[idx].attributes, "name", "fileupload"); + + + // imageupload + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testImageupload"); + assertAttribute(list[idx].attributes, "class", "component optional"); + + assertEqual(list[++idx].name, "label"); + assertAttribute(list[idx].attributes, "for", "testImageuploadControl"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testImageuploadControl"); + assertAttribute(list[idx].attributes, "class", "image"); + assertAttribute(list[idx].attributes, "type", "file"); + assertAttribute(list[idx].attributes, "name", "imageupload"); + + + // submit + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testSubmit"); + assertAttribute(list[idx].attributes, "class", "component"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testSubmitControl"); + assertAttribute(list[idx].attributes, "class", "submit"); + assertAttribute(list[idx].attributes, "name", "submit"); + assertAttribute(list[idx].attributes, "value", "Submit this form"); + assertAttribute(list[idx].attributes, "type", "submit"); + + + // cancel + assertEqual(list[++idx].name, "div"); + assertAttribute(list[idx].attributes, "id", "testCancel"); + assertAttribute(list[idx].attributes, "class", "component"); + + assertEqual(list[++idx].name, "input"); + assertAttribute(list[idx].attributes, "id", "testCancelControl"); + assertAttribute(list[idx].attributes, "class", "button"); + assertAttribute(list[idx].attributes, "name", "cancel"); + assertAttribute(list[idx].attributes, "value", "Cancel edit"); + assertAttribute(list[idx].attributes, "type", "button"); + + return; +} + + +/** + * Test the form validation mechanism + */ +var testFormValidate = function() { + var reqData = getRequestData(); + + // default userinput values that should validate + var tracker = form.validate(reqData); + assertFalse(tracker.hasError()); + + // now try invalid values in userinput: + reqData["alias"] = "a"; + reqData["desc"] = ""; + reqData["pushdate"] = "17.5.2007"; + reqData["category"] = "invalidOption"; + tracker = form.validate(reqData); + assertTrue(tracker.hasError()); + assertEqual(tracker.errors["alias"], "Alias is too short."); + assertEqual(tracker.errors["desc"], "Please enter text into this field."); + assertEqual(tracker.errors["pushdate"], "This date cannot be parsed."); + assertEqual(tracker.errors["category"], "Please select a valid option."); + + // reset to default userinput: + reqData = getRequestData(); + // require a smaller image: + form.components.uploadfieldset.components.imageupload.require("maxwidth", 100, "Maximum width exceeded."); + tracker = form.validate(reqData); + assertTrue(tracker.hasError()); + assertEqual(tracker.errors["imageupload"], "Maximum width exceeded."); + // undo image restriction: + form.components.uploadfieldset.components.imageupload.require("maxwidth", 200, "Maximum width exceeded."); + tracker = form.validate(reqData); + assertFalse(tracker.hasError()); + + return; +}; + + +/** + * Test the form rendering mechanism in the case of an error + */ +var testFormRenderWithError = function() { + var reqData = getRequestData(); + reqData["alias"] = "a"; + var tracker = form.validate(reqData); + + var html = new jala.HtmlDocument(form.renderAsString()); + var list = html.getAll("*"); + assertEqual(list[4].name, "div"); + assertEqual(list[4].value, "Alias is too short."); + assertAttribute(list[4].attributes, "class", "errorText"); +}; + + +/** + * Test the form save mechanism + */ +var testFormSave = function() { + var dataObj = form.getDataObject(); + + var reqData = getRequestData(); + var tracker = form.validate(reqData); + assertFalse(tracker.hasError()); + form.save(); + assertEqual(dataObj.alias, "aliasValue"); + assertEqual(dataObj.getProperty("desc"), "descriptionValue"); + assertEqual(dataObj.pushdate.toString(), new Date(2007, 4, 17, 11, 32, 0).toString()); + assertEqual(dataObj.isonline, 1); + assertEqual(dataObj.getProperty("category"), "cat2"); + + return; +} + + + +/** + * Helper function to dump an html element to the response + * @param {Object} el + */ +var debugElement = function(el) { + res.write("" + el.name + " (" + el.value + ")
    "); + if (el.attributes) { + var attrList = el.attributes; + for (var i=0; i"); + } + } +}; + + +/** + * Helper function to assert that a given attribute exists + * in an element + * @param {Array} attrList Array with attribute objects + * @param {String} name Name of attribute + * @param {String} value Value of attribute + */ +var assertAttribute = function(attrList, name, value) { + for (var i=0; iHello, World!' + + 'foo' + + '' + + 'foobar' + + ''; + +/** + * Simple test of the HtmlDocument.getLinks method. + * An instance of HtmlDocument is created from a very + * simple HTML source. The result of getLinks is then + * evaluated and tested. + */ +var testGetLinks = function() { + var html = new jala.HtmlDocument(source); + var links = html.getLinks(); + assertEqual(links.constructor, Array); + assertEqual(links.length, 3); + assertEqual(links[0].constructor, Object); + for (var i in links) { + assertNotUndefined(links[i].url); + assertNotUndefined(links[i].text); + } + assertEqual(links[0].url, "http://localhost/1"); + assertEqual(links[0].text, "foo"); + assertEqual(links[1].url, "http://localhost/2"); + assertEqual(links[1].text, "bar"); + assertEqual(links[2].url, "http://localhost/3"); + assertEqual(links[2].text, "foobar"); + return; +}; + +/** + * Simple test of the HtmlDocument.geAll method. + * An instance of HtmlDocument is created from a very + * simple HTML source. The result of getAll is then + * evaluated and tested. + */ +var testGetAll = function() { + var names = ["html", "head", "title", "body", "h1", "a", "div", "a", "a"]; + var html = new jala.HtmlDocument(source); + var list = html.getAll("*"); + for (var i in list) { + assertNotUndefined(list[i].name); + assertEqual(list[i].name, names[i]); + } + assertEqual(list[2].value, "Test"); + assertEqual(list[4].value, "Hello, World!"); + assertEqual(list[5].value, "foo"); + assertEqual(list[7].value, "bar"); + assertEqual(list[8].value, "foobar"); + assertEqual(html.getAll("h1")[0].value, "Hello, World!"); + return; +}; diff --git a/modules/jala/tests/I18n.js b/modules/jala/tests/I18n.js new file mode 100644 index 00000000..4305f06a --- /dev/null +++ b/modules/jala/tests/I18n.js @@ -0,0 +1,136 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Declare which test methods should be run in which order + * @type Array + * @final + */ + +var oldMessages; + +/** + * Called before running the tests + */ +var setup = function() { + // save any currently used message bundle before + // creating the one for this test + oldMessages = jala.i18n.getMessages(); + // setup the test message bundle + var messages = {}; + messages.de_AT = { + "Hello, World!": "Hallo, Welt!", + "This is {0}.": "Das ist {0}.", + "You've got one new mail.": "Du hast eine neue E-Mail.", + "You've got {0} new mails.": "Du hast {0} neue E-Mails." + }; + // tell jala where to find the messages + jala.i18n.setMessages(messages); + // assign a method for retrieving the locale for translation + jala.i18n.setLocaleGetter(new Function("return res.meta.locale;")); + // set the locale to use by jala.i18n + res.meta.locale = new java.util.Locale("de", "AT"); + return; +}; + + +/** + * Called after tests have finished. This method will be called + * regarless whether the test succeeded or failed. + */ +var cleanup = function() { + // restore any previous message set + jala.i18n.setMessages(oldMessages); + return; +}; + +/** + * Tests for formatMessage + */ +var testFormatMessage = function() { + var msg = "Es ist jetzt {0,date,EEEE, dd. MMMM yyyy, HH:mm} Uhr."; + var args = [new Date(2007, 1, 8, 17, 58)]; + var result = jala.i18n.formatMessage(msg, args); + var expected = "Es ist jetzt Donnerstag, 08. Februar 2007, 17:58 Uhr."; + assertEqual(expected, result); + return; +}; + +/** + * Tests for gettext() + */ +var testGettext = function() { + assertEqual("Hallo, Welt!", gettext("Hello, World!")); + // test not found message key + assertEqual("Hello You!", gettext("Hello You!")); + // test gettext with additional replacement value + assertEqual("Das ist Jala I18n.", gettext("This is {0}.", "Jala I18n")); + return; +}; + +/** + * Tests for ngettext() + */ +var testNgettext = function() { + // zero + assertEqual("Du hast 0 neue E-Mails.", + ngettext("You've got one new mail.", + "You've got {0} new mails.", + 0)); + // one + assertEqual("Du hast eine neue E-Mail.", + ngettext("You've got one new mail.", + "You've got {0} new mails.", + 1)); + // more + assertEqual("Du hast 23 neue E-Mails.", + ngettext("You've got one new mail.", + "You've got {0} new mails.", + 23)); + return; +}; + +/** + * Tests for message macro + */ +var testMessageMacro = function() { + // singular + var skin = createSkin('<% message text="You\'ve got one new mail." %>'); + assertEqual("Du hast eine neue E-Mail.", renderSkinAsString(skin)); + + res.handlers.testHandler = {value: 0}; + // value replacement using testHandler + skin = createSkin('<% message text="You\'ve got {0} new mails." values="testHandler.value" %>'); + assertEqual("Du hast 0 neue E-Mails.", renderSkinAsString(skin)); + // plural including replacement using testHandler + res.handlers.testHandler.value = 23; + skin = createSkin('<% message text="You\'ve got one new mail." plural="You\'ve got {0} new mails." values="testHandler.value" %>'); + assertEqual("Du hast 23 neue E-Mails.", renderSkinAsString(skin)); + // using a value of the param object passed to the skin + // FIXME: appearently this doesn't work, but why? + /* + skin = createSkin('<% message text="You\'ve got one new mail." plural="You\'ve got {0} new mails." values="param.spam" %>'); + assertEqual("Du hast 45 neue E-Mails.", renderSkinAsString(skin, {spam: 45})); + */ +}; diff --git a/modules/jala/tests/ImageFilter.js b/modules/jala/tests/ImageFilter.js new file mode 100644 index 00000000..cb588788 --- /dev/null +++ b/modules/jala/tests/ImageFilter.js @@ -0,0 +1,100 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + +/** + * Called after tests have finished. This method will be called + * regarless whether the test succeeded or failed. + */ +var cleanup = function() { + var tempDir = new helma.File(java.lang.System.getProperty("java.io.tmpdir")); + var names = ["sharpen", "unsharpMask", "gaussianBlur"]; + var file; + for (var i=0; iSubclasses:
    -' . +# join('
    -', +# map ({"$_"} +# map ( { s/\s*(\w+)\s*/$1/; $_} @{@_->[0]}) +# ) +# ) . '

    ' +# }; +# +# $CLASS_ATTRS_MAP{with} = +# sub { +# 'This class has a \'@with\' attribute' +# }; +#}; + +# Method attributes +# eval { +# +# Uncomment this to allow the filename to be displayed for +# each function +# +# $METHOD_ATTRS_MAP{filename} = +# sub { +# '

    Filename: ' . $_[0] . '

    ' +# }; +# $CLASS_ATTRS_MAP{filename} = $METHOD_ATTRS_MAP{filename}; +# +# }; +# + diff --git a/modules/jala/util/HopKit/JSDoc/CHANGES b/modules/jala/util/HopKit/JSDoc/CHANGES new file mode 100644 index 00000000..deae94f5 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/CHANGES @@ -0,0 +1,605 @@ +JSDoc 1.9.9.2 +============= + +- Fixed disappearing argument list for package-style class constructors + +JSDoc 1.9.9.1 +============= + +- Fixed bug in template dir designation that caused JSDoc to crash if + run from an absolute path + +JSDoc 1.9.9 +=========== + +- Added a commandline parameter for supplying a template directory + +- Adding sorting of class names on overview-summary-$filename.js + (sf.net bug #1416564) + +- Fix for broken anchors from the overview-summary-$filename page to static + methods (SF.net bug #1416543) + +JSDoc 1.9.8.1 +============= + +- Don't touch the file source (src) when processing the file overview data + +- Pick up functions as constructors of the @class tag is used + +JSDoc 1.9.8 +=========== + +- Allow the @base tag to accept the form: @base ClassName URL (RFE 1114510) + +- Be more lenient with @param and @return types (RFE 1104728) + +- Corrected CSS error, changed "pts" to "pt" + +JSDoc 1.9.7 +=========== + +- Added "--no-lexical-privates" option to ignore locally-defined values + from within constructors + +- Fixed linking to static fields/methods + +JSDoc 1.9.6.2 +============= + +- Set correct permissions on files in packaging script + +- Fixed compile error on some versions of perl + +- Create distinct anchors for static methods and fields in HTML so that + if there is a static and instance method of the same name, the links work + correctly + +JSDoc 1.9.6.1 +============= + +- Updated unit tests for clearing of function contents + +- Removed collapsing of string literals; this was originally added for version + 1.9.5.1 to avoid segfaults, but the decision has been made that it is up + to the user to use a version of perl that doesn't segfault instead of + trying to work around it in perl code. + +- Added (experimental) @exec tag for initialization blocks that should be 'run' + +JSDoc 1.9.6 +=========== + +- Fix for incorrect return type and parameter types for static method + listing in file overview + +- Clear out unused nested functions with the preprocessor to avoid problems + +JSDoc 1.9.5.8 +============= + +- Yet another fix for __defineGetter__ and __defineSetter__ + +JSDoc 1.9.5.7 +============= + +- Fixed bug in syntax highlighting for single-line inline comments + +- Fixed bug in preprocessing of __defineGetter__ and __defineSetter__ + +JSDoc 1.9.5.6 +============= + +- Fixed incorrect listing of private classes when --private not enabled + +JSDoc 1.9.5.4 +============= + +- Corrected bug with function assignment inside constructor + +JSDoc 1.9.5.3 +============= + +- Added ability to specify different file extensions on commandline + +JSDoc 1.9.5.2 +============= + +- Fixed formatted text munging for @class description + +- Added support for @package tag to be used with XMI export + +JSDoc 1.9.5.1 +============= + +- Added collapsing of string literals during preprocessing + +JSDoc 1.9.5 +=========== + +- Added listing of global (static) methods to file overview summary, code + submitted by Jeremy Gillick + +- Allow a global variable to be defined as a class from an anonymous + function declaration + +JSDoc 1.9.4.2.1 +=============== + +- Further fix for typed parameter names starting with a dollar sign + +JSDoc 1.9.4.2 +============= + +- Added ability to handle parameter names starting with a dollar sign + +JSDoc 1.9.4.1 +============= + +- Only use the first sentence for file and class summary on the + overview pages + +- Add a non-breaking space in the overview summary tables when there is no + appropriate value to display + +JSDoc 1.9.4 +=========== + +- If there are multiple source files documented, the index page defaults + to the overview summary for the main frame + +- Made JSDoc site link open in parent frame + +- Added overview and file summary tables (similar to package overview table + in JavaDoc) + +JSDoc 1.9.3.1 +============= + +- Fixed duplicate class-tree output + +JSDoc 1.9.3 +=========== + +- Added alpha release of XML and XMI output formats + +- Upgrade a function to a class if the @base tag is used + +- Fixed issue with sub-package nested classes requiring the @addon tag + +- Added the implicit "Object" class to the inheritance tree, as well as + other classes that are referenced but not defined + +JSDoc 1.9.2.1 +============= + +- Added @addon tag, which is used when adding static methods to core classes + or classes not defined within the files being documented + +- Fix for the base class of nested classes not being properly set + +- Fix for infinite recursion when all classes are private + + +JSDoc 1.9.2 +=========== + +- Removed unecessary table from overview-summary.tmpl + +- Added the @ignore tag to allow total hiding of functions + +- Fix for incorrect marking of methods as void when the return value is + enclosed in parentheses + +- Fix so that methods with a @return tag but without a return statement + are not marked as void + +- Fixed issue with not all files being listed in the file listing + + +JSDoc 1.9.1.3 +============= + +- Fixed issue with backslashes in path + +- Fixed issue with

     tags and JavaScript code within fileoverview sections
    +
    +- Made documented versions of a method take precedence over a 
    +  non-documented version
    +
    +- Added support for prototype assignment without parentheses
    +
    +- Added new @return label {type typeLink} Description... syntax
    +
    +JSDoc 1.9.1.2
    +=============
    +
    +- Further improvements to mark_void_method
    +
    +- Improved handling of dynamically-bound methods within functions
    +
    +- Improved handling of erroneous documenting of 'this'
    +
    +- Fixed quoting on error message
    +
    +- Added a few new unit tests for testing general behaviour
    +
    +JSDoc 1.9.1.1
    +=============
    +
    +- Fix for embarrassing bug in mark_void_method
    +
    +JSDoc 1.9.1
    +===========
    +
    +- Fix for the incorrect void marking of methods that return a string literal
    +
    +- Fix to stop dynamic prototyping from adding non-dynamic classes
    +
    +- Added ability to add a link to parameter-type data, as follows:
    +    @param {TypeName http://my.link.com/} myParam Description of parameter
    +
    +JSDoc 1.9
    +=========
    +
    +- Added support for a Constant Values page like in Javadoc
    +
    +- Added support for private classes (by marking the constructor with
    +  the @private attribute)
    +
    +- Added a "File" page with links to it in the navbar. The "File" page includes
    +  the file overview if one has been supplied, as well as the source view
    +  (unless jsdoc has been invoked with the --no-sources flag)
    +
    +- Added a --no-sources commandline option to not show the sourcecode for
    +  the JavaScript files 
    +
    +- Added --package-naming commandline option, which specifies that the path 
    +  leading to each source file will be preserved. This allows for the same 
    +  filename to be used in different directories. Using the same class name
    +  in different packages is _not_ supported (yet)
    +
    +- Added JSDoc link and creation time in the footer of each page
    +
    +- Added support for @member tag to explicitly mark a method as a member of
    +  a class
    +
    +JSDoc 1.8.4
    +===========
    +
    +- Added step in prepocessing to attempt to add missing @constructor tags where
    +  the 'new' operator is used in combination with a function name elsewhere
    +  in the source.
    +
    +- Only the first @extends marking (or assignment of an instance to a sub-
    +  class's prototype) will be used in determining the base class of a class.
    +
    +- Updated test.js to show off more features of JSDoc, as well as a general 
    +  clean-up.
    +    
    +- Changed the parser to consider a method to be a class declaration if its
    +  documentation contains a @class tag (in addition to the @constructor tag)
    +
    +JSDoc 1.8.3.1
    +=============
    +
    +- Some general code cleanup and refactoring. 
    +
    +- Properly fixed marking of void/non-void methods, and at the same time
    +  re-introduced recursive regexes (this time non-dynamic, as dynamic seem
    +  to be much too unstable)
    +
    +JSDoc 1.8.3
    +===========
    +
    +- Changed the handling for __defineGetter__ and __defineSetter__
    +  to define a property instead of a method in the documentation
    +
    +- Fixed bug in parse_jsdoc_comment that didn't allow for email addresses
    +  to be entered verbatim (instead, the domain of the address was parsed
    +  as a tag)
    +
    +- Re-did the @fileoverview parsing, now other tags and inner {@link...} 
    +  tags are included. Additionally, if only one file is processed and there
    +  is no project overview file included, the file's overview (if it exists)
    +  is used as the project overview. Thanks to Robert Flaherty for input
    +  and bug reports on this issue.
    +
    +JSDoc 1.8.2.1
    +=============
    +
    +- Got rid of extra '*' with @fileoverview
    +
    +JSDoc 1.8.2
    +=============
    +
    +- Fixed bug where other @tags were included as part of the @fileoverview
    +
    +- Added support for @version in method documentation
    +
    +- Partial fix for incorrect marking of void methods
    +
    +- Made field and return @type handling more robust and flexible
    +
    +JSDoc 1.8.1
    +===========
    +
    +- Added @extends as a synonym for @base
    +
    +- Fixed doubled-up 
      tags in hierarchy tree code (thanks to Robert Flaherty) + +- Fixed bug where a class's base class would not get recorded if + there was a forward assignment of a static value to the class + (thanks to Robert Flaherty) + + +JSDoc 1.8 +========= + +- Remove the GLOBALS class if it is empty + +- Fixed case-sensitive sort in index + +- Added support for comments with long blocks of '*'s in the opening and + closing of the doc string + +- Added sourcecode view + +- Fixed bug where named anonymous functions were not recognized as methods + when assigned to prototypes + +- Allow for singletons to be declared with var + +- Allow for binding static properties to classes before they are defined + +- Added @overviewfile attribute for class documentation, inlines html or + textfiles into the documentation + +- Added beginnings of unit testing + +- Don't add 'constructor' as an instance or class property + +- Added an @overviewfile tag which can be put in an independent + jsdoc-comment block at the top of each file. This results in a project + overview page for each file with an overview, similar to JavaDoc's + package pages. + +- Added support for Mozilla's __defineGetter__ and __defineSetter__ + +- Return type for methods is now Object, and is displayed instead of the + 'function' declaration. The 'void' type is shown if no return can be + found in the function and no other type is defined. The defaulting to + Object also goes for fields, and is shown instead of the 'var' declaration + +- Allow usage of the {@link url label} construct for the @type tag + + +JSDoc 1.7.2.1 +============= + +- Fixed segfault problem in huge constructors with deconstruct_constructor + selection regex + + +JSDoc 1.7.2 +=========== + +- Added a @class tag to constructors, for providing class-specific information + +- Added handling for Singleton classes + +- Added handler for @base tag to denote inheritance + +JSDoc 1.7.1.4 +============= + +- Fixed bug introduced by refactoring of &format_link + +JSDoc 1.7.1.3 +============= + +- Added workaround in &format_link for apparent bug in some builds of + perl 5.8.0 + +- Fixed bug in handling of --recursive (was always recursive) + +JSDoc 1.7.1.2 +============= + +- Fixed problems with new preprocessor when confronted with nested classes + +JSDoc 1.7.1.1 +============= + +- Fixed bug where {@link}s inside of @params weren't processed + +JSDoc 1.7.1 +=========== + +- Added --quiet switch and message to signify ending of successful execution + +- Fixed problem with perl segfaulting on big class prototype block definitions + +- Fixed incorrectly formatted {@link}s nested in other @attributes + +- Added preprocessor for handling private methods to replace bulky + and buggy evaluate_constructor method + +JSDoc 1.7 +========= + +- Added usage of strict and warnings in JSDoc.pm + +- Added ability to set type information for method parameters + (e.g. /** @param {String} userName The name of the current user */ ) + +- Added support for class prototype initialization blocks (finally!) + +JSDoc 1.6.3.1 +============= + +- Fixed bug where static fields initialized to 0 are not picked up + +JSDoc 1.6.3 +=========== + +- Removed the constraint that a nested class constructor must be marked + with the @constructor attribute + +- Allow @constructor attribute to mark nested class constructors which would + otherwise be considered static methods + +- Allow newlines as well as semi-colon for line-endings + +- Allow a leading '$' for field names + + +JSDoc 1.6.2.1 +============= + +- Fixed splicing error for nested classes, thanks again to jdber + + +JSDoc 1.6.2 +=========== + +- Carry over overridden method description attributes even if there is + no text description to carry over + +- Improved HTML in main.tmpl + +- Fixed infinite loop and recognition for when static inner class construct is + used (thanks to jdber for the patch) + +- Added a Nested Class Summary section to the output documentation to display + inner classes + +JSDoc 1.6.1.1 +============= + +- Fixed bug in carrying over description of overridden methods + +JSDoc 1.6.1 +=========== + +- Improved the format_link function in jsdoc.pl so that {@links} will + not be made to non-existent resources, and parentheses are not placed + after a field name (as opposed to a method name) + +- Carry over method documentation for overridden methods if no new + documentation has been supplied for the method. This is in following with + javadoc functionality + +- Fixed /* functionality(whatever) bug + +- Fixed remaining problems with comments inside of parameter lists + +JSDoc 1.6 +========= + +- Big cleanup in jsdoc.pl in terms of writing templates to file + +- Fixed bug where multi-line @params don't work + +- Added filename-scoped frame, as well as the name of the filename for + each class + +- Improved the linking implementation for @link and @see to do a better job + in terms of not building broken links + +JSDoc 1.5.2 +=========== + +- Changed the name '[default context]' for non-class functions to be + GLOBALS, also made this name configurable with command-line parameters + +- Made jsdoc easily runnable from anywhere on the filesystem, without + requiring installing JSDoc.pm in the @INC + +JSDoc 1.5.1 +=========== + +- Added support for @requires in methods + +- Generic '@' attributes now work for constructors, such as @see and @throws. + Also added support for @return and @returns for constructors + +- Fixed the @link construct to allow custom labels + +- Added standard support for @author in methods as well as classes + (Thanks for Rainer Eschen for bringing me to my senses) + +- Fixed spacing for @author attributes + + +JSDoc 1.5 +=========== + +- Fixed bug that would break HTML links within documentation + +- Fixed bug in path to logo in IMG tags + +- Added support for type information for both methods and fields + +- Added suppport for @private in instance fields + +- Fixed bug where private methods would show up in the inherited methods list + in subclasses + +- Private class methods are now also supported + +- Method parameters details are displayed in the same order as the parameter + list for a method + +- Moved more info into the 'vars' member of methods, and away from the parser + +- Added @final (with synonym @const) for class and instance properties + +- Fix in parser where string literals bound to classes in a constructor were + not caught by the parser + + + +JSDoc 1.4 +========= + +- Added @attributes: @author, @deprecated, @see, @version, @requires, @throws + +- Updated pod (removed documentation for non-existant parse_jsdoc_source, +added a small example) + +- Added function to reset the parser (reset_parser) + +- Fixed bug where the same property could be bound to a class's prototype +more than once + +- Fixed bug where embedded // comments would break the parser + +- Added ability to set project name, page footer, logo and project summary +(thanks to Jeff Conrad for code and suggestions) + +- Added overview summary (thanks to Jeff Conrad for code) + +- Split up loading/parsing of sources file to prevent crashes that were caused +by overloading the regex engine + +- Added overview-tree (thanks to Jeff Conrad for the code contribution) + +- Fixed bug where some assignments of methods to instances in a constructor +would get lost + +- Fix in doc-parsing where a line with only a star and a newline would get +passed over + +- Added ability to 'hide' methods with @private + + +JSDoc 1.3 +========= + +- When a function is marked with @constructor, it will always be dealt +with as a class + +- Improved doc regex + +- Added recursive directory handling diff --git a/modules/jala/util/HopKit/JSDoc/JSDoc.pm b/modules/jala/util/HopKit/JSDoc/JSDoc.pm new file mode 100644 index 00000000..bd7e898a --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JSDoc.pm @@ -0,0 +1,1070 @@ +package JSDoc; + +=head1 NAME + +JSDoc - parse JavaScript source file for JSDoc comments + +=head1 SYNOPSIS + +Create JavaScript sourcefiles commented in a manner similar to javadoc +(ie. with documentation starting with '/**' and then pass a list of references +to JavaScript source to parse_code_tree: + + /** + * This is a class for example purposes + * @param name Name for the new object + * @constructor + */ + function MyClass(name){ + this.name = name; + } + + $code_tree = parse_code_tree(@src_refs); + +A tree structure describing the code layout, inheritance and documentation +is returned + +To clear the cache of classes and functions in the parser: + + reset_parser(); + + +=head1 DESCRIPTION + +The C function requires a ref to a string holding the +souce code of a javascript object file or files. It returns a data structure +that describes the object hierarchy contained in the source file, as well +as included documentation for all fields and methods. The resulting +data structure has the following form (for each class): + + Class + | + +- classname + | + +- constructor_args + | + +- extends + | + +- constructor_detail + | + +- constructor_vars + | + +- class_methods + | | + | +- description + | | + | +- mapped_name + | | + | +- argument_list + | | + | +- vars + | + +- instance_methods + | | + | +- description + | | + | +- mapped_name + | | + | +- argument_list + | | + | +- vars + | + +- class_fields + | | + | +- field_description + | | + | +- field_name + | | + | +- field_value + | | + | +- field_vars + | + +- instance_fields + | | + | +- field_description + | | + | +- field_name + | | + | +- field_value + | | + | +- field_vars + | + +- inner_classes + | | + | +- class_name + | + +- inherits + | + +- Class + | + +- instance_fields + | + +- instance_methods + + +There is also an additional entry under the key __FILES__ that contains +keyed entries for each @tag that was defined in the first JSDoc comment +block with a @fileoverview tag. Each entry under __FILES__ is keyed by +filename, and is a hash reference. + +=head1 AUTHORS + +Gabriel Reid gab_reid@users.sourceforge.net, +Michael Mathews michael@mathews.net + +=cut + +require 5.000; +use strict; +use warnings; +use Exporter; + +# Recursion limit for recursive regexes +use constant RECURSION => 10; + +use vars qw/ @ISA @EXPORT /; + +@ISA = qw(Exporter); +@EXPORT = qw(parse_code_tree configure_parser reset_parser); + +# State +use vars qw/ %CLASSES %FUNCTIONS %CONFIG $CTX_FILE /; + +# Regexes +use vars qw/ $BAL_PAREN $BAL_BRACE $SQUOTE $DQUOTE $NONQUOTE + $FUNC_DEF $RET_FUNC_DEF $ANON_FUNCTION $LITERAL $FUNC_CALL + $JSDOC_COMMENT $MLINE_COMMENT $SLINE_COMMENT /; + +# This limits nested braces to 30 levels, but is much more +# stable than using a dynamic regex +$BAL_BRACE = qr/\{(?:[^\{\}])*\}/; +$BAL_PAREN = qr/\((?:[^()])*\)/; +for (1..RECURSION){ + $BAL_BRACE = qr/\{(?:[^\{\}]|$BAL_BRACE)*\}/; + $BAL_PAREN = qr/\((?:[^()]|$BAL_PAREN)*\)/; +} +$SQUOTE = qr{'[^'\\]*(?:\\.[^'\\]*)*'}; +$DQUOTE = qr{"[^"\\]*(?:\\.[^"\\]*)*"}; +$NONQUOTE = qr{[^"'/]}; +$FUNC_DEF = qr/function\s+\w+(?:\.\w+)*\s*$BAL_PAREN\s*$BAL_BRACE/; +$RET_FUNC_DEF = qr/function\s+(\w+(?:\.\w+)*)\s*($BAL_PAREN)\s*($BAL_BRACE)/; +$ANON_FUNCTION = qr/function\s*$BAL_PAREN\s*$BAL_BRACE/; +$LITERAL = qr/$DQUOTE|$SQUOTE|\d+/; +$FUNC_CALL = qr/(?:new\s+)?\w+(?:\.\w+)*\s*$BAL_PAREN/; +$JSDOC_COMMENT = qr{/\*\*[^*]*\*+(?:[^/*][^*]*\*+)*/}; +$MLINE_COMMENT = qr{/\*[^*]*\*+(?:[^/*][^*]*\*+)*/}; +$SLINE_COMMENT = qr{//[^\n]*}; + + +# +# Public function that returns a datastructure representing the JS classes +# and their documentation +# +sub parse_code_tree { + + &initialize_parser; + + # + # This (I mean the "<<$_>>") is pretty hacky, but I've made it this + # way to maintain backwards compatibility with anyone who's automatically + # expecting this to work when they throw an array of refs to it. If you're + # using this for your own work, please don't expect to be able to + # put the context file in like this in the future + # + for my $js_src (map { ref and ${$_} or "<<$_>>" } @_){ + if ($js_src =~ /^<<(.+)>>$/){ + $CTX_FILE = $1; + next; + } + + # perlify os line-endings + $js_src =~ s/(\r\n|\r)/\n/g; + + &parse_file_info($js_src); + $js_src = &preprocess_source($js_src); + &fetch_funcs_and_classes($js_src); + } + + &map_all_properties(); + &build_class_hierarchy(); + &set_class_constructors(); + &filter_globals; + + while (my ($classname, $class) = each %CLASSES){ + delete $class->{_class_properties}; + delete $class->{_instance_properties}; + $class->{classname} = $classname unless $classname eq '__FILES__'; + } + return \%CLASSES; +} + +# +# Parses up a a jsdoc comment into its component parts +# PARAM: The document string to be parsed +# +sub parse_jsdoc_comment { + my ($doc, $raw) = @_; + + # Remove excess '*' characters + $doc =~ s/^[*\s]*([^*].*?)[*\s]*$/$1/s; + $doc =~ s/^\s*\*//gm; + + my %parsed = (); # remember each part that is parsed + + # the first paragraph could be a summary statement + # a paragraph may follow of variable defs (variable names start with "@") + my ($summary, $variable_str) = $doc =~ + /^\s* + ( + (?:[^{@]|(?:\{[^@]))* + (?:\{\@ + (?:[^{@]|(?:\{[^@]))*)* + ) + \s* + (.*) + $/xs; + $summary =~ s/^\s*(\S.*?)\s*$/$1/s; + $parsed{summary} = $summary; + + # two types of variable def can be dealt with here: + # a @argument has a two-part value -- the arg name and a description + # all other @ only have a single value each (although there may + # be many variables with the same name) + if($variable_str) { + my %vars = (); + while ($variable_str =~ / + (?{$_} = [] for qw(instance_fields class_fields + instance_methods class_methods + inner_classes); + } + unless ($CLASSES{$class}->{extends}){ + &set_base_class($class, $1) + if $class_doc =~ /\@base\s+(\w+(?:\.\w+)*)/; + } +} + +# +# Set the base class for a given class +# +sub set_base_class { + my ($class, $base_class) = @_; + &add_class($class); + $CLASSES{$class}->{extends} = $base_class + unless $CLASSES{$class}->{extends}; +} + +# +# Add a property, either a class or instance method or field +# +sub add_property { + my ($doc, $class, $property, $value, $is_class_property) = @_; + &add_class($class); + return if $property eq 'constructor'; + my $parsed_doc = &parse_jsdoc_comment($doc); + $doc = $parsed_doc->{summary}; + my $key = $is_class_property ? '_class_properties' : '_instance_properties'; + for my $classref (@{$CLASSES{$class}->{$key}}){ + if ($classref->{property_name} eq $property){ + # Whine about rebinding functions to classes + if ($FUNCTIONS{$value}){ + warn "Already bound property '$property' to '$class'\n"; + return; + } + + # Only take on new attributes + $classref->{property_doc} ||= $doc; + $classref->{property_vars} ||= $parsed_doc->{vars}; + return; + } + } + + push @{$CLASSES{$class}->{$key}}, { + property_doc => $doc, + property_name => $property, + property_value => $value, + property_vars => $parsed_doc->{vars} + }; +} + + +# +# Add a function and its documentation to the global FUNCTION hash +# +sub add_function { + my ($doc, $function, $arg_list, $is_private) = @_; + + # clean remaining comments out of arg list + # (all others are already gone) + # Again, taken from Jeffrey Friedl's "Mastering Regular Expressions" + { + no warnings; + $arg_list =~ s/ + ($NONQUOTE+| + $DQUOTE$NONQUOTE*| + $SQUOTE$NONQUOTE*) + |$MLINE_COMMENT|$SLINE_COMMENT/$1/gx; + } + + if ($FUNCTIONS{$function}){ + warn "Function '$function' already declared\n"; + unless ($doc && !$FUNCTIONS{$function}->{documentation}->{summary}){ + return 0; + } + } + $FUNCTIONS{$function} = {}; + my $func = $FUNCTIONS{$function}; + $arg_list and $func->{argument_list} = join(" ", split("\\s+", $arg_list)) + or $func->{argument_list} = "()"; + + my $documentation = parse_jsdoc_comment($doc); + if ($documentation->{vars}->{member}){ + my ($classname) = map { s/^\s*(\S*)\s*$/$1/; $_ } + @{$documentation->{vars}->{member}}; + &add_property($doc, $classname, $function, $function, 0) + if $classname =~ /\w+/; + } + my $function_ref = $FUNCTIONS{$function}; + + $function_ref->{documentation} = $documentation; + $function_ref->{description} = $documentation->{summary}; + $function_ref->{vars} = $function_ref->{documentation}->{vars}; + $function_ref->{vars}->{filename} = $CTX_FILE; + $function_ref->{vars}->{private} = 1 if $is_private; + 1; +} + + +# +# Map all the class and instance properties to their implementation +# +sub map_all_properties { + for my $type (qw(_class_properties _instance_properties)){ + for my $class (keys %CLASSES){ + &map_single_property( + $class, + $_->{property_name}, + $_->{property_value}, + $_->{property_doc}, + $_->{property_vars}, $type eq '_class_properties') + for @{$CLASSES{$class}->{$type}} + } + } + + # Map all the unattached functions + my $classname = $CONFIG{GLOBALS_NAME} || 'GLOBALS'; + &add_class($classname); + for my $function + (grep !($FUNCTIONS{$_}->{is_mapped} || $CLASSES{$_}), keys %FUNCTIONS){ + &map_single_property( + $classname, $function, $function, '', undef, 1); + } + + # Map static inner classes + for $classname (keys %CLASSES){ + my $i = 0; + my @to_remove; + for my $cprop (@{$CLASSES{$classname}->{class_methods}}){ + my $propname = $cprop->{mapped_name}; + if ($CLASSES{"$classname.$propname"}){ + push @to_remove, $i; + push @{$CLASSES{$classname}->{inner_classes}}, + {class_name => "$classname." . $cprop->{mapped_name}}; + $FUNCTIONS{"$classname.$propname"} = + delete $FUNCTIONS{"__$classname.$propname"}; + } + $i++; + } + splice(@{$CLASSES{$classname}->{class_methods}}, $_, 1) + for reverse @to_remove; + } +} + +# +# Map a single instance or class field or method +# +sub map_single_property { + my ($class, $prop_name, $prop_val, + $description, $vars, $is_class_prop) = @_; + if (!$FUNCTIONS{$prop_val}){ + push @{$CLASSES{$class}->{$is_class_prop + ? 'class_fields' : 'instance_fields'}}, { + field_name => $prop_name, + field_description => $description, + field_value => $prop_val, + field_vars => $vars }; + return; + } + my %method; + my $function = $FUNCTIONS{$prop_val}; + $function->{is_mapped} = 1; + $method{mapped_name} = $prop_name; + + $method{$_} = $function->{$_} for + qw/ argument_list description vars /; + + push @{$CLASSES{$class}->{$is_class_prop + ? 'class_methods' + : 'instance_methods'}}, \%method; +} + + + +# +# Build up the full hierarchy of classes, including figuring out +# what methods are overridden by subclasses, etc +# PARAM: The JS source code +# +sub build_class_hierarchy { + # Find out what is inherited + for my $class (map($CLASSES{$_}, sort keys %CLASSES)){ + my $superclassname = $class->{extends}; + !$superclassname and next; + my $superclass = $CLASSES{$superclassname}; + $class->{inherits} = {}; + while ($superclass){ + $class->{inherits}->{$superclassname} = {}; + my @instance_fields; + my @instance_methods; + + &handle_instance_methods($superclass, $superclassname, + $class, \@instance_methods); + + &handle_instance_fields($superclass, $superclassname, + $class, \@instance_fields); + + $superclassname = $superclass->{extends}; + $superclass = $superclassname ? $CLASSES{$superclassname} : undef; + } + } +} + +# +# This is just a helper function for build_class_hierarchy +# because that function was getting way oversized +# +sub handle_instance_methods { + my ($superclass, $superclassname, $class, $instance_methods) = @_; + if ($superclass->{instance_methods}){ + INSTANCE_METHODS: + for my $base_method (@{$superclass->{instance_methods}}){ + for my $method (@{$class->{instance_methods}}){ + if ($$base_method{mapped_name} eq $$method{mapped_name}){ + + # Carry over the description for overridden methods with + # no description (to be javadoc compliant) + if (($base_method->{description} or $base_method->{vars}) + and not $method->{description}){ + + $method->{description} = $base_method->{description}; + for my $varkey (keys(%{$base_method->{vars}})){ + $method->{vars}->{$varkey} + = $base_method->{vars}->{$varkey} + unless $method->{vars}->{$varkey}; + } + } + next INSTANCE_METHODS; + } + } + for (keys %{$class->{inherits}}){ + my $inherited = $class->{inherits}->{$_}; + for my $method (@{$inherited->{instance_methods}}){ + next INSTANCE_METHODS + if $$base_method{mapped_name} eq $method; + } + } + push @$instance_methods, $$base_method{mapped_name}; + } + $class->{inherits}->{$superclassname}->{instance_methods} + = $instance_methods; + } +} + +# +# This is just a helper function for build_class_hierarchy +# because that function was getting way oversized +# +sub handle_instance_fields { + my ($superclass, $superclassname, $class, $instance_fields) = @_; + if ($superclass->{instance_fields}){ + INSTANCE_FIELDS: + for my $base_field (@{$superclass->{instance_fields}}){ + for my $field (@{$class->{instance_fields}}){ + next INSTANCE_FIELDS if $field eq $base_field; + } + push @$instance_fields, $base_field->{field_name}; + } + $class->{inherits}->{$superclassname}->{instance_fields} + = $instance_fields; + } +} + +# +# Set all the class constructors +# +sub set_class_constructors { + for my $classname (keys %CLASSES){ + my $constructor = $FUNCTIONS{$classname}; + $CLASSES{$classname}->{constructor_args} = + $constructor->{argument_list}; + $CLASSES{$classname}->{constructor_detail} + = $constructor->{description}; + + $CLASSES{$classname}->{constructor_vars} = $constructor->{vars} || {}; + } +} + +# +# Clear out everything from the parsed classes and functions +# +sub reset_parser { + %CLASSES = (); + %FUNCTIONS = (); +} + +# +# Set global parameters for the parser +# +sub configure_parser { + %CONFIG = @_; +} + +# +# Set the initial defaults for the parser +# +sub initialize_parser { + $CONFIG{GLOBALS_NAME} ||= 'GLOBALS'; +} + +# +# Run through the source and convert 'confusing' JavaScript constructs +# into ones that are understood by the parser, as well as stripping +# out unwanted comment blocks. +# +# For example: +# +# Foo.prototype = { +# bar: function(){ return "Eep!"; }, +# baz: "Ha!" +# } +# +# becomes +# +# Foo.prototype.bar = function(){ return "Eep!"; }; +# Foo.prototype.baz = "Ha!"; +# +sub preprocess_source { + my ($src) = @_; + + # Make all the @extends tags into @base tags + $src =~ s/\@extends\b/\@base/g; + + # This had better not break anything! + $src = &deconstruct_getset($src); + + # Convert: + # /** @constructor */ + # Foo.Bar = function(){...} + # to: + # /** @constroctor */ + # Foo.Bar = function(){} + # /** @constructor */ + # function Foo.Bar(){...} + # + # Note that we have to keep the original declaration so that Foo.Bar + # can be recognized as a nested class. Yes, I know it's bad... + $src =~ s! + ($JSDOC_COMMENT\s*) + (?:var\s*)?(\w+(?:\.\w+)*?) + \s*= + (\s*function)(?=\s*($BAL_PAREN)\s*\{) + !index($1, '@constructor') == -1 ? "$1$2 = $3" : "$1$2 = function$4 {};\n$1$3 $2"!egx; + + # remove all uninteresting comments, but only if they're not inside + # of other comments + # (adapted from Jeffrey Friedl's "Mastering Regular Expressions" + { + no warnings; + $src =~ s/ + ($NONQUOTE+| + $JSDOC_COMMENT$NONQUOTE*| + $DQUOTE$NONQUOTE*| + $SQUOTE$NONQUOTE*) + |$MLINE_COMMENT|$SLINE_COMMENT/$1/gx; + + 1 while $src =~ s/$JSDOC_COMMENT\s*($JSDOC_COMMENT)/$1/g; + } + + # Alter the prototype-initialization blocks + $src =~ s/ + (\w+(?:\.\w+)*)\.prototype + \s*=\s*($BAL_BRACE)/deconstruct_prototype($1, $2)/egx; + + # Mark all constructors based on 'new' statements + my %seen; + my @classnames = grep { not $seen{$_}++ } + $src =~ /\bnew\s+(\w+(?:\.\w+)*)\s*\(/g; + for my $cname (@classnames){ + $src =~ s/($JSDOC_COMMENT?) + (?=\s*function\s+\Q$cname\E\s*$BAL_PAREN + \s*$BAL_BRACE) + /&annotate_comment($1, '@constructor')/ex; + } + + $src =~ s/ + ($JSDOC_COMMENT?)\s* + (function\s+\w+(?:\.\w+)*\s*$BAL_PAREN\s*) + ($BAL_BRACE) + /&deconstruct_constructor($1, "$2$3")/egx; + + $src =~ s! + (?:var\s+)?(\w+(?:\.\w+)*) + \s*=\s* + new\s+ + ($ANON_FUNCTION)!&deconstruct_singleton($1, $2)!egx; + + $src = &remove_dynamic_bindings($src); + + # Mark all void methods with "@type void" + $src =~ s/($JSDOC_COMMENT?)\s* + ((?: + (?:function\s+\w+(?:\.\w+)*\s*$BAL_PAREN\s*) + | + (?:\w+(?:\.\w+)*\s*=\s*function\s*(?:\w+\s*)?$BAL_PAREN\s*) + )$BAL_BRACE) + /&mark_void_method($1, $2)/egx; + + # Clear nested functions (will save trouble later on) + $src =~ s/($JSDOC_COMMENT?)\s* + (\w+(?:\.\w+)*\s*=\s*)? + (function(?:\s+\w+(?:\.\w+)*)?\s*$BAL_PAREN\s*) + ($BAL_BRACE) + /&clear_nested($1, $2, $3, $4)/egx; + + return $src; +} + +sub clear_nested { + my ($doc, $assign_to, $declaration, $funcbody) = @_; + $assign_to ||= ''; + if ($doc =~ /^(?=.*\@constructor|\@class)(?=.*\@exec)/){ + warn "\@constructor or \@class can't be used together with \@exec\n"; + } + if ($doc !~ /\@(constructor|class|exec)/ + or $assign_to =~ /^\w+\.prototype\./) { + return "$doc\n$assign_to$declaration" . "{}\n"; + } elsif ($doc =~ /\@(constructor|class)/) { + return "$doc\n$assign_to$declaration$funcbody"; + } else { + my @visible_funcs = $funcbody =~ / + ((?:$JSDOC_COMMENT)? + (?:\w+\.\w+(?:\.\w+)*)\s*=\s* + (?: + $FUNC_DEF + | + $ANON_FUNCTION + | + $FUNC_CALL + | + \w+ + )\s*;)/gx; + return join("\n", @visible_funcs); + } +} + +# +# Remove dynamic binding. +# Change this: +# +# function MyFunc(class){ +# var x = 2; +# class.prototype.func = function(){}; +# return x; +# } +# +# to: +# +# function MyFunc(class){ +# var x = 2; +# +# return x; +# } +# +# and change this: +# +# function BindMethod(obj){ +# obj.someFunc = function(){ return null; }; +# return obj; +# } +# +# to: +# +# function BindMethod(obj){ +# +# return obj; +# } +# +sub remove_dynamic_bindings { + my ($src) = @_; + while ($src =~ /$RET_FUNC_DEF/g){ + my ($fname, $params, $definition) = ($1, $2, $3); + next unless $definition =~ /\bfunction\b|\w+\.prototype\./; + my @params = split(/\s*,\s*/, substr($params, 1, length($params) - 2)); + for my $param (@params){ + $src =~ s/\b$param\.prototype\.[^;\n]*[;\n]//g; + $src =~ s/\b$param\.\w+ = $ANON_FUNCTION//g; + } + } + $src; +} + +# +# Annotate a method as being void if no @type can be found, and there is no +# statement to return a value in the method itself. +# +sub mark_void_method { + my ($doc, $funcdef) = @_; + return "$doc\n$funcdef" if $doc =~ /\@(constructor|type|returns?)\b/; + my ($fbody) = $funcdef =~ /^[^{]*($BAL_BRACE)/; + $fbody =~ s/$FUNC_DEF/function x(){}/g; + $fbody =~ s/$ANON_FUNCTION/function (){}/g; + $doc = &annotate_comment($doc, '@type void') + if $fbody !~ /\breturn\s+(?:(?:\w+)|(?:(["']).*?\1)|$BAL_PAREN)/; + "$doc\n$funcdef"; +} + +# +# A helper to change singleton declarations like +# +# MySingleton = new function(){this.x=function(){}} +# +# into: +# +# function MySingleton(){} +# MySingleton.prototype.x = function(){}; +# +sub deconstruct_singleton { + my ($classname, $definition) = @_; + $definition =~ s/function\s*$BAL_PAREN\s*\{(.*)\}\s*$/$1/s; + $definition =~ s/\bthis\./$classname.prototype\./g; + qq# + function $classname(){} + $definition; + #; +} + +# +# A helper to preprocess_source, change prototype-initialization +# blocks into multiple prototype-property assignments +# +sub deconstruct_prototype { + my ($class, $src) = @_; + $src =~ s/^\{(.*)\}$/$1/s; + $src =~ s! + (\w+) + \s*:\s* + ( + $ANON_FUNCTION + | + $FUNC_DEF + | + $FUNC_CALL + | + $LITERAL + | + \w+ + ) + \s*,? + !$class.prototype.$1 = $2;!gsx; + + $src; +} + +# +# Unpacks a constructor into separate calls +# +sub deconstruct_constructor { + my ($doc, $func_def) = @_; + return "$doc$func_def" unless $doc =~ /\@(constructor|class)/; + my ($classname) = $func_def =~ /function\s+(\w+(?:\.\w+)*)/; + $func_def =~ s/ + (\{.*\})$ + /&deconstruct_inner_constructor($classname, $1)/esx; + "$doc$func_def"; +} + +sub deconstruct_inner_constructor { + my ($classname, $inner_src) = @_; + $inner_src = substr($inner_src, 1, -1); + my @doc_n_fnames = $inner_src =~ /($JSDOC_COMMENT?)\s*function\s+(\w+)/g; + + unless ($CONFIG{NO_LEXICAL_PRIVATES}){ + $inner_src =~ s/ + ($JSDOC_COMMENT)? + \s* + var + \s+ + (\w+)/&annotate_comment($1) . "\n$classname\.prototype\.$2"/egx; + + $inner_src =~ s/ + ($JSDOC_COMMENT)?\s* + ^\s* + function + \s+ + (\w+) + /&annotate_comment($1) . + "\n$classname\.prototype\.$2 = function"/egmx; + } + + { + no warnings; + $inner_src =~ s/ + ($JSDOC_COMMENT\s*)? + ^\s*this(?=\.) + /$1$classname.prototype/gmx; + } + + # Replace all bindings of private methods to public names + for (my $i = 0; $i < @doc_n_fnames; $i += 2) + { + my ($doc, $fname) = @doc_n_fnames[$i, $i + 1]; + $inner_src =~ s/ + ($JSDOC_COMMENT\s* + $classname\.prototype\.\w+) + \s*=\s* + $fname\s*[\n;] + /$1 = function(){}/gx; + + $inner_src =~ s/ + ($classname\.prototype\.\w+) + \s*=\s* + $fname\s*[\n;] + /$doc\n$1 = function(){}/gx; + } + "{}\n$inner_src"; +} + +# +# Deconstruct mozilla's __defineGetter__ and __defineSetter__ +# (Yes, I know this goes against my principles...) +# +sub deconstruct_getset { + my ($src) = @_; + # Crack open the assignments for define(Getter|Setter) + my $crack = sub { + my $code = shift; $code =~ s/^.(.*).$/$1/s; + my ($name) = split ",", $code; + $name = ($name =~ /.*?(['"])([^'"]+)\1/)[1]; + $name; + }; + for my $prefix ('get', 'set'){ + my $fname = "define\u${prefix}ter"; + $src =~ s/ + (\w+(?:\.\w+)* + \.prototype) + \.__${fname}__\s*($BAL_PAREN)/ + my $name = $crack->($2); + "$1.$name = null"/gex; + } + $src; +} + + +# +# Add an annotation (@tag) to a documentation block. The block is assumed to +# be a valid JSDoc documentation block ==> /^\/\*\*.*\*\/$/ +# and no checking is done to verify this +# +sub annotate_comment { + my $annotation = $_[1] || '@private'; + return "\n/** $annotation */" unless $_[0]; + substr($_[0], 0, -2) . " \n$annotation \n*/"; +} + +# +# This is here to stop perl from segfaulting from deep recursion in regexes +# The first character in the text _should_ be open_token, as everything +# before open_token will be discarded, unless there is no matching text +# at all. +# +sub find_balanced_block { + my ($open_token, $close_token, $text) = @_; + my ($count, $open, $close) = (0, 0, 0); + return ('', $text) unless $text =~ /\Q$open_token\E/; + $text =~ s/^.*?(?=\Q$open_token\E)//s; + for (split //, $text){ + $count++; + $open++ if $_ eq $open_token; + $close++ if $_ eq $close_token; + last unless ($open != $close); + } + warn "Unbalanced block\n" if ($open != $close); + (substr($text, 0, $count), substr($text, $count)); +} + +# +# Remove the $CONFIG{GLOBALS_NAME} class if it doesn't contain anything +# +sub filter_globals { + my $global = $CLASSES{$CONFIG{GLOBALS_NAME}}; + delete $CLASSES{$CONFIG{GLOBALS_NAME}} if + not (defined $global->{constructor_args} || + defined $global->{constructor_detail}) + && not (@{$global->{instance_methods}} || + @{$global->{instance_fields}} || + @{$global->{class_methods}} || + @{$global->{class_fields}}); + + # Also get rid of extra info under the '__files__' key + delete $CLASSES{__FILES__}->{$_} for qw(constructor_params constructor_args + constructor_detail class_methods + constructor_vars); +} + + +# +# Try to grab the first block comment from the file that has a @fileoverview +# tag in it, and get the file info from there +# +sub parse_file_info { + my ($src) = @_; + my %fileinfo = ( src => $src ); + while ($src =~ /($JSDOC_COMMENT)/g){ + local $_ = substr($1, 3, length($1) - 5); # Get the actual content + if (/\@fileoverview\b/){ + my $doc = parse_jsdoc_comment($_, 1); + %fileinfo = (%{$doc->{vars}}, %fileinfo); + last; + } + } + $CLASSES{__FILES__}->{$CTX_FILE} = \%fileinfo if $CTX_FILE; +} + +1; diff --git a/modules/jala/util/HopKit/JSDoc/JSDoc/XMI.pm b/modules/jala/util/HopKit/JSDoc/JSDoc/XMI.pm new file mode 100644 index 00000000..77b5e0af --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JSDoc/XMI.pm @@ -0,0 +1,291 @@ +package JSDoc::XMI; + +use strict; +use warnings; +use HTML::Template; +use Data::Dumper; + +=head1 DESCRIPTION + + @packages + + @classes + $classname + $classid + $classuuid + $classvisibility (public|protected|private) + + @specializationids + $specializationid + + $generalizationid + + @attributes + $attributeid + $attributeuuid + $attributename + $attributevisibility (public|protected|private) + $ownerscope (instance|classifier) + $classid + $typeid + + @methods + $methodid + $methoduuid + $methodname + $methodvisibility (public|protected|private) + $ownerscope (instance|classifier) + $returnid + $returnuuid + $returntypeid + + @datatypes + $datatypeid + $datatypeuuid + $datatypename + + @generalizations + $generalizationid + $generalizationuuid + $generalizationchild + $generalizationparent + +=cut + +sub new { + my ($package, $location) = @_; + bless { + location => "${location}JSDoc/", + idcounter => 2, + types => {}, + classes => {}, + generalizations => {} + }, $package; +} + +sub output { + my ($self, $classes) = @_; + + my $template = HTML::Template->new( + filename => $self->{location} . 'xmi.tmpl', + die_on_bad_params => 1); + + my @packages = $self->get_packages($classes); + my @datatypes = $self->get_datatypes; + my @generalizations = $self->get_generalizations; + + $template->param( + packages => \@packages, + datatypes => \@datatypes, + generalizations => \@generalizations ); + return $template->output; +} + +sub get_id { + 'xmi.' . shift->{idcounter}++; +} + +sub get_uuid { + my @chars = ('A'..'Z', 'a'..'z', 0..9); + my @uuid; + for (1..32){ + push @uuid, $chars[rand(@chars)]; + } + join("", @uuid); +} + +sub get_packages { + my ($self, $classes) = @_; + my %packages; + push(@{$packages{$_->{package}}}, $_) + for $self->get_classes($classes); + map { + name => $_, + classes => $packages{$_}, + packageid => $self->get_id, + packageuuid => $self->get_uuid + }, keys %packages; +} + +sub get_classes { + my ($self, $classes) = @_; + my @classes; + + # Store all the class-ids before we start on anything else + $self->add_class($_) for keys %$classes; + + for my $cname (keys %$classes){ + my $class = { + classname => $cname, + classid => $self->add_class($cname), + classuuid => $self->get_uuid, + classvisibility => + defined($classes->{$cname}->{constructor_vars}->{private}) + ? 'private' : 'public' + }; + $class->{attributes} = $self->get_attributes( + $class->{classid}, + $classes->{$cname}); + + $class->{methods} = $self->get_methods( + $class->{classid}, + $classes->{$cname}); + + $class->{generalizationid} = + $self->get_generalizationid($classes->{$cname}); + + $class->{package} = + defined($classes->{$cname}->{constructor_vars}->{package}) + ? $classes->{$cname}->{constructor_vars}->{package}->[0] : ''; + + push @classes, $class; + } + + for my $class (@classes){ + $class->{specializationids} = $self->get_specializationids($class); + } + + @classes; +} + +sub get_methods { + my ($self, $classid, $class) = @_; + my @methods; + + for my $k (qw(instance class)){ + for my $method (@{$class->{"${k}_methods"}}){ + my $type = defined($method->{vars}->{type}) + ? $method->{vars}->{type}->[0] : 'Object'; + my $meth = { + methodid => $self->get_id, + methoduuid => $self->get_uuid, + methodname => $method->{mapped_name}, + methodvisibility => + defined($method->{vars}->{private}) + ? 'private' : 'public', + ownerscope => + $k eq 'class' ? 'classifier' : 'instance', + returnid => $self->get_id, + returnuuid => $self->get_uuid, + returntypeid => $self->add_type($type) + }; + push @methods, $meth; + } + } + return \@methods; +} + +sub get_attributes { + my ($self, $classid, $class) = @_; + my @attributes; + for my $k (qw(instance class)){ + for my $field (@{$class->{"${k}_fields"}}){ + my $type = defined($field->{field_vars}->{type}) + ? $field->{field_vars}->{type}->[0] : 'Object'; + my $attr = { + attributeid => $self->get_id, + attributeuuid => $self->get_uuid, + attributename => $field->{field_name}, + attributevisibility => + defined($field->{field_vars}->{private}) + ? 'private' : 'public', + ownerscope => + $k eq 'class' ? 'classifier' : 'instance', + classid => $classid, + typeid => $self->add_type($type) + }; + push @attributes, $attr; + } + } + \@attributes; +} + +sub get_generalizationid { + my ($self, $class) = @_; + + if ($class->{extends}){ + return $self->add_generalization( + $class->{classname}, + $class->{extends}); + } + ''; +} + +sub get_specializationids { + my ($self, $class) = @_; + my $cname = $class->{classname}; + my $cid = $self->add_class($cname); + + my @specializationids; + + for my $id (keys %{$self->{generalizations}}){ + my $generalization = $self->{generalizations}->{$id}; + if ($generalization->{parent} eq $cid){ + push @specializationids, { specializationid => $id }; + } + } + \@specializationids; +} + +sub get_datatypes { + my ($self) = @_; + my @datatypes; + + while (my ($type, $id) = each(%{$self->{types}})){ + push @datatypes, { + datatypeid => $id, + datatypeuuid => $self->get_uuid, + datatypename => $type }; + } + @datatypes; +} + +sub get_generalizations { + my ($self) = @_; + my @generalizations; + + while (my ($id, $generalization) = each(%{$self->{generalizations}})){ + push @generalizations, { + generalizationid => $id, + generalizationuuid => $self->get_uuid, + generalizationchild => $generalization->{parent}, + generalizationparent => $generalization->{child}}; + } + @generalizations; +} + +sub add_type { + my ($self, $type) = @_; + $type =~ s/^\s*(\S+)\s*$/$1/; + if (defined($self->{classes}->{$type})){ + return $self->add_class($type); + } elsif (defined($self->{types}->{$type})){ + return $self->{types}->{$type}; + } + $self->{types}->{$type} = $self->get_id; +} + +sub add_class { + my ($self, $class) = @_; + $class =~ s/^\s*(\S+)\s*$/$1/; + if (defined($self->{classes}->{$class})){ + return $self->{classes}->{$class}; + } + $self->{classes}->{$class} = $self->get_id; +} + +sub add_generalization { + my ($self, $subclassname, $superclassname) = @_; + my $subclassid = $self->add_class($subclassname); + my $superclassid = $self->add_class($superclassname); + + my $generalization = { + child => $subclassid, + parent => $superclassid }; + + my $generalizationid = $self->get_id; + $self->{generalizations}->{$generalizationid} = $generalization; + $generalizationid; +} + +1; diff --git a/modules/jala/util/HopKit/JSDoc/JSDoc/XML.pm b/modules/jala/util/HopKit/JSDoc/JSDoc/XML.pm new file mode 100644 index 00000000..aa07f307 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JSDoc/XML.pm @@ -0,0 +1,72 @@ +package JSDoc::XML; + +use strict; +use warnings; +use HTML::Template; + +sub new { + my ($package, $location) = @_; + bless { location => "${location}JSDoc/" }, $package; +} + +sub output { + my ($self, $classes) = @_; + my @classes = _preprocess( + grep {defined($_->{classname})} values %$classes); + my $template = HTML::Template->new( + filename => $self->{location} . 'xml.tmpl', + die_on_bad_params => 1); + + $template->param(classes => \@classes); + return $template->output; +} + +sub _preprocess { + my @classes = @_; + for (@classes){ + $_->{inherits} = _preprocess_inherits($_->{inherits}); + $_->{constructor_vars} = _preprocess_vars($_->{constructor_vars}); + for my $method (@{$_->{instance_methods}}, @{$_->{class_methods}}){ + $method->{vars} = _preprocess_vars($method->{vars}); + } + for my $field (@{$_->{instance_fields}}, @{$_->{class_fields}}){ + $field->{field_vars} = _preprocess_vars($field->{field_vars}); + } + } + @classes; +} + +sub _preprocess_inherits { + my ($inherits) = @_; + my @inherits; + for my $class (keys %$inherits){ + my $inherit = { + class => $class, + methods => [map { name => $_ }, + @{$inherits->{$class}->{instance_methods}}]}; + push @inherits, $inherit; + } + \@inherits; +} + +sub _preprocess_vars { + my ($vars) = @_; + return $vars if ref($vars) eq 'ARRAY'; + my @vars; + for my $key (keys %$vars){ + my $var; + if (ref($vars->{$key}) eq 'ARRAY'){ + $var = { + '@name' => $key, + values => [map { val => $_ }, @{$vars->{$key}}] }; + } else { + $var = { + '@name' => $key, + values => [ { val => $vars->{$key} } ] }; + } + push @vars, $var; + } + \@vars; +} + +1; diff --git a/modules/jala/util/HopKit/JSDoc/JSDoc/xmi.tmpl b/modules/jala/util/HopKit/JSDoc/JSDoc/xmi.tmpl new file mode 100644 index 00000000..7aa07d5f --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JSDoc/xmi.tmpl @@ -0,0 +1,250 @@ + + + + + JSDoc XMI Export + 0.1 + + + + + + JSDoc + + + + + + + + + + + " + xmi.uuid=""> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + return + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/jala/util/HopKit/JSDoc/JSDoc/xml.tmpl b/modules/jala/util/HopKit/JSDoc/JSDoc/xml.tmpl new file mode 100644 index 00000000..0757ac73 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JSDoc/xml.tmpl @@ -0,0 +1,128 @@ + + + + + " + extends="" > + + + + + + ]]> + + + + + + ]]> + + + + + ]]> + + + + + + ]]> + + + + + + + + + + + + ]]> + ]]> + + + + + ]]> + + + + + + + + + + + + ]]> + + + + + + ]]> + + + + + + + + + + + + + + + + ]]> + ]]> + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/jala/util/HopKit/JSDoc/JavaScript/Syntax/HTML.pm b/modules/jala/util/HopKit/JSDoc/JavaScript/Syntax/HTML.pm new file mode 100644 index 00000000..909facb7 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/JavaScript/Syntax/HTML.pm @@ -0,0 +1,95 @@ +package JavaScript::Syntax::HTML; + +=head1 NAME + +JavaScript::Syntax::HTML - Convert JavaScript sourcecode to HTML + +=head1 SYNOPSIS + + use JavaScript::Syntax::HTML qw(to_html to_html_document); + my $html_fragment = to_html($js_src); + my $html_doc = output_html_document($js_src); + +=head1 DESCRIPTION + +JavaScript::Syntax::HTML processes JavaScript code and outputs HTML with +all reserved words marked up. + +The to_html method only outputs an HTML fragment (no or tags), +and only marks up the reserved words with CSS styles. + +The to_html_document method outputs a full HTML document, and does include +style information for the reserved words markup. + +The style classes that can be defined for use with to_html are C, +C, and C. + +=head1 AUTHOR + +Gabriel Reid gab_reid@users.sourceforge.net + +=cut + +use warnings; +use strict; +use Exporter; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(to_html to_html_document); + +sub to_html { + local $_ = shift; + s/\&/&/g; + s//>/g; + s/ + ((?:\/\*.*?\*\/) + | + (?:\/\/[^\n]*$)) + | + ('[^']*'|"[^"]*") + | + \b(function|for|if|while|return|else|prototype|this)\b + / get_substitution($1, $2, $3) /egsxm; + $_; +} + +sub get_substitution { + my ($comment, $stringliteral, $resword) = @_; + my $content; + if ($comment){ + $comment =~ s/(\@\w+)\b/get_span('attrib', $1)/eg; + return get_span('comment', $comment); + } elsif ($stringliteral){ + return get_span('literal', $stringliteral); + } elsif ($resword){ + return get_span('reserved', $resword); + } +} + +sub get_span { + my ($class, $inner) = @_; + qq($inner); +} + +sub to_html_document { + my ($src) = @_; + $src = &to_html($src); + qq( + + + + + +
      +$src
      +	
      + +); +} diff --git a/modules/jala/util/HopKit/JSDoc/README b/modules/jala/util/HopKit/JSDoc/README new file mode 100644 index 00000000..cb34ca75 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/README @@ -0,0 +1,30 @@ +README for jsdoc.pl + +jsdoc.pl is a script that produces javadoc-style documentation from well-formed +JavaScript sourcefiles. At the moment, this means it supports sourcefiles where +all functions are mapped to a class using prototype-based inheritance. +Anonymous function definitions +(e.g. Circle.prototype.getRadius = function(){ ...} ) are supported. + +This application requires Perl5, as well as one non-standard addon module: + - HTML::Template, which is available from CPAN (cpan.org) + +Invocation is simple: Just run the application, giving one or more well-formed +OO JavaScript sourcefilename(s) as arguments. A sample JS sourcefile, test.js, +is given along with this application. An example of running the application is +shown below: + + $ ./jsdoc.pl test.js + +OR + perl jsdoc.pl test.js + +Further information about using JsDoc can be found at +http://jsdoc.sourceforge.net + +If there are any questions, comments, problems or anything else, please mail +the jsdoc-user mailing list; more information can be found at +http://sourceforge.net/mail/?group_id=30801. This application has been +successfully tested on Linux (Debian and Redhat), and Windows 2000 with +ActivePerl. + diff --git a/modules/jala/util/HopKit/JSDoc/TODO b/modules/jala/util/HopKit/JSDoc/TODO new file mode 100644 index 00000000..414e805b --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/TODO @@ -0,0 +1,46 @@ +TODO for JSDoc + +- XML / XMI export + +- Improve the --package-naming option so that there are separate namespaces + for each package (so that you can have the same class name defined in + different packages) + +- Fix some spacing/table issues in the navbar in the templates (use a td + border in the stylesheet to debug) + +- Introduce a more generalized system for generating the navbar + +- Handle additional information (such as @see) for fields + +- Uncallable methods/functions should be marked as private, or show the scope + from which they can be called + +- Dynamic handling of assignment of prototype to a temp variable (preprocessor) + +- Add support for interfaces, but first this has to be better defined + +- Top-level var documenting (maybe add a '@global' tag to force toplevel vars + to be documented + +- Add an FAQ, more and better documentation + +- Java port (someday...) + +- Make a more polished API for using other doclets, like javadoc + +- Add a deprecated page, make deprecated support more like javadoc + +- Add support for js files without .js extension + +- Support for a time stamp + +- Some of the ->{vars} are set to undef, should always be an empty map + +- Add command line params --dump-tree, --dump-xml + +- Add command line param --stylesheet + +- Make navbar links selective so they are never broken + +- Update the help doc diff --git a/modules/jala/util/HopKit/JSDoc/TestJSDoc.pl b/modules/jala/util/HopKit/JSDoc/TestJSDoc.pl new file mode 100644 index 00000000..aa35933f --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/TestJSDoc.pl @@ -0,0 +1,679 @@ +#!/usr/bin/perl + +package JSDoc; +# +# Unit testing of JSDoc +# +# Run with 'perl TestJSDoc.pl' or './TestJSDoc.pl' +# + +use strict; +use warnings; + + + +use JSDoc; +use Data::Dumper; +use Test::More qw(no_plan); + +$|++; + +# parse_jsdoc_comment +diag("Testing parse_jsdoc_comment"); +is_deeply(parse_jsdoc_comment(''), {summary => ''}, + "Ensure only summary is filled in"); + +is(parse_jsdoc_comment('')->{summary}, '', 'Empty comment value'); + + +is(parse_jsdoc_comment( + '************************* test *************')->{summary}, + 'test', 'long leading and trailing stars'); + + +# annotate_comment +diag("Testing annotate_comment"); +is(annotate_comment, "\n/** \@private */", 'annotate_comment w/o arg'); +like(annotate_comment("/** This is a test */"), + qr#^/\s*\*\*\s*This is a test\s+\@private\s*\*/\s*$#, + 'annotate_comment w/ arg'); +like(annotate_comment("/** This is a test */", '@testtag value'), + qr#^/\s*\*\*\s*This is a test\s+\@testtag\svalue\s*\*/\s*$#, + 'annotate_comment w/ tag argument'); + +# find_balanced_block +diag("Testing find_balanced_block"); +my @blocks = ( + # basic simple input + ['{', '}', '{ this is in the braces } {this is after}{{', + ['{ this is in the braces }', ' {this is after}{{'] , + 'basic input'], + + # discard leading chars before opening char + ['{', '}', 'discard {inner} after', + ['{inner}', ' after'], 'discard leading chars'], + + # empty input string + ['{', '}', '', + ['', ''], 'empty input string'], + + # nothing to match at all + ['{', '}', 'there is nothing to match', + ['', 'there is nothing to match'], 'nothing to match'], + ); +for my $test (@blocks){ + my @args = @{$test}[0..2]; + my ($expect, $explain) = @{$test}[3,4]; + is_deeply([find_balanced_block(@args)], $expect, $explain); +} + +# +# Test the @member tag +# +diag('Testing the @member tag'); +reset_parser(); +my $src = q# +/** @constructor */ +function Foo(){ + this.x = function(){return null;}; +} +/** Unrelated */ +function myfunc(){return null;} +#; +my $classes = parse_code_tree(\$src); +my %method_names = map { $_->{mapped_name} => 1 } + @{$classes->{Foo}->{instance_methods}}; +ok(not(defined($method_names{myfunc})), + 'Unrelated method is not added to class without @member tag'); +reset_parser(); +$src = q# +/** @constructor */ +function Foo(){ + this.x = function(){return null;}; +} +/** + * @member Foo + */ +function myfunc(){return null;} +#; +$classes = parse_code_tree(\$src); +%method_names = map { $_->{mapped_name} => 1 } + @{$classes->{Foo}->{instance_methods}}; +ok(defined($method_names{myfunc}), + 'Add method marked with @member to class'); +reset_parser(); + +# +# preprocess_source +# + +diag("Testing preprocess_source"); + +# Make sure that: +# +# Foo.prototype = { +# bar: function(){ return "Eep!"; }, +# baz: "Ha!" +# } +# +# becomes: +# +# Foo.prototype.bar = function(){ return "Eep!"; }; +# Foo.prototype.baz = "Ha!"; + +my $before = q/ + Foo.prototype = { + bar: function(){ return "Eep!"; }, + baz: "Ha!" + } /; + +my $after_re = qr/^\s*(?:$JSDOC_COMMENT)?\s*Foo.prototype.bar + \s*=\s* + function\(\s*\)\s*\{[^\}]*}\s*;\s* + Foo\.prototype\.baz\s*=\s*"[^"]+"\s*;\s*$/x; + +like(preprocess_source($before), $after_re, + 'Unpack prototype block assignment'); + +# +# Make sure that: +# +# /** @constructor */ +# Foo.Bar = function(){this.x = 2;var y = 3;} +# becomes: +# /** @constructor */ +# Foo.Bar = function(){}; +# +# /** @constructor */ +# function Foo.Bar(){} +# +# Foo.Bar.prototype.x = 2; +# +# /** @private */ +# Foo.Bar.prototype.y = 3; +# +$before = q# + /** @constructor */ + Foo.Bar = function(){this.x = 2; var y = 3; }#; +$after_re = qr{ + ^\s*/\*\*\s*\@constructor\s*\*/\s* + Foo\.Bar\s*=\s*function\s*\(\s*\)\s*\{\s*\}\s*;\s* + /\*\*\s*\@constructor\s*\*/\s* + function\s+Foo\.Bar\s*\(\s*\)\s*\{\s*\} + \s* + Foo\.Bar\.prototype\.x\s*=\s*2\s*;\s* + /\*\*\s*\@private\s*\*/\s* + Foo\.Bar\.prototype\.y\s*=\s*3\s*;\s*$ + }x; +like(preprocess_source($before), $after_re, + 'Unpack nested class'); + +# +# Make sure that: +# MySingleton = new function(){this.x=function(){}} +# and +# var MySingleton = new function(){this.x=function(){}} +# become: +# function MySingleton(){} +# MySingleton.prototype.x = function(){}; +# +$before = q# MySingleton = new function(){this.x=function(){}} #; +$after_re = qr{ + ^\s*(?:$JSDOC_COMMENT)? + \s*function\s*MySingleton\s*\(\)\s*\{\s*\}\s* + (?:$JSDOC_COMMENT)?\s* + MySingleton\.prototype\.x\s*=\s*function\s*\(\s*\)\s*\{\s*\}\s*;\s*$}x; +like(preprocess_source($before), $after_re, + 'Unpack singleton'); + +# Same thing, but with var before the declaration +$before = q#var MySingleton = new function(){this.x=function(){}} #; +like(preprocess_source($before), $after_re, + "Unpack var'd singleton"); + + +# +# Test unpacking a constructor into a bunch of +# prototype-based declarations +# + +$before = q# + /** + * @constructor + */ + function MyClass(){ + /** Private variable 'x' */ + var x = 3; + /** + * This is my function + */ + this.myFunction = function(){ return null; }; + + /** + * This is a private function + */ + function myPrivateFunction(x){ + return null; + } + } +#; +$after_re = qr{ + /\*\*\s* + \*\s*\@constructor\s* + \*/\s* + function\s+MyClass\s*\(\s*\)\s*\{\s*\}\s* + + /\*\*\s*Private\svariable\s'x'\s* + \@private\s*\*/\s* + MyClass\.prototype\.x\s*=\s*3\s*;\s* + + /\*\*\s* + \*\s*This\sis\smy\sfunction\s*\*/\s* + MyClass\.prototype\.myFunction\s*=\s*function\s*\(\s*\)\s*\{ + [^\}]*\}\s*;\s* + + /\*\*\s* + \*\s*This\sis\sa\sprivate\sfunction\s* + \@private\s*\*/\s* + MyClass\.prototype\.myPrivateFunction\s*=\s*function\(\s*x\s*\)\s* + \{[^\}]*\}\s*$ +}x; + +like(preprocess_source($before), $after_re, + 'Testing unpacking a constructor into prototype-based assignments'); + + +# +# Test the marking of void methods +# +$before = q'function MyFunc(){}'; +$after_re = qr{/\*\*\s*\@type\s+void\s*\*/\s*function\s+MyFunc\s*\(\)\{\}}; +like(preprocess_source($before), $after_re, + "Testing basic marking of void method without a docstring"); + +$before = q' +/** Method */ +function MyFunc(){} +'; +$after_re = qr{/\*\*\s*Method\s+\@type\s+void\s*\*/\s* + function\s+MyFunc\(\)\{\}}x; +like(preprocess_source($before), $after_re, + "Testing basic marking of void methods"); + +$before = '/** Method */ + Shape.prototype.MyFunc = function(){}'; +$after_re = qr{ + /\*\*\s* + Method\s+ + \@type\s+void\s* + \*/\s*Shape\.prototype\.MyFunc\s*=\s*function\(\)\{\}}x; +like(preprocess_source($before), $after_re, + "Testing marking of void anonymous method"); + +$before = 'Shape.prototype.MyFunc = function(){return null;}'; +$after_re = qr{^\s*Shape\.prototype\.MyFunc\s*= + \s*function\(\)\{[^\}]*\}}x; +like(preprocess_source($before), $after_re, + "Testing marking of void anonymous method"); + +$before = "function x(){return null;}"; +$after_re = qr{\s*function\sx\(\)\s*\{[^\}]*\}\s*$}; +like(preprocess_source($before), $after_re, + "Leave non-void methods without docstrings alone"); + +$before = "/** My test function */\nfunction x(){return null;}"; +$after_re = qr{\s*/\*\*\s*My\stest\sfunction\s*\*/\s* + function\sx\(\)\s*\{[^\}]*\}\s*$}x; +like(preprocess_source($before), $after_re, + "Leave non-void methods with docstrings alone"); + +reset_parser(); +$src = q# +/** + * @constructor + */ +function MyClass(){ + this.af = afunc; + this.bf = bfunc; + this.cf = cfunc; + function afunc(){} + function bfunc(){} + function cfunc(){} +} +#; +$classes = parse_code_tree(\$src); +ok(eq_set( + [ map { $_->{mapped_name} } + @{$classes->{MyClass}->{instance_methods}}], + ['af', 'bf', 'cf', 'afunc', 'bfunc', 'cfunc']), + "Ensure instance methods in constructor are correctly assigned"); + + + +reset_parser(); +$src = 'function MyFunction(){ return ""; }'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}), + "Ensure a function returning an empty string is not marked as void"); + +reset_parser(); +$src = 'function A(){ var x = "x"; }'; +$classes = parse_code_tree(\$src); +ok($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}->[0] eq 'void', + "Ensure a global void is void"); + +reset_parser(); +$src = 'function A(c){ c.someFunc = function(){ return 2; }; }'; +$classes = parse_code_tree(\$src); +ok($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}->[0] eq 'void', + "Ensure inner function definitions don't affect the return type"); + +reset_parser(); +$src = 'function A(c){ c.someFunc = function(){ return 2; }; return ""; }'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}->[0]), + "Ensure inner-function measures don't affect non-void functions"); + +reset_parser(); +$src = '/** @return {int} Description */function f(){}'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}->[0]), + 'Methods with a @return tag but no return statement are not marked void'); + +reset_parser(); +$src = 'function f(){ return (true ? "t" : "f");}'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{GLOBALS}->{class_methods}->[0]->{vars}->{type}->[0]), + "Non-void with non-trivial return statement is not marked as void"); + +# +# Try huge constructor input +# +my @testsrc = (q# +/** + * @class This is class information + * @constructor + */ + function MyClass(){ + +#); +for (1..30){ + push @testsrc, " + /** This is a private method */ + function f$_(){ return null; } + + /** + * THis is function number $_ + * \@return Nothing + */ + this.func$_ = function(){if(true){if(false){return null;}}} ;\n"; +} +push @testsrc, "\n}\n"; +my $testsrc = join("\n", @testsrc); +# This could crash everything +preprocess_source($testsrc); +pass("Process huge constructor with preprocess_source"); + + +# +# Huge constructor with unbalanced input +# +@testsrc = (q# +/** + * @class This is class information + * @constructor + */ + function MyClass(){ + +#); +for (1..100){ + push @testsrc, " + /** + * THis is function number $_ + * \@return Nothing + */ + this.func$_ = function(){if(true){if(false){return null;}};\n"; +} +push @testsrc, "\n}\n"; +$testsrc = join("\n", @testsrc); +# This could crash everything +preprocess_source($testsrc); +pass("Process huge unbalanced constructor with preprocess_source"); + +# +# deconstruct_mozilla_getset +# +$before = 'MyClass.prototype.__defineGetter__("myProp", function(){return null;});'; +$after_re = qr{ + ^\s*MyClass\.prototype\.myProp\s*=\s*null\s*;\s*$}x; + #\s*function\s*\(\s*\)\s*\{\s*return\s+null\s*;\s*\}\s*;\s*$}x; + +like(deconstruct_getset($before), $after_re, + "Testing behaviour of __defineGetter__"); +like(preprocess_source($before), $after_re, + "Testing behaviour of __defineGetter__ in preprocess_source"); + +$before = 'MyClass.prototype.__defineSetter__("myProp", function(){return null;});'; +$after_re = qr{ + ^\s*MyClass\.prototype\.myProp\s*=\s*null\s*;\s*$}x; + +like(deconstruct_getset($before), $after_re, + "Testing behaviour of __defineSetter__"); +like(preprocess_source($before), $after_re, + "Testing behaviour of __defineSetter__ in preprocess_source"); + +reset_parser(); +$src = " + function MyFunc(theclass){ + var x = 2; + theclass.prototype.f = function(){}; + return x; + } + MyClass.prototype.f = function(){}; +"; +$classes = parse_code_tree(\$src); +ok(not(defined($classes->{theclass})), + "Ensure that dynamic prototyping doesn't add classes"); +ok(defined($classes->{MyClass}), + "Ensure that normal classes are added with static prototyping"); + +# +# miscellaneous tests +# +diag("Miscellaneous tests"); +reset_parser(); +$src = " + /** \@constructor */ + function A(){} + /** \@constructor */ + function C(){} + /** \@constructor + \@extends A + */ + function B(){} + B.prototype = new C();"; + +$classes = parse_code_tree(\$src); +is($classes->{B}->{extends}, 'A', + "Test that the first extends marking is the good one, others are ignored"); + +reset_parser(); +$src = "function A(){ this.n = function(){return 2};} + var a = new A(); "; +$classes = parse_code_tree(\$src); +ok(defined($classes->{A}), + "Functions are later used with 'new' must be treated as a constructor"); + +ok(!defined($classes->{this}), "'this' cannot be added as a class"); + + +# +# Ensure using the @base tag automatically qualifies a function as a class, +# even if the base class isn't defined +# +reset_parser(); +$src = '/** @base SomeOtherClass */ +function MyClass(){}'; +$classes = parse_code_tree(\$src); +ok(defined($classes->{MyClass}), + 'A function must be upgraded to a class if the @base tag is used'); + +# +# Allow an anonymous function to be assigned to a global variable, +# resulting in a new class +# +reset_parser(); +$src = ' +/** + * Some function + * @constructor + */ +var SomeClass = function(){ this.x = 2; } +'; +$classes = parse_code_tree(\$src); +ok(defined($classes->{SomeClass}), + "Allow anonymous function to be assigned to a global variable"); + +# +# Make sure that dynamically binding methods to a object at a later time +# do not affect the documentation +# +reset_parser(); +$src = ' +function AddCallback(obj){ + obj.callback = function(){ return null; }; +}'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{obj}), + "Don't add passed-in objects as classes when doing dynamic binding"); + +reset_parser(); +$src = ' +/** @constructor */ +function A(){} +A.prototype.setup = A_Setup; +A.prototype.tearDown = A_TearDown; +function A_Setup(){ + this.callback = function(){ return null; }; +} +function A_TearDown(){ + this.tornDown = true; +}'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{this}), + "Don't add 'this' as a class when dynamically adding methods in a method"); + +# +# Test block prototype assignment +# +diag("Test block prototype assignment"); +reset_parser(); +$src = ' +SomeClass.prototype = { + funcA: function(){ return null; }, + valA: 3, + funcB: function(){ return null; }, + valB: "just testing", + funcC: function(){} +};'; +$classes = parse_code_tree(\$src); +ok(eq_set( + [ map { $_->{mapped_name} } + @{$classes->{SomeClass}->{instance_methods}}], + ['funcA', 'funcB', 'funcC']), + "Ensure instance methods are assigned in prototype definition block"); +ok(eq_set( + [ map { $_->{field_name} } + @{$classes->{SomeClass}->{instance_fields}}], + ['valA', 'valB']), + "Ensure instance fields are assigned in prototype definition block"); + +# +# Test prototype assignment +# +diag("Test prototype assignment"); +reset_parser(); +$src = ' +function Base(){} +function Sub(){} +Sub.prototype = new Base(); +'; +$classes = parse_code_tree(\$src); +ok($classes->{Sub}->{extends} eq 'Base', + "Prototype assignment results in inheritance"); + +reset_parser(); +$src = ' +function Base(){} +function Sub(){} +Sub.prototype = new Base; +'; +$classes = parse_code_tree(\$src); +ok($classes->{Sub}->{extends} eq 'Base', + "Prototype assignment results in inheritance (2)"); + +# +# Test the handling of methods defined more than once +# +reset_parser(); +$src = ' +function f(){} +/** doc */ +function f(){} +'; +$classes = parse_code_tree(\$src); +ok($classes->{GLOBALS}->{class_methods}->[0]->{description} eq 'doc', + "In case of double function definition, the one with most info wins"); + +reset_parser(); +$src = ' +/** doc */ +function f(){} +function f(){} +'; +$classes = parse_code_tree(\$src); +ok($classes->{GLOBALS}->{class_methods}->[0]->{description} eq 'doc', + "In case of double function definition, the one with most info wins (2)"); + +# +# Make sure that extra JSDoc-style comment blocks are not viewed as source +# +reset_parser(); +$src = ' +/** @constructor */ +function x(){} + +/** more doc +function y(){} +*/ + +/** @constructor */ +function z(){} +'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{GLOBALS}->{class_methods}->[0]), + "Ignore JSDoc in extra JSDoc-comment blocks"); + + +# +# Test the behaviour of the @ignore tag +# +reset_parser(); +$src = ' +/** This method is normal */ +function Normal(){} + +/** @ignore */ +function Hidden(){} +'; +$classes = parse_code_tree(\$src); +my %fnames = map { $_->{mapped_name} => 1 } + @{$classes->{GLOBALS}->{class_methods}}; +ok(defined $fnames{Normal}, "A normal method is picked up and documented"); +ok(!defined $fnames{Hidden}, 'An @ignored method is not picked up'); + +# +# Test the behaviour of the @addon tag +# +reset_parser(); +$src = ' +/** + * Should be ignored + */ +ClassOne.funcOne = function(){}; + +/** + * Should not be ignored + * @addon + */ +ClassTwo.funcOne = function(){}; + +ClassThree.prototype = new Object(); +ClassThree.funcThree = function(){}'; +$classes = parse_code_tree(\$src); +ok(!defined($classes->{ClassOne}), + 'Extensions to undefined classes/objects without @addon are ignored'); +ok(defined($classes->{ClassTwo}), + 'Extensions to undefined classes/objects with @addon are not ignored'); +ok($classes->{ClassThree}->{class_methods}->[0]->{mapped_name} eq 'funcThree', + 'Class methods without @addon work on pre-defined classes'); + +# +# Ensure enclosing package-classes are still recognized without using @addon +# +reset_parser(); +$src = ' +/** + * @constructor + */ +package.MyClass = function MyClass(){} + +package.MyClass.prototype.foo = function foo(){} +'; +$classes = parse_code_tree(\$src); +ok(defined($classes->{package}), + 'Super-package-classes must be recognized without the @addon tag'); +ok(defined($classes->{'package.MyClass'}), + 'Sub-package-classes must be recognized without the @addon tag'); + + diff --git a/modules/jala/util/HopKit/JSDoc/jsdoc.pl b/modules/jala/util/HopKit/JSDoc/jsdoc.pl new file mode 100644 index 00000000..8ef004bd --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/jsdoc.pl @@ -0,0 +1,1282 @@ +#!/usr/bin/perl -w + +# +# This program makes use of the JSDoc module to make a JavaDoc equivalent +# for JavaScript. The template that is used is based on the JavaDoc +# doclet. This program only needs to be invoked with one or more +# JS OO sourcefiles as command-line args. +# + +use strict; +use HTML::Template; +use File::Copy; +use File::Basename; +use Getopt::Long; +use File::Find; +use lib dirname($0); +use JSDoc; +use JSDoc::XML; +use JSDoc::XMI; +use JavaScript::Syntax::HTML qw(to_html); + + +use constant LOCATION => dirname($0) . '/'; +use constant MAIN_TMPL => "main.tmpl"; +use constant ALLCLASSES_TMPL => 'allclasses-frame.tmpl'; +use constant ALLCLASSES_NOFRAME_TMPL => 'allclasses-noframe.tmpl'; +use constant OVERVIEW_FRAME_TMPL => 'overview-frame.tmpl'; +use constant TREE_TMPL => 'overview-tree.tmpl'; +use constant OVERVIEW_TMPL => 'overview-summary.tmpl'; +use constant INDEX_TMPL => 'index.tmpl'; +use constant DEFAULT_DEST_DIR => 'js_docs_out/'; +use constant STYLESHEET => 'stylesheet.css'; +use constant HELP_TMPL => 'help-doc.tmpl'; +use constant INDEX_ALL_TMPL => 'index-all.tmpl'; +use constant CONSTANTS_TMPL => 'constant-values.tmpl'; + +use vars qw/ $CLASSES $DEFAULT_CLASSNAME @CLASSNAMES @INDEX %TMPL_CACHE + %CLASS_ATTRS_MAP %METHOD_ATTRS_MAP %FILE_ATTRS_MAP %OPTIONS + @FILENAMES %FILE_OVERVIEWS $TIME $CURRENT_CLASS /; + +# +# Begin main execution +# + +&parse_cmdline; +&initialize_param_maps; +$TIME = localtime(); +do '.jsdoc_config'; +warn "Error parsing config file: $@\n" if $@; + +my @sources; + +mkdir($OPTIONS{OUTPUT}) + or die "Can't create output directory $OPTIONS{OUTPUT}: $!\n" + unless (-e $OPTIONS{OUTPUT} && -d $OPTIONS{OUTPUT}); + + +if (@ARGV < 1 || $OPTIONS{HELP} || !(@sources = &load_sources())){ + warn "No sourcefiles supplied\n" if !$OPTIONS{HELP}; + &show_usage(); + exit(1); +} + +# Parse the code tree +&configure_parser( + GLOBALS_NAME => $OPTIONS{GLOBALS_NAME}, + NO_LEXICAL_PRIVATES => $OPTIONS{NO_LEXICAL_PRIVATES}); +$CLASSES = &parse_code_tree(@sources); +%FILE_OVERVIEWS = %{delete $CLASSES->{__FILES__}}; +die "Nothing to document, exiting\n" unless keys %{$CLASSES}; + +if ($OPTIONS{FORMAT} eq 'html'){ + &output_html; +} elsif ($OPTIONS{FORMAT} eq 'xml') { + &output_xml; +} elsif ($OPTIONS{FORMAT} eq 'xmi'){ + &output_xmi; +} else { + die "Unknown data format '$OPTIONS{FORMAT}'\n"; +} + +&_log('Completed generating documentation'); + +# +# End main execution +# + + +# +# Output a single template +# +sub output_template { + my ($tmplname, $outname, $params, $relaxed) = (@_); + + $OPTIONS{TEMPLATEDIR} =~ s/(\S+)\/$/$1/; + + $tmplname = $OPTIONS{TEMPLATEDIR} . "/$tmplname"; + die "Template file '$tmplname' not found" unless -e $tmplname; + + # Caching templates seems to improve performance quite a lot + if (!$TMPL_CACHE{$tmplname}){ + $TMPL_CACHE{$tmplname} = new HTML::Template( + die_on_bad_params => !$relaxed, + filename => $tmplname); + } + my $tmpl = $TMPL_CACHE{$tmplname}; + $tmpl->param($params); + $outname = sprintf('%s%s', $OPTIONS{OUTPUT}, mangle($outname)); + &print_file($outname, $tmpl->output); +} + + +# +# Output data to a file +# +sub print_file { + my ($fname, $data) = @_; + open FILE, ">$fname" + or die "Couldn't open '$fname' to write: $!\n"; + print FILE $data; + close FILE; +} + +# +# Output HTML documentation in the output directory +# +sub output_html { + &output_class_templates(); + &output_index_template(); + &output_aux_templates(); + &output_tree_template(); +} + +# +# Output XMI in the output directory +# +sub output_xmi { + my $xmi = JSDoc::XMI->new(LOCATION); + &print_file("$OPTIONS{OUTPUT}/jsdoc.xmi", $xmi->output($CLASSES)); +} + +# +# Output XML in the output directory +# +sub output_xml { + my $xml = JSDoc::XML->new(LOCATION); + &print_file("$OPTIONS{OUTPUT}/jsdoc.xml", $xml->output($CLASSES)); +} + +# +# Gather information for each class and output its template +# +sub output_class_templates { + + # Note the class name for later, including classes that aren't defined + # but are used for inheritance + my %seen; + @CLASSNAMES = sort { lc $a->{classname} cmp lc $b->{classname}} + grep { !$seen{$_->{classname}}++ } + (map {classname => $_} , + grep { not defined $CLASSES->{$_}->{constructor_vars}->{private} + or $OPTIONS{PRIVATE} } + keys %$CLASSES), + (map { classname => $_ }, grep { !defined($$CLASSES{$_}) } + map { $_->{extends} } grep { defined($_->{extends}) } + values %$CLASSES); + die "Nothing to document, exiting\n" unless @CLASSNAMES; + + @FILENAMES = map {filename => $_, mangledfilename => mangle($_)}, + sort {lc($a) cmp lc($b)} grep {length $_} keys %FILE_OVERVIEWS; + for (my $i = 0; $i < @CLASSNAMES; $i++){ + my $classname = $CLASSNAMES[$i]->{classname}; + $CURRENT_CLASS = $classname; + next unless $$CLASSES{$classname}; + + # Template Parameters + my ($class, $subclasses, $class_summary, @constructor_params, + $next_class, $prev_class, $constructor_attrs, $constructor_detail); + + $class= $$CLASSES{$classname}; + &add_to_index($class, $classname); + + # Set up the constructor and class information + &resolve_synonyms($class->{constructor_vars}); + &format_vars($class->{constructor_vars}); + @constructor_params = + &fetch_args($class->{constructor_vars}, + \$class->{constructor_args}); + $constructor_attrs = + &format_method_attributes($class->{constructor_vars}); + $constructor_detail = + &resolve_inner_links($class->{constructor_detail}); + $class_summary = &format_class_attributes($class->{constructor_vars}); + $class_summary = &resolve_inner_links($class_summary); + + # Navbar information + $next_class = $i + 1 < @CLASSNAMES + ? $CLASSNAMES[$i + 1]->{classname} + : undef; + $prev_class = $i > 0 ? $CLASSNAMES[$i - 1]->{classname} : undef; + + # Find all the direct subclasses + $subclasses = join( ',', + map qq| $_|, + @{&find_subclasses($classname)}); + + my $superclass = $class->{extends} || ''; + + if ($$CLASSES{$superclass}){ + $superclass = "$superclass" + unless (!$OPTIONS{PRIVATE} + && $$CLASSES{$superclass}->{constructor_vars}->{private}); + } + + my $file_overview = $class->{constructor_vars}->{filename} ? + sprintf('overview-summary-%s.html', + mangle($class->{constructor_vars}->{filename})) + : ''; + + &output_template(MAIN_TMPL, "$classname.html", { + next_class => $next_class, + prev_class => $prev_class, + file_overview => $file_overview, + superclass => $superclass, + constructor_args => $class->{constructor_args}, + constructor_params => \@constructor_params, + constructor_attrs => $constructor_attrs, + constructor_returns => $class->{constructor_vars}->{returns}[0], + class_summary => $class_summary, + class_attribs => $class->{constructor_vars}->{private} ? + '<private>' : '', + constructor_detail => $constructor_detail, + constructor_summary => &get_summary($constructor_detail), + classname => $classname, + subclasses => $subclasses, + class_tree => &build_class_tree($classname, $CLASSES), + fields => &map_fields($class), + methods => &map_methods($class), + method_inheritance => &map_method_inheritance($class), + field_inheritance => &map_field_inheritance($class), + inner_classes => $class->{inner_classes}, + project_name => $OPTIONS{PROJECT_NAME}, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME + }, 1); + } +} + +# +# Handle cleaning up / resolving inner links in FILE_OVERVIEWS +# +sub process_file_overviews { + for my $filename (map{$_->{filename}} @FILENAMES){ + my $overview = $FILE_OVERVIEWS{$filename}; + my $src = $overview->{src}; + $overview->{src} = ''; + format_vars($overview); + $overview = + resolve_inner_links($FILE_OVERVIEWS{$filename}); + $overview->{src} = $src; + $FILE_OVERVIEWS{$filename} = $overview; + } +} + +# +# Output all the non-class template files +# +sub output_aux_templates(){ + + unless ($OPTIONS{LOGO} and -f $OPTIONS{LOGO} and -r $OPTIONS{LOGO}){ + $OPTIONS{LOGO} and warn "Can't read $OPTIONS{LOGO}"; + $OPTIONS{LOGO} = ''; + } + $OPTIONS{LOGO} and copy $OPTIONS{LOGO}, $OPTIONS{OUTPUT}; + + &process_file_overviews; + $DEFAULT_CLASSNAME = + (grep { + defined($$CLASSES{$_->{classname}}) } @CLASSNAMES)[0]->{classname}; + + my $summary = &get_overall_summary; + + &output_classes_frames_templates; + &output_multiple_files_templates if @FILENAMES > 1; + &output_index_and_help_templates($summary); + &output_overview_summaries($summary); + &output_const_summary(); + my $stylesheet = LOCATION . STYLESHEET; + if ($OPTIONS{TEMPLATEDIR} ne LOCATION){ + $stylesheet = $OPTIONS{TEMPLATEDIR} . '/' . STYLESHEET; + die "Stylesheet '$stylesheet' not found" unless -e $stylesheet; + } + copy ($stylesheet, $OPTIONS{OUTPUT} . STYLESHEET); +} + +sub get_overall_summary { + my $summary; + if ($OPTIONS{PROJECT_SUMMARY}){ + if (-f $OPTIONS{PROJECT_SUMMARY} and + open SUMMARY, $OPTIONS{PROJECT_SUMMARY}){ + local $/ = undef; + $summary = ; + close SUMMARY; + } else { + warn "Can't open $OPTIONS{PROJECT_SUMMARY}"; + } + } elsif (@FILENAMES == 1) { + # If we only have one file and it has an overview, use that overview + my $filename = $FILENAMES[0]->{filename}; + if ($FILE_OVERVIEWS{$filename}->{fileoverview}){ + $summary = $FILE_OVERVIEWS{$filename}->{fileoverview}[0]; + $summary .= "

      "; + + while (my ($name, $val) = each %{$FILE_OVERVIEWS{$filename}}){ + $summary .= &{$FILE_ATTRS_MAP{$name}}($val) + if $FILE_ATTRS_MAP{$name}; + } + } + } + $summary; +} + +# +# Output the main (default) page and the help template +# +sub output_index_and_help_templates { + + my ($summary) = @_; + + # Output the main index template + &output_template(INDEX_TMPL, 'index.html', { + DEFAULT_CLASSNAME => @FILENAMES > 1 + ? 'overview-summary' + : $DEFAULT_CLASSNAME, + multifile => @FILENAMES > 1 }); + + # Output the help document template + &output_template(HELP_TMPL, 'help-doc.html', { + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME, + project_name => $OPTIONS{PROJECT_NAME} }); + +} + +# +# Output the frames listing all the classes +# +sub output_classes_frames_templates { + my $classnamesref = + [ grep { defined($$CLASSES{$_->{classname}}) } @CLASSNAMES ]; + my $params = { + filename => 'All Classes', + fname_link => 'All Classes', + CLASSNAMES => $classnamesref }; + if (@FILENAMES < 2){ + $params->{project_name} = $OPTIONS{PROJECT_NAME}; + $params->{logo} = basename($OPTIONS{LOGO}); + } + &output_template(ALLCLASSES_TMPL, 'allclasses-frame.html', $params); + + &output_template(ALLCLASSES_NOFRAME_TMPL, 'allclasses-noframe.html', { + CLASSNAMES => $classnamesref, + project_name => $OPTIONS{PROJECT_NAME}, + logo => basename($OPTIONS{LOGO}) }); + +} + +# +# Output the overview summary templates +# +sub output_overview_summaries { + my ($summary) = @_; + + my @overviews = map { + name => $_, + link => &mangle("overview-summary-$_.html"), + overview => + get_summary( + $FILE_OVERVIEWS{$_}{fileoverview}[0] || ' ') + }, sort {lc($a) cmp lc($b)} keys(%FILE_OVERVIEWS); + + &output_template(OVERVIEW_TMPL, 'overview-summary.html', { + generic => 1, + project_name => $OPTIONS{PROJECT_NAME}, + project_title => $OPTIONS{PROJECT_NAME}, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME, + project_summary => $summary, + is_file_summary => 0, + overviews => \@overviews }); + + for my $filename (keys %FILE_OVERVIEWS){ + my @classes = grep { + ($$CLASSES{$_}->{constructor_vars}->{filename} || '') eq $filename + } keys %$CLASSES; + my @class_overviews = sort { lc($a->{name}) cmp lc($b->{name}) } + map { + name => $_, + link => "$_.html", + overview => get_summary( + $CLASSES->{$_}->{constructor_vars}->{class}[0] || ' ') + }, grep { !$CLASSES->{$_}->{constructor_vars}->{private} + || $OPTIONS{PRIVATE} } @classes; + my %overview = %{$FILE_OVERVIEWS{$filename}}; + my $src = delete $overview{src}; + my $summary = $overview{fileoverview}[0] || + "No overview generated for '$filename'"; + $summary .= "

      "; + while (my ($name, $val) = each %overview){ + $summary .= &{$FILE_ATTRS_MAP{$name}}($val) + if $FILE_ATTRS_MAP{$name}; + } + my @methods = + map { + is_private => $_->{is_private}, + method_summary => $_->{method_summary}, + is_class_method => $_->{is_class_method}, + method_anchor => + sprintf('%s%s', $_->{is_class_method} ? '!s!' : '', + $_->{method_name}), + method_arguments=> $_->{method_arguments}, + method_name => $_->{method_name}, + type => $_->{type}, + file_link => $OPTIONS{GLOBALS_NAME} . ".html" + }, @{&map_methods($$CLASSES{$OPTIONS{GLOBALS_NAME}}, $filename)}; + + &output_template(OVERVIEW_TMPL, "overview-summary-$filename.html", { + generic => 0, + sourcecode => $OPTIONS{NO_SRC} ? '' : &to_html($src), + project_name => $OPTIONS{PROJECT_NAME}, + project_title => $filename, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME, + project_summary => $summary, + is_file_summary => 1, + methods => \@methods, + overviews => \@class_overviews }); + } + +} + +# +# Output a summary page about the 'static constant' field values for all +# classes +# +sub output_const_summary { + my @static_params; + for my $classname (sort { uc($a) cmp uc($b) } keys %$CLASSES){ + my $class = $CLASSES->{$classname}; + my @statics = grep { $_->{field_value} =~ /^(?:\d+)|(?:(['"]).*\1)$/} + grep { $_->{field_vars}->{final}} @{$class->{class_fields}}; + if (@statics){ + push @static_params, { + classname => $classname, + static_values => [map { + name => $_->{field_name}, + value => $_->{field_value}, + classname => $classname}, @statics] }; + } + } + &output_template(CONSTANTS_TMPL, 'constant-values.html', { + project_name => $OPTIONS{PROJECT_NAME}, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME, + classnames => [map {name => $_->{classname}}, @static_params], + static_finals => \@static_params + } + ) if @static_params; +} + +# +# Method to handle outputting file overview template if +# more than one sourcefile is being processed +# +sub output_multiple_files_templates { + &output_template(OVERVIEW_FRAME_TMPL, 'overview-frame.html', { + logo => basename($OPTIONS{LOGO}), + project_name => $OPTIONS{PROJECT_NAME}, + filenames => \@FILENAMES }); + + for my $fname (map { $_->{filename}} @FILENAMES){ + my @classes = grep { + ($$CLASSES{$_}->{constructor_vars}->{filename} || '') eq $fname + } keys %$CLASSES; + + #methods under GLOBAL (detached) class + my @methods; + for (my $i = 0; $i < @CLASSNAMES; $i++){ + if($CLASSNAMES[$i]->{classname} eq $OPTIONS{GLOBALS_NAME}){ + my $class = $$CLASSES{$CLASSNAMES[$i]->{classname}}; + for my $method ( + sort {lc $a->{mapped_name} cmp lc $b->{mapped_name} } + @{$class->{class_methods}}){ + if(defined($fname) + && $fname eq $method->{vars}->{filename}){ + $method->{filename} = $fname; + push(@methods, $method); + } + } + last; + } + } + + &output_template(ALLCLASSES_TMPL, + sprintf('overview-%s.html', $fname), { + filename => $fname, + fname_link => $FILE_OVERVIEWS{$fname} + ? sprintf('%s', + mangle($fname), $fname) + : $fname, + CLASSNAMES => [map {classname => $_}, + grep { !$$CLASSES{$_}->{constructor_vars}->{private} + || $OPTIONS{PRIVATE} } sort @classes] }); + } +} + +# +# Mangle a file path so that it can be used as a filename +# +sub mangle { + local $_ = shift; + tr{/\\}{_}; + $_; +} + +# +# Build the tree representation of the inheritance +# PARAM: Name of the class +# +sub build_class_tree { + my $classname = shift; + my $class = $$CLASSES{$classname}; + my $tree = ""; + my @family; + push @family, $classname; + while ($class->{extends} and $class->{extends} ne ""){ + my $base = $class->{extends}; + if ($$CLASSES{$base}){ + $base = "$base" + unless (!$OPTIONS{PRIVATE} + && $$CLASSES{$base}->{constructor_vars}->{private}); + } elsif ($class->{constructor_vars}->{base}){ + if (my ($bcname, $url) = + $class->{constructor_vars}->{base}->[0] + =~ /^(\S+)\s(\S.*)$/){ + $base = "$base"; + } + } + push @family, $base; + $class = $$CLASSES{$class->{extends}}; + } + push @family, "Object"; + my $indent = 3; + $tree = (pop @family) . "\n"; + my $name = $_; + while ($name = pop (@family)){ + my $instr = " " x $indent; + $tree .= sprintf "%s|\n%s+--%s%s%s\n", $instr, $instr, + $name eq $classname ? "" : "", $name, + $name eq $classname ? "" : ""; + $indent += 6; + } + $tree; +} + +# +# Shown if no commandline args are given +# +sub show_usage(){ + print qq{Usage: jsdoc [OPTIONS] + + + -h | --help Show this message and exit + -r | --recursive Recurse through given directories + -p | --private Show private methods and fields + -d | --directory Specify output directory (defaults to js_docs_out) + -q | --quiet Suppress normal output + + --page-footer Specify (html) footer string that will be added to + all docs + --project-name Specify project name for that will be added to docs + --logo Specify a path to a logo to be used in the docs + --project-summary Specify a path to a text file that contains an + overview summary of the project + + --no-sources Don't include the source code view + + --extensions Provide a comma-separated list of file extensions + to be considered as JavaScript source files + + --package-naming Use package-style naming (i.e. keep directory names + in the file path). This is useful if you have multiple + files with the same name, but in different directories. + This option is only useful if --recursive is also used. + + --globals-name Specify a 'class name' under which all unattached + methods will be classified. The defaults to GLOBALS + + --format Set the output format. The options are html, xml + and xmi, defaulting to html. The others are currently + alpha software. + + --template-dir Provide another directory containing HTML templates + + --no-lexical-privates Ignore "private" variables and functions that are + lexically defined within constructors + + \n}; + +} + +# +# Take all the command line args as filenames and add them to @SOURCESFILES +# +sub load_sources(){ + my (@filenames, @sources); + my $ext_re = sprintf('%s', + join '|', split /\s*,\s*/, $OPTIONS{EXTENSIONS}); + for my $arg (@ARGV){ + if (-d $arg) { + $arg =~ s/(.*[^\/])$/$1\//; + find( { + wanted => sub { + push @filenames, { + name => $_, + relname => $OPTIONS{PACKAGENAMING} + ? substr($_, length($arg)) + : (fileparse($_))[0] + } if ((-f and -r and /.+\.$ext_re$/oi) && + (/^\Q$arg\E[^\/]+$/ || $OPTIONS{RECURSIVE})) + }, + no_chdir => 1 }, $arg); + } elsif (-f $arg){ + my $relname = (fileparse($arg))[0]; + push @filenames, { name => $arg, relname => $relname }; + } + } + for (@filenames){ + &_log(sprintf 'Loading sources from %s', $_->{name}); + open SRC, '<', $_->{name} + or (warn sprintf("Can't open %s, skipping: $!\n", $_->{name}) + and next); + local $/ = undef; + push @sources, $_->{relname}; + push @sources, \; + close SRC; + } + @sources; +} + +# +# Once all sources have been parsed, finds all subclasses +# of $classname +# +sub find_subclasses(){ + my ($classname) = @_; + my @subclasses; + for my $class (keys %$CLASSES){ + my $subclassname = $$CLASSES{$class}->{extends}; + if ($$CLASSES{$class}->{extends} and + $$CLASSES{$class}->{extends} eq $classname){ + push @subclasses, $class; + } + } + \@subclasses; +} + +# +# Make a summary of a description, cutting it off either at the first +# double newline or the first period followed by whitespace. +# PARAM: $description +# +sub get_summary { + my ($description) = @_; + my $summary; + if ($description){ + ($summary) = $description =~ /^(.*?(?:[?!.](?=\s)|\n\n)).*$/gs + or $summary = $description; + } else { + $summary = ""; + } + $summary; +} + + +# +# Set up all the instance and class methods for one template +# PARAM: A reference to a class +# PARAM: Optional filename, only maps methods for that file (used for GLOBAL) +# +sub map_methods{ + my ($class, $fname) = @_; + my @methods; + for my $mtype (qw(instance_methods class_methods)){ + next unless $class->{$mtype}; + + for my $method ( + sort {lc $a->{mapped_name} cmp lc $b->{mapped_name} } + @{$class->{$mtype}}){ + next if $fname && $fname ne $method->{vars}->{filename}; + &resolve_synonyms($method->{vars}); + next if (!$OPTIONS{PRIVATE} && $method->{vars}->{private}); + + $method->{vars}->{returns}[0] = + $method->{vars}->{returns}[0] || $method->{vars}->{return}; + + my @args = &fetch_args($method->{vars}, \$method->{argument_list}); + @args = map { &format_vars($_); $_ } @args; + + &format_vars($method->{vars}); + my $desc = &resolve_inner_links($method->{description}); + my $type = &map_return_type($method); + my $ret = $method->{vars}->{returns}[0]; + my $attrs = &format_method_attributes($method->{vars}); + + push @methods, { + method_description => $desc, + method_summary => &get_summary($desc), + method_name => $method->{mapped_name}, + method_arguments => $method->{argument_list}, + method_params => \@args, + method_returns => $ret, + is_class_method => $mtype eq 'class_methods', + is_private => defined($method->{vars}->{private}), + attributes => $attrs, + type => $type }; + } + } + \@methods; +} + +# +# Map a function return type +# +sub map_return_type { + my ($method) = @_; + #return 'Object' unless $method->{vars}->{type}[0]; + my $name = 'Object'; + my $link = ''; + if (defined($method->{vars}->{type})){ + $name = $method->{vars}->{type}[0]; + } elsif (defined($method->{vars}->{returns}[0])){ + if ($method->{vars}->{returns}[0] =~ s/\s*\{(\S+)(?:\s+([^}]+))?\}//){ + $name = $1; + $link = $2; + } + $method->{vars}->{type} = [$name]; + } + $name =~ s/^\s*(\S.*?)\s*$/$1/; + if ($$CLASSES{$name} || $link){ + $link ||= "$name.html"; + return qq|$name|; + } + $name; +} + +# +# Set up all the instance and class methods for one template +# PARAM: A reference to a class +# +sub map_fields { + my $class = shift; + my @fields; + # Set up the instance fields + for my $type (qw(instance_fields class_fields)){ + next unless $class->{$type}; + for (sort {lc $a->{field_name} cmp lc $b->{field_name} } + @{$class->{$type}}){ + + &resolve_synonyms($_->{field_vars}); + next if (!$OPTIONS{PRIVATE} && $_->{field_vars}->{private}); + my $description = &resolve_inner_links($_->{field_description}); + my $const_link = ($_->{field_vars}->{final} && + ($_->{field_value} =~ /^\-?\d+(\.\d+)?$/ + || $_->{field_value} =~ /^(["']).*\1$/)) + ? $class->{classname} : ''; + push @fields, { + field_name => $_->{field_name}, + field_description => $description, + field_summary => &get_summary($description), + is_final => defined($_->{field_vars}->{final}), + is_private => defined($_->{field_vars}->{private}), + is_class_field => $type eq 'class_fields', + type => &map_field_type($_), + const_link => $const_link}; + } + } + \@fields; +} + +# +# Map a field type +# +sub map_field_type { + my ($field) = @_; + return 'Object' unless $field->{field_vars}->{type}[0]; + my $name = $field->{field_vars}->{type}[0]; + $name =~ s/^\s*(\S.*?)\s*$/$1/; + return qq|$name| if $$CLASSES{$name}; + $name; +} + +# +# Map all the inherited methods to a template parameter +# PARAM: A reference to a class +# +sub map_method_inheritance { + my $class = shift; + my @method_inheritance; + # Set up the inherited methods + if ($class->{inherits}){ + my $superclassname = $class->{extends}; + my $superclass = $$CLASSES{$superclassname}; + while ($superclass){ + if (!$superclass->{constructor_vars}->{private} + || $OPTIONS{PRIVATE}){ + my $methods = + $class->{inherits}->{$superclassname}->{instance_methods}; + push @method_inheritance, { + superclass_name => $superclassname, + inherited_methods => join(', ', + map(qq|$_|, + &filter_private_methods( + $methods, $superclassname)))} + if ($methods and @$methods); + } + $superclassname = $superclass->{extends}; + $superclass = $superclassname ? $$CLASSES{$superclassname} : undef; + } + } + \@method_inheritance; +} + +# +# Map all the inherited fields to a template parameter +# PARAM: A reference to a class +# +sub map_field_inheritance { + my $class = shift; + my @field_inheritance; + # Set up the inherited fields + if ($class->{inherits}){ + my $superclassname = $class->{extends}; + my $superclass = $$CLASSES{$superclassname}; + while ($superclass){ + if (!$superclass->{constructor_vars}->{private} + || $OPTIONS{PRIVATE}){ + my $fields = + $class->{inherits}->{$superclassname}->{instance_fields}; + push @field_inheritance, { + superclass_name => $superclassname, + inherited_fields => join(', ', + map(qq|$_|, + &filter_private_fields($fields, $superclassname)))} + if ($fields and @$fields); + } + $superclassname = $superclass->{extends}; + $superclass = $superclassname ? $$CLASSES{$superclassname} : undef; + } + } + \@field_inheritance; +} + +# +# Filter out private inherited methods +# +sub filter_private_methods { + my ($methods, $superclassname) = @_; + my @visible_methods; + for my $method(@$methods){ + for my $super_method + (@{$$CLASSES{$superclassname}->{instance_methods}}){ + push @visible_methods, $method + if $method eq $super_method->{mapped_name} and + (!$super_method->{vars}->{private} || $OPTIONS{PRIVATE}); + } + } + @visible_methods; +} + +# +# Filter out private inherited fields +# +sub filter_private_fields { + my ($fields, $superclassname) = @_; + my @visible_fields; + for my $field (@$fields){ + for my $super_field(@{$$CLASSES{$superclassname}->{instance_fields}}){ + push @visible_fields, $field + if $field eq $super_field->{field_name} and + (!$super_field->{field_vars}->{private} + || $OPTIONS{PRIVATE}); + } + } + @visible_fields; +} + +# +# Adds a class's information to the global INDEX list +# +sub add_to_index { + my ($class, $classname) = @_; + push @INDEX, { + name => $classname, + class => $classname, + type => '', linkname => '' + }; + + if (!$class->{constructor_args}){ + $class->{constructor_args} = ''; + } else { + push @INDEX, { + name => "$classname$class->{constructor_args}", + class => $classname, + type => 'Constructor in ', + linkname => 'constructor_detail' }; + } + for my $mtype (qw(class_methods instance_methods)){ + my $type = sprintf('%s method in ', + $mtype eq 'class_methods' ? 'Class' : 'Instance'); + push @INDEX, { + name => "$_->{mapped_name}$_->{argument_list}", + class => $classname, + type => $type, + linkname => $_->{mapped_name}} + for grep { + not($_->{vars}->{private} and not $OPTIONS{PRIVATE}) + } @{$class->{$mtype}}; + + } + for my $ftype (qw(class_fields instance_fields)){ + my $type = sprintf('%s field in ', + $ftype eq 'class_fields' ? 'Class' : 'Instance'); + push @INDEX, { + name => $_->{field_name}, + class => $classname, + type => $type, + linkname => $_->{field_name}} + for grep { + not($_->{field_vars}->{private} and not $OPTIONS{PRIVATE}) + } @{$class->{$ftype}}; + } +} + +# +# Outputs the index page +# +sub output_index_template { + @INDEX = sort {lc $a->{name} cmp lc $b->{name}} @INDEX; + my %letters; + for my $item (@INDEX){ + my $letter = uc(substr($item->{name}, 0, 1)); + $letter = uc(substr($item->{class}, 0, 1)) if $letter eq ''; + push @{$letters{$letter}}, $item; + } + + my $letter_list = [map {letter_name => $_}, + sort {lc $a cmp lc $b} keys %letters]; + &output_template(INDEX_ALL_TMPL, 'index-all.html', { + letters => $letter_list, + project_name => $OPTIONS{PROJECT_NAME}, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME, + index_list => [map { + letter => $_->{letter_name}, + value => $letters{$_->{letter_name}} + }, @{$letter_list}] }); +} + +# +# Recursively builds up the overview tree +# +sub build_tree { + my $parentclassname = shift || ''; + my $ret = ""; + for my $cname (map {$_->{classname}} @CLASSNAMES) { + next if $cname eq $OPTIONS{GLOBALS_NAME}; + my $class = $$CLASSES{$cname}; + my $parent = $class->{extends} || '-'; + if ((!$parentclassname && $parent eq '-') + or ($parent eq $parentclassname)) { + $ret .= $$CLASSES{$cname} ? qq{ +
    • + + $cname
    • + } : qq{ +
    • + $cname
    • + }; + my $childrentree .= &build_tree($cname); + $ret = "$ret$childrentree" if $childrentree; + } + } + $ret = "
        $ret
      " unless not $ret; + if ($parentclassname eq ''){ + $ret = qq{
      • Object
      • $ret
      }; + } + $ret; +} + +# +# Outputs the overview tree +# +sub output_tree_template { + my $tree = &build_tree(); + &output_template(TREE_TMPL, 'overview-tree.html', { + classtrees => $tree, + project_name => $OPTIONS{PROJECT_NAME}, + page_footer => $OPTIONS{PAGE_FOOTER}, + ctime => $TIME }, 1); +} + +# +# Formats additional non-standard attributes for methods according to user +# configuration +# +sub format_method_attributes { + my ($attrs) = shift; + my $attributes = ''; + while (my ($name, $val) = each %{$attrs}) { + $attributes .= &{$METHOD_ATTRS_MAP{$name}}($val) + if $METHOD_ATTRS_MAP{$name}; + } + $attributes; +} + +# +# Formats additional non-standard attributes for classes according to user +# configuration +# +sub format_class_attributes { + my ($attrs) = shift; + my $attributes; + if ($attrs->{class} && @{ $attrs->{class} }){ + $attributes = sprintf('
      %s
      ', $attrs->{class}[0] || '') + } + while (my ($name, $val) = each %{$attrs}) { + $attributes .= &{$CLASS_ATTRS_MAP{$name}}($val) + if $CLASS_ATTRS_MAP{$name}; + } + $attributes; +} + +# +# Parses the command line options +# +sub parse_cmdline { + $OPTIONS{OUTPUT} = DEFAULT_DEST_DIR; + $OPTIONS{PROJECT_NAME} = ''; + $OPTIONS{COPYRIGHT} = ''; + $OPTIONS{PROJECT_SUMMARY} = ''; + $OPTIONS{LOGO} = ''; + $OPTIONS{GLOBALS_NAME} = 'GLOBALS'; + $OPTIONS{FORMAT} = 'html'; + $OPTIONS{EXTENSIONS} = 'js'; + $OPTIONS{TEMPLATEDIR} = LOCATION; + GetOptions( + 'private|p' => \$OPTIONS{PRIVATE}, + 'directory|d=s' => \$OPTIONS{OUTPUT}, + 'help|h' => \$OPTIONS{HELP}, + 'recursive|r' => \$OPTIONS{RECURSIVE}, + 'page-footer=s' => \$OPTIONS{PAGE_FOOTER}, + 'project-name=s' => \$OPTIONS{PROJECT_NAME}, + 'project-summary=s' => \$OPTIONS{PROJECT_SUMMARY}, + 'logo=s' => \$OPTIONS{LOGO}, + 'globals-name=s' => \$OPTIONS{GLOBALS_NAME}, + 'quiet|q' => \$OPTIONS{QUIET}, + 'no-sources' => \$OPTIONS{NO_SRC}, + 'package-naming' => \$OPTIONS{PACKAGENAMING}, + 'format=s' => \$OPTIONS{FORMAT}, + 'extensions=s' => \$OPTIONS{EXTENSIONS}, + 'no-lexical-privates' => \$OPTIONS{NO_LEXICAL_PRIVATES}, + 'template-dir=s' => \$OPTIONS{TEMPLATEDIR}); + $OPTIONS{OUTPUT} =~ s/([^\/])$/$1\//; +} + +# +# Resolves links for {@link } items +# +sub resolve_inner_links { + my $doc = shift; + $doc =~ s{\{\@link\s+([^\}]+)\}}{&format_link($1)}eg if $doc; + return $doc; +} + + +# +# Formats a {@link } item +# +sub format_link { + my ($link) = shift; + die unless $CURRENT_CLASS; + $link =~ s/^\s*(.*?)\s*$/$1/; + $link =~ s/<[^>]*>//g; + my ($class, $method, $label, $url); + my $class_re = qr/\w+(?:\.\w+)*/; + unless ((($class, $method, $label) = + $link =~ /^($class_re)?#($class_re)\s*(.*)$/) + or (($class, $label) = $link =~ /^($class_re)(?:\s+(.*))?$/)){ + if (($url, $label) = $link =~ /^(https?:\/\/\S+)\s+(.*?)\s*$/){ + return "$label"; + } else { + return $link; + } + } + if ($class){ + unless ($$CLASSES{$class}){ + warn "\@link can't find reference $class\n"; + return $link; + } + } + if (!$method){ + $label = $class unless $label; + qq{$label}; + } else { + my $clss = $CLASSES->{$class || $CURRENT_CLASS}; + my @methods = (@{$clss->{instance_methods}}, + @{$clss->{class_methods}}); + my @fields = (@{$clss->{instance_fields}}, @{$clss->{class_fields}}); + my @statics = (@{$clss->{class_methods}}, @{$clss->{class_fields}}); + my $ismethod = grep { $_->{mapped_name} eq $method } @methods; + my $isfield = grep { $_->{field_name} eq $method } @fields + unless $ismethod; + my $isstatic = grep { + ($_->{field_name} || $_->{mapped_name}) eq $method } @statics; + if ($class){ + $label = "$class.$method" . ($ismethod ? '()' : '') unless $label; + if ($ismethod or $isfield){ + $method = ($isstatic ? "!s!" : "") . $method; + qq{$label}; + } else { + warn "\@link can't find reference $method in $class\n"; + $link; + } + } else { + $label = $method . ($ismethod ? "()" : "") unless $label; + $method = ($isstatic ? "!s!" : "") . $method; + qq{$label}; + } + } +} + + +# +# Initializes the customizable maps for @attributes +# +sub initialize_param_maps { + %CLASS_ATTRS_MAP = ( + author => + sub { + 'Author: ' . + join(', ', @{$_[0]}) . "
      " + }, + deprecated => + sub { + 'Deprecated ' . ($_[0] ? $_[0]->[0] : '') . + "

      "; + }, + see => + sub { + 'See:
        - ' . + join('
        - ', map {&format_link($_)} @{$_[0]}) . "
      " + }, + version => + sub { + 'Version: ' . + join(', ', @{$_[0]}) . '

      ' + }, + requires => + sub { + 'Requires:
        - ' . + join('
        - ', map {&format_link($_)} @{$_[0]}) . "
      " + }, + filename => + sub { + sprintf 'Defined in %s

      ', + sprintf("%s", + mangle($_[0]), $_[0]); + }, + overviewfile => + sub { + my ($content, $fh) = ""; + my $fname = $_[0][0] or return ''; + unless(open $fh, "$fname"){ + warn "Can't open overview file '$fname' : $!\n"; + return ''; + } + { local $/ = undef; $content .= <$fh> } + close $fh or warn "Couldn't close overview file '$fname'\n"; + # Crude manner to strip out extra HTML + $content =~ s/(.*)<\/body>/$1/si; + "$content
      "; + } + ); + + %METHOD_ATTRS_MAP = ( + throws => + sub { + "Throws:
        - " . + join("
        - ", @{$_[0]}) . "
      " + }, + ); + $METHOD_ATTRS_MAP{exception} = $METHOD_ATTRS_MAP{throws}; + $METHOD_ATTRS_MAP{$_} = $CLASS_ATTRS_MAP{$_} for qw(author version + deprecated see requires); + $FILE_ATTRS_MAP{$_} = $CLASS_ATTRS_MAP{$_} for qw(author version + see requires); +} + +# +# Parse the @param or @argument values into name/value pairs and +# return the list of them +# +sub fetch_args { + my ($vars, $arg_list_ref) = @_; + return unless $vars and $$arg_list_ref; + my (@args, %used); + for my $arg (split /\W+(?{param}}){ + my ($type, $link, $name, $value) = + /(?: + \{\s* + (\S+) # type name + (?:\s+(\S+)\s*)? # optional link + \})? + \s* + (\$?\w+) # parameter name + (.*) # description + /x; + next unless $name eq $arg; + $used{$name} = 1; + $type ||= ''; + if ($$CLASSES{$type} || $link){ + $link ||= "$type.html"; + $type = qq|$type| ; + } + my $type_regex = qr{\Q$arg\E\b}; + $$arg_list_ref =~ s/(? $name, vardescrip => $value}; + } + } + for (@{$vars->{param}}){ + my ($type, $link, $name, $value) + = /(?:\{\s*(\S+)(?:\s+(\S+)\s*)?\})?\s*(\$?\w+)(.*)/; + next if $used{$name}; + push @args, { varname => $name, vardescrip => $value }; + } + @args; +} + +sub resolve_synonyms { + my ($item) = @_; + $item->{param} = $item->{param} || $item->{argument}; + $item->{returns} = $item->{return} || $item->{returns}; + $item->{final} = $item->{final} || $item->{const}; +} + +# +# Log a message to STDOUT if the --quiet switch is not used +# +sub _log { + print $_[0], "\n" unless $OPTIONS{QUIET}; +} + +# +# Takes a vars hash and resolves {@link}s within it +# +sub format_vars { + my ($vars) = @_; + for my $key (keys %$vars){ + if (ref($vars->{$key}) eq 'ARRAY'){ + for (0..$#{$vars->{$key}}){ + $vars->{$key}->[$_] = &resolve_inner_links($vars->{$key}->[$_]); + } + } else { + $vars->{$key} = &resolve_inner_links($vars->{$key}); + } + } +} + diff --git a/modules/jala/util/HopKit/JSDoc/templates/allclasses-frame.tmpl b/modules/jala/util/HopKit/JSDoc/templates/allclasses-frame.tmpl new file mode 100644 index 00000000..e2a4ce31 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/allclasses-frame.tmpl @@ -0,0 +1,37 @@ + + + + + +<TMPL_VAR NAME="project_name"> <TMPL_VAR NAME="filename"> + + + + + + + "/> + +

      + + +
      + + + + + + + + +
      .html" TARGET="classFrame"> +
      +
      + + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/allclasses-noframe.tmpl b/modules/jala/util/HopKit/JSDoc/templates/allclasses-noframe.tmpl new file mode 100644 index 00000000..6da363c1 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/allclasses-noframe.tmpl @@ -0,0 +1,36 @@ + + + + +<TMPL_VAR NAME="project_name"> All Classes + + + + + + + "/> + +

      + +All Classes +
      + + + + + + + + +
      .html" > +
      +
      + + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/constant-values.tmpl b/modules/jala/util/HopKit/JSDoc/templates/constant-values.tmpl new file mode 100644 index 00000000..fb4307c4 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/constant-values.tmpl @@ -0,0 +1,151 @@ + + + + +<TMPL_VAR NAME="project_name"> Constant Values + + + + + + + + + + + + + + + + + + +
      + + +
      + + +
      +

      Constant Field Values

      +
      +
        + +
      • ">
      • +
        +
      + +
      + + + "> + + + + + + + + + + + +
      + .html"> +
      .html#">
      +

      + +

      + + +


      + + + + + + + + + + + + + +
      + + +
      + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/help-doc.tmpl b/modules/jala/util/HopKit/JSDoc/templates/help-doc.tmpl new file mode 100644 index 00000000..5f70ef3c --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/help-doc.tmpl @@ -0,0 +1,160 @@ + + + + +<TMPL_VAR NAME="project_name"> API Help + + + + + + + + + + + + + + + + + + +
      + + +
      + + +
      +
      +

      +How This API Document Is Organized

      +
      +This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

      +Class

      +
      + +

      +Each class has its own separate page. Each of these pages has three sections consisting of a class description, summary tables, and detailed member descriptions:

        +
      • Class inheritance diagram
      • Direct Subclasses
      • Class declaration
      • Class description +

        +

      • Field Summary
      • Constructor Summary
      • Method Summary +

        +

      • Field Detail
      • Constructor Detail
      • Method Detail
      +Each summary entry contains the first sentence from the detailed description for that item.
      + + +

      +Index

      +
      +The Index contains an alphabetic list of all classes, constructors, methods, and fields.
      +

      +Prev/Next

      +These links take you to the next or previous class, interface, package, or related page.

      +Frames/No Frames

      +These links show and hide the HTML frames. All pages are available with or without frames. +

      + + +This help file applies to API documentation generated using the standard doclet. + +
      +


      + + + + + + + + + + + + + +
      + + +
      + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/index-all.tmpl b/modules/jala/util/HopKit/JSDoc/templates/index-all.tmpl new file mode 100644 index 00000000..262a1e22 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/index-all.tmpl @@ -0,0 +1,142 @@ + + + + + +Index () + + + + + + + + + + + + + + + + + + +
      + + +
      + + + + __"> +
      + + +__">

      +

      + +
      +
      .html#"> - + class .html"> +
        +
      +
      +
      +
      + + __"> + +
      + + + + + + + + + + + + +
      + + +
      + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/index.tmpl b/modules/jala/util/HopKit/JSDoc/templates/index.tmpl new file mode 100644 index 00000000..1899a483 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/index.tmpl @@ -0,0 +1,27 @@ + + + + +Generated Javascript Documentation + + + + + + + + + + + +.html" name="classFrame"> + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to <A HREF="allclasses-frame.html">Non-frame version.</A> + diff --git a/modules/jala/util/HopKit/JSDoc/templates/main.tmpl b/modules/jala/util/HopKit/JSDoc/templates/main.tmpl new file mode 100644 index 00000000..b89866e3 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/main.tmpl @@ -0,0 +1,448 @@ + + + + + +<TMPL_VAR name="classname"> + + + + + + + + + + + + + + + + + + + + + +
      + + +
      + +
      + + +

      Class

      +
      + +
      +
      + Direct Known Subclasses: +
      + +
      +
      +
      + +
      +
      + +
       class + + +
      extends + + +
      + +

      + +

      +
      +
      + + + + + + + + + + + + + + +
      +Nested Class Summary
      + <static class>.html">
      +  +
      + + + + + + + + + + + + + + + + + + + +
      + Field Summary
      + <private> <static>  <final> !s!"> +
      +           
      +   +
      + + + +   + + + + + + + +
      Fields inherited from class .html">
      + +
      +  +
      +
      + + + + + + + + + + + + + + +
      +Constructor Summary
      + + + .html#()"> + + + +
      +             + +
      +
      + + +  + + + + + + + + + + + + + + + + +
      +Method Summary
      + + <static> <private>   + + + + + !s!"> + +
      +            + +
      +
      + + + + + + + + + +
      Methods inherited from class .html">
      + + +
      +  +
      +

      + + + + + + + + + + +
      Field Detail
      + + + !s!
      "> +

      +
      <private> <static> <final>  
      + +
      +
      + + + + + + + + + + + +
      + Constructor Detail +
      + +()">

      +

      +
      + + +
        + +
      +
      + + +
        + Parameters: + +
          - +
        +
        + +
      +
      + + + +
        + Returns: +
          + +
        +
      +
      + + + + +
        + +
      +
      +
      + + + + + + + + + + + + +
      + Method Detail +
      + + + + !s!
      "> +

      +
      <static>  <private>  
      + +
      +
      + + + +
        + Parameters: + +
          - +
        +
        +
      +
      + + + +
        + Returns: +
          + +
        +
      +
      + + + +
        + +
      +
      + +
      + +
      + + + + + + + + + + + + + + + + + + + + +
      + + +
      + + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/overview-frame.tmpl b/modules/jala/util/HopKit/JSDoc/templates/overview-frame.tmpl new file mode 100644 index 00000000..5097ca4c --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/overview-frame.tmpl @@ -0,0 +1,43 @@ + + + + +Overview () + + + + + + + "/> + +

      + + + + +
      + + + + + +
      All Classes +

      + +Files +
      + +.html" TARGET="packageFrame">
      +
      +

      + +

      +  + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/overview-summary.tmpl b/modules/jala/util/HopKit/JSDoc/templates/overview-summary.tmpl new file mode 100644 index 00000000..504c1f76 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/overview-summary.tmpl @@ -0,0 +1,222 @@ + + + + +<tmpl_var name="project_name"> Overview + + + + + + + + + + + + + + + + + + +
      + + +
      + + +


      +
      + +

      + +

      JSDoc Documentation

      +
      +
      + + +

      + This document is the API Specification for + . +

      +
      +
      + +

      Summary

      +

      + + + + No summary generated for these documents. + +

      + +
      + + + + + + + + + + + + +
      + + Class Summary + + File Summary + +
      ">
      +
      +
      + + + + + + + + + + + + + + + + +
      + + Method Summary + +
      + + static private   + + + + + #"> + +
      +            + +
      +

      + + + + +

      +
      +
      + + + + + + + + + + + + + + +
      + +
      + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/overview-tree.tmpl b/modules/jala/util/HopKit/JSDoc/templates/overview-tree.tmpl new file mode 100644 index 00000000..47968010 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/overview-tree.tmpl @@ -0,0 +1,121 @@ + + + + + +<TMPL_VAR name="project_name"> Class Hierarchy + + + + + + + + + + + + + + + + + + +
      + +
      + + +
      +

      Class Hierarchy

      + + + +
      + + + + + + + + + + + + + +
      + +
      + + +
      + + + +
      Documentation generated by JSDoc on
      + + diff --git a/modules/jala/util/HopKit/JSDoc/templates/stylesheet.css b/modules/jala/util/HopKit/JSDoc/templates/stylesheet.css new file mode 100644 index 00000000..7a35c0c1 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/templates/stylesheet.css @@ -0,0 +1,39 @@ +/* JSDoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ +.TableRowColor { background: #FFFFFF } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameHeadingFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } + +/* Example of smaller, sans-serif font in frames */ +/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ +.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} + +.jsdoc_ctime { font-family: Arial, Helvetica, sans-serif; font-size: 9pt; + text-align: right } + +/* Sourcecode view */ +.sourceview { background: #FFFFFF } +.attrib { color: #DD7777 } +.comment { color: #55AA55 } +.reserved { color: #FF5555 } +.literal { color: #5555FF } + diff --git a/modules/jala/util/HopKit/JSDoc/test.js b/modules/jala/util/HopKit/JSDoc/test.js new file mode 100644 index 00000000..72e3fde5 --- /dev/null +++ b/modules/jala/util/HopKit/JSDoc/test.js @@ -0,0 +1,505 @@ +/** + * @fileoverview This file is to be used for testing the JSDoc parser + * It is not intended to be an example of good JavaScript OO-programming, + * nor is it intended to fulfill any specific purpose apart from + * demonstrating the functionality of the + * {@link http://sourceforge.net/projects/jsdoc JSDoc} parser + * + * @author Gabriel Reid gab_reid@users.sourceforge.net + * @version 0.1 + */ + + +/** + * Construct a new Shape object. + * @class This is the basic Shape class. + * It can be considered an abstract class, even though no such thing + * really existing in JavaScript + * @constructor + * @throws MemoryException if there is no more memory + * @throws GeneralShapeException rarely (if ever) + * @return A new shape + */ +function Shape(){ + + /** + * This is an example of a function that is not given as a property + * of a prototype, but instead it is assigned within a constructor. + * For inner functions like this to be picked up by the parser, the + * function that acts as a constructor must be denoted with + * the @constructor tag in its comment. + * @type String + */ + this.getClassName = function(){ + return "Shape"; + } + + /** + * This is a private method, just used here as an example + */ + function addReference(){ + // Do nothing... + } + +} + +/** + * Create a new Hexagon instance. + * @extends Shape + * @class Hexagon is a class that is a logical sublcass of + * {@link Shape} (thanks to the @extends tag), but in + * reality it is completely unrelated to Shape. + * @param {int} sideLength The length of one side for the new Hexagon + */ +function Hexagon(sideLength) { +} + + +/** + * This is an unattached (static) function that adds two integers together. + * @param {int} One The first number to add + * @param {int http://jsdoc.sourceforge.net/} Two The second number to add + * @author Gabriel Reid + * @deprecated So you shouldn't use it anymore! + */ +function Add(One, Two){ + return One + Two; +} + + +/** + * The color of this shape + * @type Color + */ +Shape.prototype.color = null; + +/** + * The border of this shape. + * @type int + */ +Shape.prototype.border = null; + +/* + * The assignment of function implementations for Shape, documentation will + * be taken over from the method declaration. + */ + +Shape.prototype.getCoords = Shape_GetCoords; + +Shape.prototype.getColor = Shape_GetColor; + +Shape.prototype.setCoords = Shape_SetCoords; + +Shape.prototype.setColor = Shape_SetColor; + +/* + * These are all the instance method implementations for Shape + */ + +/** + * Get the coordinates of this shape. It is assumed that we're always talking + * about shapes in a 2D location here. + * @requires Shape The shape class + * @returns A Coordinate object representing the location of this Shape + * @type Coordinate + */ +function Shape_GetCoords(){ + return this.coords; +} + +/** + * Get the color of this shape. + * @see #setColor + * @type Color + */ +function Shape_GetColor(){ + return this.color; +} + +/** + * Set the coordinates for this Shape + * @param {Coordinate} coordinates The coordinates to set for this Shape + */ +function Shape_SetCoords(coordinates){ + this.coords = coordinates; +} + +/** + * Set the color for this Shape + * @param {Color} color The color to set for this Shape + * @param other There is no other param, but it can still be documented if + * optional parameters are used + * @throws NonExistantColorException (no, not really!) + * @see #getColor + */ +function Shape_SetColor(color){ + this.color = color; +} + +/** + * Clone this shape + * @returns A copy of this shape + * @type Shape + * @author Gabriel Reid + */ +Shape.prototype.clone = function(){ + return new Shape(); +} + +/** + * Create a new Rectangle instance. + * @class A basic rectangle class, inherits from Shape. + * This class could be considered a concrete implementation class + * @constructor + * @param {int} width The optional width for this Rectangle + * @param {int} height Thie optional height for this Rectangle + * @author Gabriel Reid + * @see Shape Shape is the base class for this + */ +function Rectangle(width, // This is the width + height // This is the height + ){ + if (width){ + this.width = width; + if (height){ + this.height = height; + } + } +} + + +/* Inherit from Shape */ +Rectangle.prototype = new Shape(); + +/** + * Value to represent the width of the Rectangle. + *
      Text in bold and italic and a + * link to SourceForge + * @private + * @type int + */ +Rectangle.prototype.width = 0; + +/** + * Value to represent the height of the Rectangle + * @private + * @type int + */ +Rectangle.prototype.height = 0; + +/** + * Get the type of this object. + * @type String + */ +Rectangle.prototype.getClassName= function(){ + return "Rectangle"; +} + +/* + * These are all the instance method implementations for Rectangle + */ + +Rectangle.prototype.getWidth = Rectangle_GetWidth; + +Rectangle.prototype.getHeight = Rectangle_GetHeight; + +Rectangle.prototype.setWidth = Rectangle_SetWidth; + +Rectangle.prototype.setHeight = Rectangle_SetHeight; + +Rectangle.prototype.getArea = Rectangle_GetArea; + + +/** + * Get the value of the width for the Rectangle + * @type int + * @see #setWidth + */ +function Rectangle_GetWidth(){ + return this.width; +} + +/** + * Get the value of the height for the Rectangle. + * Another getter is the {@link Shape#getColor} method in the + * {@link Shape base Shape class}. + * @return The height of this Rectangle + * @type int + * @see #setHeight + */ +function Rectangle_GetHeight(){ + return this.height; +} + +/** + * Set the width value for this Rectangle. + * @param {int} width The width value to be set + * @see #getWidth + */ +function Rectangle_SetWidth(width){ + this.width = width; +} + +/** + * Set the height value for this Rectangle. + * @param {int} height The height value to be set + * @see #getHeight + */ +function Rectangle_SetHeight(height){ + this.height = height; +} + +/** + * Get the value for the total area of this Rectangle + * @return total area of this Rectangle + * @type int + */ +function Rectangle_GetArea(){ + return width * height; +} + + +/** + * Create a new Square instance. + * @class A Square is a subclass of {@link Rectangle} + * @param {int} width The optional width for this Rectangle + * @param {int} height The optional height for this Rectangle + */ +function Square(width, height){ + if (width){ + this.width = width; + if (height){ + this.height = height; + } + } + +} + +/* Square is a subclass of Rectangle */ +Square.prototype = new Rectangle(); + + +/* + * The assignment of function implementation for Shape. + */ +Square.prototype.setWidth = Square_SetWidth; + +Square.prototype.setHeight = Square_SetHeight; + + + +/** + * Set the width value for this Square. + * @param {int} width The width value to be set + * @see #getWidth + */ +function Square_SetWidth(width){ + this.width = this.height = width; +} + +/** + * Set the height value for this Square + * Sets the {@link Rectangle#height height} attribute in the Rectangle. + * @param {int} height The height value to be set + */ +function Square_SetHeight(height){ + this.height = this.width = height; +} + + +/** + * Create a new Circle instance based on a radius. + * @class Circle class is another subclass of Shape + * @param {int} radius The optional radius of this Circle + */ +function Circle(radius){ + if (radius){ + this.radius = radius; + } +} + +/* Circle inherits from Shape */ +Circle.prototype = new Shape(); + +/** + * The radius value for this Circle + * @private + * @type int + */ +Circle.prototype.radius = 0; + +/** + * A very simple class (static) field that is also a constant + * @final + * @type float + */ +Circle.PI = 3.14; + +Circle.createCircle = Circle_CreateCircle; + +Circle.prototype.getRadius = Circle_GetRadius; + +Circle.prototype.setRadius = Circle_SetRadius; + +/** + * Get the radius value for this Circle + * @type int + * @see #setRadius + */ +function Circle_GetRadius(){ + return this.radius; +} + +/** + * Set the radius value for this Circle + * @param {int} radius The radius value to set + * @see #getRadius + */ +function Circle_SetRadius(radius){ + this.radius = radius; +} + +/** + * An example of a class (static) method that acts as a factory for Circle + * objects. Given a radius value, this method creates a new Circle. + * @param {int} radius The radius value to use for the new Circle. + * @type Circle + */ +function Circle_CreateCircle(radius){ + return new Circle(radius); +} + + +/** + * Create a new Coordinate instance based on x and y grid data. + * @class Coordinate is a class that can encapsulate location information. + * @param {int} x The optional x portion of the Coordinate + * @param {int} y The optinal y portion of the Coordinate + */ +function Coordinate(x, y){ + if (x){ + this.x = x; + if (y){ + this.y = y; + } + } +} + +/** + * The x portion of the Coordinate + * @type int + * @see #getX + * @see #setX + */ +Coordinate.prototype.x = 0; + +/** + * The y portion of the Coordinate + * @type int + * @see #getY + * @see #setY + */ +Coordinate.prototype.y = 0; + +Coordinate.prototype.getX = Coordinate_GetX; +Coordinate.prototype.getY = Coordinate_GetY; +Coordinate.prototype.setX = Coordinate_SetX; +Coordinate.prototype.setY = Coordinate_SetY; + +/** + * Gets the x portion of the Coordinate. + * @type int + * @see #setX + */ +function Coordinate_GetX(){ + return this.x; +} + +/** + * Get the y portion of the Coordinate. + * @type int + * @see #setY + */ +function Coordinate_GetY(){ + return this.y; +} + +/** + * Sets the x portion of the Coordinate. + * @param {int} x The x value to set + * @see #getX + */ +function Coordinate_SetX(x){ + this.x = x; +} + +/** + * Sets the y portion of the Coordinate. + * @param {int} y The y value to set + * @see #getY + */ +function Coordinate_SetY(y){ + this.y = y; +} + +/** + * @class This class exists to demonstrate the assignment of a class prototype + * as an anonymous block. + */ +function ShapeFactory(){ +} + +ShapeFactory.prototype = { + /** + * Creates a new {@link Shape} instance. + * @return A new {@link Shape} + * @type Shape + */ + createShape: function(){ + return new Shape(); + } +} + +/** + * An example of a singleton class + */ +MySingletonShapeFactory = new function(){ + + /** + * Get the next {@link Shape} + * @type Shape + * @return A new {@link Shape} + */ + this.getShape = function(){ + return null; + } + +} + + +/** + * Create a new Foo instance. + * @class This is the Foo class. It exists to demonstrate 'nested' classes. + * @constructor + * @see Foo.Bar + */ +function Foo(){} + +/** + * Creates a new instance of Bar. + * @class This class exists to demonstrate 'nested' classes. + * @constructor + * @see Foo.Bar + */ +function Bar(){} + +/** + * Nested class + * @constructor + */ +Foo.Bar = function(){this.x = 2;} + +Foo.Bar.prototype = new Bar(); + +Foo.Bar.prototype.y = '3'; + diff --git a/modules/jala/util/HopKit/build.bat b/modules/jala/util/HopKit/build.bat new file mode 100755 index 00000000..886c2ba2 --- /dev/null +++ b/modules/jala/util/HopKit/build.bat @@ -0,0 +1,69 @@ +:: +:: Jala Project [http://opensvn.csie.org/traccgi/jala] +:: +:: Copyright 2004 ORF Online und Teletext GmbH +:: +:: Licensed under the Apache License, Version 2.0 (the ``License''); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an ``AS IS'' BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: +:: $Revision$ +:: $LastChangedBy$ +:: $LastChangedDate$ +:: $HeadURL$ +:: + + +@echo off + +rem This is build.bat for Ant 1.7 + +rem Define the path to the ANT binary directory +rem (traling slash is mandatory!) +rem set ANT_HOME=%PROGRAMFILES%\Apache Group\apache-ant-1.7.0\bin\ + +rem Set this to the directory of your Helma installation if necessary +set HELMA_HOME="" + +rem ========================================================================== +rem No need to edit anything past here + +rem store path of this script as BUILD_HOME +set BUILD_HOME=%~dp0 + +rem Set this to the directory of your Helma installation +if "%HELMA_HOME%"=="""" set HELMA_HOME="%BUILD_HOME%/../../../.." + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). +set ANT_CMD_LINE_ARGS=%1 +if ""%1""=="""" goto runAnt +shift +:setupArgs +if ""%1""=="""" goto runAnt +if ""%1""==""-noclasspath"" goto runAnt +set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 +shift +goto setupArgs + +:runAnt + +rem ---- if there is no build.xml in the working directory, use the library +rem ---- in this directory +if not exist ".\build.xml" ( + set ANT_CMD_LINE_ARGS=-file "%BUILD_HOME%lib.xml" %ANT_CMD_LINE_ARGS% +) + +echo BUILD_HOME: %BUILD_HOME% + +ant -Dant.home=. -Dbasedir=. -lib "%BUILD_HOME%\lib;%HELMA_HOME%\lib" -propertyfile "%CD%\build.properties" %ANT_CMD_LINE_ARGS% + +:end diff --git a/modules/jala/util/HopKit/build.sh b/modules/jala/util/HopKit/build.sh new file mode 100755 index 00000000..691439c6 --- /dev/null +++ b/modules/jala/util/HopKit/build.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +## +## Jala Project [http://opensvn.csie.org/traccgi/jala] +## +## Copyright 2004 ORF Online und Teletext GmbH +## +## Licensed under the Apache License, Version 2.0 (the ``License''); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an ``AS IS'' BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +## $Revision: 3 $ +## $LastChangedBy: tobi $ +## $LastChangedDate: 2007-01-19 14:33:08 +0100 (Fri, 19 Jan 2007) $ +## $HeadURL: https://robert@opensvn.csie.org/jala/trunk/util/HopKit/build.bat $ +## + +# Uncomment and set this to the directory of your Helma installation +# if you installed jala in a different subdirectory than "modules/jala" +# HELMA_HOME="path/to/helma/installation" + +#-------------------------------------------- +# No need to change anything below +# buildfile for ant 1.7.0 +#-------------------------------------------- +if test -z "${ANT_HOME}" ; then + echo "ERROR: ANT_HOME not found in your environment." + echo "Please, set the ANT_HOME variable in your environment to match the" + echo "location of the Apache Ant installation you want to use." + exit +fi + +#---- store path of this script as BUILD_HOME +BUILD_HOME=$(dirname $0) +if [ "${BUILD_HOME:0:1}" != "/" ] ; then + # convert to absolute path + BUILD_HOME=${PWD}/${BUILD_HOME} +fi +export BUILD_HOME + +#---- store HELMA_HOME if not defined above +if [ -z "$HELMA_HOME" ] ; then + HELMA_HOME=$BUILD_HOME/../../../.. +fi + +#---- Slurp the command line arguments. +while [ $# -ne 0 ] +do + ANT_CMD_LINE_ARGS="${ANT_CMD_LINE_ARGS} $1" + shift +done + +#---- if there is no build.xml in the working directory, use the lib.xml +#---- in this directory +if test ! -f ${PWD}/build.xml ; then + BUILD_XML="${BUILD_HOME}/lib.xml" +else + BUILD_XML="${PWD}/build.xml" +fi + +${ANT_HOME}/bin/ant -Dant.home="${BUILD_HOME}" -Dbasedir="${PWD}" -lib "${BUILD_HOME}/lib:${HELMA_HOME}/lib" -propertyfile "${PWD}/build.properties" -file $BUILD_XML ${ANT_CMD_LINE_ARGS} + +exit diff --git a/modules/jala/util/HopKit/js.bat b/modules/jala/util/HopKit/js.bat new file mode 100755 index 00000000..b9c5fa64 --- /dev/null +++ b/modules/jala/util/HopKit/js.bat @@ -0,0 +1,107 @@ +:: +:: Jala Project [http://opensvn.csie.org/traccgi/jala] +:: +:: Copyright 2004 ORF Online und Teletext GmbH +:: +:: Licensed under the Apache License, Version 2.0 (the ``License''); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an ``AS IS'' BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: +:: $Revision$ +:: $LastChangedBy$ +:: $LastChangedDate$ +:: $HeadURL$ +:: + + +@echo off + +set HOPKIT=%~dp0 + +set JAVA=java +set JSJAR="%HOPKIT%\lib\js.jar" +set JSTOOLS=org.mozilla.javascript.tools + +goto %1 + + +rem -- S H E L L -- +:shell + +if "%2"=="" ( + %JAVA% -cp "%JSJAR%" "%JSTOOLS%.shell.Main" +) else ( + %JAVA% -cp "%JSJAR%" "%JSTOOLS%.shell.Main" "%2" +) + +goto end + + +rem -- T E S T -- +:test + + +rem -- C O M P I L E -- +:compile + +%JAVA% -cp "%JSJAR%" "%JSTOOLS%.jsc.Main" -nosource "%2" + +goto end + + +rem -- L I N T -- +:lint + +%JAVA% -cp "%JSJAR%" "%JSTOOLS%.shell.Main jslint.js" "%2" + +goto end + + +rem -- D O C S -- +:docs + +if "%3"=="" ( + set DOCDIR=docs +) else ( + set DOCDIR=%3 +) + +"%HOPKIT%\JSDoc\jsdoc.pl" -q -r -d "%DOCDIR%" --template-dir "%HOPKIT%/JSDoc/templates" --package-naming --globals-name Global --project-name "%2" --project-summary "./.jsdoc/summary.html" . + +goto end + + +rem -- M I N I F Y -- +:minify + +"%HOPKIT%\jsmin" "%2" + + +rem -- P A C K -- +:pack + + +rem -- H E L P -- +:help + +echo Currently the following build targets are supported: +echo docs - Create JSDoc API documentation. +echo help - Output this information. +echo compile - Compile a JavaScript file as Java class. +echo lint - Apply JavaScript Lint to a file. +echo minify - Minify JavaScript source files. +rem echo pack - Pack and obsfucate JavaScript source files. +echo shell - Start Rhino's interactive JavaScript shell. +echo test - Apply unit tests to JavaScript code. + + +rem -- E N D -- +:end diff --git a/modules/jala/util/HopKit/lib.xml b/modules/jala/util/HopKit/lib.xml new file mode 100644 index 00000000..99a166af --- /dev/null +++ b/modules/jala/util/HopKit/lib.xml @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + validate failed: error(s) in javascript code. + + + + diff --git a/modules/jala/util/HopKit/lib/bsf.jar b/modules/jala/util/HopKit/lib/bsf.jar new file mode 100644 index 00000000..3c035ff4 Binary files /dev/null and b/modules/jala/util/HopKit/lib/bsf.jar differ diff --git a/modules/jala/util/HopKit/scripts/MessageParser.js b/modules/jala/util/HopKit/scripts/MessageParser.js new file mode 100644 index 00000000..fc786d0c --- /dev/null +++ b/modules/jala/util/HopKit/scripts/MessageParser.js @@ -0,0 +1,428 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview + * MessageParser script that extracts all gettext message macros + * out of skin files and all calls of gettext functions + * (that is "gettext", "ngettext" and "_") out of function + * files and directly generates a .pot file from it. + * If an argument "-o" is given and it is followed by + * a path to a file, the output is written to this file. + * Any other argument is interpreted as directory or file + * that should be parsed. + */ + + +/** + * @constructor + */ +var Message = function(id, pluralId) { + this.id = id && String(id); + this.pluralId = pluralId && String(pluralId); + this.locations = []; + return this; +}; + +/** + * Static method that constructs a message key by + * which a message can be identified in the messages map. + * @param {String} id The message Id + * @param {String} pluralId The plural message Id + * @returns The generated message key + * @type String + */ +Message.getKey = function(id, pluralId) { + if (id && pluralId) { + return id + pluralId; + } else { + return id; + } +}; + +/** + * Encloses the string passed as argument in quotes + * and wraps the string if it is longer than 80 characters. + * @param {String} str The string to format + * @param {Boolean} wrap If true the message string will be splitted in + * parts where each one is max. 80 characters long + * @returns The formatted string. + * @type String + */ +Message.formatId = function(str, wrap) { + var escapeQuotes = function(s) { + return s.replace(/(^|[^\\])"/g, '$1\\"'); + }; + + var len = 80; + var buf = new java.lang.StringBuffer(); + if (wrap == true && str.length > len) { + buf.append('""\n'); + var offset = 0; + while (offset < str.length) { + buf.append('"'); + buf.append(escapeQuotes(str.substring(offset, offset += len))); + buf.append('"'); + buf.append("\n"); + } + return buf.toString(); + } else { + buf.append('"'); + buf.append(escapeQuotes(str)); + buf.append('"\n'); + } + return buf.toString(); +}; + +/** + * Adds a new location to this Message instance. + * @param {String} filePath The path to the file this message + * is located in. + * @param {Number} lineNum The line number at which this message + * was found at + */ +Message.prototype.addLocation = function(filePath, lineNum) { + this.locations.push(filePath + ":" + lineNum); +}; + +/** + * Writes this Message instance as .po compatible string to + * the StringBuffer passed as argument. + * @param {java.lang.StringBuffer} buf The StringBuffer instance + * to write into + */ +Message.prototype.write = function(buf) { + for (var i=0;i -1 + || (this.pluralId != null && this.pluralId.indexOf("{") > -1)) { + buf.append("#, java-format\n"); + } + buf.append('msgid '); + buf.append(Message.formatId(this.id)); + if (this.pluralId != null) { + buf.append('msgid_plural '); + buf.append(Message.formatId(this.pluralId)); + buf.append('msgstr[0] ""\nmsgstr[1] ""\n') + } else { + buf.append('msgstr ""\n') + } + buf.append("\n"); + return; +}; + +/** + * @constructor + */ +var MessageParser = function() { + this.messages = {}; + return this; +}; + +/** + * Object containing the accepted function names, currently + * supported are "gettext", "ngettext" and "_". This is used + * as a lookup map during function file parsing. + * @type Object + */ +MessageParser.FUNCTION_NAMES = { + "_": true, + "gettext": true, + "ngettext": true, + "markgettext": true +}; + +/** + * The name of the gettext macro + * @type String + */ +MessageParser.MACRO_NAME = "message"; + +/** + * The name of the macro attribute that will be interpreted + * as gettext attribute. + * @type String + */ +MessageParser.ATTRIBUTE_NAME = MessageParser.MACRO_NAME; + +/** + * A regular expression for parsing macros in a skin. The result + * of this regular expression contains: + * result[1] = macro handler name (can be empty for global macros) + * result[2] = macro name + * result[3] = the macro's attributes + * @type RegExp + */ +MessageParser.REGEX_MACRO = /<%\s*(?:([\w]+)\.)?([\w]+)\s+([^%]+?)\s*%>/gm; + +/** + * A regular expression for parsing the attributes of a macro. The result + * of this regular expression contains: + * result[1] = attribute name + * result[2] = attribute value + * @type RegExp + */ +MessageParser.REGEX_PARAM = /([\w]*)\s*=\s*["'](.*?)["']\s*(?=\w+=|$)/gm; + +/** + * Calculates the line number in the string passed as argument + * at which the specified index position is located. + * @param {String} str The source string + * @param {Number} idx The index position to get the line number for. + * @returns The line number of the index position in the source string. + * @type Number + */ +MessageParser.getLineNum = function(str, idx) { + return str.substring(0, idx).split(/.*(?:\r\n|\n\r|\r|\n)/).length; +}; + +/** + * Parses the file passed as argument. If the file + * is a directory, this method recurses down the directory + * tree and parses all skin and function files. + * @param {java.io.File} file The file or directory to start at. + * @param {String} encoding The encoding to use + */ +MessageParser.prototype.parse = function(file, encoding) { + if (file.isDirectory()) { + var list = file.list(); + for (var i=0;i -1) { + switch (String(fName.substring(dotIdx+1))) { + case "skin": + print("Parsing skin file " + file.getAbsolutePath() + "..."); + this.parseSkinFile(file, encoding); + break; + case "hac": + case "js": + print("Parsing function file " + file.getAbsolutePath() + "..."); + this.parseFunctionFile(file, encoding); + break; + default: + break; + } + } + } + return; +}; + +/** @ignore */ +MessageParser.prototype.toString = function() { + return "[Jala Message Parser]"; +}; + +/** + * Parses a .js file and creates Message instances for all + * calls of "gettext", "ngettext", "markgettext" and "_". + * @param {java.io.File} file The function file to parse + * @param {String} encoding The encoding to use + */ +MessageParser.prototype.parseFunctionFile = function(file, encoding) { + var fis = new java.io.FileInputStream(file); + var isr = new java.io.InputStreamReader(fis, encoding || "UTF-8"); + var reader = new java.io.BufferedReader(isr); + var tokenizer = new java.io.StreamTokenizer(reader); + var messages = [], stack = []; + var c; + while ((c = tokenizer.nextToken()) != java.io.StreamTokenizer.TT_EOF) { + switch (c) { + case java.io.StreamTokenizer.TT_WORD: + if (MessageParser.FUNCTION_NAMES[tokenizer.sval] == true) { + stack.push({name: tokenizer.sval, lineNr: tokenizer.lineno()}); + } else if (stack.length > 0) { + // it's something else than a string argument inside a gettext method call + // so finalize the argument parsing here as we aren't interested in that + messages.push(stack.pop()); + } + break; + case java.io.StreamTokenizer.TT_NUMBER: + break; + default: + if (stack.length > 0) { + if ("\u0028".charCodeAt(0) == c) { + // start of arguments (an opening bracket) + stack[stack.length-1].args = []; + } else if ("\u0029".charCodeAt(0) == c) { + // end of arguments (a closing bracket) + messages.push(stack.pop()); + } else if ("\u0022".charCodeAt(0) == c || "\u0027".charCodeAt(0) == c) { + // a quoted string argument + stack[stack.length-1].args.push(tokenizer.sval); + } + } + break; + } + } + if (messages.length > 0) { + var msgParam, key, msg; + for (var i=0;i 0) { + key = Message.getKey(msgParam.args[0]); + if (!(msg = this.messages[key])) { + this.messages[key] = msg = new Message(msgParam.args[0], msgParam.args[1]); + } + if (!msg.pluralId && msgParam.args.length > 1) { + msg.pluralId = msgParam.args[1]; + } + msg.addLocation(file.getAbsolutePath(), msgParam.lineNr); + } + } + } + fis.close(); + isr.close(); + reader.close(); + return; +}; + +/** + * Parses a skin file and creates Message instances for + * all macros which name is either "message" or + * that have attributes named "message" and optional + * "plural" + * @param {java.io.File} file The skin file to parse + * @param {String} encoding The encoding to use + */ +MessageParser.prototype.parseSkinFile = function(file, encoding) { + var content = readFile(file.getAbsolutePath(), encoding || "UTF-8"); + var macro, id, pluralId, params, key; + while (macro = MessageParser.REGEX_MACRO.exec(content)) { + while (params = MessageParser.REGEX_PARAM.exec(macro[3])) { + if (macro[2] == MessageParser.MACRO_NAME) { + if (params[1] == "text") { + id = params[2]; + pluralId = null; + } else if (params[1] == "plural") { + pluralId = params[2]; + } + } else { + if (params[1] == MessageParser.ATTRIBUTE_NAME) { + id = params[2]; + pluralId = null; + } else if (params[1] == "plural") { + pluralId = params[2]; + } + } + } + if (id != null) { + // create new Message instance or update the existing one + key = Message.getKey(id); + if (!(msg = this.messages[key])) { + this.messages[key] = msg = new Message(id, pluralId, file.getAbsolutePath()); + } + msg.addLocation(file.getAbsolutePath(), + MessageParser.getLineNum(content, macro.index)); + } + } + return; +}; + +/** + * Prints a standard Header of a .po file + * FIXME: why the hell is Plural-Forms ignored in poEdit? + * @see http://drupal.org/node/17564 + */ +MessageParser.prototype.getPotString = function() { + var buf = new java.lang.StringBuffer(); + buf.append('# SOME DESCRIPTIVE TITLE.\n'); + buf.append('# Copyright (C) YEAR THE PACKAGE\'S COPYRIGHT HOLDER\n'); + buf.append('# This file is distributed under the same license as the PACKAGE package.\n'); + buf.append('# FIRST AUTHOR , YEAR.\n'); + buf.append('#\n'); + buf.append('#, fuzzy\n'); + buf.append('msgid ""\n'); + buf.append('msgstr ""\n'); + buf.append('"Project-Id-Version: PACKAGE VERSION\\n"\n'); + buf.append('"Report-Msgid-Bugs-To: \\n"\n'); + var sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mmZ"); + buf.append('"POT-Creation-Date: ' + sdf.format(new java.util.Date()) + '\\n"\n'); + buf.append('"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"\n'); + buf.append('"Last-Translator: FULL NAME \\n"\n'); + buf.append('"Language-Team: LANGUAGE \\n"\n'); + buf.append('"MIME-Version: 1.0\\n"\n'); + buf.append('"Content-Type: text/plain; charset=utf-8\\n"\n'); + buf.append('"Content-Transfer-Encoding: 8bit\\n"\n'); + buf.append('"Plural-Forms: nplurals=2; plural=(n != 1);\\n"\n'); + buf.append('\n'); + + // sort all messages by their singular key + var keys = []; + for (var i in this.messages) { + keys[keys.length] = this.messages[i].id; + } + keys.sort(); + // add all the messages + for (var i=0;ijava -cp rhino.jar org.mozilla.javascript.tools.shell.Main PoParser.js [namespace] + * + * The accepted arguments are: + *
        + *
      • input: Either a single .po file or a directory containing multiple files
      • + *
      • output: The directory where to put the generated message files
      • + *
      • namespace: An optional namespace in which the generated message object will reside + * (eg. if the namespace is called "jala", the messages will be stored in global.jala.messages)
      • + *
      + */ + + +/** + * Constructs a new PoParser instance. + * @class Instances of this class can generate JavaScript message files out + * of GNU Gettext .po files for use with jala.I18n (and possibly other internationalization + * environments too). + * @param {String} handler An optional namespace where the parsed messages should be stored + * @returns A newly created instance of PoParser + * @constructor + */ +var PoParser = function(namespace) { + /** + * An array containing the parsed messages + * @type Array + */ + this.messages = []; + + /** + * The locale key string (eg. "de_AT") of the .po file + * @type String + */ + this.localeKey = null; + + /** + * The namespace (optional) where to store the generated messages + * @type String + */ + this.namespace = namespace; + return this; +}; + +/** + * A regular expression for splitting the contents of a .po file into + * single lines + * @type RegExp + */ +PoParser.REGEX_LINES = /\r\n|\r|\n|\u0085|\u2028|\u2029/; + +/** + * A regular expression for parsing singular message keys + * @type RegExp + */ +PoParser.REGEX_MSGID = /^\s*msgid(?!_plural)\s+\"(.*)\"\s*$/; + +/** + * A regular expression for parsing plural message keys + * @type RegExp + */ +PoParser.REGEX_MSGID_PLURAL = /^\s*msgid_plural\s+\"(.*)\"\s*$/; + +/** + * A regular expression for parsing message key continuations + * @type RegExp + */ +PoParser.REGEX_MSG_CONT = /^\s*\"(.*)\"\s*$/; + +/** + * A regular expression for parsing a message translation + * @type RegExp + */ +PoParser.REGEX_MSGSTR = /^\s*msgstr(?:\[(\d)\])?\s+\"(.*)\"\s*$/; + +/** + * A regular expression used to detect lines other than whitespace + * and comments + * @type RegExp + */ +PoParser.REGEX_DATA = /^\s*msg/; + +PoParser.isData = function(str) { + return PoParser.REGEX_DATA.test(str); +}; + +/** + * Reads the file passed as argument, assuming that it is UTF-8 encoded + * @param {java.io.File} file The file to read + * @returns The contents of the file + * @type java.lang.String + */ +PoParser.readFile = function(file) { + var inStream = new java.io.InputStreamReader(new java.io.FileInputStream(file), "UTF-8"); + var buffer = new java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 2048); + var read = 0; + var r = 0; + while ((r = inStream.read(buffer, read, buffer.length - read)) > -1) { + read += r; + if (read == buffer.length) { + // grow input buffer + var newBuffer = new java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, buffer.length * 2); + java.lang.System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); + buffer = newBuffer; + } + } + inStream.close(); + return new java.lang.String(buffer, 0, read); +} + +/** + * Parses the PO file passed as argument into the messages array + * of this PoParser instance. + * @param {java.io.File} file The .po file to parse + */ +PoParser.prototype.parse = function(file) { + // parse the locale key out of the file name + var fileName = file.getName(); + if (!(this.localeKey = fileName.substring(0, fileName.indexOf(".")))) { + throw "Invalid PO file name: " + fileName; + } + + // read the PO file content and parse it into messages + var content = PoParser.readFile(file); + var start = new Date(); + var lines = content.split(PoParser.REGEX_LINES); + var idx = -1; + var line = null; + var m, value, nr; + var msg; + + var hasMoreLines = function() { + return idx < lines.length - 1; + }; + + var nextLine = function() { + return (line = lines[idx += 1]) != null; + }; + + var getContinuation = function(str) { + var nLine; + while ((nLine = lines[idx + 1]) != null) { + if ((m = nLine.match(PoParser.REGEX_MSG_CONT)) != null) { + str += m[1]; + nextLine(); + } else { + break; + } + } + return str; + } + + while (nextLine()) { + if ((m = line.match(PoParser.REGEX_MSGID)) != null) { + value = getContinuation(m[1]); + if (value) { + msg = this.messages[this.messages.length] = new Message(value); + } + } else if ((m = line.match(PoParser.REGEX_MSGID_PLURAL)) != null) { + value = getContinuation(m[1]); + if (value && msg != null) { + msg.pluralKey = value; + } + } else if ((m = line.match(PoParser.REGEX_MSGSTR)) != null) { + nr = m[1]; + value = getContinuation(m[2]); + if (value && msg != null) { + nr = parseInt(nr, 10); + msg.translations[nr || 0] = value; + } + } + } + return; +}; + +/** + * Converts the array containing the parsed messages into a message + * catalog script file and saves it on disk. + * @param {java.io.File} outputDir The directory where the message + * file should be saved + */ +PoParser.prototype.writeToFile = function(output) { + var buf = new java.lang.StringBuffer(); + // write header + buf.append('/**\n'); + buf.append(' * Instantiate the messages namespace if it\'s not already existing\n'); + buf.append(' */\n'); + var objPath = ""; + if (this.namespace) { + objPath += this.namespace; + buf.append('if (!global.' + objPath + ') {\n'); + buf.append(' global.' + objPath + ' = {};\n'); + buf.append('}\n'); + objPath += "."; + } + objPath += "messages"; + buf.append('if (!global.' + objPath + ') {\n'); + buf.append(' global.' + objPath + ' = {};\n'); + buf.append('}\n\n'); + + buf.append('/**\n'); + buf.append(' * Messages for locale "' + this.localeKey + '"\n'); + buf.append(' */\n'); + objPath += "." + this.localeKey; + buf.append('global.' + objPath + ' = {\n'); + // write messages + for (var i=0;i [namespace]"); + print(": Either a single .po file or a directory containing .po files"); + print(": The directory where the generated messages files should be stored"); + print("[namespace]: An optional global namespace where the messages should be"); + print(" stored (eg. a namespace like 'jala' will lead to messages"); + print(" stored in global.jala.messages by their locale."); + quit(); +} + +var input = new java.io.File(arguments[0]); +var output = new java.io.File(arguments[1]); +var namespace = arguments[2]; + +// check if the output destination is a directory +if (output.isFile()) { + print("Invalid arguments: the output destination must be a directory."); + quit(); +} + +if (namespace && namespace.indexOf(".") != -1) { + print("Invalid arguments: Please don't specify complex object paths, as this"); + print("would corrupt the messages file."); + quit(); +} + +// parse the PO file(s) and create the message catalog files +var parser; +if (input.isDirectory()) { + var files = input.listFiles(); + var file; + for (var i=0;i. + + var myReport = JSLINT.report(option); + + If the option is true, then the report will be limited to only errors. +*/ + +String.prototype.entityify = function () { + return this. + replace(/&/g, '&'). + replace(//g, '>'); +}; + +String.prototype.isAlpha = function () { + return (this >= 'a' && this <= 'z\uffff') || + (this >= 'A' && this <= 'Z\uffff'); +}; + + +String.prototype.isDigit = function () { + return (this >= '0' && this <= '9'); +}; + + +// We build the application inside a function so that we produce only a single +// global variable. The function will be invoked, its return value is the JSLINT +// function itself. + +var JSLINT; +JSLINT = function () { + + var anonname, + +// browser contains a set of global names which are commonly provided by a +// web browser environment. + + browser = { + alert: true, + blur: true, + clearInterval: true, + clearTimeout: true, + close: true, + closed: true, + confirm: true, + defaultStatus: true, + document: true, + event: true, + focus: true, + frames: true, + history: true, + Image: true, + length: true, + location: true, + moveBy: true, + moveTo: true, + name: true, + navigator: true, + onblur: true, + onerror: true, + onfocus: true, + onload: true, + onresize: true, + onunload: true, + open: true, + opener: true, + parent: true, + print: true, + prompt: true, + resizeBy: true, + resizeTo: true, + screen: true, + scroll: true, + scrollBy: true, + scrollTo: true, + self: true, + setInterval: true, + setTimeout: true, + status: true, + top: true, + window: true, + XMLHttpRequest: true + }, + funlab, funstack, functions, globals, + +// konfab contains the global names which are provided to a Konfabulator widget. + + konfab = { + alert: true, + animator: true, + appleScript: true, + beep: true, + bytesToUIString: true, + chooseColor: true, + chooseFile: true, + chooseFolder: true, + convertPathToHFS: true, + convertPathToPlatform: true, + closeWidget: true, + CustomAnimation: true, + escape: true, + FadeAnimation: true, + focusWidget: true, + form: true, + include: true, + isApplicationRunning: true, + iTunes: true, + konfabulatorVersion: true, + log: true, + MoveAnimation: true, + openURL: true, + play: true, + popupMenu: true, + print: true, + prompt: true, + reloadWidget: true, + resolvePath: true, + resumeUpdates: true, + RotateAnimation: true, + runCommand: true, + runCommandInBg: true, + saveAs: true, + savePreferences: true, + showWidgetPreferences: true, + sleep: true, + speak: true, + suppressUpdates: true, + tellWidget: true, + unescape: true, + updateNow: true, + yahooCheckLogin: true, + yahooLogin: true, + yahooLogout: true, + COM: true, + filesystem: true, + preferenceGroups: true, + preferences: true, + screen: true, + system: true, + URL: true, + XMLDOM: true, + XMLHttpRequest: true + }, + lines, lookahead, member, noreach, option, prevtoken, stack, + +// standard contains the global names that are provided by standard JavaScript. + + standard = { + Array: true, + Boolean: true, + Date: true, + decodeURI: true, + decodeURIComponent: true, + encodeURI: true, + encodeURIComponent: true, + Error: true, + escape: true, + 'eval': true, + EvalError: true, + Function: true, + isFinite: true, + isNaN: true, + Math: true, + Number: true, + Object: true, + parseInt: true, + parseFloat: true, + RangeError: true, + ReferenceError: true, + RegExp: true, + String: true, + SyntaxError: true, + TypeError: true, + unescape: true, + URIError: true + }, + syntax = {}, token, verb, +/* + xmode is used to adapt to the exceptions in XML parsing. It can have these + states: + false .js script file + " A " attribute + ' A ' attribute + content The content of a script tag + CDATA A CDATA block +*/ + xmode, +/* + xtype identifies the type of document being analyzed. It can have these + states: + false .js script file + html .html file + widget .kon Konfabulator file +*/ + xtype, +// token + tx = /^([(){}[.,:;'"~]|\](\]>)?|\?>?|==?=?|\/(\*(global|extern)*|=|)|\*[\/=]?|\+[+=]?|-[-=]?|%[=>]?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=%\?]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+-]?[0-9]+)?)/, +// string ending in single quote + sx = /^((\\[^\x00-\x1f]|[^\x00-\x1f'\\])*)'/, + sxx = /^(([^\x00-\x1f'])*)'/, +// string ending in double quote + qx = /^((\\[^\x00-\x1f]|[^\x00-\x1f"\\])*)"/, + qxx = /^(([^\x00-\x1f"])*)"/, +// regular expression + rx = /^(\\[^\x00-\x1f]|\[(\\[^\x00-\x1f]|[^\x00-\x1f\\\/])*\]|[^\x00-\x1f\\\/\[])+\/[gim]*/, +// star slash + lx = /\*\/|\/\*/, +// global identifier + gx = /^([a-zA-Z_$][a-zA-Z0-9_$]*)/, +// identifier + ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*$)/, +// global separators + hx = /^[\x00-\x20,]*(\*\/)?/, +// whitespace + wx = /^\s*(\/\/.*\r*$)?/; + +// Make a new object that inherits from an existing object. + + function object(o) { + function F() {} + F.prototype = o; + return new F(); + } + +// Produce an error warning. + + function warning(m, x, y) { + var l, c, t = typeof x === 'object' ? x : token; + if (typeof x === 'number') { + l = x; + c = y || 0; + } else { + if (t.id === '(end)') { + t = prevtoken; + } + l = t.line || 0; + c = t.from || 0; + } + JSLINT.errors.push({ + id: '(error)', + reason: m, + evidence: lines[l] || '', + line: l, + character: c + }); + if (option.passfail) { + JSLINT.errors.push(null); + throw null; + } + } + + function error(m, x, y) { + warning(m, x, y); + JSLINT.errors.push(null); + throw null; + } + + +// lexical analysis + + var lex = function () { + var character, from, line, s; + +// Private lex methods + + function nextLine() { + line += 1; + if (line >= lines.length) { + return false; + } + character = 0; + s = lines[line]; + return true; + } + +// Produce a token object. The token inherits from a syntax symbol. + + function it(type, value) { + var t; + if (type === '(punctuator)') { + t = syntax[value]; + } else if (type === '(identifier)') { + t = syntax[value]; + if (!t || typeof t != 'object') { + t = syntax[type]; + } + } else { + t = syntax[type]; + } + if (!t || typeof t != 'object') { + error("Unrecognized symbol: '" + value + "' " + type); + } + t = object(t); + if (value || type === '(string)') { + t.value = value; + } + t.line = line; + t.character = character; + t.from = from; + return t; + } + +// Public lex methods + + return { + init: function (source) { + if (typeof source === 'string') { + lines = source.split('\n'); + if (lines.length == 1) { + lines = lines[0].split('\r'); + } + } else { + lines = source; + } + line = 0; + character = 0; + from = 0; + s = lines[0]; + }, + +// token -- this is called by advance to get the next token. + + token: function () { + var c, i, l, r, t; + + function string(x) { + var a, j; + r = x.exec(s); + if (r) { + t = r[1]; + l = r[0].length; + s = s.substr(l); + character += l; + if (xmode == 'script') { + if (t.indexOf('<\/') >= 0) { + warning( + 'Expected "...<\\/..." and instead saw "...<\/...".', token); + } + } + return it('(string)', r[1]); + } else { + for (j = 0; j < s.length; j += 1) { + a = s.charAt(j); + if (a < ' ') { + if (a === '\n' || a === '\r') { + break; + } + error("Control character in string: " + + s.substring(0, j), line, character + j); + } + } + error("Unclosed string: " + s, line, character); + } + } + + for (;;) { + if (!s) { + return it(nextLine() ? '(endline)' : '(end)', ''); + } + r = wx.exec(s); + if (!r || !r[0]) { + break; + } + l = r[0].length; + s = s.substr(l); + character += l; + if (s) { + break; + } + } + from = character; + r = tx.exec(s); + if (r) { + t = r[0]; + l = t.length; + s = s.substr(l); + character += l; + c = t.substr(0, 1); + +// identifier + + if (c.isAlpha() || c === '_' || c === '$') { + return it('(identifier)', t); + } + +// number + + if (c.isDigit()) { + if (token.id === '.') { + warning( + "A decimal fraction should have a zero before the decimal point.", + token); + } + if (!isFinite(Number(t))) { + warning("Bad number: '" + t + "'.", + line, character); + } + if (s.substr(0, 1).isAlpha()) { + error("Space is required after a number: '" + + t + "'.", line, character); + } + if (c === '0' && t.substr(1,1).isDigit()) { + warning("Don't use extra leading zeros: '" + + t + "'.", line, character); + } + if (t.substr(t.length - 1) === '.') { + warning( + "A trailing decimal point can be confused with a dot: '" + t + "'.", + line, character); + } + return it('(number)', t); + } + +// string + + if (t === '"') { + return (xmode === '"' || xmode === 'string') ? + it('(punctuator)', t) : + string(xmode === 'xml' ? qxx : qx); + } + if (t === "'") { + return (xmode === "'" || xmode === 'string') ? + it('(punctuator)', t) : + string(xmode === 'xml' ? sxx : sx); + } + +// unbegun comment + + if (t === '/*') { + for (;;) { + i = s.search(lx); + if (i >= 0) { + break; + } + if (!nextLine()) { + error("Unclosed comment.", token); + } + } + character += i + 2; + if (s.substr(i, 1) === '/') { + error("Nested comment."); + } + s = s.substr(i + 2); + return this.token(); + } + +// /*extern + + if (t === '/*extern' || t === '/*global') { + for (;;) { + r = hx.exec(s); + if (r) { + l = r[0].length; + s = s.substr(l); + character += l; + if (r[1] === '*/') { + return this.token(); + } + } + if (s) { + r = gx.exec(s); + if (r) { + l = r[0].length; + s = s.substr(l); + character += l; + globals[r[1]] = true; + } else { + error("Bad extern identifier: '" + + s + "'.", line, character); + } + } else if (!nextLine()) { + error("Unclosed comment."); + } + } + } + +// punctuator + + return it('(punctuator)', t); + } + error("Unexpected token: " + (t || s.substr(0, 1)), + line, character); + }, + +// skip -- skip past the next occurrence of a particular string. +// If the argument is empty, skip to just before the next '<' character. +// This is used to ignore HTML content. Return false if it isn't found. + + skip: function (to) { + if (token.id) { + if (!to) { + to = ''; + if (token.id.substr(0, 1) === '<') { + lookahead.push(token); + return true; + } + } else if (token.id.indexOf(to) >= 0) { + return true; + } + } + prevtoken = token; + token = syntax['(error)']; + for (;;) { + var i = s.indexOf(to || '<'); + if (i >= 0) { + character += i + to.length; + s = s.substr(i + to.length); + return true; + } + if (!nextLine()) { + break; + } + } + return false; + }, + +// regex -- this is called by parse when it sees '/' being used as a prefix. + + regex: function () { + var l, r = rx.exec(s), x; + if (r) { + l = r[0].length; + character += l; + s = s.substr(l); + x = r[1]; + return it('(regex)', x); + } + error("Bad regular expression: " + s); + } + }; + }(); + + function builtin(name) { + return standard[name] === true || + globals[name] === true || + ((xtype === 'widget' || option.widget) && konfab[name] === true) || + ((xtype === 'html' || option.browser) && browser[name] === true); + } + + function addlabel(t, type) { + if (t) { + if (typeof funlab[t] === 'string') { + switch (funlab[t]) { + case 'var': + case 'var*': + if (type === 'global') { + funlab[t] = 'var*'; + return; + } + break; + case 'global': + if (type === 'var') { + warning('Var ' + t + + ' was used before it was declared.', prevtoken); + return; + } + if (type === 'var*' || type === 'global') { + return; + } + break; + case 'function': + case 'parameter': + if (type === 'global') { + return; + } + break; + } + warning("Identifier '" + t + "' already declared as " + + funlab[t], prevtoken); + } + funlab[t] = type; + } + } + + +// We need a peek function. If it has an argument, it peeks that much farther +// ahead. It is used to distinguish +// for ( var i in ... +// from +// for ( var i = ... + + function peek(i) { + var j = 0, t; + if (token == syntax['(error)']) { + return token; + } + if (typeof i === 'undefined') { + i = 0; + } + while (j <= i) { + t = lookahead[j]; + if (!t) { + t = lookahead[j] = lex.token(); + } + j += 1; + } + return t; + } + + + var badbreak = {')': true, ']': true, '++': true, '--': true}; + +// Produce the next token. It looks for programming errors. + + function advance(id, t) { + var l; + switch (prevtoken.id) { + case '(number)': + if (token.id === '.') { + warning( +"A dot following a number can be confused with a decimal point.", prevtoken); + } + break; + case '-': + if (token.id === '-' || token.id === '--') { + warning("Confusing minusses."); + } + break; + case '+': + if (token.id === '+' || token.id === '++') { + warning("Confusing plusses."); + } + break; + } + if (prevtoken.type === '(string)' || prevtoken.identifier) { + anonname = prevtoken.value; + } + + if (id && token.value != id) { + if (t) { + if (token.id === '(end)') { + warning("Unmatched '" + t.id + "'.", t); + } else { + warning("Expected '" + id + "' to match '" + + t.id + "' from line " + (t.line + 1) + + " and instead saw '" + token.value + "'."); + } + } else { + warning("Expected '" + id + "' and instead saw '" + + token.value + "'."); + } + } + prevtoken = token; + for (;;) { + token = lookahead.shift() || lex.token(); + if (token.id === ''); + } else { + error("Unexpected token '') { + if (xmode === 'CDATA') { + xmode = 'script'; + } else { + error("Unexpected token ']]>"); + } + } else if (token.id !== '(endline)') { + break; + } + if (xmode === '"' || xmode === "'") { + error("Missing '" + xmode + "'.", prevtoken); + } + l = !xmode && !option.laxLineEnd && + (prevtoken.type == '(string)' || prevtoken.type == '(number)' || + prevtoken.type == '(identifier)' || badbreak[prevtoken.id]); + } + if (l && token.id != '{' && token.id != '}' && token.id != ']') { + warning( + "Line breaking error: '" + + prevtoken.value + "'.", prevtoken); + } + if (xtype === 'widget' && xmode === 'script' && token.id) { + l = token.id.charAt(0); + if (l === '<' || l === '&') { + token.nud = token.led = null; + token.lbp = 0; + token.reach = true; + } + } + } + + + function advanceregex() { + token = lex.regex(); + } + + + function beginfunction(i) { + var f = {'(name)': i, '(line)': token.line + 1, '(context)': funlab}; + funstack.push(funlab); + funlab = f; + functions.push(funlab); + } + + + function endfunction() { + funlab = funstack.pop(); + } + + +// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it +// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is +// like nud except that it is only used on the first token of a statement. +// Having .fud makes it much easier to define JavaScript. I retained Pratt's +// nomenclature, even though it isn't very descriptive. + +// .nud Null denotation +// .fud First null denotation +// .led Left denotation +// lbp Left binding power +// rbp Right binding power + +// They are key to the parsing method called Top Down Operator Precedence. + + function parse(rbp, initial) { + var l, left, o; + if (token.id && token.id === '/') { + if (prevtoken.id != '(' && prevtoken.id != '=' && + prevtoken.id != ':' && prevtoken.id != ',' && + prevtoken.id != '=') { + warning( +"Expected to see a '(' or '=' or ':' or ',' preceding a regular expression literal, and instead saw '" + + prevtoken.value + "'.", prevtoken); + } + advanceregex(); + } + if (token.id === '(end)') { + warning("Unexpected early end of program", prevtoken); + } + advance(); + if (initial) { + anonname = 'anonymous'; + verb = prevtoken.value; + } + if (initial && prevtoken.fud) { + prevtoken.fud(); + } else { + if (prevtoken.nud) { + o = prevtoken.exps; + left = prevtoken.nud(); + } else { + if (token.type === '(number)' && prevtoken.id === '.') { + warning( +"A leading decimal point can be confused with a dot: ." + token.value, + prevtoken); + } + error("Expected an identifier and instead saw '" + + prevtoken.id + "'.", prevtoken); + } + while (rbp < token.lbp) { + o = token.exps; + advance(); + if (prevtoken.led) { + left = prevtoken.led(left); + } else { + error("Expected an operator and instead saw '" + + prevtoken.id + "'."); + } + } + if (initial && !o) { + warning( +"Expected an assignment or function call and instead saw an expression.", + prevtoken); + } + } + if (l) { + funlab[l] = 'label'; + } + if (left && left.id === 'eval') { + warning("evalError", left); + } + return left; + } + + +// Parasitic constructors for making the symbols that will be inherited by +// tokens. + + function symbol(s, p) { + return syntax[s] || (syntax[s] = {id: s, lbp: p, value: s}); + } + + + function delim(s) { + return symbol(s, 0); + } + + + function stmt(s, f) { + var x = delim(s); + x.identifier = x.reserved = true; + x.fud = f; + return x; + } + + + function blockstmt(s, f) { + var x = stmt(s, f); + x.block = true; + return x; + } + + + function prefix(s, f) { + var x = symbol(s, 150); + x.nud = (typeof f === 'function') ? f : function () { + parse(150); + return this; + }; + return x; + } + + + function prefixname(s, f) { + var x = prefix(s, f); + x.identifier = x.reserved = true; + return x; + } + + + function type(s, f) { + var x = delim(s); + x.type = s; + x.nud = f; + return x; + } + + + function reserve(s, f) { + var x = type(s, f); + x.identifier = x.reserved = true; + return x; + } + + + function reservevar(s) { + return reserve(s, function () { + return this; + }); + } + + + function infix(s, f, p) { + var x = symbol(s, p); + x.led = (typeof f === 'function') ? f : function (left) { + return [f, left, parse(p)]; + }; + return x; + } + + + function assignop(s, f) { + symbol(s, 20).exps = true; + return infix(s, function (left) { + if (left) { + if (left.id === '.' || left.id === '[' || + (left.identifier && !left.reserved)) { + parse(19); + return left; + } + if (left == syntax['function']) { + if (option.jscript) { + parse(19); + return left; + } else { + warning( +"Expected an identifier in an assignment, and instead saw a function invocation.", + prevtoken); + } + } + } + error("Bad assignment.", this); + }, 20); + } + + + function suffix(s, f) { + var x = symbol(s, 150); + x.led = function (left) { + if (option.plusplus) { + warning(this.id + " is considered harmful.", this); + } + return [f, left]; + }; + return x; + } + + + function optionalidentifier() { + if (token.reserved) { + warning("Expected an identifier and instead saw '" + + token.id + "' (a reserved word)."); + } + if (token.identifier) { + advance(); + return prevtoken.value; + } + } + + + function identifier() { + var i = optionalidentifier(); + if (i) { + return i; + } + if (prevtoken.id === 'function' && token.id === '(') { + warning("Missing name in function statement."); + } else { + error("Expected an identifier and instead saw '" + + token.value + "'.", token); + } + } + + + function reachable(s) { + var i = 0, t; + if (token.id != ';' || noreach) { + return; + } + for (;;) { + t = peek(i); + if (t.reach) { + return; + } + if (t.id != '(endline)') { + if (t.id === 'function') { + warning( +"Inner functions should be listed at the top of the outer function.", t); + break; + } + warning("Unreachable '" + t.value + "' after '" + s + + "'.", t); + break; + } + i += 1; + } + } + + + function statement() { + var t = token; + while (t.id === ';') { + warning("Unnecessary semicolon", t); + advance(';'); + t = token; + if (t.id === '}') { + return; + } + } + if (t.identifier && !t.reserved && peek().id === ':') { + advance(); + advance(':'); + addlabel(t.value, 'live*'); + if (!token.labelled) { + warning("Label '" + t.value + + "' on unlabelable statement '" + token.value + "'.", + token); + } + if (t.value.toLowerCase() == 'javascript') { + warning("Label '" + t.value + + "' looks like a javascript url.", + token); + } + token.label = t.value; + t = token; + } + parse(0, true); + if (!t.block) { + if (token.id != ';') { + warning("Missing ';'", prevtoken.line, + prevtoken.from + prevtoken.value.length); + } else { + advance(';'); + } + } + } + + + function statements() { + while (!token.reach) { + statement(); + } + } + + + function block() { + var t = token; + if (token.id === '{') { + advance('{'); + statements(); + advance('}', t); + } else { + warning("Missing '{' before '" + token.value + "'."); + noreach = true; + statement(); + noreach = false; + } + verb = null; + } + + +// An identity function, used by string and number tokens. + + function idValue() { + return this; + } + + + function countMember(m) { + if (typeof member[m] === 'number') { + member[m] += 1; + } else { + member[m] = 1; + } + } + + +// Common HTML attributes that carry scripts. + + var scriptstring = { + onblur: true, + onchange: true, + onclick: true, + ondblclick: true, + onfocus: true, + onkeydown: true, + onkeypress: true, + onkeyup: true, + onload: true, + onmousedown: true, + onmousemove: true, + onmouseout: true, + onmouseover: true, + onmouseup: true, + onreset: true, + onselect: true, + onsubmit: true, + onunload: true + }; + + +// XML types. Currently we support html and widget. + + var xmltype = { + HTML: { + doBegin: function (n) { + if (!option.cap) { + warning("HTML case error."); + } + xmltype.html.doBegin(); + } + }, + html: { + doBegin: function (n) { + xtype = 'html'; + xmltype.html.script = false; + }, + doTagName: function (n, p) { + var i, t = xmltype.html.tag[n], x; + if (!t) { + error('Unrecognized tag: <' + n + '>. ' + + (n === n.toLowerCase() ? + 'Did you mean <' + n.toLowerCase() + '>?' : '')); + } + x = t.parent; + if (x) { + if (x.indexOf(' ' + p + ' ') < 0) { + error('A <' + n + '> must be within <' + x + '>', + prevtoken); + } + } else { + i = stack.length; + do { + if (i <= 0) { + error('A <' + n + '> must be within the body', + prevtoken); + } + i -= 1; + } while (stack[i].name !== 'body'); + } + xmltype.html.script = n === 'script'; + return t.simple; + }, + doAttribute: function (n, a) { + if (n === 'script') { + if (a === 'src') { + xmltype.html.script = false; + return 'string'; + } else if (a === 'language') { + warning("The 'language' attribute is deprecated", + prevtoken); + return false; + } + } + return scriptstring[a] && 'script'; + }, + doIt: function (n) { + return xmltype.html.script ? 'script' : + n !== 'html' && xmltype.html.tag[n].special && 'special'; + }, + tag: { + a: {}, + abbr: {}, + acronym: {}, + address: {}, + applet: {}, + area: {simple: true, parent: ' map '}, + b: {}, + base: {simple: true, parent: ' head '}, + bdo: {}, + big: {}, + blockquote: {}, + body: {parent: ' html noframes '}, + br: {simple: true}, + button: {}, + caption: {parent: ' table '}, + center: {}, + cite: {}, + code: {}, + col: {simple: true, parent: ' table colgroup '}, + colgroup: {parent: ' table '}, + dd: {parent: ' dl '}, + del: {}, + dfn: {}, + dir: {}, + div: {}, + dl: {}, + dt: {parent: ' dl '}, + em: {}, + embed: {}, + fieldset: {}, + font: {}, + form: {}, + frame: {simple: true, parent: ' frameset '}, + frameset: {parent: ' html frameset '}, + h1: {}, + h2: {}, + h3: {}, + h4: {}, + h5: {}, + h6: {}, + head: {parent: ' html '}, + html: {}, + hr: {simple: true}, + i: {}, + iframe: {}, + img: {simple: true}, + input: {simple: true}, + ins: {}, + kbd: {}, + label: {}, + legend: {parent: ' fieldset '}, + li: {parent: ' dir menu ol ul '}, + link: {simple: true, parent: ' head '}, + map: {}, + menu: {}, + meta: {simple: true, parent: ' head noscript '}, + noframes: {parent: ' html body '}, + noscript: {parent: ' html head body frameset '}, + object: {}, + ol: {}, + optgroup: {parent: ' select '}, + option: {parent: ' optgroup select '}, + p: {}, + param: {simple: true, parent: ' applet object '}, + pre: {}, + q: {}, + samp: {}, + script: {parent: +' head body p div span abbr acronym address bdo blockquote cite code del dfn em ins kbd pre samp strong th td var '}, + select: {}, + small: {}, + span: {}, + strong: {}, + style: {parent: ' head ', special: true}, + sub: {}, + sup: {}, + table: {}, + tbody: {parent: ' table '}, + td: {parent: ' tr '}, + textarea: {}, + tfoot: {parent: ' table '}, + th: {parent: ' tr '}, + thead: {parent: ' table '}, + title: {parent: ' head '}, + tr: {parent: ' table tbody thead tfoot '}, + tt: {}, + u: {}, + ul: {}, + 'var': {} + } + }, + widget: { + doBegin: function (n) { + xtype = 'widget'; + }, + doTagName: function (n, p) { + var t = xmltype.widget.tag[n]; + if (!t) { + error('Unrecognized tag: <' + n + '>. '); + } + var x = t.parent; + if (x.indexOf(' ' + p + ' ') < 0) { + error('A <' + n + '> must be within <' + x + '>', prevtoken); + } + }, + doAttribute: function (n, a) { + var t = xmltype.widget.tag[a]; + if (!t) { + error('Unrecognized attribute: <' + n + ' ' + a + '>. '); + } + var x = t.parent; + if (x.indexOf(' ' + n + ' ') < 0) { + error('Attribute ' + a + ' does not belong in <' + + n + '>'); + } + return t.script ? 'script' : a === 'name' ? 'define' : 'string'; + }, + doIt: function (n) { + var x = xmltype.widget.tag[n]; + return x && x.script && 'script'; + }, + tag: { + "about-box": {parent: ' widget '}, + "about-image": {parent: ' about-box '}, + "about-text": {parent: ' about-box '}, + "about-version": {parent: ' about-box '}, + action: {parent: ' widget ', script: true}, + alignment: {parent: ' image text textarea window '}, + author: {parent: ' widget '}, + autoHide: {parent: ' scrollbar '}, + bgColor: {parent: ' text textarea '}, + bgOpacity: {parent: ' text textarea '}, + checked: {parent: ' image '}, + clipRect: {parent: ' image '}, + color: {parent: ' about-text about-version shadow text textarea '}, + contextMenuItems: {parent: ' frame image text textarea window '}, + colorize: {parent: ' image '}, + columns: {parent: ' textarea '}, + company: {parent: ' widget '}, + copyright: {parent: ' widget '}, + data: {parent: ' about-text about-version text textarea '}, + debug: {parent: ' widget '}, + defaultValue: {parent: ' preference '}, + defaultTracking: {parent: ' widget '}, + description: {parent: ' preference '}, + directory: {parent: ' preference '}, + editable: {parent: ' textarea '}, + enabled: {parent: ' menuItem '}, + extension: {parent: ' preference '}, + file: {parent: ' action preference '}, + fillMode: {parent: ' image '}, + font: {parent: ' about-text about-version text textarea '}, + frame: {parent: ' frame window '}, + group: {parent: ' preference '}, + hAlign: {parent: ' frame image scrollbar text textarea '}, + height: {parent: ' frame image scrollbar text textarea window '}, + hidden: {parent: ' preference '}, + hLineSize: {parent: ' frame '}, + hOffset: {parent: ' about-text about-version frame image scrollbar shadow text textarea window '}, + hotkey: {parent: ' widget '}, + hRegistrationPoint: {parent: ' image '}, + hslAdjustment: {parent: ' image '}, + hslTinting: {parent: ' image '}, + hScrollBar: {parent: ' frame '}, + icon: {parent: ' preferenceGroup '}, + image: {parent: ' about-box frame window widget '}, + interval: {parent: ' action timer '}, + key: {parent: ' hotkey '}, + kind: {parent: ' preference '}, + level: {parent: ' window '}, + lines: {parent: ' textarea '}, + loadingSrc: {parent: ' image '}, + max: {parent: ' scrollbar '}, + maxLength: {parent: ' preference '}, + menuItem: {parent: ' contextMenuItems '}, + min: {parent: ' scrollbar '}, + minimumVersion: {parent: ' widget '}, + minLength: {parent: ' preference '}, + missingSrc: {parent: ' image '}, + modifier: {parent: ' hotkey '}, + name: {parent: ' hotkey image preference preferenceGroup text textarea timer window '}, + notSaved: {parent: ' preference '}, + onContextMenu: {parent: ' frame image text textarea window ', script: true}, + onDragDrop: {parent: ' frame image text textarea ', script: true}, + onDragEnter: {parent: ' frame image text textarea ', script: true}, + onDragExit: {parent: ' frame image text textarea ', script: true}, + onFirstDisplay: {parent: ' window ', script: true}, + onGainFocus: {parent: ' textarea window ', script: true}, + onKeyDown: {parent: ' hotkey text textarea ', script: true}, + onKeyPress: {parent: ' textarea ', script: true}, + onKeyUp: {parent: ' hotkey text textarea ', script: true}, + onImageLoaded: {parent: ' image ', script: true}, + onLoseFocus: {parent: ' textarea window ', script: true}, + onMouseDown: {parent: ' frame image text textarea ', script: true}, + onMouseEnter: {parent: ' frame image text textarea ', script: true}, + onMouseExit: {parent: ' frame image text textarea ', script: true}, + onMouseMove: {parent: ' frame image text ', script: true}, + onMouseUp: {parent: ' frame image text textarea ', script: true}, + onMouseWheel: {parent: ' frame ', script: true}, + onMultiClick: {parent: ' frame image text textarea window ', script: true}, + onSelect: {parent: ' menuItem ', script: true}, + onTimerFired: {parent: ' timer ', script: true}, + onValueChanged: {parent: ' scrollbar ', script: true}, + opacity: {parent: ' frame image scrollbar shadow text textarea window '}, + option: {parent: ' preference widget '}, + optionValue: {parent: ' preference '}, + order: {parent: ' preferenceGroup '}, + orientation: {parent: ' scrollbar '}, + pageSize: {parent: ' scrollbar '}, + preference: {parent: ' widget '}, + preferenceGroup: {parent: ' widget '}, + remoteAsync: {parent: ' image '}, + requiredPlatform: {parent: ' widget '}, + rotation: {parent: ' image '}, + scrollX: {parent: ' frame '}, + scrollY: {parent: ' frame '}, + secure: {parent: ' preference textarea '}, + scrollbar: {parent: ' text textarea '}, + shadow: {parent: ' about-text text window '}, + size: {parent: ' about-text about-version text textarea '}, + spellcheck: {parent: ' textarea '}, + src: {parent: ' image '}, + srcHeight: {parent: ' image '}, + srcWidth: {parent: ' image '}, + style: {parent: ' about-text about-version preference text textarea '}, + text: {parent: ' frame window '}, + textarea: {parent: ' frame window '}, + timer: {parent: ' widget '}, + thumbColor: {parent: ' scrollbar '}, + ticking: {parent: ' timer '}, + ticks: {parent: ' preference '}, + tickLabel: {parent: ' preference '}, + tileOrigin: {parent: ' image '}, + title: {parent: ' menuItem preference preferenceGroup window '}, + tooltip: {parent: ' image text textarea '}, + tracking: {parent: ' image '}, + trigger: {parent: ' action '}, + truncation: {parent: ' text '}, + type: {parent: ' preference '}, + useFileIcon: {parent: ' image '}, + vAlign: {parent: ' frame image scrollbar text textarea '}, + value: {parent: ' preference scrollbar '}, + version: {parent: ' widget '}, + visible: {parent: ' frame image scrollbar text textarea window '}, + vLineSize: {parent: ' frame '}, + vOffset: {parent: ' about-text about-version frame image scrollbar shadow text textarea window '}, + vRegistrationPoint: {parent: ' image '}, + vScrollBar: {parent: ' frame '}, + width: {parent: ' frame image scrollbar text textarea window '}, + window: {parent: ' widget '}, + zOrder: {parent: ' frame image scrollbar text textarea '} + } + } + }; + + function xmlword(tag) { + var w = token.value; + if (!token.identifier) { + if (token.id === '<') { + error(tag ? "Expected < and saw '<'" : "Missing '>'", + prevtoken); + } else { + warning("Missing quotes", prevtoken); + } + } + advance(); + while (token.id === '-' || token.id === ':') { + w += token.id; + advance(); + if (!token.identifier) { + error('Bad name: ' + w + token.value); + } + w += token.value; + advance(); + } + return w; + } + + function xml() { + var a, e, n, q, t; + xmode = 'xml'; + stack = []; + for (;;) { + switch (token.value) { + case '<': + advance('<'); + t = token; + n = xmlword(true); + t.name = n; + if (!xtype) { + if (xmltype[n]) { + xmltype[n].doBegin(); + n = xtype; + e = false; + } else { + error("Unrecognized <" + n + ">"); + } + } else { + if (option.cap && xtype === 'html') { + n = n.toLowerCase(); + } + e = xmltype[xtype].doTagName(n, stack[stack.length - 1].type); + } + t.type = n; + for (;;) { + if (token.id === '/') { + advance('/'); + e = true; + break; + } + if (token.id && token.id.substr(0, 1) === '>') { + break; + } + a = xmlword(); + switch (xmltype[xtype].doAttribute(n, a)) { + case 'script': + xmode = 'string'; + advance('='); + q = token.id; + if (q !== '"' && q !== "'") { + error('Missing quote.'); + } + xmode = q; + advance(q); + statements(); + if (token.id !== q) { + error( + 'Missing close quote on script attribute'); + } + xmode = 'xml'; + advance(q); + break; + case 'value': + advance('='); + if (!token.identifier && + token.type != '(string)' && + token.type != '(number)') { + error('Bad value: ' + token.value); + } + advance(); + break; + case 'string': + advance('='); + if (token.type !== '(string)') { + error('Bad value: ' + token.value); + } + advance(); + break; + case 'define': + advance('='); + if (token.type !== '(string)') { + error('Bad value: ' + token.value); + } + addlabel(token.value, 'global'); + advance(); + break; + default: + if (token.id === '=') { + advance('='); + if (!token.identifier && + token.type != '(string)' && + token.type != '(number)') { + } + advance(); + } + } + } + switch (xmltype[xtype].doIt(n)) { + case 'script': + xmode = 'script'; + advance('>'); + statements(); + xmode = 'xml'; + break; + case 'special': + e = true; + n = ''; + if (!lex.skip(n)) { + error("Missing " + n, t); + } + break; + default: + lex.skip('>'); + } + if (!e) { + stack.push(t); + } + break; + case ''); + } + if (t.name != n) { + error('Expected and instead saw '); + } + if (token.id !== '>') { + error("Expected '>'"); + } + lex.skip('>'); + break; + case '') { + break; + } + if (token.id === '<' || token.id === '(end)') { + error("Missing '>'.", prevtoken); + } + } + lex.skip('>'); + break; + case ''); + break; + case '<%': + lex.skip('%>'); + break; + case '') { + break; + } + if (token.id === '' || token.id === '(end)') { + error("Missing '?>'.", prevtoken); + } + } + lex.skip('?>'); + break; + case '<=': + case '<<': + case '<<=': + error("Expected '<'."); + break; + case '(end)': + return; + } + if (!lex.skip('')) { + if (stack.length) { + t = stack.pop(); + error('Missing ', t); + } + return; + } + advance(); + } + } + + +// Build the syntax table by declaring the syntactic elements of the language. + + type('(number)', idValue); + type('(string)', idValue); + + syntax['(identifier)'] = { + type: '(identifier)', + lbp: 0, + identifier: true, + nud: function () { + if (option.undef && !builtin(this.value) && + xmode !== '"' && xmode !== "'") { + var c = funlab; + while (!c[this.value]) { + c = c['(context)']; + if (!c) { + warning("Undefined variable: " + this.value, + prevtoken); + break; + } + } + } + addlabel(this.value, 'global'); + return this; + }, + led: function () { + error("Expected an operator and instead saw '" + + token.value + "'."); + } + }; + + type('(regex)', function () { + return [this.id, this.value, this.flags]; + }); + + delim('(endline)'); + delim('(begin)'); + delim('(end)').reach = true; + delim(''); + delim('?>'); + delim('(error)').reach = true; + delim('}').reach = true; + delim(')'); + delim(']'); + delim(']]>').reach = true; + delim('"').reach = true; + delim("'").reach = true; + delim(';'); + delim(':').reach = true; + delim(','); + reservevar('eval'); + reserve('else'); + reserve('case').reach = true; + reserve('default').reach = true; + reserve('catch'); + reserve('finally'); + reservevar('arguments'); + reservevar('false'); + reservevar('Infinity'); + reservevar('NaN'); + reservevar('null'); + reservevar('this'); + reservevar('true'); + reservevar('undefined'); + assignop('=', 'assign', 20); + assignop('+=', 'assignadd', 20); + assignop('-=', 'assignsub', 20); + assignop('*=', 'assignmult', 20); + assignop('/=', 'assigndiv', 20).nud = function () { + warning( + "A regular expression literal can be confused with '/='."); + }; + assignop('%=', 'assignmod', 20); + assignop('&=', 'assignbitand', 20); + assignop('|=', 'assignbitor', 20); + assignop('^=', 'assignbitxor', 20); + assignop('<<=', 'assignshiftleft', 20); + assignop('>>=', 'assignshiftright', 20); + assignop('>>>=', 'assignshiftrightunsigned', 20); + infix('?', function (left) { + parse(10); + advance(':'); + parse(10); + }, 30); + + infix('||', 'or', 40); + infix('&&', 'and', 50); + infix('|', 'bitor', 70); + infix('^', 'bitxor', 80); + infix('&', 'bitand', 90); + infix('==', function (left) { + var t = token; + if ( (t.type === '(number)' && !+t.value) || + (t.type === '(string)' && !t.value) || + t.type === 'true' || t.type === 'false' || + t.type === 'undefined' || t.type === 'null') { + warning("Use '===' to compare with '" + t.value + "'.", t); + } + return ['==', left, parse(100)]; + }, 100); + infix('===', 'equalexact', 100); + infix('!=', function (left) { + var t = token; + if ( (t.type === '(number)' && !+t.value) || + (t.type === '(string)' && !t.value) || + t.type === 'true' || t.type === 'false' || + t.type === 'undefined' || t.type === 'null') { + warning("Use '!==' to compare with '" + t.value + "'.", t); + } + return ['!=', left, parse(100)]; + }, 100); + infix('!==', 'notequalexact', 100); + infix('<', 'less', 110); + infix('>', 'greater', 110); + infix('<=', 'lessequal', 110); + infix('>=', 'greaterequal', 110); + infix('<<', 'shiftleft', 120); + infix('>>', 'shiftright', 120); + infix('>>>', 'shiftrightunsigned', 120); + infix('in', 'in', 120); + infix('instanceof', 'instanceof', 120); + infix('+', 'addconcat', 130); + prefix('+', 'num'); + infix('-', 'sub', 130); + prefix('-', 'neg'); + infix('*', 'mult', 140); + infix('/', 'div', 140); + infix('%', 'mod', 140); + + suffix('++', 'postinc'); + prefix('++', 'preinc'); + syntax['++'].exps = true; + + suffix('--', 'postdec'); + prefix('--', 'predec'); + syntax['--'].exps = true; + prefixname('delete', function () { + parse(0); + }).exps = true; + + + prefix('~', 'bitnot'); + prefix('!', 'not'); + prefixname('typeof', 'typeof'); + prefixname('new', function () { + var c = parse(155), + i; + if (c) { + if (c.identifier) { + c['new'] = true; + switch (c.value) { + case 'Object': + warning('Use the object literal notation {}.', prevtoken); + break; + case 'Array': + warning('Use the array literal notation [].', prevtoken); + break; + case 'Number': + case 'String': + case 'Boolean': + warning("Do not use the " + c.value + + " function as a constructor.", prevtoken); + break; + case 'Function': + if (!option.evil) { + warning('The Function constructor is eval.'); + } + break; + default: + i = c.value.substr(0, 1); + if (i < 'A' || i > 'Z') { + warning( + 'A constructor name should start with an uppercase letter.', c); + } + } + } else { + if (c.id !== '.' && c.id !== '[' && c.id !== '(') { + warning('Bad constructor', prevtoken); + } + } + } else { + warning('Weird construction.', this); + } + if (token.id === '(') { + advance('('); + if (token.id !== ')') { + for (;;) { + parse(10); + if (token.id !== ',') { + break; + } + advance(','); + } + } + advance(')'); + } else { + warning("Missing '()' invoking a constructor."); + } + return syntax['function']; + }); + syntax['new'].exps = true; + + infix('.', function (left) { + var m = identifier(); + if (typeof m === 'string') { + countMember(m); + } + if (!option.evil && left && left.value === 'document' && + (m === 'write' || m === 'writeln')) { + warning("document.write can be a form of eval.", left); + } + this.left = left; + this.right = m; + return this; + }, 160); + + infix('(', function (left) { + var n = 0, p = []; + if (left && left.type === '(identifier)') { + if (left.value.match(/^[A-Z](.*[a-z].*)?$/)) { + if (left.value !== 'Number' && left.value !== 'String') { + warning("Missing 'new' prefix when invoking a constructor", + left); + } + } + } + if (token.id !== ')') { + for (;;) { + p[p.length] = parse(10); + n += 1; + if (token.id !== ',') { + break; + } + advance(','); + } + } + advance(')'); + if (typeof left === 'object') { + if (left.value == 'parseInt' && n == 1) { + warning("Missing radix parameter", left); + } + if (!option.evil) { + if (left.value == 'eval' || left.value == 'Function') { + warning("eval is evil", left); + } else if (p[0] && p[0].id === '(string)' && + (left.value === 'setTimeout' || + left.value === 'setInterval')) { + warning( + "Implied eval is evil. Use a function argument instead of a string", left); + } + } + if (!left.identifier && left.id !== '.' && + left.id !== '[' && left.id !== '(') { + warning('Bad invocation.', left); + } + + } + return syntax['function']; + }, 155).exps = true; + + prefix('(', function () { + parse(0); + advance(')', this); + }); + + infix('[', function (left) { + var e = parse(0); + if (e && e.type === '(string)') { + countMember(e.value); + if (ix.test(e.value)) { + var s = syntax[e.value]; + if (!s || !s.reserved) { + warning("This is better written in dot notation.", e); + } + } + } + advance(']', this); + this.left = left; + this.right = e; + return this; + }, 160); + + prefix('[', function () { + if (token.id === ']') { + advance(']'); + return; + } + for (;;) { + parse(10); + if (token.id === ',') { + advance(','); + if (token.id === ']' || token.id === ',') { + warning('Extra comma.', prevtoken); + } + } else { + advance(']', this); + return; + } + } + }, 160); + + (function (x) { + x.nud = function () { + var i; + if (token.id === '}') { + advance('}'); + return; + } + for (;;) { + i = optionalidentifier(true); + if (!i && (token.id === '(string)' || token.id === '(number)')) { + i = token.id; + advance(); + } + if (!i) { + error("Expected an identifier and instead saw '" + + token.value + "'."); + } + if (typeof i.value === 'string') { + countMember(i.value); + } + advance(':'); + parse(10); + if (token.id === ',') { + advance(','); + if (token.id === ',' || token.id === '}') { + warning("Extra comma."); + } + } else { + advance('}', this); + return; + } + } + }; + x.fud = function () { + error( + "Expected to see a statement and instead saw a block."); + }; + })(delim('{')); + + + function varstatement() { + var i, n; + for (;;) { + n = identifier(); + if (!option.redef) { + for (i = funstack.length - 1; i >= 0; i -= 1) { + if (funstack[i][n]) { + warning("Redefinition of '" + n + "'.", prevtoken); + break; + } + } + } + addlabel(n, 'var'); + if (token.id === '=') { + advance('='); + parse(20); + } + if (token.id === ',') { + advance(','); + } else { + return; + } + } + } + + + stmt('var', varstatement); + + stmt('new', function () { + error("'new' should not be used as a statement"); + }); + + + function functionparams() { + var t = token; + advance('('); + if (token.id === ')') { + advance(')'); + return; + } + for (;;) { + addlabel(identifier(), 'parameter'); + if (token.id === ',') { + advance(','); + } else { + advance(')', t); + return; + } + } + } + + + blockstmt('function', function () { + var i = identifier(); + addlabel(i, 'var*'); + beginfunction(i); + addlabel(i, 'function'); + functionparams(); + block(); + endfunction(); + }); + + prefixname('function', function () { + var i = optionalidentifier() || ('"' + anonname + '"'); + beginfunction(i); + addlabel(i, 'function'); + functionparams(); + block(); + endfunction(); + }); + + blockstmt('if', function () { + var t = token; + advance('('); + parse(20); + advance(')', t); + block(); + if (token.id === 'else') { + advance('else'); + if (token.id === 'if' || token.id === 'switch') { + statement(); + } else { + block(); + } + } + }); + + blockstmt('try', function () { + var b; + block(); + if (token.id === 'catch') { + advance('catch'); + beginfunction('"catch"'); + functionparams(); + block(); + endfunction(); + b = true; + } + if (token.id === 'finally') { + advance('finally'); + beginfunction('"finally"'); + block(); + endfunction(); + return; + } else if (!b) { + error("Expected 'catch' or 'finally' and instead saw '" + + token.value + "'."); + } + }); + + blockstmt('while', function () { + var t= token; + advance('('); + parse(20); + advance(')', t); + block(); + }).labelled = true; + + reserve('with'); + + blockstmt('switch', function () { + var t = token; + advance('('); + var g = false; + parse(20); + advance(')', t); + t = token; + advance('{'); + for (;;) { + switch (token.id) { + case 'case': + switch (verb) { + case 'break': + case 'case': + case 'continue': + case 'return': + case 'switch': + case 'throw': + break; + default: + warning( + "Expected a 'break' statement before 'case'.", + prevtoken); + } + advance('case'); + parse(20); + g = true; + advance(':'); + verb = 'case'; + break; + case 'default': + switch (verb) { + case 'break': + case 'continue': + case 'return': + case 'throw': + break; + default: + warning( + "Expected a 'break' statement before 'default'.", + prevtoken); + } + advance('default'); + g = true; + advance(':'); + break; + case '}': + advance('}', t); + return; + case '(end)': + error("Missing '}'."); + return; + default: + if (prevtoken.id !== ':') { + error("Missing ':' on a case clause", prevtoken); + } + if (g) { + statements(); + } else { + error("Expected to see 'case' and instead saw '" + + token.value + "'."); + } + } + } + }).labelled = true; + + stmt('debugger', function () { + if (!option.debug) { + warning("All debugger statements should be removed."); + } + }); + + stmt('do', function () { + block(); + advance('while'); + var t = token; + advance('('); + parse(20); + advance(')', t); + }).labelled = true; + + blockstmt('for', function () { + var t = token; + advance('('); + if (peek(token.id === 'var' ? 1 : 0).id === 'in') { + if (token.id === 'var') { + advance('var'); + addlabel(identifier(), 'var'); + } else { + advance(); + } + advance('in'); + parse(20); + advance(')', t); + block(); + return; + } else { + if (token.id != ';') { + if (token.id === 'var') { + advance('var'); + varstatement(); + } else { + for (;;) { + parse(0); + if (token.id !== ',') { + break; + } + advance(','); + } + } + } + advance(';'); + if (token.id != ';') { + parse(20); + } + advance(';'); + if (token.id === ';') { + error("Expected to see ')' and instead saw ';'"); + } + if (token.id != ')') { + for (;;) { + parse(0); + if (token.id !== ',') { + break; + } + advance(','); + } + } + advance(')', t); + block(); + } + }).labelled = true; + + + function nolinebreak(t) { + if (t.line !== token.line) { + warning("Statement broken badly.", t); + } + } + + + stmt('break', function () { + nolinebreak(this); + if (funlab[token.value] === 'live*') { + advance(); + } + reachable('break'); + }); + + + stmt('continue', function () { + nolinebreak(this); + if (funlab[token.id] === 'live*') { + advance(); + } + reachable('continue'); + }); + + + stmt('return', function () { + nolinebreak(this); + if (token.id != ';' && !token.reach) { + parse(20); + } + reachable('return'); + }); + + + stmt('throw', function () { + nolinebreak(this); + parse(20); + reachable('throw'); + }); + + +// Superfluous reserved words + + reserve('abstract'); + reserve('boolean'); + reserve('byte'); + reserve('char'); + reserve('class'); + reserve('const'); + reserve('double'); + reserve('enum'); + reserve('export'); + reserve('extends'); + reserve('final'); + reserve('float'); + reserve('goto'); + reserve('implements'); + reserve('import'); + reserve('int'); + reserve('interface'); + reserve('long'); + reserve('native'); + reserve('package'); + reserve('private'); + reserve('protected'); + reserve('public'); + reserve('short'); + reserve('static'); + reserve('super'); + reserve('synchronized'); + reserve('throws'); + reserve('transient'); + reserve('void'); + reserve('volatile'); + + +// The actual JSLINT function itself. + + var j = function (s, o) { + option = o; + if (!o) { + option = {}; + } + JSLINT.errors = []; + globals = {}; + functions = []; + xmode = false; + xtype = ''; + stack = null; + funlab = {}; + member = {}; + funstack = []; + lookahead = []; + lex.init(s); + + prevtoken = token = syntax['(begin)']; + try { + advance(); + if (token.value.charAt(0) === '<') { + xml(); + } else { + statements(); + advance('(end)'); + } + } catch (e) { + if (e) { + JSLINT.errors.push({ + reason: "JSLint error: " + e.description, + line: token.line, + character: token.from, + evidence: token.value + }); + } + } + return JSLINT.errors.length === 0; + }; + + +// Report generator. + + j.report = function (option) { + var a = [], c, cc, f, i, k, o = [], s; + + function detail(h) { + if (s.length) { + o.push('
      ' + h + ':  ' + s.sort().join(', ') + + '
      '); + } + } + + k = JSLINT.errors.length; + if (k) { + o.push( + '
      Error:
      '); + for (i = 0; i < k; i += 1) { + c = JSLINT.errors[i]; + if (c) { + o.push('

      Problem at line ' + (c.line + 1) + + ' character ' + (c.character + 1) + + ': ' + c.reason.entityify() + + '

      ' + c.evidence.entityify() + + '

      '); + } + } + o.push('
      '); + if (!c) { + return o.join(''); + } + } + + if (!option) { + for (k in member) { + a.push(k); + } + if (a.length) { + a = a.sort(); + o.push( + ''); + for (i = 0; i < a.length; i += 1) { + o.push(''); + } + o.push('
      MembersOccurrences
      ', a[i], '', member[a[i]], + '
      '); + } + for (i = 0; i < functions.length; ++i) { + f = functions[i]; + for (k in f) { + if (f[k] === 'global') { + c = f['(context)']; + for (;;) { + cc = c['(context)']; + if (!cc) { + if ((!funlab[k] || funlab[k] === 'var?') && + !builtin(k)) { + funlab[k] = 'var?'; + f[k] = 'global?'; + } + break; + } + if (c[k] === 'parameter!' || c[k] === 'var!') { + f[k] = 'var.'; + break; + } + if (c[k] === 'var' || c[k] === 'var*' || + c[k] === 'var!') { + f[k] = 'var.'; + c[k] = 'var!'; + break; + } + if (c[k] === 'parameter') { + f[k] = 'var.'; + c[k] = 'parameter!'; + break; + } + c = cc; + } + } + } + } + s = []; + for (k in funlab) { + c = funlab[k]; + if (typeof c === 'string' && c.substr(0, 3) === 'var') { + if (c === 'var?') { + s.push('' + k + ' (?)'); + } else { + s.push('' + k + ''); + } + } + } + detail('Global'); + if (functions.length) { + o.push('
      Function:
        '); + } + for (i = 0; i < functions.length; i += 1) { + f = functions[i]; + o.push('
      1. ' + (f['(name)'] || '') + ''); + s = []; + for (k in f) { + if (k.charAt(0) != '(') { + switch (f[k]) { + case 'parameter': + s.push('' + k + ''); + break; + case 'parameter!': + s.push('' + k + + ' (closure)'); + break; + } + } + } + detail('Parameter'); + s = []; + for (k in f) { + if (k.charAt(0) != '(') { + switch(f[k]) { + case 'var': + s.push('' + k + + ' (unused)'); + break; + case 'var*': + s.push('' + k + ''); + break; + case 'var!': + s.push('' + k + + ' (closure)'); + break; + case 'var.': + s.push('' + k + + ' (outer)'); + break; + } + } + } + detail('Var'); + s = []; + c = f['(context)']; + for (k in f) { + if (k.charAt(0) != '(' && f[k].substr(0, 6) === 'global') { + if (f[k] === 'global?') { + s.push('' + k + ' (?)'); + } else { + s.push('' + k + ''); + } + } + } + detail('Global'); + s = []; + for (k in f) { + if (k.charAt(0) != '(' && f[k] === 'label') { + s.push(k); + } + } + detail('Label'); + o.push('
      2. '); + } + if (functions.length) { + o.push('
      '); + } + } + return o.join(''); + }; + + return j; + +}(); \ No newline at end of file diff --git a/modules/jala/util/HopKit/scripts/jsmin.js b/modules/jala/util/HopKit/scripts/jsmin.js new file mode 100644 index 00000000..1ef29cf1 --- /dev/null +++ b/modules/jala/util/HopKit/scripts/jsmin.js @@ -0,0 +1,316 @@ +/* jsmin.js - 2006-08-31 +Author: Franck Marcia +This work is an adaptation of jsminc.c published by Douglas Crockford. +Permission is hereby granted to use the Javascript version under the same +conditions as the jsmin.c on which it is based. + +jsmin.c +2006-05-04 + +Copyright (c) 2002 Douglas Crockford (www.crockford.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Update: + add level: + 1: minimal, keep linefeeds if single + 2: normal, the standard algorithm + 3: agressive, remove any linefeed and doesn't take care of potential + missing semicolons (can be regressive) + store stats + jsmin.oldSize + jsmin.newSize +*/ + +String.prototype.has = function(c) { + return this.indexOf(c) > -1; +}; + +function jsmin(comment, input, level) { + + if (input === undefined) { + input = comment; + comment = ''; + level = 2; + } else if (level === undefined || level < 1 || level > 3) { + level = 2; + } + + if (comment.length > 0) { + comment += '\n'; + } + + var a = '', + b = '', + EOF = -1, + LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', + DIGITS = '0123456789', + ALNUM = LETTERS + DIGITS + '_$\\', + theLookahead = EOF; + + + /* isAlphanum -- return true if the character is a letter, digit, underscore, + dollar sign, or non-ASCII character. + */ + + function isAlphanum(c) { + return c != EOF && (ALNUM.has(c) || c.charCodeAt(0) > 126); + } + + + /* get -- return the next character. Watch out for lookahead. If the + character is a control character, translate it to a space or + linefeed. + */ + + function get() { + + var c = theLookahead; + if (get.i == get.l) { + return EOF; + } + theLookahead = EOF; + if (c == EOF) { + c = input.charAt(get.i); + ++get.i; + } + if (c >= ' ' || c == '\n') { + return c; + } + if (c == '\r') { + return '\n'; + } + return ' '; + } + + get.i = 0; + get.l = input.length; + + + /* peek -- get the next character without getting it. + */ + + function peek() { + theLookahead = get(); + return theLookahead; + } + + + /* next -- get the next character, excluding comments. peek() is used to see + if a '/' is followed by a '/' or '*'. + */ + + function next() { + + var c = get(); + if (c == '/') { + switch (peek()) { + case '/': + for (;;) { + c = get(); + if (c <= '\n') { + return c; + } + } + break; + case '*': + get(); + for (;;) { + switch (get()) { + case '*': + if (peek() == '/') { + get(); + return ' '; + } + break; + case EOF: + throw 'Error: Unterminated comment.'; + } + } + break; + default: + return c; + } + } + return c; + } + + + /* action -- do something! What you do is determined by the argument: + 1 Output A. Copy B to A. Get the next B. + 2 Copy B to A. Get the next B. (Delete A). + 3 Get the next B. (Delete B). + action treats a string as a single character. Wow! + action recognizes a regular expression if it is preceded by ( or , or =. + */ + + function action(d) { + + var r = []; + + if (d == 1) { + r.push(a); + } + + if (d < 3) { + a = b; + if (a == '\'' || a == '"') { + for (;;) { + r.push(a); + a = get(); + if (a == b) { + break; + } + if (a <= '\n') { + throw 'Error: unterminated string literal: ' + a; + } + if (a == '\\') { + r.push(a); + a = get(); + } + } + } + } + + b = next(); + + if (b == '/' && '(,=:[!&|'.has(a)) { + r.push(a); + r.push(b); + for (;;) { + a = get(); + if (a == '/') { + break; + } else if (a =='\\') { + r.push(a); + a = get(); + } else if (a <= '\n') { + throw 'Error: unterminated Regular Expression literal'; + } + r.push(a); + } + b = next(); + } + + return r.join(''); + } + + + /* m -- Copy the input to the output, deleting the characters which are + insignificant to JavaScript. Comments will be removed. Tabs will be + replaced with spaces. Carriage returns will be replaced with + linefeeds. + Most spaces and linefeeds will be removed. + */ + + function m() { + + var r = []; + a = '\n'; + + r.push(action(3)); + + while (a != EOF) { + switch (a) { + case ' ': + if (isAlphanum(b)) { + r.push(action(1)); + } else { + r.push(action(2)); + } + break; + case '\n': + switch (b) { + case '{': + case '[': + case '(': + case '+': + case '-': + r.push(action(1)); + break; + case ' ': + r.push(action(3)); + break; + default: + if (isAlphanum(b)) { + r.push(action(1)); + } else { + if (level == 1 && b != '\n') { + r.push(action(1)); + } else { + r.push(action(2)); + } + } + } + break; + default: + switch (b) { + case ' ': + if (isAlphanum(a)) { + r.push(action(1)); + break; + } + r.push(action(3)); + break; + case '\n': + if (level == 1 && a != '\n') { + r.push(action(1)); + } else { + switch (a) { + case '}': + case ']': + case ')': + case '+': + case '-': + case '"': + case '\'': + if (level == 3) { + r.push(action(3)); + } else { + r.push(action(1)); + } + break; + default: + if (isAlphanum(a)) { + r.push(action(1)); + } else { + r.push(action(3)); + } + } + } + break; + default: + r.push(action(1)); + break; + } + } + } + + return r.join(''); + } + + jsmin.oldSize = input.length; + ret = m(input); + jsmin.newSize = ret.length; + + return comment + ret; + +} diff --git a/modules/jala/util/Test/code/Global/Root.js b/modules/jala/util/Test/code/Global/Root.js new file mode 100644 index 00000000..86713cc7 --- /dev/null +++ b/modules/jala/util/Test/code/Global/Root.js @@ -0,0 +1,53 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Module dependencies + */ +app.addRepository("modules/core/HopObject.js"); +app.addRepository("modules/core/Array.js"); +app.addRepository("modules/helma/File.js"); + +/** + * Test runner + */ +Root.prototype.jala_test_action = function() { + res.handlers.test = new jala.Test(); + if (req.isGet() && req.data.test) { + res.handlers.test.execute(req.data.test); + } else if (req.isPost() && (req.data.test_array || req.data.test)) { + res.handlers.test.execute(req.data.test_array || req.data.test); + } + renderSkin("jala.Test"); + return; +}; + +/** + * External stylesheet for test runner + */ +Root.prototype.jala_test_css_action = function() { + res.contentType = "text/css"; + renderSkin("jala.Test#stylesheet"); + return; +}; diff --git a/modules/jala/util/Test/code/Global/jala.Test.js b/modules/jala/util/Test/code/Global/jala.Test.js new file mode 100644 index 00000000..cc2ef26e --- /dev/null +++ b/modules/jala/util/Test/code/Global/jala.Test.js @@ -0,0 +1,1598 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * @fileoverview Fields and methods of the jala.Test class. + */ + + +// Define the global namespace for Jala modules +if (!global.jala) { + global.jala = {}; +} + +/** + * HelmaLib dependencies + */ +app.addRepository("modules/core/String.js"); +app.addRepository("modules/helma/Http.js"); + +/** + * Jala dependencies + */ +app.addRepository(getProperty("jala.dir", "modules/jala") + + "/code/Database.js"); + +/** + * Constructs a new Test instance. + * @class Provides various methods for automated tests. + * This is essentially a port of JSUnit (http://www.edwardh.com/jsunit/) + * suitable for testing Helma applications. + * @param {Number} capacity The capacity of the cache + * @constructor + */ +jala.Test = function() { + + /** + * Contains the number of tests that were executed + * @type Number + */ + this.testsRun = 0; + + /** + * Contains the number of tests that failed + * @type Boolean + */ + this.testsFailed = 0; + + /** + * Contains the number of test functions that passed + * @type Number + */ + this.functionsPassed = 0; + + /** + * Contains the number of test functions that failed + * @type Number + */ + this.functionsFailed = 0; + + /** + * An Array containing the results of this Test instance. + * @type Array + */ + this.results = []; + + return this; +}; + + + +/************************************************************* + ***** S T A T I C F I E L D S A N D M E T H O D S ***** + *************************************************************/ + + +/** + * Constant indicating "passed" status + * @type String + * @final + */ +jala.Test.PASSED = "passed"; + +/** + * Constant indicating "failed" status + * @type String + * @final + */ +jala.Test.FAILED = "failed"; + +/** + * Helper method useable for displaying a value + * @param {Object} The value to render + * @returns The value rendered as string + * @type String + */ +jala.Test.valueToString = function(val) { + res.push(); + if (val === null) { + res.write("null"); + } else if (val === undefined) { + res.write("undefined"); + } else { + if (typeof(val) == "function") { + // functions can be either JS methods or Java classes + // the latter throws an exception when trying to access a property + try { + res.write(val.name || val); + } catch (e) { + res.write(val); + } + } else { + if (val.constructor && val.constructor == String) { + res.write('"' + encode(val.head(200)) + '"'); + } else { + res.write(val.toString()); + } + res.write(" ("); + if (val.constructor && val.constructor.name != null) { + res.write(val.constructor.name); + } else { + res.write(typeof(val)); + } + res.write(")"); + } + } + return res.pop(); +}; + +/** + * Returns the directory containing the test files. + * The location of the directory is either defined by the + * application property "jala.testDir" or expected to be one level + * above the application directory (and named "tests") + * @returns The directory containing the test files + * @type helma.File + */ +jala.Test.getTestsDirectory = function() { + var dir; + if (getProperty("jala.testDir") != null) { + dir = new helma.File(getProperty("jala.testDir")); + } + if (!dir || !dir.exists()) { + var appDir = new helma.File(app.dir); + dir = new helma.File(appDir.getParent(), "tests"); + if (!dir.exists()) + return null; + } + return dir; +}; + +/** + * Returns an array containing the test files located + * in the directory. + * @returns An array containing the names of all test files + * @type Array + */ +jala.Test.getTestFiles = function() { + var dir; + if ((dir = jala.Test.getTestsDirectory()) != null) { + return dir.list(/.*\.js$/).sort(); + } + return null; +}; + +/** + * Returns the testfile with the given name + * @param {String} fileName The name of the test file + * @returns The test file + * @type helma.File + */ +jala.Test.getTestFile = function(fileName) { + var dir = jala.Test.getTestsDirectory(); + if (dir != null) { + return new helma.File(dir, fileName); + } + return null; +}; + +/** + * @param {Number} nr The number of arguments to be expected + * @param {Object} args The arguments array. + * @returns True in case the number of arguments matches + * the expected amount, false otherwise. + * @type Boolean + */ +jala.Test.evalArguments = function(args, argsExpected) { + if (!(args.length == argsExpected || + (args.length == argsExpected + 1 && typeof(args[0]) == "string"))) { + throw new jala.Test.ArgumentsException("Insufficient arguments passed to assertion function"); + } + return; +}; + +/** + * Returns true if the arguments array passed as argument + * contains an additional comment. + * @param {Array} args The arguments array to check for an existing comment. + * @param {Number} argsExpected The number of arguments expected by the + * assertion function. + * @returns True if the arguments contain a comment, false otherwise. + * @type Boolean + */ +jala.Test.argsContainComment = function(args, argsExpected) { + return !(args.length <= argsExpected + || (args.length == argsExpected + 1 && typeof(args[0]) != "string")) +}; + +/** + * Cuts out the comment from the arguments array passed + * as argument and returns it. CAUTION: this actually modifies + * the arguments array! + * @param {Array} args The arguments array. + * @returns The comment, if existing. Null otherwise. + * @type String + */ +jala.Test.getComment = function(args, argsExpected) { + if (jala.Test.argsContainComment(args, argsExpected)) + return args[0]; + return null; +}; + +/** + * Returns the argument on the index position in the array + * passed as arguments. This method respects an optional comment + * at the beginning of the arguments array. + * @param {Array} args The arguments to retrieve the non-comment + * value from. + * @param {Number} idx The index position on which the value to + * retrieve is to be expected if no comment is existing. + * @returns The non-comment value, or null. + * @type Object + */ +jala.Test.getValue = function(args, argsExpected, idx) { + return jala.Test.argsContainComment(args, argsExpected) ? args[idx+1] : args[idx]; +}; + + +/** + * Creates a stack trace and parses it for display. + * @param {java.lang.StackTraceElement} trace The trace to parse. If not given + * a stacktrace will be generated + * @returns The parsed stack trace + * @type String + */ +jala.Test.getStackTrace = function(trace) { + /** + * Private method for filtering out only JS parts of the stack trace + * @param {Object} name + */ + var accept = function(name) { + return name.endsWith(".js") || name.endsWith(".hac") || + name.endsWith(".hsp"); + }; + + // create exception and fill in stack trace + if (!trace) { + var ex = new Packages.org.mozilla.javascript.EvaluatorException(""); + ex.fillInStackTrace(); + trace = ex.getStackTrace(); + } + var stack = []; + var el, fileName, lineNumber; + // parse the stack trace and keep only the js elements + var inTrace = false; + for (var i=trace.length; i>0; i--) { + el = trace[i-1]; + fileName = el.getFileName(); + lineNumber = el.getLineNumber(); + if (fileName != null && lineNumber > -1 && accept(fileName)) { + if (fileName.endsWith(res.meta.currentTest)) { + inTrace = true; + } + if (inTrace == true) { + // ignore all trace lines that refer to jala.Test + if (fileName.endsWith("jala.Test.js")) { + break; + } + stack.push("at " + fileName + ":" + lineNumber); + } + } + } + return stack.reverse().join("\n"); +}; + +/** + * Adds all assertion methods, the http client, test database manager and + * smpt server to the per-thread global object. + * @private + */ +jala.Test.prepareTestScope = function() { + // define global assertion functions + for (var i in jala.Test.prototype) { + if (i.indexOf("assert") == 0) { + global[i] = jala.Test.prototype[i]; + } + } + // add global include method + global.include = function(file) { + jala.Test.include(global, file); + return; + }; + // instantiate a global HttpClient + global.httpClient = new jala.Test.HttpClient(); + // instantiate the test database manager + global.testDatabases = new jala.Test.DatabaseMgr(); + // instantiate the smtp server + global.smtpServer = new jala.Test.SmtpServer(); + return; +}; + +/** + * Evaluates a javascript file in the global test scope. This method can be used + * to include generic testing code in test files. This method is available as + * global method "include" for all test methods + * @param {Object} scope The scope in which the file should be evaluated + * @param {String} fileName The name of the file to include, including the path + */ +jala.Test.include = function(scope, file) { + var file = new helma.File(file); + var fileName = file.getName(); + if (file.canRead() && file.exists()) { + var cx = Packages.org.mozilla.javascript.Context.enter(); + var code = new java.lang.String(file.readAll() || ""); + cx.evaluateString(scope, code, fileName, 1, null); + } + return; +}; + + + +/******************************* + ***** E X C E P T I O N S ***** + *******************************/ + + +/** + * Creates a new Exception instance + * @class Base exception class + * @returns A newly created Exception instance + * @constructor + */ +jala.Test.Exception = function Exception() { + return this; +}; + +/** @ignore */ +jala.Test.Exception.prototype.toString = function() { + return "[jala.Test.Exception: " + this.message + "]"; +}; + +/** + * Creates a new TestException instance + * @class Instances of this exception are thrown whenever an + * assertion function fails + * @param {String} comment An optional comment + * @param {String} message The failure message + * @returns A newly created TestException instance + * @constructor + */ +jala.Test.TestException = function TestException(comment, message) { + this.functionName = null; + this.comment = comment; + this.message = message; + this.stackTrace = jala.Test.getStackTrace(); + return this; +}; +jala.Test.TestException.prototype = new jala.Test.Exception(); + +/** @ignore */ +jala.Test.TestException.prototype.toString = function() { + return "[jala.Test.TestException in " + this.functionName + + ": " + this.message + "]"; +}; + +/** + * Creates a new ArgumentsException instance + * @class Instances of this exception are thrown whenever an assertion + * function is called with incorrect or insufficient arguments + * @param {String} message The failure message + * @returns A newly created ArgumentsException instance + * @constructor + */ +jala.Test.ArgumentsException = function ArgumentsException(message) { + this.functionName = null; + this.message = message; + this.stackTrace = jala.Test.getStackTrace(); + return this; +}; +jala.Test.ArgumentsException.prototype = new jala.Test.Exception(); + +/** @ignore */ +jala.Test.ArgumentsException.prototype.toString = function() { + return "[jala.Test.ArgumentsException in " + this.functionName + + ": " + this.message + "]"; +}; + +/** + * Creates a new EvaluatorException instance + * @class Instances of this exception are thrown when attempt + * to evaluate the test code fails. + * @param {String} message The failure message, or an Error previously + * thrown. + * @param {String} exception An optional nested Error + * @returns A newly created EvaluatorException instance + * @constructor + */ +jala.Test.EvaluatorException = function EvaluatorException(message, exception) { + this.functionName = null; + this.message = null; + this.stackTrace = null; + this.fileName = null; + this.lineNumber = null; + + if (arguments.length == 1 && arguments[0] instanceof Error) { + this.message = ""; + exception = arguments[0]; + } else { + this.message = message; + } + + if (exception != null) { + this.name = exception.name; + if (exception.rhinoException != null) { + var e = exception.rhinoException; + this.message += e.details(); + this.stackTrace = jala.Test.getStackTrace(e.getStackTrace()); + } else if (exception instanceof Error) { + this.message = exception.message; + } + if (!this.stackTrace) { + // got no stack trace, so add at least filename and line number + this.fileName = exception.fileName || null; + this.lineNumber = exception.lineNumber || null; + } + } + + return this; +}; +jala.Test.EvaluatorException.prototype = new jala.Test.Exception(); + +/** @ignore */ +jala.Test.EvaluatorException.prototype.toString = function() { + return "[jala.Test.EvaluatorException: " + this.message + "]"; +}; + + + +/************************************************* + ***** R E S U L T C O N S T R U C T O R S ***** + *************************************************/ + + +/** + * Constructs a new TestResult instance + * @class Instances of this class represent the result of the execution + * of a single test file + * @param {String} testFileName The name of the excecuted test file + * @returns A new TestResult instance + * @constructor + */ +jala.Test.TestResult = function(testFileName) { + this.name = testFileName; + this.elapsed = 0; + this.status = jala.Test.PASSED; + this.log = []; + return this; +}; + +/** + * Constructs a new TestFunctionResult instance + * @class Instances of this class represent the result of the successful + * execution of a single test function (failed executions will be represented + * as Exceptions in the log of a test result). + * @param {String} functionName The name of the excecuted test function + * @param {Date} startTime A Date instance marking the begin of the test + * @returns A new TestFunctionResult instance + * @constructor + */ +jala.Test.TestFunctionResult = function(functionName, startTime) { + this.functionName = functionName; + this.elapsed = (new Date()) - startTime; + return this; +}; + + + +/************************************************* + ***** P R O T O T Y P E F U N C T I O N S ***** + *************************************************/ + + +/** + * Executes a single test file + * @param {helma.File} testFile The file containing the test to run + */ +jala.Test.prototype.executeTest = function(testFile) { + var testFileName = testFile.getName(); + // store the name of the current test in res.meta.currentTest + // as this is needed in getStackTrace + res.meta.currentTest = testFileName; + + var cx = Packages.org.mozilla.javascript.Context.enter(); + var code = new java.lang.String(testFile.readAll() || ""); + var testResult = new jala.Test.TestResult(testFileName); + global.testFunctionIdents = []; + try { + // prepare the test scope + jala.Test.prepareTestScope(); + // evaluate the test file in the per-thread which is garbage + // collected at the end of the test run + cx.evaluateString(global, code, testFileName, 1, null); + for (var ident in global) { + if (ident.startsWith("test") && (global[ident] instanceof Function)) { + testFunctionIdents.push(ident); + } + } + var start = new Date(); + // run all test methods defined in the array "tests" + var functionName; + for (var i=0;i 0) { + for (var i=0;i 0) { + var fileName, skinParam; + for (var i=0;i= 301 && result.code <= 303 && result.location != null) { + // received a redirect location, so follow it + result = this.executeRequest("GET", result.location); + } + return result; +}; + +/** + * Convenience method for requesting the url passed as argument + * using method GET + * @param {String} url The url to request + * @param {Object} param A parameter object to use with this request + * @return An object containing response values + * @see helma.Http.prototype.getUrl + */ +jala.Test.HttpClient.prototype.getUrl = function(url, param) { + return this.executeRequest("GET", url, param); +}; + +/** + * Convenience method for submitting a form. + * @param {String} url The url to request + * @param {Object} param A parameter object to use with this request + * @return An object containing response values + * @see helma.Http.prototype.getUrl + */ +jala.Test.HttpClient.prototype.submitForm = function(url, param) { + return this.executeRequest("POST", url, param); +}; + +/** @ignore */ +jala.Test.HttpClient.prototype.toString = function() { + return "[jala.Test.HttpClient]"; +}; + + + + +/***************************************************** + ***** T E S T D A T A B A S E M A N A G E R ***** + *****************************************************/ + + +/** + * Returns a newly created DatabaseMgr instance + * @class Instances of this class allow managing test databases + * and switching a running application to an in-memory test + * database to use within a unit test. + * @returns A newly created instance of DatabaseMgr + * @constructor + */ +jala.Test.DatabaseMgr = function() { + /** + * Map containing all test databases + */ + this.databases = {}; + + /** + * Map containing the original datasource + * properties that were temporarily deactivated + * by activating a test database + */ + this.dbSourceProperties = {}; + + return this; +}; + +jala.Test.DatabaseMgr.prototype.toString = function() { + return "[jala.Test DatabaseMgr]"; +}; + +/** + * Returns a newly initialized in-memory test database with the given name + * @param {String} name The name of the test database + * @returns The newly initialized test database + * @type jala.db.RamDatabase + */ +jala.Test.DatabaseMgr.prototype.initDatabase = function(name) { + return new jala.db.RamDatabase(name); +}; + +/** + * Switches the application to the test database passed as argument. + * In addition this method clears the application cache and invalidates + * the root object. + * @param {jala.db.RamDatabase} testDb The test database to switch to. + * @param {String} dbSourceName Optional name of the application's database + * source that will be replaced by the test database. + */ +jala.Test.DatabaseMgr.prototype.switchToDatabase = function(testDb, dbSourceName) { + var dbName = dbSourceName || testDb.getName(); + // switch the datasource to the test database + var dbSource = app.getDbSource(dbName); + var oldProps = dbSource.switchProperties(testDb.getProperties()); + // store the old db properties in this manager for use in stopAll() + this.databases[dbName] = testDb; + this.dbSourceProperties[dbName] = oldProps; + // clear the application cache and invalidate root + app.clearCache(); + root.invalidate(); + return; +}; + +/** + * Switches the application datasource with the given name + * to a newly created in-memory database. In addition this method + * also clears the application cache and invalidates the root + * object to ensure that everything is re-retrieved from the + * test database. + * This method can be called with a second boolean argument indicating + * that tables used by the application should be created in the in-memory + * database (excluding any data). + * @param {String} dbSourceName The name of the application database + * source as defined in db.properties + * @param {Boolean} copyTables If true this method also copies all + * tables in the source database to the test database (excluding + * indexes). + * @param {Array} tables An optional array containing table names that + * should be created in the test database. If not specified this method + * collects all tables that are mapped in the application. + * @returns The test database + * @type jala.db.RamDatabase + */ +jala.Test.DatabaseMgr.prototype.startDatabase = function(dbSourceName, copyTables, tables) { + try { + var testDb = this.initDatabase(dbSourceName); + // switch the datasource to the test database + var dbSource = app.getDbSource(dbSourceName); + if (copyTables === true) { + if (tables === null || tables === undefined) { + // collect the table names of all relational prototypes + tables = []; + var protos = app.getPrototypes(); + for each (var proto in protos) { + var dbMap = proto.getDbMapping(); + if (dbMap.isRelational()) { + tables.push(dbMap.getTableName()); + } + } + } + testDb.copyTables(dbSource, tables); + } + this.switchToDatabase(testDb); + return testDb; + } catch (e) { + throw new jala.Test.EvaluatorException("Unable to switch to test database because of ", e); + } +}; + +/** + * Stops all registered test databases and and reverts the application + * to its original datasource(s) as defined in db.properties file. + * In addition this method rolls back all pending changes within the request, + * clears the application cache and invalidates the root object + * to ensure no traces of the test database are left behind. + */ +jala.Test.DatabaseMgr.prototype.stopAll = function() { + // throw away all pending transactions + res.rollback(); + try { + // loop over all registered databases and revert the appropriate + // datasource back to the original database + var testDb, dbSource; + for (var dbSourceName in this.databases) { + testDb = this.databases[dbSourceName]; + dbSource = app.getDbSource(dbSourceName); + dbSource.switchProperties(this.dbSourceProperties[dbSourceName]); + testDb.shutdown(); + } + // clear the application cache and invalidate root + app.clearCache(); + root.invalidate(); + } catch (e) { + throw new jala.Test.EvaluatorException("Unable to stop test databases because of ", e); + } + return; +}; + + + +/********************************* + ***** S M T P S E R V E R ***** + *********************************/ + + +/** + * Creates a new SmtpServer instance + * @class Instances of this class represent an SMTP server listening on + * localhost. By default jala.Test will create a global variable called + * "smtpServer" that contains an instance of this class. To use the server call + * {@link #start} in a test method (eg. in the basic setup method) and + * {@link #stop} in the cleanup method. + * @param {Number} port Optional port to listen on (defaults to 25) + * @returns A newly created SmtpServer instance + * @constructor + */ +jala.Test.SmtpServer = function(port) { + var server = null; + + var oldSmtpServer = null; + + /** + * Starts the SMTP server. Note that this method switches the SMTP server as + * defined in app.properties of the tested application or server.properties + * to "localhost" to ensure that all mails sent during tests are received + * by this server. The SMTP server definition is switched back to the + * original when {@link #stop} is called. + */ + this.start = function() { + server = new Packages.org.subethamail.wiser.Wiser() + // listen only on localhost + server.setHostname("localhost"); + if (port != null && !isNaN(port)) { + server.setPort(port); + } + // switch smtp property of tested application + oldSmtpServer = getProperty("smtp"); + app.__app__.getProperties().put("smtp", "localhost"); + server.start(); + return; + }; + + /** + * Stops the SMTP server and switches the "smtp" property of the tested + * application back to the value defined in app or server.properties + */ + this.stop = function() { + server.stop(); + server = null; + // switch back to original SMTP server address + var props = app.__app__.getProperties(); + if (oldSmtpServer != null) { + props.put("smtp", oldSmtpServer); + } else { + props.remove("smtp"); + } + return; + }; + + /** + * Returns an array containing all mails received by the server, + * where each one is an instance of {@link jala.Test.SmtpServer.Message} + * @returns An array with all messages + * @type Array + */ + this.getMessages = function() { + var it = server.getMessages().listIterator(); + var result = []; + while (it.hasNext()) { + result.push(new jala.Test.SmtpServer.Message(it.next())); + } + return result; + }; + + return this; +}; + +/** @ignore */ +jala.Test.SmtpServer.prototype.toString = function() { + return "[Jala Test SmtpServer]"; +}; + +/** + * Creates a new Mail instance + * @class Instances of this class represent a mail message received + * by the SMTP server + * @param {org.subethamail.wiser.WiserMessage} message The message + * as received by the SMTP server + * @returns A newly created Mail instance + * @constructor + */ +jala.Test.SmtpServer.Message = function(message) { + /** + * The wrapped message as MimeMessage instance + * @type javax.mail.internet.MimeMessage + * @private + */ + var mimeMessage = message.getMimeMessage(); + + /** + * Returns the wrapped message + * @type org.subethamail.wiser.WiserMessage + */ + this.getMessage = function() { + return message; + }; + + /** + * Returns the wrapped message as MimeMessage + * @type javax.mail.internet.MimeMessage + */ + this.getMimeMessage = function() { + return mimeMessage; + }; + + return this; +}; + +/** @ignore */ +jala.Test.SmtpServer.Message.prototype.toString = function() { + return "[Jala Test Mail]"; +}; + +/** + * Returns an array containing all senders of this mail + * @returns An array with all senders of this mail + * @type Array + */ +jala.Test.SmtpServer.Message.prototype.getFrom = function() { + var result = []; + this.getMimeMessage().getFrom().forEach(function(addr) { + result.push(addr.toString()) + }); + return result; +}; + +/** + * Returns an array containing all recipients of this mail + * @returns An array with all recipients of this mail + * @type Array + */ +jala.Test.SmtpServer.Message.prototype.getTo = function() { + var type = Packages.javax.mail.internet.MimeMessage.RecipientType.TO; + var result = []; + this.getMimeMessage().getRecipients(type).forEach(function(addr) { + result.push(addr.toString()) + }); + return result; +}; + +/** + * Returns an array containing all CC recipients of this mail + * @returns An array with all CC recipients of this mail + * @type Array + */ +jala.Test.SmtpServer.Message.prototype.getCc = function() { + var type = Packages.javax.mail.internet.MimeMessage.RecipientType.CC; + var result = []; + this.getMimeMessage().getRecipients(type).forEach(function(addr) { + result.push(addr.toString()) + }); + return result; +}; + +/** + * Returns an array with all reply-to addresses of this mail + * @returns An array with all reply-to addresses of this mail + * @type Array + */ +jala.Test.SmtpServer.Message.prototype.getReplyTo = function() { + var result = []; + this.getMimeMessage().getReplyTo().forEach(function(addr) { + result.push(addr.toString()) + }); + return result; +}; + +/** + * Returns the encoding of this mail as defined in the "Content-Transfer-Encoding" + * header field + * @returns The encoding of this mail + * @type String + */ +jala.Test.SmtpServer.Message.prototype.getEncoding = function() { + return this.getMimeMessage().getEncoding(); +}; + +/** + * Returns the subject of this mail + * @returns The subject of this mail + * @type String + */ +jala.Test.SmtpServer.Message.prototype.getSubject = function() { + return this.getMimeMessage().getSubject(); +}; + +/** + * Returns the content of this mail + * @returns The content of this mail + */ +jala.Test.SmtpServer.Message.prototype.getContent = function() { + return this.getMimeMessage().getContent(); +}; + +/** + * Returns the content type of this mail as defined in the "Content-Type" + * header field + * @returns The content type of this mail + * @type String + */ +jala.Test.SmtpServer.Message.prototype.getContentType = function() { + return this.getMimeMessage().getContentType(); +}; diff --git a/modules/jala/util/Test/code/Global/jala.Test.skin b/modules/jala/util/Test/code/Global/jala.Test.skin new file mode 100644 index 00000000..e03b8647 --- /dev/null +++ b/modules/jala/util/Test/code/Global/jala.Test.skin @@ -0,0 +1,294 @@ +<% +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// +%> + + + +Jala Unit Test Runner +" /> + + + +
      +
      Jala Unit Test Runner
      +
      <% test.directory prefix="Tests: " %>
      +
      +
      +
      +
      "> + <% test.list prefix='

      Available Tests

      ' %> +
      +
      +
      + + + + + + + + + + + + + +
      TestsFunctions
      <% test.testsRun %> run<% test.functionsPassed %> passed
      <% test.testsFailed %> failed<% test.functionsFailed %> failed
      + <% test.results %> +
      +
      + + + + + +<% #result ------------------------------------------------------------------ %> + +

      Results of '<% param.name %>':

      +<% param.log prefix="
      " suffix="
      " %> + + + +<% #item -------------------------------------------------------------------- %> + +
    • + /><% param.name %> +
    • + + + +<% #logFailed --------------------------------------------------------------- %> + +
      Error
      +
      + <% param.functionName prefix='' suffix='()' %> +
      <% param.name suffix=": " %><% param.message %>
      +
      <% param.comment %>
      +
      <% param.fileName prefix="at " %><% param.lineNumber prefix=":" %>
      +
      <% param.stackTrace encoding="html" %>
      +
      + + + +<% #logPassed --------------------------------------------------------------- %> + +
      Passed
      +
      <% param.functionName %>()(in <% param.elapsed %> ms)
      + + + +<% #stylesheet -------------------------------------------------------------- %> + +body { + font-family: Verdana, Arial, Helvetica; + font-size: 0.85em; + margin: 0; + padding: 0; +} + +a { + text-decoration: none; + color: #333; +} + +a:hover { + text-decoration: underline; +} + +div.header { + background-color: #aaa; + border-bottom: 1px solid #333; + font-size: 18px; + font-weight: bold; + color: #ddd; + padding: 10px 20px; +} + +div.header div.title { + float: left; + font-size: 18px; + font-weight: bold; + color: #ddd; +} + +div.header div.directory { + text-align: right; + font-size: 11px; + font-weight: normal; + color: #eee; + padding: 5px; +} + +div.main { + margin: 20px; +} + +div.footer { + margin-top: 400px; + padding: 10px 0 10px 20px; + clear: both; + background-color: #eee; + font-size: 0.7em; + color: #999; +} + +div.list { + float: left; + width: 200px; + padding-right: 30px; + border-right: 1px solid #ccc; +} + +div.list h4 { + margin: 0; + padding: 0 0 10px 0; + font-size: 1em; +} + +div.list form { + margin: 0; + padding: 0; +} + +div.list ul { + list-style-type: none; + margin: 0; + padding: 0; +} + +div.list ul li { + padding: 0; + margin-top:1px; + font-size: 0.95em; +} + +div.list .submit { + margin: 15px 0 0 0; + padding: 0 10px; + border: 1px solid gray; +} + +div.result { + margin-left: 250px; + padding-left: 20px; +} + +/** statistics **/ + +table.statistics { + xborder: 1px solid black; + border-collapse: collapse; +} + +table.statistics th { + text-align: left; + font-size: 0.9em; +} + +table.statistics td { + padding-right: 15px; + color: #666; +} + +table.statistics span.passed { + color: #009900; + font-weight: bold; +} + +table.statistics span.failed { + color: #cc0000; + font-weight: bold; +} + +/** result formattings **/ + +div.result h4 { + font-size: 1em; + font-weight: bold; + border-top: 1px solid #ccc; + padding-top: 20px; +} + +dt { + float: left; +} + +dt.test { + width: 70px; + padding: 2px 10px; +} + +dt.passed { + background-color:#33cc33; + font-size: 0.9em; +} + +dt.error { + background-color:#cc0000; + color: #efefef; + font-size: 0.9em; +} + +dd { + font-size: 0.95em; + margin: 0 0 10px 100px; + padding: 2px; +} + + +span.title, span.function { + width: 200px; + padding-right:10px; +} + +span.function { + font-style: italic; +} + +span.elapsed { + font-size: 0.9em; +} diff --git a/modules/jala/util/Test/code/subetha-smtp.jar b/modules/jala/util/Test/code/subetha-smtp.jar new file mode 100644 index 00000000..ed83063b Binary files /dev/null and b/modules/jala/util/Test/code/subetha-smtp.jar differ diff --git a/modules/jala/util/Test/code/subetha-wiser.jar b/modules/jala/util/Test/code/subetha-wiser.jar new file mode 100644 index 00000000..c75cc70c Binary files /dev/null and b/modules/jala/util/Test/code/subetha-wiser.jar differ diff --git a/modules/jala/util/Test/code/subethasmtp.license.txt b/modules/jala/util/Test/code/subethasmtp.license.txt new file mode 100644 index 00000000..8b3eb3ad --- /dev/null +++ b/modules/jala/util/Test/code/subethasmtp.license.txt @@ -0,0 +1,204 @@ +SubEthaSMTP - A SMTP mail server +Copyright (C) 2006-2007 SubEthaMail.org + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) 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. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/modules/jala/util/Test/docs/Root.html b/modules/jala/util/Test/docs/Root.html new file mode 100644 index 00000000..22ffee06 --- /dev/null +++ b/modules/jala/util/Test/docs/Root.html @@ -0,0 +1,302 @@ + + + + + +Root + + + + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + +
      + + +

      Class Root

      +
      Object
      +   |
      +   +--Root
      +
      + + +
      +
      + +
      class + Root + + +
      + +
      + + + + + + + + + + + + + + + + + + +  + + + + + + + + + + + + + + + + + + + + + +
      +Method Summary
      + +  void + + + + + jala_test_action() + +
      +            + Test runner +
      + +  void + + + + + jala_test_css_action() + +
      +            + External stylesheet for test runner +
      + + + +

      + + + + + + + + + + + + + + + + + +


      + + + + + + + + + + + + +
      + Method Detail +
      + + + + +

      jala_test_action

      +
      void jala_test_action()
      + +
        Test runner
      + + + + + + + + + + + +
      + + +

      jala_test_css_action

      +
      void jala_test_css_action()
      + +
        External stylesheet for test runner
      + + + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + + + +
      + + + +
      Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
      + + diff --git a/modules/jala/util/Test/docs/allclasses-frame.html b/modules/jala/util/Test/docs/allclasses-frame.html new file mode 100644 index 00000000..277e728e --- /dev/null +++ b/modules/jala/util/Test/docs/allclasses-frame.html @@ -0,0 +1,107 @@ + + + + + + All Classes + + + + + + +

      + +All Classes +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      jala +
      +
      jala.Test +
      +
      jala.Test.ArgumentsException +
      +
      jala.Test.DatabaseMgr +
      +
      jala.Test.EvaluatorException +
      +
      jala.Test.Exception +
      +
      jala.Test.HttpClient +
      +
      jala.Test.SmtpServer +
      +
      jala.Test.SmtpServer.Message +
      +
      jala.Test.TestException +
      +
      jala.Test.TestFunctionResult +
      +
      jala.Test.TestResult +
      +
      Root +
      +
      + + + diff --git a/modules/jala/util/Test/docs/allclasses-noframe.html b/modules/jala/util/Test/docs/allclasses-noframe.html new file mode 100644 index 00000000..7c79845a --- /dev/null +++ b/modules/jala/util/Test/docs/allclasses-noframe.html @@ -0,0 +1,106 @@ + + + + +Jala Test All Classes + + + + + + +

      Jala Test

      + +All Classes +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      jala +
      +
      jala.Test +
      +
      jala.Test.ArgumentsException +
      +
      jala.Test.DatabaseMgr +
      +
      jala.Test.EvaluatorException +
      +
      jala.Test.Exception +
      +
      jala.Test.HttpClient +
      +
      jala.Test.SmtpServer +
      +
      jala.Test.SmtpServer.Message +
      +
      jala.Test.TestException +
      +
      jala.Test.TestFunctionResult +
      +
      jala.Test.TestResult +
      +
      Root +
      +
      + + + diff --git a/modules/jala/util/Test/docs/constant-values.html b/modules/jala/util/Test/docs/constant-values.html new file mode 100644 index 00000000..519a296e --- /dev/null +++ b/modules/jala/util/Test/docs/constant-values.html @@ -0,0 +1,156 @@ + + + + +Jala Test Constant Values + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + + +
      +

      Constant Field Values

      +
      + + +
      + + + + + + + + + + + + + + + + + + + +
      + jala.Test +
      PASSED"passed"
      FAILED"failed"
      +

      + +

      + + +


      + + + + + + + + + + + + + +
      +Jala Test + +
      + + +
      + + + +
      Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
      + + diff --git a/modules/jala/util/Test/docs/help-doc.html b/modules/jala/util/Test/docs/help-doc.html new file mode 100644 index 00000000..8ecda993 --- /dev/null +++ b/modules/jala/util/Test/docs/help-doc.html @@ -0,0 +1,160 @@ + + + + +Jala Test API Help + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + + +
      +
      +

      +How This API Document Is Organized

      +
      +This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

      +Class

      +
      + +

      +Each class has its own separate page. Each of these pages has three sections consisting of a class description, summary tables, and detailed member descriptions:

        +
      • Class inheritance diagram
      • Direct Subclasses
      • Class declaration
      • Class description +

        +

      • Field Summary
      • Constructor Summary
      • Method Summary +

        +

      • Field Detail
      • Constructor Detail
      • Method Detail
      +Each summary entry contains the first sentence from the detailed description for that item.
      + + +

      +Index

      +
      +The Index contains an alphabetic list of all classes, constructors, methods, and fields.
      +

      +Prev/Next

      +These links take you to the next or previous class, interface, package, or related page.

      +Frames/No Frames

      +These links show and hide the HTML frames. All pages are available with or without frames. +

      + + +This help file applies to API documentation generated using the standard doclet. + +
      +


      + + + + + + + + + + + + + +
      +Jala Test + +
      + + +
      + + + +
      Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
      + + diff --git a/modules/jala/util/Test/docs/index-all.html b/modules/jala/util/Test/docs/index-all.html new file mode 100644 index 00000000..96b11df9 --- /dev/null +++ b/modules/jala/util/Test/docs/index-all.html @@ -0,0 +1,771 @@ + + + + + +Index () + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + + +A D E F G I J L N P R S T V +
      + + +

      +A

      + +
      +
      argsContainComment(args, argsExpected) - +Class method in class jala.Test +
        +
      + +
      +
      assertEqual(val1, val2) - +Instance method in class jala.Test +
        +
      + +
      +
      assertEqualFile(val, file) - +Instance method in class jala.Test +
        +
      + +
      +
      assertFalse(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertMatch(val, rxp) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNaN(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNotEqual(val1, val2) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNotNaN(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNotNull(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNotUndefined(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertNull(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertStringContains(val, str) - +Instance method in class jala.Test +
        +
      + +
      +
      assertThrows(func, exception) - +Instance method in class jala.Test +
        +
      + +
      +
      assertTrue(val) - +Instance method in class jala.Test +
        +
      + +
      +
      assertUndefined(val) - +Instance method in class jala.Test +
        +
      + +
      + +

      +D

      + +
      +
      databases - +Instance field in class jala.Test.DatabaseMgr +
        +
      + +
      +
      dbSourceProperties - +Instance field in class jala.Test.DatabaseMgr +
        +
      + +
      +
      directory_macro() - +Instance method in class jala.Test +
        +
      + +
      + +

      +E

      + +
      +
      elapsed - +Instance field in class jala.Test.TestFunctionResult +
        +
      + +
      +
      elapsed - +Instance field in class jala.Test.TestResult +
        +
      + +
      +
      evalArguments(args, argsExpected) - +Class method in class jala.Test +
        +
      + +
      +
      execute(what) - +Instance method in class jala.Test +
        +
      + +
      +
      executeRequest(method, url, param) - +Instance method in class jala.Test.HttpClient +
        +
      + +
      +
      executeTest(testFile) - +Instance method in class jala.Test +
        +
      + +
      +
      executeTestFunction(functionName, scope) - +Instance method in class jala.Test +
        +
      + +
      + +

      +F

      + +
      +
      FAILED - +Class field in class jala.Test +
        +
      + +
      +
      functionName - +Instance field in class jala.Test.TestFunctionResult +
        +
      + +
      +
      functionsFailed - +Instance field in class jala.Test +
        +
      + +
      +
      functionsPassed - +Instance field in class jala.Test +
        +
      + +
      + +

      +G

      + +
      +
      getCc() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getClient() - +Instance method in class jala.Test.HttpClient +
        +
      + +
      +
      getComment(args, argsExpected) - +Class method in class jala.Test +
        +
      + +
      +
      getContent() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getContentType() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getCookies() - +Instance method in class jala.Test.HttpClient +
        +
      + +
      +
      getEncoding() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getFrom() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getMessage() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getMessages() - +Instance method in class jala.Test.SmtpServer +
        +
      + +
      +
      getMimeMessage() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getReplyTo() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getStackTrace(trace) - +Class method in class jala.Test +
        +
      + +
      +
      getSubject() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getTestFile(fileName) - +Class method in class jala.Test +
        +
      + +
      +
      getTestFiles() - +Class method in class jala.Test +
        +
      + +
      +
      getTestsDirectory() - +Class method in class jala.Test +
        +
      + +
      +
      getTo() - +Instance method in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      getUrl(url, param) - +Instance method in class jala.Test.HttpClient +
        +
      + +
      +
      getValue(args, argsExpected, idx) - +Class method in class jala.Test +
        +
      + +
      + +

      +I

      + +
      +
      include(scope, file) - +Class method in class jala.Test +
        +
      + +
      + +

      +J

      + +
      +
      jala - + class jala +
        +
      + +
      +
      jala.Test - + class jala.Test +
        +
      + +
      +
      jala.Test() - +Constructor in class jala.Test +
        +
      + +
      +
      jala.Test.ArgumentsException - + class jala.Test.ArgumentsException +
        +
      + +
      +
      jala.Test.ArgumentsException(message) - +Constructor in class jala.Test.ArgumentsException +
        +
      + +
      +
      jala.Test.DatabaseMgr - + class jala.Test.DatabaseMgr +
        +
      + +
      +
      jala.Test.DatabaseMgr() - +Constructor in class jala.Test.DatabaseMgr +
        +
      + +
      +
      jala.Test.EvaluatorException - + class jala.Test.EvaluatorException +
        +
      + +
      +
      jala.Test.EvaluatorException(message, exception) - +Constructor in class jala.Test.EvaluatorException +
        +
      + +
      +
      jala.Test.Exception - + class jala.Test.Exception +
        +
      + +
      +
      jala.Test.Exception() - +Constructor in class jala.Test.Exception +
        +
      + +
      +
      jala.Test.HttpClient - + class jala.Test.HttpClient +
        +
      + +
      +
      jala.Test.HttpClient() - +Constructor in class jala.Test.HttpClient +
        +
      + +
      +
      jala.Test.SmtpServer - + class jala.Test.SmtpServer +
        +
      + +
      +
      jala.Test.SmtpServer(port) - +Constructor in class jala.Test.SmtpServer +
        +
      + +
      +
      jala.Test.SmtpServer.Message - + class jala.Test.SmtpServer.Message +
        +
      + +
      +
      jala.Test.SmtpServer.Message(message) - +Constructor in class jala.Test.SmtpServer.Message +
        +
      + +
      +
      jala.Test.TestException - + class jala.Test.TestException +
        +
      + +
      +
      jala.Test.TestException(comment, message) - +Constructor in class jala.Test.TestException +
        +
      + +
      +
      jala.Test.TestFunctionResult - + class jala.Test.TestFunctionResult +
        +
      + +
      +
      jala.Test.TestFunctionResult(functionName, startTime) - +Constructor in class jala.Test.TestFunctionResult +
        +
      + +
      +
      jala.Test.TestResult - + class jala.Test.TestResult +
        +
      + +
      +
      jala.Test.TestResult(testFileName) - +Constructor in class jala.Test.TestResult +
        +
      + +
      +
      jala_test_action() - +Instance method in class Root +
        +
      + +
      +
      jala_test_css_action() - +Instance method in class Root +
        +
      + +
      + +

      +L

      + +
      +
      list_macro() - +Instance method in class jala.Test +
        +
      + +
      +
      log - +Instance field in class jala.Test.TestResult +
        +
      + +
      + +

      +N

      + +
      +
      name - +Instance field in class jala.Test.TestResult +
        +
      + +
      + +

      +P

      + +
      +
      PASSED - +Class field in class jala.Test +
        +
      + +
      + +

      +R

      + +
      +
      renderResult(result) - +Instance method in class jala.Test +
        +
      + +
      +
      renderResults() - +Instance method in class jala.Test +
        +
      + +
      +
      results - +Instance field in class jala.Test +
        +
      + +
      +
      results_macro() - +Instance method in class jala.Test +
        +
      + +
      +
      Root - + class Root +
        +
      + +
      + +

      +S

      + +
      +
      setCookies(arr) - +Instance method in class jala.Test.HttpClient +
        +
      + +
      +
      start() - +Instance method in class jala.Test.SmtpServer +
        +
      + +
      +
      startDatabase(dbSourceName, copyTables, tables) - +Instance method in class jala.Test.DatabaseMgr +
        +
      + +
      +
      status - +Instance field in class jala.Test.TestResult +
        +
      + +
      +
      stop() - +Instance method in class jala.Test.SmtpServer +
        +
      + +
      +
      stopAll() - +Instance method in class jala.Test.DatabaseMgr +
        +
      + +
      +
      submitForm(url, param) - +Instance method in class jala.Test.HttpClient +
        +
      + +
      + +

      +T

      + +
      +
      testsFailed - +Instance field in class jala.Test +
        +
      + +
      +
      testsRun - +Instance field in class jala.Test +
        +
      + +
      +
      toString() - +Instance method in class jala.Test.DatabaseMgr +
        +
      + +
      + +

      +V

      + +
      +
      valueToString(val) - +Class method in class jala.Test +
        +
      + +
      + +A D E F G I J L N P R S T V + + + + + + + + + + + + + + +
      +Jala Test + +
      + + +
      + + + +
      Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
      + + diff --git a/modules/jala/util/Test/docs/index.html b/modules/jala/util/Test/docs/index.html new file mode 100644 index 00000000..8a7b7ade --- /dev/null +++ b/modules/jala/util/Test/docs/index.html @@ -0,0 +1,27 @@ + + + + +Generated Javascript Documentation + + + + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to <A HREF="allclasses-frame.html">Non-frame version.</A> + diff --git a/modules/jala/util/Test/docs/jala.Test.ArgumentsException.html b/modules/jala/util/Test/docs/jala.Test.ArgumentsException.html new file mode 100644 index 00000000..a0393e46 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.ArgumentsException.html @@ -0,0 +1,276 @@ + + + + + +jala.Test.ArgumentsException + + + + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + +
      + + +

      Class jala.Test.ArgumentsException

      +
      Object
      +   |
      +   +--jala.Test.Exception
      +         |
      +         +--jala.Test.ArgumentsException
      +
      + + +
      +
      + +
      class + jala.Test.ArgumentsException + +
      extends jala.Test.Exception + + +
      + +

      +
      Instances of this exception are thrown whenever an assertion + function is called with incorrect or insufficient arguments +
      Defined in Global/jala.Test.js

      +

      + +
      + + + + + + + + + + + + + + + + + + + + + + + + +
      +Constructor Summary
      + + + jala.Test.ArgumentsException + + (<String> message) + +
      +             + Creates a new ArgumentsException instance +
      + + + +  + + + + + +

      + + + + + + + + + + + + + + + +
      + Constructor Detail +
      + +

      +jala.Test.ArgumentsException

      +
      jala.Test.ArgumentsException(<String> message)
      + + +
        + Creates a new ArgumentsException instance +
      + + + +
        + Parameters: + +
          message - The failure message +
        + + +
      + + + + +
        + Returns: +
          + A newly created ArgumentsException instance +
        +
      + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + + + +
      + + + +
      Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
      + + diff --git a/modules/jala/util/Test/docs/jala.Test.DatabaseMgr.html b/modules/jala/util/Test/docs/jala.Test.DatabaseMgr.html new file mode 100644 index 00000000..ee77071e --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.DatabaseMgr.html @@ -0,0 +1,486 @@ + + + + + +jala.Test.DatabaseMgr + + + + + + + + + + + + + + + + + + + + + +
      +Jala Test + +
      + +
      + + +

      Class jala.Test.DatabaseMgr

      +
      Object
      +   |
      +   +--jala.Test.DatabaseMgr
      +
      + + +
      +
      + +
      class + jala.Test.DatabaseMgr + + +
      + +

      +
      Instances of this class allow managing test databases + and switching a running application to an in-memory test + database to use within a unit test. +
      Defined in Global/jala.Test.js

      +

      + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + Field Summary
      +  Objectdatabases +
      +           Map containing all test databases
      +  ObjectdbSourceProperties +
      +           Map containing the original datasource + properties that were temporarily deactivated + by activating a test database
      +   + + + + + + + + + + + + + + + + + +
      +Constructor Summary
      + + + jala.Test.DatabaseMgr + + () + +
      +             + Returns a newly created DatabaseMgr instance +
      + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +Method Summary
      + +  jala.db.RamDatabase + + + + + startDatabase(<String> dbSourceName, <Boolean> copyTables, <Array> tables) + +
      +            + Switches the application datasource with the given name + to a newly created in-memory database. +
      + +  void + + + + + stopAll() + +
      +            + Stops all registered test databases and and reverts the application + to its original datasource(s) as defined in db.properties file. +
      + +  Object + + + + + toString() + +
      +            + +
      + + + +

      + + + + + + + + + + +
      Field Detail
      + + + +

      databases

      +
      Object databases
      +
        + Map containing all test databases + +
      +
      + + +

      dbSourceProperties

      +
      Object dbSourceProperties
      +
        + Map containing the original datasource + properties that were temporarily deactivated + by activating a test database + +
      +
      + + + + + + + + + + + + +
      + Constructor Detail +
      + +

      +jala.Test.DatabaseMgr

      +
      jala.Test.DatabaseMgr()
      + + +
        + Returns a newly created DatabaseMgr instance +
      + + + +
    + + + + +
      + Returns: +
        + A newly created instance of DatabaseMgr +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    startDatabase

    +
    jala.db.RamDatabase startDatabase(<String> dbSourceName, <Boolean> copyTables, <Array> tables)
    + +
      Switches the application datasource with the given name + to a newly created in-memory database. In addition this method + also clears the application cache and invalidates the root + object to ensure that everything is re-retrieved from the + test database. + This method can be called with a second boolean argument indicating + that tables used by the application should be created in the in-memory + database (excluding any data).
    + + + + +
      + Parameters: + +
        dbSourceName - The name of the application database source as defined in db.properties +
      + +
        copyTables - If true this method also copies all tables in the source database to the test database (excluding indexes). +
      + +
        tables - An optional array containing table names that should be created in the test database. If not specified this method collects all tables that are mapped in the application. +
      + +
    + + + + +
      + Returns: +
        + The test database +
      +
    + + + + + +
    + + +

    stopAll

    +
    void stopAll()
    + +
      Stops all registered test databases and and reverts the application + to its original datasource(s) as defined in db.properties file. + In addition this method commits all pending changes within the request, + cleares the application cache and invalidates the root object + to ensure no traces of the test database are left behind.
    + + + + + + + + + + + +
    + + +

    toString

    +
    Object toString()
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.EvaluatorException.html b/modules/jala/util/Test/docs/jala.Test.EvaluatorException.html new file mode 100644 index 00000000..d6b8fbb1 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.EvaluatorException.html @@ -0,0 +1,279 @@ + + + + + +jala.Test.EvaluatorException + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.EvaluatorException

    +
    Object
    +   |
    +   +--jala.Test.Exception
    +         |
    +         +--jala.Test.EvaluatorException
    +
    + + +
    +
    + +
    class + jala.Test.EvaluatorException + +
    extends jala.Test.Exception + + +
    + +

    +
    Instances of this exception are thrown when attempt + to evaluate the test code fails. +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.EvaluatorException + + (<String> message, <String> exception) + +
    +             + Creates a new EvaluatorException instance +
    + + + +  + + + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.EvaluatorException

    +
    jala.Test.EvaluatorException(<String> message, <String> exception)
    + + +
      + Creates a new EvaluatorException instance +
    + + + +
      + Parameters: + +
        message - The failure message, or an Error previously thrown. +
      + +
        exception - An optional nested Error +
      + + +
    + + + + +
      + Returns: +
        + A newly created EvaluatorException instance +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.Exception.html b/modules/jala/util/Test/docs/jala.Test.Exception.html new file mode 100644 index 00000000..8145120c --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.Exception.html @@ -0,0 +1,272 @@ + + + + + +jala.Test.Exception + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.Exception

    +
    Object
    +   |
    +   +--jala.Test.Exception
    +
    + +
    +
    + Direct Known Subclasses: +
    + jala.Test.EvaluatorException, jala.Test.ArgumentsException, jala.Test.TestException +
    +
    + + +
    +
    + +
    class + jala.Test.Exception + + +
    + +

    +
    Base exception class +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.Exception + + () + +
    +             + Creates a new Exception instance +
    + + + +  + + + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.Exception

    +
    jala.Test.Exception()
    + + +
      + Creates a new Exception instance +
    + + + + + + + + +
      + Returns: +
        + A newly created Exception instance +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.HttpClient.html b/modules/jala/util/Test/docs/jala.Test.HttpClient.html new file mode 100644 index 00000000..cbdc5838 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.HttpClient.html @@ -0,0 +1,593 @@ + + + + + +jala.Test.HttpClient + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.HttpClient

    +
    Object
    +   |
    +   +--jala.Test.HttpClient
    +
    + + +
    +
    + +
    class + jala.Test.HttpClient + + +
    + +

    +
    Instances of this class represent a http client useable for + testing, as any session cookies received by the tested application + are stored and used for subsequent requests, allowing simple "walkthrough" + tests. +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.HttpClient + + () + +
    +             + Constructs a new HttpClient instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Object + + + + + executeRequest(<String> method, <String> url, <Object> param) + +
    +            + Sends a HTTP request to the Url passed as argument +
    + +  helma.Http + + + + + getClient() + +
    +            + Returns the http client used +
    + +  Array + + + + + getCookies() + +
    +            + Returns the cookies set for this http client +
    + +  Object + + + + + getUrl(<String> url, <Object> param) + +
    +            + Convenience method for requesting the url passed as argument + using method GET +
    + +  void + + + + + setCookies(<Array> arr) + +
    +            + Sets the cookie to use for subsequent requests using this client +
    + +  Object + + + + + submitForm(<String> url, <Object> param) + +
    +            + Convenience method for submitting a form. +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.HttpClient

    +
    jala.Test.HttpClient()
    + + +
      + Constructs a new HttpClient instance +
    + + + + + + + + +
      + Returns: +
        + A newly constructed HttpClient +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    executeRequest

    +
    Object executeRequest(<String> method, <String> url, <Object> param)
    + +
      Sends a HTTP request to the Url passed as argument
    + + + + +
      + Parameters: + +
        method - The HTTP method to use +
      + +
        url - The url to request +
      + +
        param - A parameter object to use with this request +
      + +
    + + + + +
      + Returns: +
        + An object containing response values +
      +
    + + + + +
      + See:
        - helma.Http.prototype.getUrl
      +
    + + +
    + + +

    getClient

    +
    helma.Http getClient()
    + +
      Returns the http client used
    + + + + + + + +
      + Returns: +
        + The http client used +
      +
    + + + + + +
    + + +

    getCookies

    +
    Array getCookies()
    + +
      Returns the cookies set for this http client
    + + + + + + + +
      + Returns: +
        + The cookies to use for subsequent requests +
      +
    + + + + + +
    + + +

    getUrl

    +
    Object getUrl(<String> url, <Object> param)
    + +
      Convenience method for requesting the url passed as argument + using method GET
    + + + + +
      + Parameters: + +
        url - The url to request +
      + +
        param - A parameter object to use with this request +
      + +
    + + + + +
      + Returns: +
        + An object containing response values +
      +
    + + + + +
      + See:
        - helma.Http.prototype.getUrl
      +
    + + +
    + + +

    setCookies

    +
    void setCookies(<Array> arr)
    + +
      Sets the cookie to use for subsequent requests using this client
    + + + + +
      + Parameters: + +
        arr - The cookie object as received from helma.Http.getUrl +
      + +
    + + + + + + + + +
    + + +

    submitForm

    +
    Object submitForm(<String> url, <Object> param)
    + +
      Convenience method for submitting a form.
    + + + + +
      + Parameters: + +
        url - The url to request +
      + +
        param - A parameter object to use with this request +
      + +
    + + + + +
      + Returns: +
        + An object containing response values +
      +
    + + + + +
      + See:
        - helma.Http.prototype.getUrl
      +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.SmtpServer.Message.html b/modules/jala/util/Test/docs/jala.Test.SmtpServer.Message.html new file mode 100644 index 00000000..1093292f --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.SmtpServer.Message.html @@ -0,0 +1,705 @@ + + + + + +jala.Test.SmtpServer.Message + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.SmtpServer.Message

    +
    Object
    +   |
    +   +--jala.Test.SmtpServer.Message
    +
    + + +
    +
    + +
    class + jala.Test.SmtpServer.Message + + +
    + +

    +
    Instances of this class represent a mail message received + by the SMTP server +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.SmtpServer.Message + + (<org.subethamail.wiser.WiserMessage> message) + +
    +             + Creates a new Mail instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Array + + + + + getCc() + +
    +            + Returns an array containing all CC recipients of this mail +
    + +  Object + + + + + getContent() + +
    +            + Returns the content of this mail +
    + +  String + + + + + getContentType() + +
    +            + Returns the content type of this mail as defined in the "Content-Type" + header field +
    + +  String + + + + + getEncoding() + +
    +            + Returns the encoding of this mail as defined in the "Content-Transfer-Encoding" + header field +
    + +  Array + + + + + getFrom() + +
    +            + Returns an array containing all senders of this mail +
    + +  org.subethamail.wiser.WiserMessage + + + + + getMessage() + +
    +            + Returns the wrapped message +
    + +  javax.mail.internet.MimeMessage + + + + + getMimeMessage() + +
    +            + Returns the wrapped message as MimeMessage +
    + +  Array + + + + + getReplyTo() + +
    +            + Returns an array with all reply-to addresses of this mail +
    + +  String + + + + + getSubject() + +
    +            + Returns the subject of this mail +
    + +  Array + + + + + getTo() + +
    +            + Returns an array containing all recipients of this mail +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.SmtpServer.Message

    +
    jala.Test.SmtpServer.Message(<org.subethamail.wiser.WiserMessage> message)
    + + +
      + Creates a new Mail instance +
    + + + +
      + Parameters: + +
        message - The message as received by the SMTP server +
      + + +
    + + + + +
      + Returns: +
        + A newly created Mail instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getCc

    +
    Array getCc()
    + +
      Returns an array containing all CC recipients of this mail
    + + + + + + + +
      + Returns: +
        + An array with all CC recipients of this mail +
      +
    + + + + + +
    + + +

    getContent

    +
    Object getContent()
    + +
      Returns the content of this mail
    + + + + + + + +
      + Returns: +
        + The content of this mail +
      +
    + + + + + +
    + + +

    getContentType

    +
    String getContentType()
    + +
      Returns the content type of this mail as defined in the "Content-Type" + header field
    + + + + + + + +
      + Returns: +
        + The content type of this mail +
      +
    + + + + + +
    + + +

    getEncoding

    +
    String getEncoding()
    + +
      Returns the encoding of this mail as defined in the "Content-Transfer-Encoding" + header field
    + + + + + + + +
      + Returns: +
        + The encoding of this mail +
      +
    + + + + + +
    + + +

    getFrom

    +
    Array getFrom()
    + +
      Returns an array containing all senders of this mail
    + + + + + + + +
      + Returns: +
        + An array with all senders of this mail +
      +
    + + + + + +
    + + +

    getMessage

    +
    org.subethamail.wiser.WiserMessage getMessage()
    + +
      Returns the wrapped message
    + + + + + + + + + + + +
    + + +

    getMimeMessage

    +
    javax.mail.internet.MimeMessage getMimeMessage()
    + +
      Returns the wrapped message as MimeMessage
    + + + + + + + + + + + +
    + + +

    getReplyTo

    +
    Array getReplyTo()
    + +
      Returns an array with all reply-to addresses of this mail
    + + + + + + + +
      + Returns: +
        + An array with all reply-to addresses of this mail +
      +
    + + + + + +
    + + +

    getSubject

    +
    String getSubject()
    + +
      Returns the subject of this mail
    + + + + + + + +
      + Returns: +
        + The subject of this mail +
      +
    + + + + + +
    + + +

    getTo

    +
    Array getTo()
    + +
      Returns an array containing all recipients of this mail
    + + + + + + + +
      + Returns: +
        + An array with all recipients of this mail +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.SmtpServer.html b/modules/jala/util/Test/docs/jala.Test.SmtpServer.html new file mode 100644 index 00000000..c8d06ecc --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.SmtpServer.html @@ -0,0 +1,434 @@ + + + + + +jala.Test.SmtpServer + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.SmtpServer

    +
    Object
    +   |
    +   +--jala.Test.SmtpServer
    +
    + + +
    +
    + +
    class + jala.Test.SmtpServer + + +
    + +

    +
    Instances of this class represent an SMTP server listening on + localhost. By default jala.Test will create a global variable called + "smtpServer" that contains an instance of this class. To use the server call + start() in a test method (eg. in the basic setup method) and + stop() in the cleanup method. +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Test.SmtpServer.Message
    +  + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.SmtpServer + + (<Number> port) + +
    +             + Creates a new SmtpServer instance +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  Array + + + + + getMessages() + +
    +            + Returns an array containing all mails received by the server, + where each one is an instance of jala.Test.SmtpServer.Message +
    + +  void + + + + + start() + +
    +            + Starts the SMTP server. +
    + +  void + + + + + stop() + +
    +            + Stops the SMTP server and switches the "smtp" property of the tested + application back to the value defined in app or server.properties +
    + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.SmtpServer

    +
    jala.Test.SmtpServer(<Number> port)
    + + +
      + Creates a new SmtpServer instance +
    + + + +
      + Parameters: + +
        port - Optional port to listen on (defaults to 25) +
      + + +
    + + + + +
      + Returns: +
        + A newly created SmtpServer instance +
      +
    + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    getMessages

    +
    Array getMessages()
    + + + + + + + + + +
      + Returns: +
        + An array with all messages +
      +
    + + + + + +
    + + +

    start

    +
    void start()
    + +
      Starts the SMTP server. Note that this method switches the SMTP server as + defined in app.properties of the tested application or server.properties + to "localhost" to ensure that all mails sent during tests are received + by this server. The SMTP server definition is switched back to the + original when stop() is called.
    + + + + + + + + + + + +
    + + +

    stop

    +
    void stop()
    + +
      Stops the SMTP server and switches the "smtp" property of the tested + application back to the value defined in app or server.properties
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.TestException.html b/modules/jala/util/Test/docs/jala.Test.TestException.html new file mode 100644 index 00000000..98f158fe --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.TestException.html @@ -0,0 +1,279 @@ + + + + + +jala.Test.TestException + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.TestException

    +
    Object
    +   |
    +   +--jala.Test.Exception
    +         |
    +         +--jala.Test.TestException
    +
    + + +
    +
    + +
    class + jala.Test.TestException + +
    extends jala.Test.Exception + + +
    + +

    +
    Instances of this exception are thrown whenever an + assertion function fails +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.TestException + + (<String> comment, <String> message) + +
    +             + Creates a new TestException instance +
    + + + +  + + + + + +

    + + + + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.TestException

    +
    jala.Test.TestException(<String> comment, <String> message)
    + + +
      + Creates a new TestException instance +
    + + + +
      + Parameters: + +
        comment - An optional comment +
      + +
        message - The failure message +
      + + +
    + + + + +
      + Returns: +
        + A newly created TestException instance +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.TestFunctionResult.html b/modules/jala/util/Test/docs/jala.Test.TestFunctionResult.html new file mode 100644 index 00000000..44590e95 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.TestFunctionResult.html @@ -0,0 +1,332 @@ + + + + + +jala.Test.TestFunctionResult + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.TestFunctionResult

    +
    Object
    +   |
    +   +--jala.Test.TestFunctionResult
    +
    + + +
    +
    + +
    class + jala.Test.TestFunctionResult + + +
    + +

    +
    Instances of this class represent the result of the successful + execution of a single test function (failed executions will be represented + as Exceptions in the log of a test result). +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Objectelapsed +
    +           
    +  ObjectfunctionName +
    +           
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.TestFunctionResult + + (<String> functionName, <Date> startTime) + +
    +             + Constructs a new TestFunctionResult instance +
    + + + +  + + + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    elapsed

    +
    Object elapsed
    +
      + + +
    +
    + + +

    functionName

    +
    Object functionName
    +
      + + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.TestFunctionResult

    +
    jala.Test.TestFunctionResult(<String> functionName, <Date> startTime)
    + + +
      + Constructs a new TestFunctionResult instance +
    + + + +
      + Parameters: + +
        functionName - The name of the excecuted test function +
      + +
        startTime - A Date instance marking the begin of the test +
      + + +
    + + + + +
      + Returns: +
        + A new TestFunctionResult instance +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.TestResult.html b/modules/jala/util/Test/docs/jala.Test.TestResult.html new file mode 100644 index 00000000..9b631c3b --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.TestResult.html @@ -0,0 +1,362 @@ + + + + + +jala.Test.TestResult + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test.TestResult

    +
    Object
    +   |
    +   +--jala.Test.TestResult
    +
    + + +
    +
    + +
    class + jala.Test.TestResult + + +
    + +

    +
    Instances of this class represent the result of the execution + of a single test file +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  Objectelapsed +
    +           
    +  Objectlog +
    +           
    +  Objectname +
    +           
    +  Objectstatus +
    +           
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test.TestResult + + (<String> testFileName) + +
    +             + Constructs a new TestResult instance +
    + + + +  + + + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    elapsed

    +
    Object elapsed
    +
      + + +
    +
    + + +

    log

    +
    Object log
    +
      + + +
    +
    + + +

    name

    +
    Object name
    +
      + + +
    +
    + + +

    status

    +
    Object status
    +
      + + +
    +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test.TestResult

    +
    jala.Test.TestResult(<String> testFileName)
    + + +
      + Constructs a new TestResult instance +
    + + + +
      + Parameters: + +
        testFileName - The name of the excecuted test file +
      + + +
    + + + + +
      + Returns: +
        + A new TestResult instance +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.Test.html b/modules/jala/util/Test/docs/jala.Test.html new file mode 100644 index 00000000..73a857e7 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.Test.html @@ -0,0 +1,2008 @@ + + + + + +jala.Test + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala.Test

    +
    Object
    +   |
    +   +--jala.Test
    +
    + + +
    +
    + +
    class + jala.Test + + +
    + +

    +
    Provides various methods for automated tests. + This is essentially a port of JSUnit (http://www.edwardh.com/jsunit/) + suitable for testing Helma applications. +
    Defined in Global/jala.Test.js

    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Test.Exception
    + <static class>jala.Test.TestException
    + <static class>jala.Test.ArgumentsException
    + <static class>jala.Test.EvaluatorException
    + <static class>jala.Test.TestResult
    + <static class>jala.Test.TestFunctionResult
    + <static class>jala.Test.HttpClient
    + <static class>jala.Test.DatabaseMgr
    + <static class>jala.Test.SmtpServer
    +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Field Summary
    +  NumberfunctionsFailed +
    +           Contains the number of test functions that failed
    +  NumberfunctionsPassed +
    +           Contains the number of test functions that passed
    +  Arrayresults +
    +           An Array containing the results of this Test instance.
    +  BooleantestsFailed +
    +           Contains the number of tests that failed
    +  NumbertestsRun +
    +           Contains the number of tests that were executed
    + <static>  <final> StringFAILED +
    +           Constant indicating "failed" status
    + <static>  <final> StringPASSED +
    +           Constant indicating "passed" status
    +   + + + + + + + + + + + + + + + + + +
    +Constructor Summary
    + + + jala.Test + + () + +
    +             + Constructs a new Test instance. +
    + + + +  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Method Summary
    + +  void + + + + + assertEqual(<Object> val1, <Object> val2) + +
    +            + Checks if the values passed as arguments are equal. +
    + +  void + + + + + assertEqualFile(<Object> val, <String|helma.File> file) + +
    +            + Checks if the value passed as argument equals the content of a file on disk. +
    + +  void + + + + + assertFalse(<Object> val) + +
    +            + Checks if the value passed as argument is boolean false. +
    + +  void + + + + + assertMatch(<String> val, <RegExp> rxp) + +
    +            + Checks if the regular expression matches the string. +
    + +  void + + + + + assertNaN(<Object> val) + +
    +            + Checks if the value passed as argument is NaN. +
    + +  void + + + + + assertNotEqual(<Object> val1, <Object> val2) + +
    +            + Checks if the values passed as arguments are not equal. +
    + +  void + + + + + assertNotNaN(<Object> val) + +
    +            + Checks if the value passed as argument is not NaN. +
    + +  void + + + + + assertNotNull(<Object> val) + +
    +            + Checks if the value passed as argument is not null. +
    + +  void + + + + + assertNotUndefined(<Object> val) + +
    +            + Checks if the value passed as argument is not undefined. +
    + +  void + + + + + assertNull(<Object> val) + +
    +            + Checks if the value passed as argument is null. +
    + +  void + + + + + assertStringContains(<String> val, <String> str) + +
    +            + Checks if the value passed as argument contains the pattern specified. +
    + +  void + + + + + assertThrows(<Object> func, <Object> exception) + +
    +            + Checks if the function passed as argument throws a defined exception. +
    + +  void + + + + + assertTrue(<Object> val) + +
    +            + Checks if the value passed as argument is boolean true. +
    + +  void + + + + + assertUndefined(<Object> val) + +
    +            + Checks if the value passed as argument is undefined. +
    + +  String + + + + + directory_macro() + +
    +            + Returns the absolute path to the directory containing the tests +
    + +  void + + + + + execute(<String|Array> what) + +
    +            + Main test execution function +
    + +  void + + + + + executeTest(<helma.File> testFile) + +
    +            + Executes a single test file +
    + +  Object + + + + + executeTestFunction(<String> functionName, <helma.scripting.rhino.GlobalObject> scope) + +
    +            + Executes a single test function +
    + +  void + + + + + list_macro() + +
    +            + Renders the list of available tests +
    + +  void + + + + + renderResult(result) + +
    +            + Renders the result of a single test +
    + +  void + + + + + renderResults() + +
    +            + Renders the results of all tests done by this test instance + to response. +
    + +  void + + + + + results_macro() + +
    +            + Renders the test results +
    + + <static> Boolean + + + + + argsContainComment(<Array> args, <Number> argsExpected) + +
    +            + Returns true if the arguments array passed as argument + contains an additional comment. +
    + + <static> Boolean + + + + + evalArguments(<Object> args, argsExpected) + +
    +            + +
    + + <static> String + + + + + getComment(<Array> args, argsExpected) + +
    +            + Cuts out the comment from the arguments array passed + as argument and returns it. +
    + + <static> String + + + + + getStackTrace(<java.lang.StackTraceElement> trace) + +
    +            + Creates a stack trace and parses it for display. +
    + + <static> helma.File + + + + + getTestFile(<String> fileName) + +
    +            + Returns the testfile with the given name +
    + + <static> Array + + + + + getTestFiles() + +
    +            + Returns an array containing the test files located + in the directory. +
    + + <static> helma.File + + + + + getTestsDirectory() + +
    +            + Returns the directory containing the test files. +
    + + <static> Object + + + + + getValue(<Array> args, argsExpected, <Number> idx) + +
    +            + Returns the argument on the index position in the array + passed as arguments. +
    + + <static> void + + + + + include(<Object> scope, file) + +
    +            + Evaluates a javascript file in the global test scope. +
    + + <static> String + + + + + valueToString(val) + +
    +            + Helper method useable for displaying a value +
    + + + +

    + + + + + + + + + + +
    Field Detail
    + + + +

    functionsFailed

    +
    Number functionsFailed
    +
      + Contains the number of test functions that failed + +
    +
    + + +

    functionsPassed

    +
    Number functionsPassed
    +
      + Contains the number of test functions that passed + +
    +
    + + +

    results

    +
    Array results
    +
      + An Array containing the results of this Test instance. + +
    +
    + + +

    testsFailed

    +
    Boolean testsFailed
    +
      + Contains the number of tests that failed + +
    +
    + + +

    testsRun

    +
    Number testsRun
    +
      + Contains the number of tests that were executed + +
    +
    + + +

    FAILED

    +
    <static> <final> String FAILED
    + +
    + + +

    PASSED

    +
    <static> <final> String PASSED
    + +
    + + + + + + + + + + + + +
    + Constructor Detail +
    + +

    +jala.Test

    +
    jala.Test()
    + + +
      + Constructs a new Test instance. +
    + + + +
      + Parameters: + +
        capacity - The capacity of the cache +
      + + +
    + + + + + + + + +
    + + + + + + + + + + + + +
    + Method Detail +
    + + + + +

    assertEqual

    +
    void assertEqual(<Object> val1, <Object> val2)
    + +
      Checks if the values passed as arguments are equal.
    + + + + +
      + Parameters: + +
        val1 - The value that should be compared to the second argument. +
      + +
        val2 - The value that should be compared to the first argument. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertEqualFile

    +
    void assertEqualFile(<Object> val, <String|helma.File> file)
    + +
      Checks if the value passed as argument equals the content of a file on disk.
    + + + + +
      + Parameters: + +
        val - The value that should be compared with the content of the file on disk. +
      + +
        file - Either a file name (including a path), or an instance of helma.File representing the file to use for comparison. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertFalse

    +
    void assertFalse(<Object> val)
    + +
      Checks if the value passed as argument is boolean false.
    + + + + +
      + Parameters: + +
        val - The value that should be boolean false. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertMatch

    +
    void assertMatch(<String> val, <RegExp> rxp)
    + +
      Checks if the regular expression matches the string.
    + + + + +
      + Parameters: + +
        val - The string that should contain the regular expression pattern +
      + +
        rxp - The regular expression that should match the value +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNaN

    +
    void assertNaN(<Object> val)
    + +
      Checks if the value passed as argument is NaN.
    + + + + +
      + Parameters: + +
        val - The value that should be NaN. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNotEqual

    +
    void assertNotEqual(<Object> val1, <Object> val2)
    + +
      Checks if the values passed as arguments are not equal.
    + + + + +
      + Parameters: + +
        val1 - The value that should be compared to the second argument. +
      + +
        val2 - The value that should be compared to the first argument. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNotNaN

    +
    void assertNotNaN(<Object> val)
    + +
      Checks if the value passed as argument is not NaN.
    + + + + +
      + Parameters: + +
        val - The value that should be not NaN. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNotNull

    +
    void assertNotNull(<Object> val)
    + +
      Checks if the value passed as argument is not null.
    + + + + +
      + Parameters: + +
        val - The value that should be not null. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNotUndefined

    +
    void assertNotUndefined(<Object> val)
    + +
      Checks if the value passed as argument is not undefined.
    + + + + +
      + Parameters: + +
        val - The value that should be not undefined. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertNull

    +
    void assertNull(<Object> val)
    + +
      Checks if the value passed as argument is null.
    + + + + +
      + Parameters: + +
        val - The value that should be null. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertStringContains

    +
    void assertStringContains(<String> val, <String> str)
    + +
      Checks if the value passed as argument contains the pattern specified.
    + + + + +
      + Parameters: + +
        val - The string that should contain the pattern +
      + +
        str - The string that should be contained +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertThrows

    +
    void assertThrows(<Object> func, <Object> exception)
    + +
      Checks if the function passed as argument throws a defined exception.
    + + + + +
      + Parameters: + +
        func - The function to call +
      + +
        exception - Optional object expected to be thrown when executing the function +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertTrue

    +
    void assertTrue(<Object> val)
    + +
      Checks if the value passed as argument is boolean true.
    + + + + +
      + Parameters: + +
        val - The value that should be boolean true. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    assertUndefined

    +
    void assertUndefined(<Object> val)
    + +
      Checks if the value passed as argument is undefined.
    + + + + +
      + Parameters: + +
        val - The value that should be undefined. +
      + +
    + + + + + + + +
      + Throws:
        - jala.Test.ArgumentsException
        - jala.Test.TestException
      +
    + + +
    + + +

    directory_macro

    +
    String directory_macro()
    + +
      Returns the absolute path to the directory containing the tests
    + + + + + + + +
      + Returns: +
        + The path to the tests directory +
      +
    + + + + + +
    + + +

    execute

    +
    void execute(<String|Array> what)
    + +
      Main test execution function
    + + + + +
      + Parameters: + +
        what - Either the name of a single test file or an array containing the names of several function files that should be executed. +
      + +
    + + + + + + + + +
    + + +

    executeTest

    +
    void executeTest(<helma.File> testFile)
    + +
      Executes a single test file
    + + + + +
      + Parameters: + +
        testFile - The file containing the test to run +
      + +
    + + + + + + + + +
    + + +

    executeTestFunction

    +
    Object executeTestFunction(<String> functionName, <helma.scripting.rhino.GlobalObject> scope)
    + +
      Executes a single test function
    + + + + +
      + Parameters: + +
        functionName - The name of the test function to execute +
      + +
        scope - The scope to execute the test method in +
      + +
    + + + + + + + + +
    + + +

    list_macro

    +
    void list_macro()
    + +
      Renders the list of available tests
    + + + + + + + + + + + +
    + + +

    renderResult

    +
    void renderResult(result)
    + +
      Renders the result of a single test
    + + + + +
      + Parameters: + +
        The - result to render +
      + +
    + + + + + + + + +
    + + +

    renderResults

    +
    void renderResults()
    + +
      Renders the results of all tests done by this test instance + to response.
    + + + + + + + + + + + +
    + + +

    results_macro

    +
    void results_macro()
    + +
      Renders the test results
    + + + + + + + + + + + +
    + + +

    argsContainComment

    +
    <static> Boolean argsContainComment(<Array> args, <Number> argsExpected)
    + +
      Returns true if the arguments array passed as argument + contains an additional comment.
    + + + + +
      + Parameters: + +
        args - The arguments array to check for an existing comment. +
      + +
        argsExpected - The number of arguments expected by the assertion function. +
      + +
    + + + + +
      + Returns: +
        + True if the arguments contain a comment, false otherwise. +
      +
    + + + + + +
    + + +

    evalArguments

    +
    <static> Boolean evalArguments(<Object> args, argsExpected)
    + + + + +
      + Parameters: + +
        args - The arguments array. +
      + +
        nr - The number of arguments to be expected +
      + +
    + + + + +
      + Returns: +
        + True in case the number of arguments matches the expected amount, false otherwise. +
      +
    + + + + + +
    + + +

    getComment

    +
    <static> String getComment(<Array> args, argsExpected)
    + +
      Cuts out the comment from the arguments array passed + as argument and returns it. CAUTION: this actually modifies + the arguments array!
    + + + + +
      + Parameters: + +
        args - The arguments array. +
      + +
    + + + + +
      + Returns: +
        + The comment, if existing. Null otherwise. +
      +
    + + + + + +
    + + +

    getStackTrace

    +
    <static> String getStackTrace(<java.lang.StackTraceElement> trace)
    + +
      Creates a stack trace and parses it for display.
    + + + + +
      + Parameters: + +
        trace - The trace to parse. If not given a stacktrace will be generated +
      + +
    + + + + +
      + Returns: +
        + The parsed stack trace +
      +
    + + + + + +
    + + +

    getTestFile

    +
    <static> helma.File getTestFile(<String> fileName)
    + +
      Returns the testfile with the given name
    + + + + +
      + Parameters: + +
        fileName - The name of the test file +
      + +
    + + + + +
      + Returns: +
        + The test file +
      +
    + + + + + +
    + + +

    getTestFiles

    +
    <static> Array getTestFiles()
    + +
      Returns an array containing the test files located + in the directory.
    + + + + + + + +
      + Returns: +
        + An array containing the names of all test files +
      +
    + + + + + +
    + + +

    getTestsDirectory

    +
    <static> helma.File getTestsDirectory()
    + +
      Returns the directory containing the test files. + The location of the directory is either defined by the + application property "jala.testDir" or expected to be one level + above the application directory (and named "tests")
    + + + + + + + +
      + Returns: +
        + The directory containing the test files +
      +
    + + + + + +
    + + +

    getValue

    +
    <static> Object getValue(<Array> args, argsExpected, <Number> idx)
    + +
      Returns the argument on the index position in the array + passed as arguments. This method respects an optional comment + at the beginning of the arguments array.
    + + + + +
      + Parameters: + +
        args - The arguments to retrieve the non-comment value from. +
      + +
        idx - The index position on which the value to retrieve is to be expected if no comment is existing. +
      + +
    + + + + +
      + Returns: +
        + The non-comment value, or null. +
      +
    + + + + + +
    + + +

    include

    +
    <static> void include(<Object> scope, file)
    + +
      Evaluates a javascript file in the global test scope. This method can be used + to include generic testing code in test files. This method is available as + global method "include" for all test methods
    + + + + +
      + Parameters: + +
        scope - The scope in which the file should be evaluated +
      + +
        fileName - The name of the file to include, including the path +
      + +
    + + + + + + + + +
    + + +

    valueToString

    +
    <static> String valueToString(val)
    + +
      Helper method useable for displaying a value
    + + + + +
      + Parameters: + +
        The - value to render +
      + +
    + + + + +
      + Returns: +
        + The value rendered as string +
      +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/jala.html b/modules/jala/util/Test/docs/jala.html new file mode 100644 index 00000000..05de1f60 --- /dev/null +++ b/modules/jala/util/Test/docs/jala.html @@ -0,0 +1,225 @@ + + + + + +jala + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + +
    + + +

    Class jala

    +
    Object
    +   |
    +   +--jala
    +
    + + +
    +
    + +
    class + jala + + +
    + +
    + + + + + + + + + + + + + + +
    +Nested Class Summary
    + <static class>jala.Test
    +  + + + + + + + + + + + + + + + + +  + + + + + +

    + + + + + + + + + + + + + + + + + +


    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test + +
    + + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/overview-Global_Global.js.html b/modules/jala/util/Test/docs/overview-Global_Global.js.html new file mode 100644 index 00000000..f002fa10 --- /dev/null +++ b/modules/jala/util/Test/docs/overview-Global_Global.js.html @@ -0,0 +1,30 @@ + + + + + + Global/Global.js + + + + + + +

    + +Global/Global.js +
    + + + + +
    + + + diff --git a/modules/jala/util/Test/docs/overview-Global_Root.js.html b/modules/jala/util/Test/docs/overview-Global_Root.js.html new file mode 100644 index 00000000..3edefc66 --- /dev/null +++ b/modules/jala/util/Test/docs/overview-Global_Root.js.html @@ -0,0 +1,30 @@ + + + + + + Global/Root.js + + + + + + +

    + +Global/Root.js +
    + + + + +
    + + + diff --git a/modules/jala/util/Test/docs/overview-Global_jala.Test.js.html b/modules/jala/util/Test/docs/overview-Global_jala.Test.js.html new file mode 100644 index 00000000..2a6b7249 --- /dev/null +++ b/modules/jala/util/Test/docs/overview-Global_jala.Test.js.html @@ -0,0 +1,96 @@ + + + + + + Global/jala.Test.js + + + + + + +

    + +Global/jala.Test.js +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    jala.Test +
    +
    jala.Test.ArgumentsException +
    +
    jala.Test.DatabaseMgr +
    +
    jala.Test.EvaluatorException +
    +
    jala.Test.Exception +
    +
    jala.Test.HttpClient +
    +
    jala.Test.SmtpServer +
    +
    jala.Test.SmtpServer.Message +
    +
    jala.Test.TestException +
    +
    jala.Test.TestFunctionResult +
    +
    jala.Test.TestResult +
    +
    + + + diff --git a/modules/jala/util/Test/docs/overview-frame.html b/modules/jala/util/Test/docs/overview-frame.html new file mode 100644 index 00000000..fef01bd7 --- /dev/null +++ b/modules/jala/util/Test/docs/overview-frame.html @@ -0,0 +1,43 @@ + + + + +Overview () + + + + + + +

    Jala Test

    + + + + +
    + + + + + +
    All Classes +

    + +Files +
    + +Global/jala.Test.js
    + +Global/Root.js
    + +

    + +

    +  + + diff --git a/modules/jala/util/Test/docs/overview-summary-Global_Global.js.html b/modules/jala/util/Test/docs/overview-summary-Global_Global.js.html new file mode 100644 index 00000000..3eaeafd8 --- /dev/null +++ b/modules/jala/util/Test/docs/overview-summary-Global_Global.js.html @@ -0,0 +1,206 @@ + + + + +jala.Test Overview + + + + + + + + + + + + + + + + + + +
    + +jala.Test +
    + + +


    +
    + +

    Global/Global.js

    + +
    + + + + +

    Summary

    +

    + + No overview generated for 'Global/Global.js'

    + +

    + +
    + + + + + + + + +
    //
    +// Jala Project [http://opensvn.csie.org/traccgi/jala]
    +//
    +// Copyright 2004 ORF Online und Teletext GmbH
    +//
    +// Licensed under the Apache License, Version 2.0 (the ``License'');
    +// you may not use this file except in compliance with the License.
    +// You may obtain a copy of the License at
    +//
    +//    http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an ``AS IS'' BASIS,
    +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +// See the License for the specific language governing permissions and
    +// limitations under the License.
    +//
    +// $Revision$
    +// $LastChangedBy$
    +// $LastChangedDate$
    +// $HeadURL$
    +//
    +
    +
    +/**
    + * Module dependencies
    + */
    +app.addRepository("modules/core/HopObject.js");
    +app.addRepository("modules/helma/File.js");
    +
    +/**
    + * Test runner
    + */
    +Root.prototype.runner_action = function() {
    +   res.handlers.test = new jala.Test();
    +   if (req.isGet() && req.data.test) {
    +      res.handlers.test.execute(req.data.test);
    +   } else if (req.isPost() && (req.data.test_array || req.data.test)) {
    +      res.handlers.test.execute(req.data.test_array || req.data.test);
    +   }
    +   renderSkin("jala.Test.main");
    +   return;
    +};
    +
    +/**
    + * External stylesheet for test runner
    + */
    +Root.prototype.jala_Test_stylesheet_action = function() {
    +   res.contentType = "text/css";
    +   renderSkin("jala.Test.stylesheet");
    +   return;
    +};
    +
    +
    + + + + + + + + + + + + + + + +
    +jala.Test +
    + + +
    + + + +
    Documentation generated by JSDoc on Mon Feb 12 14:40:38 2007
    + + diff --git a/modules/jala/util/Test/docs/overview-summary-Global_Root.js.html b/modules/jala/util/Test/docs/overview-summary-Global_Root.js.html new file mode 100644 index 00000000..fbee4bcd --- /dev/null +++ b/modules/jala/util/Test/docs/overview-summary-Global_Root.js.html @@ -0,0 +1,151 @@ + + + + +Jala Test Overview + + + + + + + + + + + + + + + + + + +
    + +Jala Test +
    + + +
    +
    + +

    Global/Root.js

    + +
    + + + + +

    Summary

    +

    + + No overview generated for 'Global/Root.js'

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/overview-summary-Global_jala.Test.js.html b/modules/jala/util/Test/docs/overview-summary-Global_jala.Test.js.html new file mode 100644 index 00000000..8e23ecac --- /dev/null +++ b/modules/jala/util/Test/docs/overview-summary-Global_jala.Test.js.html @@ -0,0 +1,236 @@ + + + + +Jala Test Overview + + + + + + + + + + + + + + + + + + +
    + +Jala Test +
    + + +
    +
    + +

    Global/jala.Test.js

    + +
    + + + + +

    Summary

    +

    + + Fields and methods of the jala.Test class.

    + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + Class Summary + +
    jala.TestProvides various methods for automated tests.
    jala.Test.ArgumentsExceptionInstances of this exception are thrown whenever an assertion + function is called with incorrect or insufficient arguments +
    jala.Test.DatabaseMgrInstances of this class allow managing test databases + and switching a running application to an in-memory test + database to use within a unit test.
    jala.Test.EvaluatorExceptionInstances of this exception are thrown when attempt + to evaluate the test code fails.
    jala.Test.ExceptionBase exception class +
    jala.Test.HttpClientInstances of this class represent a http client useable for + testing, as any session cookies received by the tested application + are stored and used for subsequent requests, allowing simple "walkthrough" + tests.
    jala.Test.SmtpServerInstances of this class represent an SMTP server listening on + localhost.
    jala.Test.SmtpServer.MessageInstances of this class represent a mail message received + by the SMTP server +
    jala.Test.TestExceptionInstances of this exception are thrown whenever an + assertion function fails +
    jala.Test.TestFunctionResultInstances of this class represent the result of the successful + execution of a single test function (failed executions will be represented + as Exceptions in the log of a test result).
    jala.Test.TestResultInstances of this class represent the result of the execution + of a single test file +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/overview-summary.html b/modules/jala/util/Test/docs/overview-summary.html new file mode 100644 index 00000000..cd3cb6cb --- /dev/null +++ b/modules/jala/util/Test/docs/overview-summary.html @@ -0,0 +1,178 @@ + + + + +Jala Test Overview + + + + + + + + + + + + + + + + + + +
    + +Jala Test +
    + + +
    +
    + +

    Jala Test

    + +
    + + +

    + This document is the API Specification for + Jala Test. +

    + + + +

    Summary

    +

    + + No summary generated for these documents. + +

    + +
    + + + + + + + + + + + + + + + + + +
    + + File Summary + +
    Global/jala.Test.jsFields and methods of the jala.Test class.
    Global/Root.js 
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +Jala Test +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/overview-tree.html b/modules/jala/util/Test/docs/overview-tree.html new file mode 100644 index 00000000..22e0d0fd --- /dev/null +++ b/modules/jala/util/Test/docs/overview-tree.html @@ -0,0 +1,173 @@ + + + + + +Jala Test Class Hierarchy + + + + + + + + + + + + + + + + + + +
    +Jala Test +
    + + +
    +

    Class Hierarchy

    + + + +
    + + + + + + + + + + + + + +
    +Jala Test +
    + + +
    + + + +
    Documentation generated by JSDoc on Tue Jan 8 15:50:17 2008
    + + diff --git a/modules/jala/util/Test/docs/stylesheet.css b/modules/jala/util/Test/docs/stylesheet.css new file mode 100644 index 00000000..7a35c0c1 --- /dev/null +++ b/modules/jala/util/Test/docs/stylesheet.css @@ -0,0 +1,39 @@ +/* JSDoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ +.TableRowColor { background: #FFFFFF } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameHeadingFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } +.FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, san-serif } + +/* Example of smaller, sans-serif font in frames */ +/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ +.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} + +.jsdoc_ctime { font-family: Arial, Helvetica, sans-serif; font-size: 9pt; + text-align: right } + +/* Sourcecode view */ +.sourceview { background: #FFFFFF } +.attrib { color: #DD7777 } +.comment { color: #55AA55 } +.reserved { color: #FF5555 } +.literal { color: #5555FF } + diff --git a/modules/jala/util/Test/tests/selftest.js b/modules/jala/util/Test/tests/selftest.js new file mode 100644 index 00000000..5e175b6e --- /dev/null +++ b/modules/jala/util/Test/tests/selftest.js @@ -0,0 +1,169 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Declare which test methods should be run in which order + * @type Array + * @final + */ + +/** + * Test for jala.Test.evalArguments + */ +var testEvalArguments = function testEvalArguments() { + var args; + // test arguments without a comment + args = [true, false, 1, "one", new Date()]; + jala.Test.evalArguments(args, 5); + // test arguments with a comment + args = ["a comment", true, false, 1, "one", new Date()]; + jala.Test.evalArguments(args, 5); + return; +}; + +/** + * Test for jala.Test.containsComment + */ +var testArgsContainComment = function testArgsContainComment() { + var args = ["a comment", true]; + if (jala.Test.argsContainComment(args, 1) !== true) { + throw new jala.Test.TestException(null, + "Argument array is supposed to contain a comment, but doesn't"); + } + return; +}; + +/** + * Test for jala.Test.getComment + */ +var testGetComment = function testGetComment() { + var args = ["a comment", true]; + if (jala.Test.getComment(args, 1) !== args[0]) { + throw new jala.Test.TestException(null, "Couldn't get comment"); + } + return; +}; + +/** + * Test for jala.Test.getValue + */ +var testGetValue = function testGetValue() { + var args = ["a comment", 1, 2, 3]; + if (jala.Test.getValue(args, 3, 1) !== args[2]) { + throw new jala.Test.TestException("Couldn't get correct argument value"); + } + return; +}; + +/** + * Testing assertion functions + */ +var testBasicAssertionFunctions = function testAssertionFunctions() { + assertTrue("just a comment", true); + assertFalse("just a comment", false); + assertEqual(1, 1); + assertEqualArrays("asserting arrays", [1,2,3], [1,2,3]); + assertEqualArrays(["1","2"], ["1","2"]); + assertNotEqual(1, 2); + assertNull(null); + assertNotNull(true); + assertUndefined(undefined); + assertNotUndefined(true); + assertNaN("one"); + assertNotNaN(1); + assertStringContains("just a self test", "self"); + assertMatch("just a self test", /^just/); + return; +}; + +/** + * Testing assertThrows + */ +var testAssertThrows = function testAssertThrows() { + // throw undefined (yes, you can do that...) + assertThrows(function() { + throw undefined; + }, undefined); + // throw custom javascript object + assertThrows(function() { + throw new jala.Test.TestException("", "message"); + }, jala.Test.TestException); + // throw string + assertThrows(function() { + throw "my message"; + }, "my message"); + // throw java exception + assertThrows(function() { + var x = new java.util.Vector(0); + res.debug(x.get(1)); + }, java.lang.ArrayIndexOutOfBoundsException); + // throw anything, but don't check further + assertThrows(function() { + throw new Date(); + }); + // don't throw an expected exception + assertThrows(function() { + assertThrows(function() { + return; + }, "oy"); + }, jala.Test.TestException); + return; +}; + +var testInclude = function() { + var dir = java.lang.System.getProperty("java.io.tmpdir"); + var content = "var INCLUDED = true;"; + // create include file with the above content + var file = new helma.File(dir, "testInclude." + (new Date()).getTime()); + file.open(); + file.write(content); + file.close(); + include(file); + // now include the file and test if everything works + assertTrue(global["INCLUDED"]); + // finally remove the include file again + file.remove(); + return; +}; + +/** + * Testing testAssertEqualFile + */ +var testAssertEqualFile = function testAssertEqualFile() { + var str = "This is just a simple test\r\n"; + var dir = java.lang.System.getProperty("java.io.tmpdir"); + // create test file and write the string into the file + var testFile = new helma.File(dir, "testAssertEqualFile." + (new Date()).getTime()); + testFile.open(); + testFile.write(str); + testFile.close(); + // test string comparison + assertEqualFile(str, testFile); + // test byte array comparison + var arr = new java.lang.String(str).getBytes(); + assertEqualFile(arr, testFile); + // finally, remove testFile again + testFile.remove(); + return; +}; diff --git a/modules/jala/util/Test/tests/skeleton.js b/modules/jala/util/Test/tests/skeleton.js new file mode 100644 index 00000000..8cd7cf58 --- /dev/null +++ b/modules/jala/util/Test/tests/skeleton.js @@ -0,0 +1,17 @@ +/** + * Prefix all test-functions with "test" + */ + +/** + * Called before running the tests + */ +var setup = function() { + return; +}; + +/** + * Called after all tests have finished + */ +var cleanup = function() { + return; +}; diff --git a/modules/jala/util/XmlRpcClient/Global/Feedback.js b/modules/jala/util/XmlRpcClient/Global/Feedback.js new file mode 100644 index 00000000..98c0a36e --- /dev/null +++ b/modules/jala/util/XmlRpcClient/Global/Feedback.js @@ -0,0 +1,85 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Error- and Confirmation message container + * @class Instances of this class can contain numerous error- and confirm messages + * and function as a macro handler object. + * @constructor + * @returns A newly created Feedback instance + * @type Feedback + */ +var Feedback = function() { + this.errors = {}; + this.messages = {}; + this.isError = false; + return this; +}; + +/** + * Adds the message with the given name to the list of errors and + * sets the isError flag to true. + * @param {String} name The name of the message + * @param {msg} msg The message to use + */ +Feedback.prototype.setError = function(name, msg) { + this.errors[name] = msg; + this.isError = true; + return; +}; + +/** + * Adds the message with the given name to the list of confirmation messages + * and sets the isError flag to true. + * @param {String} name The name of the message + * @param {msg} msg The message to use + */ +Feedback.prototype.setMessage = function(name, msg) { + this.messages[name] = msg; + return; +}; + +/** + * Returns the message with the given name + * @returns The message with the given name + * @type String + */ +Feedback.prototype.message_macro = function(param) { + if (param.name != null) { + return this.messages[param.name]; + } + return; +}; + +/** + * Returns the error message with the given name + * @returns The error message with the given name + * @type String + */ +Feedback.prototype.error_macro = function(param) { + if (param.name != null) { + return this.errors[param.name]; + } + return; +}; diff --git a/modules/jala/util/XmlRpcClient/Global/Global.js b/modules/jala/util/XmlRpcClient/Global/Global.js new file mode 100644 index 00000000..1f8c3b3f --- /dev/null +++ b/modules/jala/util/XmlRpcClient/Global/Global.js @@ -0,0 +1,362 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Dependencies + */ +app.addRepository("modules/core/String.js"); +app.addRepository(getProperty("jala.dir", "modules/jala") + + "/code/XmlRpcRequest.js"); + +/** + * A safe eval method that uses a standard Javascript scope + * without any Helma specifics for evaluation. This method + * does a double evaluation: first it evaluates the code + * in a separate javascript scope without any Helma specifics, and only + * if that doesn't throw an exception it evaluates the expression in the + * application scope, so that objects constructed during evaluation + * belong to the correct scope (and eg. testing with instanceof returns + * the expected result). Keep in mind that due to the double + * evaluation using this method is quite costly. + * @param {String} code The code to evaluate + * @returns The result of the evaluated code + */ +var safeEval = function(code) { + var context = new Packages.org.mozilla.javascript.Context(); + try { + context.enter(); + // first evaluation in separate scope + context.evaluateString(safeEval.SCOPE, code, null, 0, null); + return eval(code); + } finally { + context.exit(); + } +}; +safeEval.SCOPE = Packages.org.mozilla.javascript.Context.getCurrentContext().initStandardObjects(); + +/** + * Returns true if the value passed as argument is a string. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is a string, false otherwise + */ +var isString = function(val) { + return typeof(val) == "string" || + val instanceof java.lang.String || + val instanceof String; +}; + +/** + * Returns true if the value passed as argument is a boolean. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is a boolean, false otherwise + */ +var isBoolean = function(val) { + return typeof(val) == "boolean" || + val instanceof Boolean; +}; + +/** + * Returns true if the value passed as argument is a number. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is a number, false otherwise + */ +var isNumber = function(val) { + return typeof(val) == "number" || + val instanceof java.lang.Integer || + val instanceof Number; +}; + +/** + * Returns true if the value passed as argument is null. + * @param {Object} val The value to test + * @returns True if the value is null, false otherwise + */ +var isNull = function(val) { + return val === null; +}; + +/** + * Returns true if the value passed as argument is undefined. + * @param {Object} val The value to test + * @returns True if the value is undefined, false otherwise + */ +var isUndefined = function(val) { + return val === undefined; +}; + +/** + * Returns true if the value passed as argument is an array. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is an array, false otherwise + */ +var isArray = function(val) { + return val instanceof Array; +}; + +/** + * Returns true if the value passed as argument is a date. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is a date, false otherwise + */ +var isDate = function(val) { + return val instanceof Date || + val instanceof java.util.Date; +}; + +/** + * Returns true if the value passed as argument is an object. Since + * this value might be constructed using the safeEval's scope + * this method tests both the application's scope and the safe one. + * @param {Object} val The value to test + * @returns True if the value is an object, false otherwise + */ +var isObject = function(val) { + return val instanceof Object || + val instanceof java.lang.Object; +}; + +/** + * Parses the argument string passed into an array containing + * evaluated arguments. The string can contain object and array literals, + * strings, numbers and dates (using standard Javascript syntax). + * @param {String} str The string to parse + * @returns The parsed arguments + * @type Array + */ +var parseArguments = function(str) { + var result = []; + var c, literalLevel = 0; + var buf = new java.lang.StringBuffer(); + for (var i=0;i 0) { + result.push(evalArgument(buf.toString())); + } + return result; +}; + +/** + * Parses a single argument string using the safeEval's method + * eval(). This way users can't do any harm since all they have is + * a plain Javascript environment without any Helma specifics. + * @param {String} str The string to evaluate + * @returns The evaluated argument + */ +var evalArgument = function(str) { + if (str) { + str = str.trim(); + return safeEval("(" + str + ")"); + } + return null; +}; + +/** + * Returns the object passed as argument as formatted JSOn compatible + * string. + * @param {Object} obj The object to format as string + * @returns The formatted string + */ +var prettyPrint = function(obj) { + + var pad = function(str) { + return " ".repeat((lvl) * 6) + str; + }; + + var printString = function(str) { + return '"' + encode(str) + '"'; + }; + + var printInteger = function(nr) { + return nr.toString(); + }; + + var printBoolean = function(bool) { + return bool.toString(); + }; + + var printUndefined = function() { + return "undefined"; + }; + + var printNull = function() { + return "null"; + }; + + var printDate = function(date) { + return date.toString(); + }; + + var printArray = function(arr) { + var buf = new java.lang.StringBuffer(); + buf.append("["); + lvl += 1; + for (var i=0;i 0) { + buf.append(","); + } + buf.append("\n"); + buf.append(pad(printValue(arr[i]))); + } + lvl -= 1; + buf.append("\n"); + buf.append(pad("]")); + return buf.toString(); + }; + + var printObject = function(obj) { + var buf = new java.lang.StringBuffer(); + buf.append("{"); + lvl += 1; + var first = true; + for (var i in obj) { + if (first) { + first = !first; + } else { + buf.append(","); + } + buf.append("\n"); + buf.append(pad(printString(i) + ": ")); + buf.append(printValue(obj[i])); + } + lvl -= 1; + buf.append("\n"); + buf.append(pad("}")); + return buf.toString(); + }; + + var printValue = function(val) { + if (isArray(val)) { + return printArray(val); + } else if (isDate(val)) { + return printDate(val); + } else if (isString(val)) { + return printString(val); + } else if (isNumber(val)) { + return printInteger(val); + } else if (isBoolean(val)) { + return printBoolean(val); + } else if (isNull(val)) { + return printNull(); + } else if (isUndefined(val)) { + return printUndefined(); + } else if (isObject(val)) { + return printObject(val); + } else if (val.toString != null) { + return val.toString(); + } + return; + }; + + var lvl = 0; + return printValue(obj); +}; + +/** + * Returns the xml source passed as argument as readable string + * with appropriate linefeeds and indents. This method uses a + * regular expression instead of converting the xml source into + * a DOM tree to be able to format invalid xml which might be useful + * for debugging. + * @param {String} xmlSource The XML source for format + * @returns The formatted source + */ +var prettyPrintXml = function(xmlSource) { + var pad = function(str) { + res.write(" ".repeat((lvl) * 6) + encode(str)); + }; + + // remove all linefeeds and carriage returns + var xml = xmlSource.replace(/\r\n|\n\r|\n|\r/g, ""); + var re = /<(\/?)([^>]+)[^<]+(?=<|$)/gm; + var lvl = 0; + var match; + var tag, prevTag; + res.push(); + while (match = re.exec(xml)) { + tag = match[2]; + if (!match[1]) { + // opening or contentless tag + if (match.index > 0) { + res.write("\n"); + lvl += 1; + } + pad(match[0]); + if (tag.indexOf("/") > -1) { + lvl -= 1; + } + } else { + // closing tag + if (tag == prevTag) { + lvl -= 1; + res.encode(match[0]); + } else { + res.write("\n"); + pad(match[0]); + lvl -= 1; + } + } + prevTag = tag; + } + return res.pop(); +}; + +/** + * Basic selection macro useable for checkboxes + * and select dropdowns. This macro checks if + * req.data[param.name] equals param.value, and if + * true it writes the specified param.attribute in + * the form 'attribute="attribute"' to response. + */ +var selection_macro = function(param) { + if (req.data[param.name] == param.value) { + res.write(" "); + res.write(param.attribute); + res.write('="'); + res.write(param.attribute); + res.write('"'); + } + return; +}; diff --git a/modules/jala/util/XmlRpcClient/Global/XmlRpcCall.js b/modules/jala/util/XmlRpcClient/Global/XmlRpcCall.js new file mode 100644 index 00000000..0a216921 --- /dev/null +++ b/modules/jala/util/XmlRpcClient/Global/XmlRpcCall.js @@ -0,0 +1,146 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Wrapper for making XmlRpc calls to remote servers. + * @class Instances of this class can make calls to remote + * XmlRpc servers, plus function as macro handlers for displaying + * results, errors etc. + * @param {String} url The url of the entry-point + * @param {String} methodName The name of the method to call (eg. "xmlrpcclient.echo") + * @param {Array} args An array containing arguments to pass to the remote function + * @returns A newly created XmlRpcCall instance + * @type XmlRpcCall + */ +var XmlRpcCall = function(url, methodName) { + this.request = new jala.XmlRpcRequest(url, methodName); + this.result = null; + return this; +}; + +/** + * Executes the XmlRpc call + */ +XmlRpcCall.prototype.execute = function() { + this.args = arguments; + this.response = jala.XmlRpcRequest.prototype.execute.apply(this.request, arguments); + return; +}; + +/** @ignore */ +XmlRpcCall.prototype.toString = function() { + return "[XmlRpcCall]"; +}; + +/** + * Returns the Url of this XmlRpcCall instance. + * @returns The url of this call + * @type String + */ +XmlRpcCall.prototype.url_macro = function() { + return this.url; +}; + +/** + * Returns the method name of this XmlRpcCall instance. + * @returns The method name of this call + * @type String + */ +XmlRpcCall.prototype.method_macro = function() { + return this.methodName; +}; + +/** + * Displays the arguments of this XmlRpcCall instance. + */ +XmlRpcCall.prototype.arguments_macro = function() { + var arg; + for (var i=0;i'); + res.write('
    ' + i + " "); + if (isArray(arg)) { + res.write("(Array)"); + } else if (isDate(arg)) { + res.write("(Date)"); + } else if (isString(arg)) { + res.write("(String)"); + } else if (isNumber(arg)) { + res.write("(Integer)"); + } else if (isBoolean(arg)) { + res.write("(Boolean)"); + } else if (isNull(arg)) { + res.write("(null)"); + } else if (isUndefined(arg)) { + res.write("(undefined)"); + } else if (isObject(arg)) { + res.write("(Object)"); + } else { + res.write("(unknown type)"); + } + res.write('
    \n
    ');
    +      res.write(prettyPrint(arg));
    +      res.write("
    "); + } + return; +}; + +/** + * Returns the result of this XmlRpcCall instance. + * @returns The result as human readable string + * @type String + */ +XmlRpcCall.prototype.result_macro = function() { + if (this.response.result != null) { + return prettyPrint(this.response.result); + } + return; +}; + +/** + * Returns the error of this XmlRpcCall instance, if any. + * @returns The error string + * @type String + */ +XmlRpcCall.prototype.error_macro = function() { + if (this.response.error != null) { + return this.response.error; + } + return; +}; + +/** + * Displays the xml source of either request or response + * @param {Object} param A parameter object containing the + * macro attributes + */ +XmlRpcCall.prototype.xml_macro = function(param) { + var xml = this.response[param.of + "Xml"]; + if (xml != null) { + res.write("
    ");
    +      res.write(prettyPrintXml(xml));
    +      res.write("
    "); + } + return; +}; diff --git a/modules/jala/util/XmlRpcClient/README b/modules/jala/util/XmlRpcClient/README new file mode 100644 index 00000000..31fae511 --- /dev/null +++ b/modules/jala/util/XmlRpcClient/README @@ -0,0 +1,59 @@ +This is the README file for the XmlRpcClient application as part of +version 1.0 of the Jala Javascript Library. + + +About XmlRpcClient +------------------ + +The XmlRpcClient is a small Helma application useful to test and debug XmlRpc +requests. + + +Installation +------------ + +To install the application add the following to the apps.properties file in +your Helma installation directory: + +xmlrpcclient +xmlrpcclient.repository.0 = ./modules/jala/util/XmlRpcClient + + +Usage Instructions +------------------ + +To access the XmlRpcClient point your browser to the URL + +http://your.server.domain[:port]/xmlrpcclient + +(replace "your.server.domain" with the domain of your server, and the ":port" +section with the port number if not 80). Then fill out the form with at least +the URL of the XmlRpc service and the method name (both are required). + +Optionally you can pass various arguments to the remote method using standard +Javascript literal notation, eg.: + +String: "a string" +Number: 1 +Boolean: true|false +Objec: {name: "jala"} +Array: [1, 2, "three", 4] +Date: new Date(2007, 0, 22, 15, 10) + +By default the XmlRpc client uses UTF-8 as encoding for request and response, +which you can change to ISO-8859-1 if necessary. If you select the "Show Xml" +checkbox the result shown will also contain the Xml source of the request and +response, which is useful for debugging. + +At last you can tell the client to use a specific HTTP proxy for the requests, +which you must define in the form "fqdn:port", eg. "my.proxy.com:3128". + + +Contact, Bugs and Feedback +-------------------------- + +The Jala Project is currently hosted at https://OpenSVN.csie.org/traccgi/jala/ +providing all necessary information about Subversion access, Ticketing, Releases +etc. + +For immediate contact you can reach the developers via jaladev AT gmail.com. diff --git a/modules/jala/util/XmlRpcClient/Root/Root.js b/modules/jala/util/XmlRpcClient/Root/Root.js new file mode 100644 index 00000000..11b2eea6 --- /dev/null +++ b/modules/jala/util/XmlRpcClient/Root/Root.js @@ -0,0 +1,84 @@ +// +// Jala Project [http://opensvn.csie.org/traccgi/jala] +// +// Copyright 2004 ORF Online und Teletext GmbH +// +// Licensed under the Apache License, Version 2.0 (the ``License''); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an ``AS IS'' BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// $Revision$ +// $LastChangedBy$ +// $LastChangedDate$ +// $HeadURL$ +// + + +/** + * Main action + */ +Root.prototype.main_action = function() { + res.handlers.xmlrpc = {}; + res.handlers.feedback = new Feedback(); + if (req.isPost()) { + if (!req.data.url) { + res.handlers.feedback.setError("url", "Please enter the URL of the XmlRpc entry point"); + } + if (!req.data.method) { + res.handlers.feedback.setError("method", "Please specify the method to call"); + } + try { + var args = parseArguments(req.data.args); + } catch (e) { + res.handlers.feedback.setError("arguments", "The method arguments are invalid"); + } + if (!res.handlers.feedback.isError) { + var xmlRpcCall = new XmlRpcCall(req.data.url, req.data.method); + xmlRpcCall.request.setEncoding(req.data.encoding); + xmlRpcCall.request.setProxy(req.data.proxy); + xmlRpcCall.request.setDebug(req.data.debug == 1); + if (app.properties.username != null && app.properties.password != null) { + xmlRpcCall.request.setCredentials(app.properties.username, app.properties.password); + } + XmlRpcCall.prototype.execute.apply(xmlRpcCall, args); + res.handlers.xmlrpc = xmlRpcCall; + } + } + this.renderSkin("main"); + return; +}; + +/** + * Main XmlRpc action. The only supported method name is "echo". + * If no additional arguments are given this action + * returns "echo" to the client. A single additional argument is returned + * as-is, multiple additional arguments are returned as array. + */ +Root.prototype.main_action_xmlrpc = function(methodName) { + switch (methodName) { + case "echo": + if (arguments.length == 1) { + return "echo"; + } else if (arguments.length == 2) { + return arguments[1]; + } else { + var result = []; + for (var i=1;i + + +Jala XmlRpc Client + + + + +
    Jala XmlRpc Client
    +
    +
    +
    <% feedback.error name="url" prefix='
    ' suffix="
    " %>" />
    + Example: http://localhost:8080/xmlrpcclient/
    +
    <% feedback.error name="method" prefix='
    ' suffix="
    " %>" />
    + Example: echo
    +
    <% feedback.error name="arguments" prefix='
    ' suffix="
    " %>" />
    + Example: "eins", 123, true, new Date(), {test: {me: "please"}}, ["a", ["b", "c"]]
    +
    +
    />
    +

    + Example: my.proxy.com:3128
    +

    (* = required)
    + + <% xmlrpc.arguments prefix="
    Arguments" suffix="
    " %> + + <% xmlrpc.error prefix='
    Error' suffix="
    " %> + + <% xmlrpc.result prefix='
    Result
    ' suffix="
    " %> + + <% xmlrpc.xml of="request" prefix="
    Request XML" suffix="
    " %> + + <% xmlrpc.xml of="response" prefix="
    Response XML" suffix="
    " %> + +
    +
    + + \ No newline at end of file diff --git a/modules/tools/Global/helma.Inspector.js b/modules/tools/Global/helma.Inspector.js new file mode 100644 index 00000000..03a46e2b --- /dev/null +++ b/modules/tools/Global/helma.Inspector.js @@ -0,0 +1,323 @@ +/* + * Helma License Notice + * + * The contents of this file are subject to the Helma License + * Version 2.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://adele.helma.org/download/helma/license.txt + * + * Copyright 1998-2005 Helma Software. All Rights Reserved. + * + * $RCSfile: helma.Inspector.js,v $ + * $Author: czv $ + * $Revision: 1.5 $ + * $Date: 2006/04/24 11:12:40 $ + */ + +// take care of any dependencies +app.addRepository('modules/core/String.js'); +app.addRepository('modules/core/Number.js'); +app.addRepository('modules/helma/Html.js'); + +if (!global.helma) { + global.helma = {}; +} + +helma.Inspector = function(hopObj) { + if (!hopObj) + hopObj == root; + + var version = "4.0"; + var children = []; + var properties = []; + var collections = []; + + var html = new helma.Html(); + var keySorter = new String.Sorter("key"); + var idSorter = new Number.Sorter("id"); + + var skins = { + child: createSkin(helma.Inspector.child_skin), + collection: createSkin(helma.Inspector.collection_skin), + date: createSkin(helma.Inspector.date_skin), + editor: createSkin(helma.Inspector.editor_skin), + property: createSkin(helma.Inspector.property_skin) + }; + + var genOptions = function(start, end, selected) { + res.push(); + for (var i=start; i<=end; i+=1) { + res.write(""); + if (i < 10) + res.write("0"); + res.write(i); + res.write("\n"); + } + return res.pop(); + }; + + this.render = function() { + for (var i in hopObj) { + var obj = { + key: i, + value: hopObj[i] + }; + if (hopObj[i]) { + if (obj.value._prototype && + obj.value._prototype == "HopObject") + collections.push(obj); + else + properties.push(obj); + } + } + properties.sort(keySorter); + collections.sort(keySorter); + + var n = hopObj.size(); + for (var i=0; i cols="40" rows="1"><% param.value encoding="form" %>
    \ +\ +\ +\ +\ +\ +\ +\ +'; + +HopObject.prototype[ (app.properties['inspectorAction'] || 'inspector') +'_action' ] = function() { + if (!helma.auth('inspector')) + res.abort(); + if (typeof helma == "undefined" || !helma.Inspector) { + res.write("Could not create instance of helma.Inspector "); + res.write("(probably due to missing helmaLib v4.0+)"); + return; + } + var inspector = new helma.Inspector(this); + inspector.action(); + return; +}; + +helma.lib = "Inspector"; +helma.dontEnum(helma.lib); +for (var i in helma[helma.lib]) + helma[helma.lib].dontEnum(i); +for (var i in helma[helma.lib].prototype) + helma[helma.lib].prototype.dontEnum(i); +delete helma.lib; diff --git a/modules/tools/Global/helma.Inspector.main.skin b/modules/tools/Global/helma.Inspector.main.skin new file mode 100644 index 00000000..da240f2c --- /dev/null +++ b/modules/tools/Global/helma.Inspector.main.skin @@ -0,0 +1,157 @@ + + + + + +helma.Inspector v<% inspector.version %> + + + + + + +

    <% inspector.title %>

    +
    <% inspector.path %><% inspector.title %>

    + + + + + + + + + + + +
    + + + + +<% inspector.children default='' %> +
    <% inspector.childProto default="child" %> objects
    none
    +
    + + + + +<% inspector.properties %> +
    properties
    +
    + + + + +<% inspector.collections default='' %> +
    collections
    none
    +
    + + + diff --git a/modules/tools/Global/helma.Markup.js b/modules/tools/Global/helma.Markup.js new file mode 100644 index 00000000..1bad0279 --- /dev/null +++ b/modules/tools/Global/helma.Markup.js @@ -0,0 +1,807 @@ +/* +* Copyright (C) 2004 Hannes Wallnoefer +*/ + +//////////////////////////////////////////////////////////////////////// +// Html element functions +//////////////////////////////////////////////////////////////////////// + +if (!global.helma) { + global.helma = {}; +} + +helma.Markup = {}; + +helma.Markup.element = function(name, attributes, content) { + if (!name) { + throw "helma.Markup.element called without element name"; + } + // open tag + res.write("<"); + res.write(name); + if (attributes) { + for (var i in attributes) { + if (typeof(attributes[i]) == "undefined") + continue; + res.write(" "); + res.write(i); + res.write("=\""); + res.write(encodeForm(attributes[i])); + res.write("\""); + } + } + // if no child objects create empty element and return + if (typeof(content) == "undefined") { + res.write(" />"); + return; + } + res.write(">"); + + // write content + res.write(content); + + // close tag + res.write(""); +} + +helma.Markup.Element = function(name, attributes, children) { + return new MarkupElement(name, attributes, children); +} + +helma.Markup.form = function(attributes, content) { + this.element("form", attributes, content); +} + +helma.Markup.Form = function(attributes, children) { + return new MarkupElement("form", attributes, children); +} + +helma.Markup.textarea = function(attributes, content) { + this.element("textarea", attributes, encodeForm(content)); +} + +helma.Markup.Textarea = function(attributes, children) { + return new HtmlTextarea(attributes, children); +} + +helma.Markup.input = function(attributes, content) { + this.element("input", attributes, content); +} + +helma.Markup.Input = function(attributes, children) { + return new MarkupElement("input", attributes, children); +} + +helma.Markup.button = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "button"; + this.element("input", attributes, content); +} + +helma.Markup.Button = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "button"; + return new MarkupElement("input", attributes, children); +} + +helma.Markup.submit = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "submit"; + this.element("input", attributes, content); +} + +helma.Markup.Submit = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "submit"; + return new MarkupElement("input", attributes, children); +} + +helma.Markup.hidden = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "hidden"; + this.element("input", attributes, content); +} + +helma.Markup.Hidden = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "hidden"; + return new MarkupElement("input", attributes, children); +} + +helma.Markup.file = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "file"; + this.element("input", attributes, content); +} + +helma.Markup.File = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "file"; + return new MarkupElement("input", attributes, children); +} + +helma.Markup.password = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "password"; + this.element("input", attributes, content); +} + +helma.Markup.Password = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "password"; + return new MarkupElement("input", attributes, children); +} + +helma.Markup.checkbox = function(attributes, content) { + if (!attributes) + attributes = {}; + attributes.type = "checkbox"; + if (!attributes.checked) + delete(attributes.checked); + this.element("input", attributes, content); +} + +helma.Markup.Checkbox = function(attributes, children) { + if (!attributes) + attributes = {}; + attributes.type = "checkbox"; + if (!attributes.checked) + delete(attributes.checked); + return new MarkupElement("input", attributes, children); +} + +helma.Markup.select = function(attributes, children, selected, firstLine) { + res.write(new HtmlSelect(attributes, children, selected, firstLine)); +} + +helma.Markup.Select = function(attributes, children, selected, firstLine) { + return new HtmlSelect(attributes, children, selected, firstLine); +} + +helma.Markup.head = function(attributes, content) { + this.element("head", attributes, content); +} + +helma.Markup.Head = function(attributes, children) { + return new MarkupElement("head", attributes, children); +} + +helma.Markup.title = function(attributes, content) { + this.element("title", attributes, content); +} + +helma.Markup.Title = function(attributes, children) { + return new MarkupElement("title", attributes, children); +} + +helma.Markup.body = function(attributes, content) { + this.element("body", attributes, content); +} + +helma.Markup.Body = function(attributes, children) { + return new MarkupElement("body", attributes, children); +} + +helma.Markup.div = function(attributes, content) { + this.element("div", attributes, content); +} + +helma.Markup.Div = function(attributes, children) { + return new MarkupElement("div", attributes, children); +} + +helma.Markup.p = function(attributes, content) { + this.element("p", attributes, content); +} + +helma.Markup.P = function(attributes, children) { + return new MarkupElement("p", attributes, children); +} + +helma.Markup.b = function(attributes, content) { + this.element("b", attributes, content); +} + +helma.Markup.B = function(attributes, children) { + return new MarkupElement("b", attributes, children); +} + +helma.Markup.span = function(attributes, content) { + this.element("span", attributes, content); +} + +helma.Markup.Span = function(attributes, children) { + return new MarkupElement("span", attributes, children); +} + +helma.Markup.img = function(attributes) { + this.element("img", attributes); +} + +helma.Markup.Img = function(attributes) { + return new MarkupElement("img", attributes); +} + +helma.Markup.script = function(attributes, content) { + this.element("script", attributes, content); +} + +helma.Markup.Script = function(attributes, children) { + return new MarkupElement("script", attributes, children); +} + +helma.Markup.ul = function(attributes, content) { + this.element("ul", attributes, content); +} + +helma.Markup.Ul = function(attributes, children) { + return new MarkupElement("ul", attributes, children); +} + +helma.Markup.ol = function(attributes, content) { + this.element("ol", attributes, content); +} + +helma.Markup.Ol = function(attributes, children) { + return new MarkupElement("ol", attributes, children); +} + +helma.Markup.li = function(attributes, content) { + this.element("li", attributes, content); +} + +helma.Markup.Li = function(attributes, children) { + return new MarkupElement("li", attributes, children); +} + + +helma.Markup.a = function(attributes, content) { + this.element("a", attributes, content); +} + +helma.Markup.link = helma.Markup.a; + +helma.Markup.A = function(attributes, children) { + return new MarkupElement("a", attributes, children); +} + +helma.Markup.table = function(attributes, content) { + this.element("table", attributes, content); +} + +helma.Markup.Table = function(attributes, children) { + return new MarkupElement("table", attributes, children); +} + +helma.Markup.Colgroup = function(attributes, children) { + return new MarkupElement("colgroup", attributes, children); +} + +helma.Markup.colgroup = function(attributes, content) { + this.element("colgroup", attributes, content); +} + +helma.Markup.Col = function(attributes, children) { + return new MarkupElement("col", attributes, children); +} + +helma.Markup.col = function(attributes, content) { + this.element("col", attributes, content); +} + +helma.Markup.tr = function(attributes, content) { + this.element("tr", attributes, content); +} + +helma.Markup.Tr = function(attributes, children) { + return new MarkupElement("tr", attributes, children); +} + +helma.Markup.th = function(attributes, content) { + this.element("th", attributes, content); +} + +helma.Markup.Th = function(attributes, children) { + return new MarkupElement("th", attributes, children); +} + +helma.Markup.td = function(attributes, content) { + this.element("td", attributes, content); +} + +helma.Markup.Td = function(attributes, children) { + return new MarkupElement("td", attributes, children); +} + +helma.Markup.h1 = function(attributes, content) { + this.element("h1", attributes, content); +} + +helma.Markup.H1 = function(attributes, children) { + return new MarkupElement("h1", attributes, children); +} + +helma.Markup.h2 = function(attributes, content) { + this.element("h2", attributes, content); +} + +helma.Markup.H2 = function(attributes, children) { + return new MarkupElement("h2", attributes, children); +} + +helma.Markup.h3 = function(attributes, content) { + this.element("h3", attributes, content); +} + +helma.Markup.H3 = function(attributes, children) { + return new MarkupElement("h3", attributes, children); +} + +helma.Markup.h4 = function(attributes, content) { + this.element("h4", attributes, content); +} + +helma.Markup.H4 = function(attributes, children) { + return new MarkupElement("h4", attributes, children); +} + +helma.Markup.h5 = function(attributes, content) { + this.element("h5", attributes, content); +} + +helma.Markup.H5 = function(attributes, children) { + return new MarkupElement("h5", attributes, children); +} + +helma.Markup.h6 = function(attributes, content) { + this.element("h6", attributes, content); +} + +helma.Markup.H6 = function(attributes, children) { + return new MarkupElement("h6", attributes, children); +} + +helma.Markup.pre = function(attributes, content) { + this.element("pre", attributes, content); +} + +helma.Markup.Pre = function(attributes, children) { + return new MarkupElement("pre", attributes, children); +} + +helma.Markup.br = function(attributes) { + this.element("br", attributes); +} + +helma.Markup.Br = function(attributes, children) { + return new MarkupElement("br", attributes, children); +} + +helma.Markup.openTag = function(name, attributes) { + if (!name) { + throw "helma.Markup.openTag called without element name"; + } + res.write("<"); + res.write(name); + if (attributes) { + for (var i in attributes) { + if (typeof(attributes[i]) == "undefined") + continue; + res.write(" "); + res.write(i); + res.write("=\""); + res.write(encodeForm(attributes[i])); + res.write("\""); + } + } + res.write(">"); +} + +helma.Markup.closeTag = function(name) { + res.write(""); +} + + +/** + * utility object to provide an easy way + * for programmatically creating an x/html table. + * @param Number the number of columns in the table + * @param Object the table's, its rows' and cells' attributes + * @return Object an instance of TableWriter + */ +helma.Markup.TableWriter = function(numberOfColumns, attr) { + this.ncols = numberOfColumns; + if (isNaN(this.ncols)) + throw "Illegal argument in TableWriter(): first argument must be a number"; + if (this.ncols < 1) + throw "Illegal argument in TableWriter(): first argument must be > 1"; + this.written = 0; + // if no attributes object given, create an empty one + if (!attr) + attr = {}; + if (!attr.trEven) attr.trEven = attr.tr; + if (!attr.trOdd) attr.trOdd = attr.tr; + if (!attr.trHead) attr.trHead = attr.trEven; + if (!attr.tdEven) attr.tdEven = attr.td; + if (!attr.tdOdd) attr.tdOdd = attr.td; + if (!attr.thEven) attr.thEven = attr.th; + if (!attr.thOdd) attr.thOdd = attr.th; + this.attr = attr; + + // write header row? set to true to use "th" tags for first row + this.writeHeader = false; + // write to string buffer rather than response? + this.writeString = false; + + /** + * Write a table cell. + * @param String the table cell content as text + * @param attr an optional attributes holder for the td tag + */ + this.write = function(text, attr) { + // set up some variables + var isHeaderRow = (this.writeHeader && this.written < this.ncols); + var isNewRow = (this.written % this.ncols == 0); + var isEvenRow = ((this.written / this.ncols) % 2 == 0); + var isEvenCol = ((this.written % this.ncols) % 2 == 0); + // write out table and table row tags + if (this.written == 0) { + if (this.writeString) + res.push(); + helma.Markup.openTag("table", this.attr.table); + helma.Markup.openTag("tr", this.attr.trHead); + } else if (isNewRow) { + helma.Markup.closeTag("tr"); + if (isEvenRow) + helma.Markup.openTag("tr", this.attr.trEven); + else + helma.Markup.openTag("tr", this.attr.trOdd); + } + // get the attribute object for the table cell + if (!attr) { + // no explicit attribute given + if (isEvenCol) + attr = isHeaderRow ? this.attr.thEven : this.attr.tdEven; + else + attr = isHeaderRow ? this.attr.thOdd : this.attr.tdOdd; + } + // write out table cell tag + helma.Markup.openTag(isHeaderRow ? "th" : "td", attr); + // write out table cell contents + if (text) + res.write(text); + // close table cell + helma.Markup.closeTag(isHeaderRow ? "th" : "td"); + if (attr && !isNaN(attr.colspan)) + this.written += attr.colspan; + else + this.written += 1; + return; + }; + + /** + * Close all open table tags. + */ + this.close = function() { + if (this.written > 0) { + while (this.written++ % this.ncols != 0) + res.write(""); + res.write(""); + this.written = 0; + } + if (this.writeString) + return res.pop(); + return; + }; + return this; +} + + +//////////////////////////////////////////////////////////////////////// +// MarkupElement is the base class for all elements +//////////////////////////////////////////////////////////////////////// + +/** + * Element constructor. Takes a name, + * a map of attributes and an array of child + * elements as arguments. + */ +function MarkupElement(name, attributes, children) { + if (!attributes) + attributes = {}; + this.attr = attributes; + // if (name && !this._elementName) { + this._elementName = name; + // } else { + if (attributes && attributes.name) { + this.name = attributes.name; + // this.attr.name = name; + } + + this.map = {}; + + this.add(children); + + this.initValueProperty(); +} + +/** + * Add a new child element + */ +MarkupElement.prototype.add = function(child) { + if (typeof(child) == "undefined") { + return; + } + // initialize child array if necessary + if (!this.children) { + this.children = []; + } + if (child instanceof Array) { + for (var i in child) { + this.add(child[i]); + } + return; + } + // add new child + this.children.push(child); + // register child if it has a name property + if (child) { + if (child.name && !this.map[child.name]) { + this.map[child.name] = child; + } + // register grandchilds unless the name slot is already taken + for (var i in child.map) { + var c = child.map[i]; + if (c && c.name && !this.map[c.name]) { + this.map[c.name] = c; + } + } + // set parent property in child + child.parent = this; + } +} + +MarkupElement.prototype.firstChild = function() { + return this.children ? this.children[0] : undefined; +} + +MarkupElement.prototype.lastChild = function() { + return this.children ? this.children[this.children.length - 1] : undefined; +} + + +/** + * Render the element to the response buffer. + */ +MarkupElement.prototype.render = function(writer) { + if (!writer) + writer = res; + + this.processValueProperty(); + // open tag + if (this._elementName) { + writer.write("<"); + writer.write(this._elementName); + for (var i in this.attr) { + if (typeof(this.attr[i]) == "undefined") + continue; + writer.write(" "); + writer.write(i); + writer.write("=\""); + writer.write(encodeForm(this.attr[i])); + writer.write("\""); + } + // render type attribute if set + if (this._type) { + writer.write(" type=\""); + writer.write(this._type); + writer.write("\""); + } + // if no child objects create empty element and return + if (typeof(this.children) == "undefined") { + writer.write(" />"); + return; + } + writer.write(">"); + } + + // write child elements + if (typeof(this.children) != "undefined") { + if (this.children instanceof Array) { + for (var i in this.children) { + if (typeof(this.children[i]) instanceof MarkupElement) { + this.children[i].render(); + } else if (this.children[i]) { + writer.write(this.children[i]); + } + } + } else { + writer.write(this.children); + } + } + + // close tag + if (this._elementName) { + writer.write(""); + } +} + +/** + * Return an object containing the rendered child elements + * of this element keyed by element name. This is suitable + * for rendering the elements of a markup object through + * a skin, using the object returned by this function as macro + * handler. + */ +MarkupElement.prototype.renderMap = function() { + var map = {}; + if (this.children && typeof(this.children) == "object") { + for (var i in this.children) { + if (typeof(this.children[i]) == "object") { + var comp = this.children[i]; + map[comp.name] = comp.toString(); + } + } + } + return map; +} + +/** + * Return an array containing the rendered child elements + * of this element keyed index position. This is suitable + * for those cases where we want to print out a markup + * object's elements programmatically. + */ +MarkupElement.prototype.renderArray = function() { + var list = []; + if (this.children && typeof(this.children) == "object") { + for (var i in this.children) { + if (typeof(this.children[i]) == "object") { + var comp = this.children[i]; + list.push(comp.toString()); + } + } + } + return list; +} + +/** + * Render the element to a string. + */ +MarkupElement.prototype.toString = function() { + res.push(); + this.render(res); + return res.pop(); +} + +/** + * Recursively populate this object and its child objects, + * reading values from the argument object. + */ +MarkupElement.prototype.populate = function(obj) { + // if no object passed populate from req.data + if (!obj) + obj = req.data; + + // set value + if (this.name && this._type != "submit") + this.value = obj[this.name]; + + // populate named child elements + for (var i in this.map) { + if (typeof(this.map[i]) == "object" && this.map[i].populate) { + this.map[i].populate(obj); + } + } +} + +/** + * Recursively validate this element and its child elements. + */ +MarkupElement.prototype.validate = function() { + // apply constraints + if (this.constraints) { + for (var i in this.constraints) { + this.contstraints[i].apply(this); + } + } + + // validate child elements + for (var i in this.map) { + if (typeof(this.map[i]) == "object" && this.map[i].validate) { + this.map[i].validate(); + } + } +} + +/** + * Set up this Element's value property. + */ +MarkupElement.prototype.initValueProperty = function() { + this.value = this.attr.value; +} + +/** + * Process this Element's value property. + */ +MarkupElement.prototype.processValueProperty = function() { + this.attr.value = this.value; +} + +//////////////////////////////////////////////////////////////////////// +// MarkupElement subclasses for Html form elements. +//////////////////////////////////////////////////////////////////////// + + +/** + * Html textarea + */ +function HtmlTextarea(attributes, children) { + this.constructor("textarea", attributes, children); +} +HtmlTextarea.prototype = new MarkupElement("textarea"); + +/** + * Set up this Textarea's value property. + */ +HtmlTextarea.prototype.initValueProperty = function() { + if (typeof(this.attr.value) != "undefined") + this.value = this.attr.value; + else if (this.children && this.children.length > 0) + this.value = this.children[0]; +} + +/** + * Process this Textarea's value property. + */ +HtmlTextarea.prototype.processValueProperty = function() { + this.children = [encodeForm(this.value)]; +} + +/** + * Select list + */ +function HtmlSelect(attributes, children, selectedValue, firstLine) { + var options = []; + if (firstLine) + options.push(new MarkupElement("option", {value: ""}, "")); + if (children instanceof Array) { + for (var i in children) { + var child = children[i]; + var value, display; + if (child instanceof Array && child.length == 2) { + value = child[0]; + display = child[1]; + } else if (child.value != null && child.display != null) { + value = child.value; + display = child.display; + } else { + display = child; + value = i; + } + var attr = {value: value}; + if (value == selectedValue) + attr.selected = "selected"; + options.push(new MarkupElement("option", attr, display)); + } + } + this.constructor("select", attributes, options); +} +HtmlSelect.prototype = new MarkupElement("select"); + diff --git a/modules/tools/Global/helma.auth.js b/modules/tools/Global/helma.auth.js new file mode 100644 index 00000000..c71a06c7 --- /dev/null +++ b/modules/tools/Global/helma.auth.js @@ -0,0 +1,91 @@ +if (!global.helma) { + global.helma = {}; +} + +/** + * Performs basic admin level access checking for the specifed realm + * @param String realm for which access should be checked and bootstrapped + * @return true if access id verified, otherwise renders login form with bootstrapping instructions + */ +helma.auth = function(realm) { + + // helper function, checks if the client host matches an allowed host pattern, + // hostnames are converted, wildcards are only allowed in ip-addresses + var hostIsAllowed = function() { + if (!getProperty(realm+'AccessAllowed')) + return true; + else if (getProperty(realm+'AccessAllowed') == 'false') + return false; + var filter = new Packages.helma.util.InetAddressFilter(); + var str = getProperty(realm+'AccessAllowed'); + if (str != null && str != "") { + var arr = str.split(","); + for (var i in arr) { + str = new java.lang.String(arr[i]); + try { + filter.addAddress(str.trim()); + } catch (a) { + try { + str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); + filter.addAddress(str); + } catch (b) { + app.log("error using address " + arr[i] + ": " + b); + } + } + } + } + return filter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)); + } + + // Check if current session is authenticated for this realm + if (session.data[realm+'Authenticated'] && hostIsAllowed()) + return true; + + // Otherwise, guide to properly configure access authentication for this realm + res.data.fontface = 'Trebuchet MS, Verdana, sans-serif'; + res.data.href = path[path.length-1].href(req.action); + var pw = getProperty('adminAccess'); + var param = {}; + var accessAllowed = true; + if (req.data.username && req.data.password) { + if (pw && hostIsAllowed()) { + if (pw == Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password)) { + session.data[realm+'Authenticated'] = true; + res.redirect(res.data.href); + } else { + param.message = 'Sorry, wrong password!'; + } + } else { + param.message = 'Currently, '+ realm + ' access is not allowed!
    '; + if (!pw) param.message += '\ + The adminAccess property is not set.
    \ + Before proceeding, add the following line to your app.properties or server.properties file:\ +

    adminAccess=' + + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password); + else param.message += 'The '+ realm +'AccessAllowed property does not match your host.
    \ + Before proceeding, remove this property from your app.properties or server.properties file \ + or include your host as follows:

    ' + + realm +'AccessAllowed=' + req.data.http_remotehost; + } + } + res.data.header = 'Authentication for '+ realm +' access'; + renderSkin('helma.auth.login', param); + return false; +} +helma.dontEnum('auth'); + +/** + * Invalidates a previously authenticated realm + * @param String realm for which an authentication should be invalidated + * @return true if an authenticated realm was invalidated, otherwise false + */ +helma.invalidate = function(realm) { + if (session.data[realm+'Authenticated']) { + delete session.data[realm+'Authenticated']; + return true; + } + else { + return false; + } +} +helma.dontEnum('invalidate'); diff --git a/modules/tools/Global/helma.auth.login.skin b/modules/tools/Global/helma.auth.login.skin new file mode 100644 index 00000000..0e519599 --- /dev/null +++ b/modules/tools/Global/helma.auth.login.skin @@ -0,0 +1,23 @@ + + + +<% response.title %> + + + +<% response.header prefix="

    " suffix="

    " %> +<% param.message prefix="

    " suffix="

    " %> +
    +

    Please enter the administrators username and password to proceed:

    +

    Username:

    +

    Password:

    + +
    + + diff --git a/modules/tools/Global/helma.shell.js b/modules/tools/Global/helma.shell.js new file mode 100644 index 00000000..df1252ea --- /dev/null +++ b/modules/tools/Global/helma.shell.js @@ -0,0 +1,60 @@ +if (!global.helma) { + global.helma = {}; +} + +/** + * Checks shell access, renders the shell skin and evaluates submitted shell commands and scripts + */ +helma.shell = function(realm) { + if (req.data.done) { + helma.invalidate('shell'); + helma.invalidate('sqlshell'); + helma.invalidate('inspector'); + res.redirect(this.href()); + } + if (!helma.auth('shell')) + res.abort(); + res.data.fontface = 'Trebuchet MS, Verdana, sans-serif'; + res.data.href = this.href(); + res.data.commands = encodeForm(req.data.commands); + var evalcode = req.data.command || req.data.commands; + if (!evalcode && helma.Inspector) { + if (!session.data.inspectorAuthenticated) + session.data.inspectorAuthenticated = true; + evalcode = '(new helma.Inspector(this)).action();"
    ";'; + } + if (evalcode) { + try { + var startTime = new Date(); + var evalResult = eval(evalcode); + var stopTime = new Date(); + res.write(evalResult); + if (req.data.commands) { + res.write('

    ') + res.write('') + res.write('Script evaluated in ' + (stopTime.getTime() - startTime.getTime()) +' milliseconds.'); + res.write('
    '); + } else if (!req.data.command) { + res.write('
    '); + } + } catch ( e ) { + res.write(''); + if ( e.javaException ) { + var s = new java.io.StringWriter(); + e.javaException.printStackTrace( new java.io.PrintWriter( s ) ); + res.write( s.toString() ); + } else { + res.write( format( e + '
    ' + e.fileName + ', lineNumber = ' + e.lineNumber ) ); + } + res.write('
    '); + if (req.data.commands) res.write('
    '); + } + } + if (!req.data.command) renderSkin('helma.shell'); +} +helma.dontEnum('shell'); + +/** + * Checks shell access, renders the shell skin and evaluates submitted shell commands and scripts + */ +HopObject.prototype[ (app.properties['shellAction'] || 'shell') +'_action' ] = helma.shell; diff --git a/modules/tools/Global/helma.shell.skin b/modules/tools/Global/helma.shell.skin new file mode 100644 index 00000000..5b436bd7 --- /dev/null +++ b/modules/tools/Global/helma.shell.skin @@ -0,0 +1,124 @@ + + +
    +
    + + +
    + +
    +
    + +
    + + +
    diff --git a/modules/tools/Global/helma.sqlshell.js b/modules/tools/Global/helma.sqlshell.js new file mode 100644 index 00000000..d2808832 --- /dev/null +++ b/modules/tools/Global/helma.sqlshell.js @@ -0,0 +1,753 @@ +if (!global.helma) { + global.helma = {}; +} + +helma.sqlshell = {}; + +/** +* Get the helma datasource with the given name +*/ +helma.sqlshell.getDatasource = function(name) { + return app.getDbSource(name); +} + +/** + * Get an array of names of all defined data sources suitable for use + * in html.select macro. + */ +helma.sqlshell.getDatasources = function() { + var dbmap = app.getDbProperties(); + var sources = []; + for (var i in dbmap) { + var dot = i.indexOf("."); + if (dot > -1 && i.lastIndexOf(".url") == i.length-4) { + var source = i.substring(0, dot); + sources.push([source, source]); + } + } + return sources; +} + +helma.sqlshell.getRepositories = function() { + var rep = []; + var repos = app.getRepositories(); + for (var i in repos) { + if (repos[i].getClass() == Packages.helma.framework.repository.FileRepository) + rep.push([i, repos[i].name]); + } + return rep; +} + +helma.sqlshell.getProtoRepositories = function(protoName) { + var rep = []; + var proto = app.getPrototype(protoName); + if (proto) { + var repos = proto.getRepositories(); + for (var i in repos) { + if (repos[i].getClass() == Packages.helma.framework.repository.FileRepository) + rep.push([i, repos[i].name]); + } + } + return rep; +} + +/** +* Main action to set the Helma Dbsource, display forms, perform queries. +*/ +helma.sqlshell.main = function() { + // If done, end sqlshell session + if (req.data.done) { + helma.invalidate('sqlshell'); + if (session.data.sqlShellReturnUrl) { + var targetUrl = session.data.sqlShellReturnUrl; + delete session.data.sqlShellReturnUrl; + } else { + var targetUrl = path.href(); + } + res.redirect(targetUrl); + } + + // Check if sqlshell is called from the shell tool + if (req.data.introFrom) { + session.data.sqlShellReturnUrl = req.data.introFrom; + if (session.data.shellAuthenticated) + session.data.sqlshellAuthenticated = true; + } + + // Check authentication + if (!helma.auth('sqlshell')) + res.abort(); + + // Handle authenticated requests + res.handlers.html = helma.sqlshell.html; + var param = {}; + param.datasource = req.data.datasource; + res.data.fontface = 'Verdana, sans-serif'; + /* if (req.data.schema) + session.data.sqlshellSchema = req.data.schema; + if (req.data.datasource) + session.data.sqlshellDatasource = req.data.datasource; */ + var dsource = req.data.datasource ? + helma.sqlshell.getDatasource(req.data.datasource) : null; + if (dsource) { + (new helma.sqlshell.Datasource(dsource)).main(); + } else { + if (req.data.datasource && req.isPost()) { + param.message = "Sorry, data source " + req.data.datasource + + " is not defined for this application."; + } + res.data.header = "Choose data source"; + res.data.datasources = helma.sqlshell.getDatasources(); + res.data.body = renderSkinAsString("helma.sqlshell.selectdb", param); + renderSkin("helma.sqlshell.page"); + } +} + +helma.sqlshell.Datasource = function(datasource) { + this.datasource = datasource; + this.name = datasource.name; + return this; +} + +/** +* Get an array of schema names defined in the current database. +*/ +helma.sqlshell.Datasource.prototype.getSchemas = function(meta) { + // get available schemas and set up an array for the drop down box: + var schemas = []; + var t = meta.getSchemas(); + while (t.next()) { + var s = t.getString(1); + schemas.push([s, s]); + } + return schemas; +} + +/** + * Get table names and set up an array for the drop down box + */ +helma.sqlshell.Datasource.prototype.getTables = function(meta, schema) { + var tables = [["", ""]]; + var t = meta.getTables (null, schema, "%", null); + while (t.next()) { + var table = t.getString (3); + tables.push([table, table]); + } + return tables; +} + +helma.sqlshell.Datasource.prototype.getColumns = function(meta, schema, table) { + var columns = []; + var t = meta.getColumns(null, schema, table, "%"); + while (t.next()) { + columns.push(t.getString(4)); + } + return columns; +} + +helma.sqlshell.Datasource.prototype.getPrototypes = function() { + var protos = [["", ""]]; + var protomap = app.getPrototypes(); + for (var i in protomap) { + if (protomap[i].lowerCaseName != "global") { + protos.push([protomap[i].name, protomap[i].name]); + } + } + return protos.sort(function(a, b) {return a < b ? -1 : 1;}); +} + +helma.sqlshell.Datasource.prototype.href = function(name) { + var href = path.href(req.action) + "?datasource="; + href += encode(req.data.datasource); + href += "&schema="; + href += encode(req.data.schema); + href += "&tab="; + href += req.data.tab; + return href; +} + +helma.sqlshell.Datasource.prototype.href_macro = function(param) { + return this.href(param.name); +} + +helma.sqlshell.colors = { + explore: "#bd9", query: "#db9", map: "#9bd" +} + +helma.sqlshell.Datasource.prototype.main = function() { + res.handlers.datasource = this; + if (!req.data.tab) { + req.data.tab = "explore"; + } + res.data.tabcolor = helma.sqlshell.colors[req.data.tab]; + + var param = new Object(); + param.action = this.href(); + + // get connection + var con = this.datasource.getConnection(); + + // get database meta data + var meta = con.getMetaData(); + + res.data.datasources = helma.sqlshell.getDatasources(); + res.data.schemas = this.getSchemas(meta); + var schema = req.data.schema; + res.data.tables = this.getTables(meta, schema); + + if (req.data.action) { + app.data.repositories = helma.sqlshell.getRepositories(); + if (req.data.action == "createproto" ) { + var repos = app.repositories[req.data.repository]; + var file = new File(repos.directory.toString(), req.data.protoname); + if (file.mkdir()) { + + renderSkin(this.getSkin("closePopup"), { + parentUrl: this.href() + "&prototype=" + req.data.protoname, + message: "

    Created directory " + file + "

    " + + "

    Please wait for prototypes to be updated...

    " + } ); + return; + } else { + res.debug("Couldn't create directory: " + file); + res.data.body = renderSkinAsString(this.getSkin("newproto")); + } + } else if (req.data.action == "extras") { + var p = {}; + var t = app.getPrototype(req.data.target); + var target = t && t.dbMapping ? t.dbMapping.tableName : null; + p.targetColumns = this.getColumns(meta, schema, target).toSource(); + p.localColumns = this.getColumns(meta, schema, req.data.__sqlshell_table__).toSource(); + res.data.body = renderSkinAsString(this.getSkin(req.data.action), p); + } else if (req.data.action == "generate") { + if (req.data.create) { + renderSkin(this.getSkin("closePopup"), { + parentUrl: this.href() + "&prototype=" + req.data.__sqlshell_prototype__, + message: "

    Created type mapping " + file + "

    " + + "

    Please wait for prototypes to be updated...

    " + } ); + } else { + var fields = {}; + var s = new java.lang.StringBuffer(); + for (var i in req.data) { + if (i.indexOf("maptype_") == 0) { + fields[i.substring(8)] = req.data[i]; + } + s.append(""); + } + if (req.data.__sqlshell_create__) { + // res.data.body = renderSkinAsString(this.getSkin("generate"), p); + var repos = app.getPrototype(req.data.__sqlshell_prototype__).repositories; + var resName = "type.properties"; + for (var i in repos) { + var resource = repos[i].getResource(resName); + if (resource && resource.exists()) { + if (resource.getClass() == Packages.helma.framework.repository.FileResource) { + var file = new File(resource.getName()); + var backup = new File(resource.getName() + ".bak"); + if (backup.exists()) { + var n = 1; + do { + backup = new File(resource.getName() + ".bak." + n++) + } while (backup.exists()); + } + if (!file.renameTo(backup)) { + res.debug("ERROR: Couldn't create backup for " + resource); + } + } else { + res.debug("WARNING: Couldn't move " + resource); + } + } + } + var file = new File(repos[req.data.__sqlshell_repository__].getResource(resName).getName()); + file.open(); + file.writeln("# Created by Helma SqlShell at " + new Date()); + if (req.data.__sqlshell_extends__) + file.writeln("_extends = " + req.data.__sqlshell_extends__); + if (req.data.__sqlshell_primaryKey__) + file.writeln("_id = " + req.data.__sqlshell_primaryKey__); + if (req.data.__sqlshell_protoColumn__) + file.writeln("_prototype = " + req.data.__sqlshell_protoColumn__); + if (req.data.__sqlshell_nameColumn__) + file.writeln("_name = " + req.data.__sqlshell_nameColumn__); + file.writeln(""); + for (var i in fields) { + var propType = parseInt(fields[i]); + var propName = req.data[i]; + if (!propName) continue; + file.write(propName); + file.write(" = "); + switch (propType) { + case 0: + file.writeln(req.data[i]); + break; + case 1: + file.writeln("object(" + req.data["target_" + i] + ")"); + break; + case 2: + file.writeln("collection(" + req.data["target_" + i] + ")"); + break; + case 3: + file.writeln("mountpoint(" + req.data["target_" + i] + ")"); + break; + default: + res.debug(i + ": " + fields[i]); + } + for (var m in this.mappingOptions) { + if (this.mappingOptions[m] <= propType && req.data[i + "_" + m]) { + file.write(propName); + file.write("."); + file.write(m.replace("_", ".")); + file.write(" = "); + file.writeln(req.data[i + "_" + m]); + } + } + file.writeln(""); + } + file.close(); + res.data.body = "Successfully created mapping in " + file; + } else { + var p = {}; + p.data = s.toString(); + res.data.repositories = helma.sqlshell.getProtoRepositories(req.data.__sqlshell_prototype__); + res.data.body = renderSkinAsString(this.getSkin("generate"), p); + } + } + } else { + res.data.body = renderSkinAsString(this.getSkin(req.data.action)); + } + } else { + // should we display type info on some table? + if (req.data.tab == "explore") { + param.body = this.explore(meta, schema, param); + } else if (req.data.tab == "query") { + param.body = this.query(con, param); + } else if (req.data.tab == "map") { + param.body = this.map(meta, schema, con, param); + } + // render the inner page skin and then the whole page + res.data.body = renderSkinAsString("helma.sqlshell.main", param); + } + + renderSkin("helma.sqlshell.page"); +} + +helma.sqlshell.Datasource.prototype.explore = function(meta, schema, param) { + res.push(); + renderSkin(this.getSkin("explore"), param); + if (req.data.__sqlshell_table__) { + var tableStyle = { table: { "class": "explore" }, td: { "class": "explore" } }; + var t = meta.getColumns(null, schema, req.data.__sqlshell_table__, "%"); + var writer = new helma.Markup.TableWriter(6, tableStyle); + writer.writeHeader = true; + var columnNames = ["Column Name", "Column Type", "Column Size", + "Nullable", "Default Value", "Extras"]; + for (var c in columnNames) { + writer.write(columnNames[c]); + } + while (t.next()) { + writer.write(t.getString(4)); + writer.write(t.getString(6)); + writer.write(t.getString(7)); + writer.write(t.getString(18)); + writer.write(t.getString(13)); + writer.write(t.getString(12)); + } + writer.close(); + } + return res.pop(); +} + +helma.sqlshell.Datasource.prototype.query = function(con, param) { + // some SQL has been submitted - evaluate it + if (req.data.sql) { + var query = req.data.sql.trim(); + + con.setReadOnly(false); + var stmt = con.createStatement(); + var value; + try { + value = stmt.execute(query); + if (!value) { + param.updated = stmt.getUpdateCount(); + } else { + var rs = stmt.getResultSet(); + var rsmeta = rs.getMetaData(); + var ncol = rsmeta.getColumnCount(); + + res.push(); + var tableStyle = { table: { "class": "query" }, td: { "class": "query" } }; + var writer = new helma.Markup.TableWriter(ncol, tableStyle); + writer.writeHeader = true; + for (var i=1; i<=ncol; i++) { + writer.write(rsmeta.getColumnName(i)); + } + + while (rs.next()) { + for (var i=1; i<=ncol; i++) { + writer.write(encode(rs.getString(i))); + } + } + + writer.close(); + param.resultset = res.pop(); + } + } catch (error) { + param.message = "Error: " + error; + } + } + return renderSkinAsString(this.getSkin("query"), param); +} + +helma.sqlshell.Datasource.prototype.map = function(meta, schema, con, param) { + // for (var i in req.data) res.debug(i); + res.push(); + res.data.prototypes = this.getPrototypes(); + var proto = app.getPrototype(req.data.__sqlshell_prototype__); + if (proto) { + var tableStyle = { table: { "class": "map" }, td: { "class": "map" } }; + var dbmap = proto.getDbMapping(); + if (!req.data.__sqlshell_table__ || + req.data.__sqlshell_prototype__ != req.data.previousProto) { + req.data.__sqlshell_table__ = dbmap.tableName; + } + param.tableSelect = renderSkinAsString(createSkin('Map to table \ + <% html.select name="__sqlshell_table__" options="response.tables" \ + onchange="document.forms.tab.submit();"%>')); + } + renderSkin(this.getSkin("map"), param); + if (proto) { + var maptypes = ["Primitive", "Reference", "Collection", "Mountpoint"]; + var tableStyle = { table: { "class": "map" }, td: { "class": "map" } }; + if (req.data.__sqlshell_table__) { + var primKey = ""; + try { + var k = meta.getPrimaryKeys(null, schema, req.data.__sqlshell_table__); + if (k.next()) { + primKey = k.getString(4); + } + if (k.next()) { + helma.Markup.p({"class": "error"}, "Table has composed primary key!"); + } + } catch (error) { + helma.Markup.p({"class": "error"}, "Error retrieving primary key: " + error); + } + var t = meta.getColumns(null, schema, req.data.__sqlshell_table__, "%"); + var columns = []; + res.data.columns = [["", ""]]; + while (t.next()) { + var colname = t.getString(4); + columns.push(colname); + res.data.columns.push([colname, colname]); + } + var writer = new helma.Markup.TableWriter(2, tableStyle); + writer.write("Extends "); + var ext = dbmap.getExtends() || app.getPrototype("hopobject").name; + writer.write(helma.Markup.Select({name: "__sqlshell_extends__"}, res.data.prototypes, ext)); + writer.write("Primary key column "); + writer.write(helma.Markup.Select({name: "__sqlshell_primaryKey__"}, res.data.columns, primKey)); + writer.write("Prototype column "); + writer.write(helma.Markup.Select({name: "__sqlshell_protoColumn__"}, res.data.columns, dbmap.prototypeField)); + writer.write("Name column "); + writer.write(helma.Markup.Select({name: "__sqlshell_nameColumn__"}, res.data.columns, dbmap.nameField)); + writer.close(); + tableStyle = { table: { "class": "map", id: "maptable" }, td: { "class": "map" } }; + writer = new helma.Markup.TableWriter(5, tableStyle); + writer.writeHeader = true; + var headers = ["Column Name", "Property Name", "Mapping", + "Target Prototype", "Extras"]; + for (var c in headers) { + writer.write(headers[c]); + } + for (var col in columns) { + var colname = columns[col]; + // if (colname == primKey) continue; + var rel = dbmap.columnNameToRelation(colname); + var value = rel && rel.propName ? rel.propName : this.toCamelCase(colname); + var type = rel ? rel.refType : 0; + var targetDisplay = type > 0 ? '': ' style="display: none;"'; + var target = rel && rel.targetType ? rel.targetType.typeName : ""; + writer.write(colname); + writer.write(''); + writer.write(helma.Markup.Select({name: "maptype_" + colname, + onchange: "toggleEditor(this)"}, maptypes, type)); + writer.write('
    ' + + helma.Markup.Select({name: "target_" + colname}, res.data.prototypes, target) + '
    '); + var buffer = new java.lang.StringBuffer(); + var config = rel ? wrapJavaMap(rel.config) : {}; + for (var i in this.mappingOptions) { + // var name = i.replace('_', '.'); + var name = colname + "_" + i; + buffer.append(helma.Markup.Hidden({id: name, name: name, value: config[i] }).toString()); + } + buffer.append(helma.Markup.A({href: this.href() + "&action=extras&col=" + colname, + id:"extralink_" + colname, style: type > 0 ? '': 'display: none;', + onclick: "openExtraEditor(this.href, '" + colname + "'); return false;"}, + "edit").toString()); + writer.write(buffer); + /* writer.write(helma.Markup.A({href: this.href() + "&action=extras&col=" + colname, + id:"extralink_" + colname, style: type > 0 ? '': 'display: none;', + onclick: "openPopup(this.href, 'extras'); return false;"}, + "edit")); */ + } + var props = dbmap.getPropertyNames(); + var collectionCount = 0; + for (var p in props) { + var rel = dbmap.propertyToRelation(props[p]); + if (rel.refType < 1 || (rel.dbField && rel.dbField != primKey)) { + continue; + } + var propName = rel.propName; + var target = rel.targetType ? rel.targetType.typeName : ""; + var type = rel.refType; + if (type == 2 && !rel.dbField) { + // helma does not separate between collections and mountpoints internally + type = 3; + } + var colname = "collection_" + (collectionCount++); + writer.write(""); + writer.write(''); + writer.write(helma.Markup.Select({name: "maptype_" + colname, + onchange: "toggleEditor(this)"}, maptypes, type)); + writer.write('
    ' + + helma.Markup.Select({name: "target_" + colname}, res.data.prototypes, target) + '
    '); + var buffer = new java.lang.StringBuffer(); + var config = wrapJavaMap(rel.config); + for (var i in this.mappingOptions) { + // var name = i.replace('_', '.'); + var name = colname + "_" + i; + buffer.append(helma.Markup.Hidden({id: name, name: name, value: config[i] }).toString()); + } + buffer.append(helma.Markup.A({href: this.href() + "&action=extras&col=" + colname, + id:"extralink_" + colname, + onclick: "openExtraEditor(this.href, '" + colname + "'); return false;"}, + "edit").toString()); + writer.write(buffer); + } + writer.close(); + // FIXME: MAJOR HACK ********************************** + res.writeln(''); + // END OF MAJOR HACK ********************************** + helma.Markup.a({href: "#", onclick:'return appendTableRow("maptable");'}, "Add Collection"); + res.write(" "); + helma.Markup.submit({name: "generateMapping", + onclick:"submitFormToPopup(document.forms.tab, '" + this.href() + "&action=generate', 'generate',500,350); return false;", + value: "Generate Mapping"}); + + } + } + return res.pop(); +} + +helma.sqlshell.Datasource.prototype.mappingOptions = { + local: 1, + foreign: 1, + order: 2, + accessname: 2, + group: 2, + group_order: 2, + group_prototype: 2, + filter: 2, + filter_additionalTables: 2, + loadmode: 1, + cachemode: 2, + maxsize: 2, + hints: 2, + logicalOperator: 2, + readonly: 2, + "private": 2 +} + +helma.sqlshell.Datasource.prototype.toCamelCase = function(str) { + var s = str.toLowerCase().split(/[-_]/); + str = s[0]; + for (var i=1; iSQL:
    \ +
    \ + \ + \ + <% param.message prefix="

    " suffix="

    " %>\ + <% param.updated prefix="

    "\ + prefix="Statement executed, "\ + suffix=" row(s) affected

    " %>\ + <% param.resultset %>'); + + case "explore": return createSkin('
    Describe Table \ + <% html.select name="__sqlshell_table__" options="response.tables" \ + onchange="document.forms.tab.submit();" %>\ +
    \ + <% param.tableheader prefix="

    " suffix="

    " %>\ + <% param.tableinfo %>'); + + case "map": return createSkin('
    Prototype \ + <% html.select name="__sqlshell_prototype__" options="response.prototypes" \ + onchange="document.forms.tab.submit();" %>\ + [new]\ + <% param.tableSelect %> \ + \ + \ + \ +
    '); + + case "newproto": return createSkin('
    \ + Prototype Name:

    \ + Create in Repository:
    <% html.select name="repository" options="app.repositories" %>

    \ + \ +
    '); + + case "extras": return createSkin('
    \ +

    Extra parameters for ' + req.data.col + '

    \ + \ + \ +
    \ + \ +
    '); + + case "generate": return createSkin('
    \ + Create type.properties in Repository:
    <% html.select name="__sqlshell_repository__"\ + options="response.repositories" %>

    \ + \ + <% param.data %>\ +
    '); + + case "closePopup": return createSkin('\ + \ + \ + \ + closing window\ + \ + \ + \ + <% param.message %>\ + \ + '); + + default: return createSkin("No skin defined for " + name); + } +} + +helma.sqlshell.Datasource.href = + +HopObject.prototype[ (app.properties['sqlshellAction'] || 'sqlshell') +'_action' ] = helma.sqlshell.main; + + +helma.dontEnum('sqlshell'); + + + + +//////////////////////////////////////////////////////////////////////// +// Macro handler for Html tags +//////////////////////////////////////////////////////////////////////// + +helma.sqlshell.html = { + + tablink_macro: function(param) { + var href = req.action + "?datasource="; + href += encode(req.data.datasource); + href += "&schema="; + href += encode(req.data.schema); + href += "&tab="; + href += param.name; + var attr = { href: href, "class": "tab" }; + if (req.data.tab == param.name) { + attr["class"] += " activetab"; + } else { + attr["class"] += " passivetab"; + } + helma.Markup.element("a", attr, param.name); + }, + + select_macro: function(param) { + if (!param.name) { + throw "dropDown macro requires name attribute"; + } + if (!param.options) { + throw "dropDown macro requires options attribute"; + } + var opts = param.options.split("."); + if (opts.length != 2) { + throw "options attribute must be of the form 'handler.options'"; + } + var handler = this.getHandler(opts[0]); + if (!handler) { + throw "handler '"+opts[0]+" not found - " + + "valid options are (response|request|session|app)"; + } + var options = handler[opts[1]]; + if (!options) { + throw param.options+" is not defined "; + } + if (options.length == 0) { + return; + } + var attr = {}; + for (var i in param) { + if (i != "options" && i != "prefix" && i != "suffix") { + attr[i] = param[i]; + } + } + helma.Markup.select(attr, options, req.data[param.name], param.firstoption); + }, + + getHandler: function (handlerName) { + switch (handlerName) { + case "response": + return res.data; + case "request": + return req.data; + case "session": + return session.data; + case "app": + return app.data; + } + return null; + } +} diff --git a/modules/tools/Global/helma.sqlshell.main.skin b/modules/tools/Global/helma.sqlshell.main.skin new file mode 100644 index 00000000..4c33095d --- /dev/null +++ b/modules/tools/Global/helma.sqlshell.main.skin @@ -0,0 +1,30 @@ +

    Helma Sql Shell

    + +
    +
    + + <% html.select name="datasource" options="response.datasources" + prefix="Data Source: " onchange="document.forms.datasource.submit(); %> +    + <% html.select name="schema" options="response.schemas" + prefix="Schema: " onchange="document.forms.datasource.submit(); %> +
    +
    + +
    + +
    +<% html.tablink name="explore" %> +<% html.tablink name="query" %> +<% html.tablink name="map" %> +
    + + + + + +<% param.body %> + +

    + +
    diff --git a/modules/tools/Global/helma.sqlshell.page.skin b/modules/tools/Global/helma.sqlshell.page.skin new file mode 100644 index 00000000..a6718273 --- /dev/null +++ b/modules/tools/Global/helma.sqlshell.page.skin @@ -0,0 +1,207 @@ + + + + +Helma SqlShell <% response.title %> + + + + + + + +<% response.header prefix="

    " suffix="

    " %> + +<% response.body %> + + diff --git a/modules/tools/Global/helma.sqlshell.selectdb.skin b/modules/tools/Global/helma.sqlshell.selectdb.skin new file mode 100644 index 00000000..27eb9977 --- /dev/null +++ b/modules/tools/Global/helma.sqlshell.selectdb.skin @@ -0,0 +1,10 @@ +

    Data sources are defined in db.properties files either at server or application level.

    + +<% param.message prefix="

    " suffix="

    " %> + +
    +Please enter a valid data source name: + <% html.select name="datasource" options="response.datasources" %> +    + +
    \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..53c80aac --- /dev/null +++ b/settings.gradle @@ -0,0 +1,9 @@ +rootProject.name = 'helma' + +// Copy task ignores multiple files per default +// See https://github.com/gradle/gradle/issues/11176 +org.apache.tools.ant.DirectoryScanner.removeDefaultExclude('**/.git') +org.apache.tools.ant.DirectoryScanner.removeDefaultExclude('**/.git/**') +org.apache.tools.ant.DirectoryScanner.removeDefaultExclude('**/.gitignore') + +include 'launcher' diff --git a/build/main/apps.properties b/src/dist/apps.properties similarity index 91% rename from build/main/apps.properties rename to src/dist/apps.properties index b76cec2f..76672bf1 100644 --- a/build/main/apps.properties +++ b/src/dist/apps.properties @@ -3,8 +3,8 @@ # http://helma.org/Documentation/Properties+Files/apps.properties/ -# Administrative application to manage all other apps on this server, -# accessible via its default mountpoint at http://:/manage +# Administrative application to manage all other apps on this server, +# accessible via its default mountpoint at http://:/manage # and using its default repository at apps/manage manage @@ -15,7 +15,7 @@ manage welcome welcome.mountpoint = / welcome.repository.0 = apps/welcome/code/ -welcome.repository.1 = modules/helmaTools.zip +welcome.repository.1 = modules/tools welcome.static = apps/welcome/static welcome.staticMountpoint = /static welcome.staticHome = index.html,default.html diff --git a/apps/manage/Application/actions.js b/src/dist/apps/manage/Application/actions.js similarity index 100% rename from apps/manage/Application/actions.js rename to src/dist/apps/manage/Application/actions.js diff --git a/apps/manage/Application/functions.js b/src/dist/apps/manage/Application/functions.js similarity index 100% rename from apps/manage/Application/functions.js rename to src/dist/apps/manage/Application/functions.js diff --git a/apps/manage/Application/head.skin b/src/dist/apps/manage/Application/head.skin similarity index 100% rename from apps/manage/Application/head.skin rename to src/dist/apps/manage/Application/head.skin diff --git a/apps/manage/Application/macros.js b/src/dist/apps/manage/Application/macros.js similarity index 100% rename from apps/manage/Application/macros.js rename to src/dist/apps/manage/Application/macros.js diff --git a/apps/manage/Application/main.skin b/src/dist/apps/manage/Application/main.skin similarity index 100% rename from apps/manage/Application/main.skin rename to src/dist/apps/manage/Application/main.skin diff --git a/apps/manage/Application/navig_active.skin b/src/dist/apps/manage/Application/navig_active.skin similarity index 100% rename from apps/manage/Application/navig_active.skin rename to src/dist/apps/manage/Application/navig_active.skin diff --git a/apps/manage/Application/navig_disabled.skin b/src/dist/apps/manage/Application/navig_disabled.skin similarity index 100% rename from apps/manage/Application/navig_disabled.skin rename to src/dist/apps/manage/Application/navig_disabled.skin diff --git a/apps/manage/DocApplication/actions.js b/src/dist/apps/manage/DocApplication/actions.js similarity index 100% rename from apps/manage/DocApplication/actions.js rename to src/dist/apps/manage/DocApplication/actions.js diff --git a/apps/manage/DocApplication/frameset.skin b/src/dist/apps/manage/DocApplication/frameset.skin similarity index 100% rename from apps/manage/DocApplication/frameset.skin rename to src/dist/apps/manage/DocApplication/frameset.skin diff --git a/apps/manage/DocApplication/functionindex.skin b/src/dist/apps/manage/DocApplication/functionindex.skin similarity index 100% rename from apps/manage/DocApplication/functionindex.skin rename to src/dist/apps/manage/DocApplication/functionindex.skin diff --git a/apps/manage/DocApplication/functions.js b/src/dist/apps/manage/DocApplication/functions.js similarity index 100% rename from apps/manage/DocApplication/functions.js rename to src/dist/apps/manage/DocApplication/functions.js diff --git a/apps/manage/DocApplication/indexSeparator.skin b/src/dist/apps/manage/DocApplication/indexSeparator.skin similarity index 100% rename from apps/manage/DocApplication/indexSeparator.skin rename to src/dist/apps/manage/DocApplication/indexSeparator.skin diff --git a/apps/manage/DocApplication/macros.js b/src/dist/apps/manage/DocApplication/macros.js similarity index 100% rename from apps/manage/DocApplication/macros.js rename to src/dist/apps/manage/DocApplication/macros.js diff --git a/apps/manage/DocApplication/prototypes.skin b/src/dist/apps/manage/DocApplication/prototypes.skin similarity index 100% rename from apps/manage/DocApplication/prototypes.skin rename to src/dist/apps/manage/DocApplication/prototypes.skin diff --git a/apps/manage/DocApplication/summary.skin b/src/dist/apps/manage/DocApplication/summary.skin similarity index 100% rename from apps/manage/DocApplication/summary.skin rename to src/dist/apps/manage/DocApplication/summary.skin diff --git a/apps/manage/DocFunction/actions.js b/src/dist/apps/manage/DocFunction/actions.js similarity index 100% rename from apps/manage/DocFunction/actions.js rename to src/dist/apps/manage/DocFunction/actions.js diff --git a/apps/manage/DocFunction/asIndexItem.skin b/src/dist/apps/manage/DocFunction/asIndexItem.skin similarity index 100% rename from apps/manage/DocFunction/asIndexItem.skin rename to src/dist/apps/manage/DocFunction/asIndexItem.skin diff --git a/apps/manage/DocFunction/asLargeListItem.skin b/src/dist/apps/manage/DocFunction/asLargeListItem.skin similarity index 100% rename from apps/manage/DocFunction/asLargeListItem.skin rename to src/dist/apps/manage/DocFunction/asLargeListItem.skin diff --git a/apps/manage/DocFunction/asLargeListItemSkin.skin b/src/dist/apps/manage/DocFunction/asLargeListItemSkin.skin similarity index 100% rename from apps/manage/DocFunction/asLargeListItemSkin.skin rename to src/dist/apps/manage/DocFunction/asLargeListItemSkin.skin diff --git a/apps/manage/DocFunction/asListItem.skin b/src/dist/apps/manage/DocFunction/asListItem.skin similarity index 100% rename from apps/manage/DocFunction/asListItem.skin rename to src/dist/apps/manage/DocFunction/asListItem.skin diff --git a/apps/manage/DocFunction/asParentListItem.skin b/src/dist/apps/manage/DocFunction/asParentListItem.skin similarity index 100% rename from apps/manage/DocFunction/asParentListItem.skin rename to src/dist/apps/manage/DocFunction/asParentListItem.skin diff --git a/apps/manage/DocFunction/functions.js b/src/dist/apps/manage/DocFunction/functions.js similarity index 100% rename from apps/manage/DocFunction/functions.js rename to src/dist/apps/manage/DocFunction/functions.js diff --git a/apps/manage/DocFunction/macros.js b/src/dist/apps/manage/DocFunction/macros.js similarity index 100% rename from apps/manage/DocFunction/macros.js rename to src/dist/apps/manage/DocFunction/macros.js diff --git a/apps/manage/DocFunction/main.skin b/src/dist/apps/manage/DocFunction/main.skin similarity index 100% rename from apps/manage/DocFunction/main.skin rename to src/dist/apps/manage/DocFunction/main.skin diff --git a/apps/manage/DocPrototype/actions.js b/src/dist/apps/manage/DocPrototype/actions.js similarity index 100% rename from apps/manage/DocPrototype/actions.js rename to src/dist/apps/manage/DocPrototype/actions.js diff --git a/apps/manage/DocPrototype/asInheritanceLink.skin b/src/dist/apps/manage/DocPrototype/asInheritanceLink.skin similarity index 100% rename from apps/manage/DocPrototype/asInheritanceLink.skin rename to src/dist/apps/manage/DocPrototype/asInheritanceLink.skin diff --git a/apps/manage/DocPrototype/asParentList.skin b/src/dist/apps/manage/DocPrototype/asParentList.skin similarity index 100% rename from apps/manage/DocPrototype/asParentList.skin rename to src/dist/apps/manage/DocPrototype/asParentList.skin diff --git a/apps/manage/DocPrototype/asPrototypeList.skin b/src/dist/apps/manage/DocPrototype/asPrototypeList.skin similarity index 100% rename from apps/manage/DocPrototype/asPrototypeList.skin rename to src/dist/apps/manage/DocPrototype/asPrototypeList.skin diff --git a/apps/manage/DocPrototype/asSummary.skin b/src/dist/apps/manage/DocPrototype/asSummary.skin similarity index 100% rename from apps/manage/DocPrototype/asSummary.skin rename to src/dist/apps/manage/DocPrototype/asSummary.skin diff --git a/apps/manage/DocPrototype/functions.js b/src/dist/apps/manage/DocPrototype/functions.js similarity index 100% rename from apps/manage/DocPrototype/functions.js rename to src/dist/apps/manage/DocPrototype/functions.js diff --git a/apps/manage/DocPrototype/list.skin b/src/dist/apps/manage/DocPrototype/list.skin similarity index 100% rename from apps/manage/DocPrototype/list.skin rename to src/dist/apps/manage/DocPrototype/list.skin diff --git a/apps/manage/DocPrototype/macros.js b/src/dist/apps/manage/DocPrototype/macros.js similarity index 100% rename from apps/manage/DocPrototype/macros.js rename to src/dist/apps/manage/DocPrototype/macros.js diff --git a/apps/manage/DocPrototype/main.skin b/src/dist/apps/manage/DocPrototype/main.skin similarity index 100% rename from apps/manage/DocPrototype/main.skin rename to src/dist/apps/manage/DocPrototype/main.skin diff --git a/apps/manage/DocPrototype/typeproperties.skin b/src/dist/apps/manage/DocPrototype/typeproperties.skin similarity index 100% rename from apps/manage/DocPrototype/typeproperties.skin rename to src/dist/apps/manage/DocPrototype/typeproperties.skin diff --git a/apps/manage/DocTag/author.skin b/src/dist/apps/manage/DocTag/author.skin similarity index 100% rename from apps/manage/DocTag/author.skin rename to src/dist/apps/manage/DocTag/author.skin diff --git a/apps/manage/DocTag/deprecated.skin b/src/dist/apps/manage/DocTag/deprecated.skin similarity index 100% rename from apps/manage/DocTag/deprecated.skin rename to src/dist/apps/manage/DocTag/deprecated.skin diff --git a/apps/manage/DocTag/main.skin b/src/dist/apps/manage/DocTag/main.skin similarity index 100% rename from apps/manage/DocTag/main.skin rename to src/dist/apps/manage/DocTag/main.skin diff --git a/apps/manage/DocTag/overrides.skin b/src/dist/apps/manage/DocTag/overrides.skin similarity index 100% rename from apps/manage/DocTag/overrides.skin rename to src/dist/apps/manage/DocTag/overrides.skin diff --git a/apps/manage/DocTag/parameter.skin b/src/dist/apps/manage/DocTag/parameter.skin similarity index 100% rename from apps/manage/DocTag/parameter.skin rename to src/dist/apps/manage/DocTag/parameter.skin diff --git a/apps/manage/DocTag/return.skin b/src/dist/apps/manage/DocTag/return.skin similarity index 100% rename from apps/manage/DocTag/return.skin rename to src/dist/apps/manage/DocTag/return.skin diff --git a/apps/manage/DocTag/see.skin b/src/dist/apps/manage/DocTag/see.skin similarity index 100% rename from apps/manage/DocTag/see.skin rename to src/dist/apps/manage/DocTag/see.skin diff --git a/apps/manage/Global/api.skin b/src/dist/apps/manage/Global/api.skin similarity index 100% rename from apps/manage/Global/api.skin rename to src/dist/apps/manage/Global/api.skin diff --git a/apps/manage/Global/basic.skin b/src/dist/apps/manage/Global/basic.skin similarity index 100% rename from apps/manage/Global/basic.skin rename to src/dist/apps/manage/Global/basic.skin diff --git a/apps/manage/Global/functions.js b/src/dist/apps/manage/Global/functions.js similarity index 100% rename from apps/manage/Global/functions.js rename to src/dist/apps/manage/Global/functions.js diff --git a/apps/manage/Global/global.skin b/src/dist/apps/manage/Global/global.skin similarity index 100% rename from apps/manage/Global/global.skin rename to src/dist/apps/manage/Global/global.skin diff --git a/apps/manage/Global/head.skin b/src/dist/apps/manage/Global/head.skin similarity index 100% rename from apps/manage/Global/head.skin rename to src/dist/apps/manage/Global/head.skin diff --git a/apps/manage/Global/macros.js b/src/dist/apps/manage/Global/macros.js similarity index 100% rename from apps/manage/Global/macros.js rename to src/dist/apps/manage/Global/macros.js diff --git a/apps/manage/Global/navig.skin b/src/dist/apps/manage/Global/navig.skin similarity index 100% rename from apps/manage/Global/navig.skin rename to src/dist/apps/manage/Global/navig.skin diff --git a/apps/manage/Global/pwdfeedback.skin b/src/dist/apps/manage/Global/pwdfeedback.skin similarity index 100% rename from apps/manage/Global/pwdfeedback.skin rename to src/dist/apps/manage/Global/pwdfeedback.skin diff --git a/apps/manage/Global/pwdform.skin b/src/dist/apps/manage/Global/pwdform.skin similarity index 100% rename from apps/manage/Global/pwdform.skin rename to src/dist/apps/manage/Global/pwdform.skin diff --git a/apps/manage/Global/renderFunctions.js b/src/dist/apps/manage/Global/renderFunctions.js similarity index 100% rename from apps/manage/Global/renderFunctions.js rename to src/dist/apps/manage/Global/renderFunctions.js diff --git a/apps/manage/README.md b/src/dist/apps/manage/README.md similarity index 100% rename from apps/manage/README.md rename to src/dist/apps/manage/README.md diff --git a/apps/manage/Root/actions.js b/src/dist/apps/manage/Root/actions.js similarity index 100% rename from apps/manage/Root/actions.js rename to src/dist/apps/manage/Root/actions.js diff --git a/apps/manage/Root/functions.js b/src/dist/apps/manage/Root/functions.js similarity index 100% rename from apps/manage/Root/functions.js rename to src/dist/apps/manage/Root/functions.js diff --git a/apps/manage/Root/macros.js b/src/dist/apps/manage/Root/macros.js similarity index 100% rename from apps/manage/Root/macros.js rename to src/dist/apps/manage/Root/macros.js diff --git a/apps/manage/Root/main.skin b/src/dist/apps/manage/Root/main.skin similarity index 100% rename from apps/manage/Root/main.skin rename to src/dist/apps/manage/Root/main.skin diff --git a/apps/manage/app.properties b/src/dist/apps/manage/app.properties similarity index 100% rename from apps/manage/app.properties rename to src/dist/apps/manage/app.properties diff --git a/apps/manage/class.properties b/src/dist/apps/manage/class.properties similarity index 100% rename from apps/manage/class.properties rename to src/dist/apps/manage/class.properties diff --git a/modules/test/README.txt b/src/dist/apps/test/README.md similarity index 100% rename from modules/test/README.txt rename to src/dist/apps/test/README.md diff --git a/modules/test/code/Global/global.js b/src/dist/apps/test/code/Global/global.js old mode 100755 new mode 100644 similarity index 100% rename from modules/test/code/Global/global.js rename to src/dist/apps/test/code/Global/global.js diff --git a/modules/test/code/Global/subskins.skin b/src/dist/apps/test/code/Global/subskins.skin old mode 100755 new mode 100644 similarity index 100% rename from modules/test/code/Global/subskins.skin rename to src/dist/apps/test/code/Global/subskins.skin diff --git a/modules/test/code/Organisation/type.properties b/src/dist/apps/test/code/Organisation/type.properties similarity index 100% rename from modules/test/code/Organisation/type.properties rename to src/dist/apps/test/code/Organisation/type.properties diff --git a/modules/test/code/Person/type.properties b/src/dist/apps/test/code/Person/type.properties similarity index 100% rename from modules/test/code/Person/type.properties rename to src/dist/apps/test/code/Person/type.properties diff --git a/modules/test/code/Root/root.js b/src/dist/apps/test/code/Root/root.js old mode 100755 new mode 100644 similarity index 100% rename from modules/test/code/Root/root.js rename to src/dist/apps/test/code/Root/root.js diff --git a/modules/test/code/Root/type.properties b/src/dist/apps/test/code/Root/type.properties old mode 100755 new mode 100644 similarity index 100% rename from modules/test/code/Root/type.properties rename to src/dist/apps/test/code/Root/type.properties diff --git a/modules/test/code/app.properties b/src/dist/apps/test/code/app.properties old mode 100755 new mode 100644 similarity index 100% rename from modules/test/code/app.properties rename to src/dist/apps/test/code/app.properties diff --git a/modules/test/code/db.properties b/src/dist/apps/test/code/db.properties similarity index 100% rename from modules/test/code/db.properties rename to src/dist/apps/test/code/db.properties diff --git a/modules/test/db-mysql.sql b/src/dist/apps/test/db-mysql.sql similarity index 100% rename from modules/test/db-mysql.sql rename to src/dist/apps/test/db-mysql.sql diff --git a/modules/test/db-oracle.sql b/src/dist/apps/test/db-oracle.sql similarity index 100% rename from modules/test/db-oracle.sql rename to src/dist/apps/test/db-oracle.sql diff --git a/modules/test/db-postgresql.sql b/src/dist/apps/test/db-postgresql.sql similarity index 100% rename from modules/test/db-postgresql.sql rename to src/dist/apps/test/db-postgresql.sql diff --git a/modules/test/tests/HopObjectBasicMapping.js b/src/dist/apps/test/tests/HopObjectBasicMapping.js similarity index 100% rename from modules/test/tests/HopObjectBasicMapping.js rename to src/dist/apps/test/tests/HopObjectBasicMapping.js diff --git a/modules/test/tests/HopObjectCollection.js b/src/dist/apps/test/tests/HopObjectCollection.js similarity index 100% rename from modules/test/tests/HopObjectCollection.js rename to src/dist/apps/test/tests/HopObjectCollection.js diff --git a/modules/test/tests/HopObjectGeneric.js b/src/dist/apps/test/tests/HopObjectGeneric.js similarity index 100% rename from modules/test/tests/HopObjectGeneric.js rename to src/dist/apps/test/tests/HopObjectGeneric.js diff --git a/modules/test/tests/HopObjectGroupBy.js b/src/dist/apps/test/tests/HopObjectGroupBy.js similarity index 100% rename from modules/test/tests/HopObjectGroupBy.js rename to src/dist/apps/test/tests/HopObjectGroupBy.js diff --git a/modules/test/tests/HopObjectHref.js b/src/dist/apps/test/tests/HopObjectHref.js similarity index 100% rename from modules/test/tests/HopObjectHref.js rename to src/dist/apps/test/tests/HopObjectHref.js diff --git a/modules/test/tests/HopObjectReference.js b/src/dist/apps/test/tests/HopObjectReference.js similarity index 100% rename from modules/test/tests/HopObjectReference.js rename to src/dist/apps/test/tests/HopObjectReference.js diff --git a/modules/test/tests/Skin.js b/src/dist/apps/test/tests/Skin.js similarity index 100% rename from modules/test/tests/Skin.js rename to src/dist/apps/test/tests/Skin.js diff --git a/modules/test/tests/helma.Http.js b/src/dist/apps/test/tests/helma.Http.js similarity index 100% rename from modules/test/tests/helma.Http.js rename to src/dist/apps/test/tests/helma.Http.js diff --git a/modules/test/tests/helma.Search.js b/src/dist/apps/test/tests/helma.Search.js similarity index 100% rename from modules/test/tests/helma.Search.js rename to src/dist/apps/test/tests/helma.Search.js diff --git a/src/dist/apps/welcome/code/Global/init.js b/src/dist/apps/welcome/code/Global/init.js new file mode 100644 index 00000000..ae6d095b --- /dev/null +++ b/src/dist/apps/welcome/code/Global/init.js @@ -0,0 +1,11 @@ +function onStart(name) { + if (!root.get('first')) { + root.name = 'root'; + var firstNode = new HopObject(); + firstNode.name = 'first'; + root.add(firstNode) + var secondNode = new HopObject(); + secondNode.name = 'second'; + firstNode.add(secondNode) + } +} diff --git a/src/dist/apps/welcome/code/Guide/handler.js b/src/dist/apps/welcome/code/Guide/handler.js new file mode 100644 index 00000000..e4bf7500 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/handler.js @@ -0,0 +1,8 @@ +function getChildElement(name) { + if (this.get(name)) + return this.get(name); + var page = new Guide(); + page.name = name; + page.parent = this; + return page; +} diff --git a/src/dist/apps/welcome/code/Guide/intro.actions.skin b/src/dist/apps/welcome/code/Guide/intro.actions.skin new file mode 100644 index 00000000..dd6f14de --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.actions.skin @@ -0,0 +1,40 @@ +

    actions

    + +

    Every request a Helma application receives is handled by an "action" + associated with the requested URL. For example, a request to + + http://<% request.http_host %>/example will be handled by the + "example" action, defined at ./apps/welcome/code/Root/example.hac

    + +
    +res.write('Hello, this is the action defined \
    +    at ./apps/welcome/code/Root/example.hac');
    +
    + +

    The file example.hac contains the Javascript code that Helma will + evaluate when handling that request. In this example, the code inside + the example.hac file automatically becomes a prototype method with an + "_action" suffix. By leveraging such conventions, Helma allows you to + structure your code in clean and uncluttered ways. Alternatively, you + can also define actions in generic Javascript files, an examples of + which can be found in ./apps/welcome/code/Root/example.js and tested via + the URL + http://<% request.http_host %>/anotherexample

    + +
    +function anotherexample_action() {
    +    res.write('Hello again, this is the action \
    +        defined in ./apps/welcome/Root/example.js');
    +}
    +
    + +

    Requests that do not specify a particular action are handled by the + "main" action. For example, a request to + http://<% request.http_host %>/ + will be handled by the "main" action, defined at + ./apps/welcome/code/Guide/main.hac

    + +

    More information about the way Helma handles requests and maps them to + actions, and how Helma maps directories and filename extensions to + objects in the Javascript environment: +
    /docs/Request-Response-Cycle/

    diff --git a/src/dist/apps/welcome/code/Guide/intro.applications.skin b/src/dist/apps/welcome/code/Guide/intro.applications.skin new file mode 100644 index 00000000..440a016c --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.applications.skin @@ -0,0 +1,48 @@ +

    applications

    + +

    Helma can serve multiple independent applications, each accessible + through a different mountpoint, using Javascript environments + running in their own global scope, and configurable to use separate + code repositories.

    + +

    A Helma default installation, for example, is serving the applications + "manage" and "welcome" and makes them accessible through the + + http://<% request.http_host %>/manage/ and + http://<% request.http_host %>/ + URLs respectively. The list of active applications is defined by the file + ./apps.properties in Helma's home directory.

    + +
    +# Administrative application to manage all 
    +# other apps on this server, accessible via its 
    +# default mountpoint at http://host:port/manage 
    +# and using its default repository at apps/manage
    +
    +manage
    +
    +
    +# More complex example of an application with 
    +# custom configuration:
    +
    +welcome
    +welcome.mountpoint = /
    +welcome.repository.0 = apps/welcome/code/
    +welcome.repository.1 = modules/helmaTools.zip
    +welcome.static = apps/welcome/static
    +welcome.staticMountpoint = /static
    +welcome.staticHome = index.html,default.html
    +welcome.staticIndex = true
    +welcome.uploadLimit = 2048
    +
    + +

    Further application specific configurations can be defined in an app.properties + file inside an application's code repository. Examples of such a file you will + find in the "manage" app's default repository directory at + ./apps/manage/app.properties and in the "welcome" application's repository at + ./apps/welcome/code/app.properties.

    + +

    More information about these files: +
    /docs/Properties+Files/apps.properties/ +
    /docs/Properties+Files/app.properties/ +

    diff --git a/src/dist/apps/welcome/code/Guide/intro.dbmapping.skin b/src/dist/apps/welcome/code/Guide/intro.dbmapping.skin new file mode 100644 index 00000000..7f200895 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.dbmapping.skin @@ -0,0 +1,56 @@ +

    database mapping

    + +

    Helma allows you to map your HopObjects to relational database tables + instead of persisting them in the application's embedded XML database.

    + +

    The list of available database connections is defined inside the file + ./db.properties in Helma's home directory or for application specific + configurations in a db.properties file inside an application's code + repository.

    + +
    +myDataSource.url = jdbc:mysql://db.domain.com/space
    +myDataSource.driver = org.gjt.mm.mysql.Driver
    +myDataSource.user = username
    +myDataSource.password = xyz
    +
    + +

    In order to add the specified JDBC driver to the classpath, place it in + the ./lib/ext/ directory. Depending on the database system you are using, + you may want to + download an appropriate JDBC driver, for example a + driver for + MySQL.

    + +

    Using the SQLshell from within your application, + you may at any time explore your database and issue SQL statements. + The SQLshell also allows you to map your database tables to properties + of your application's prototypes as desired. A simple configuration for + your object/relational mappings might look as follows:

    + +
    +_db         = myDataSource
    +_table      = PERSON
    +_id         = ID
    +
    +firstname   = FIRSTNAME
    +lastname    = LASTNAME
    +email       = EMAIL
    +createtime  = CREATETIME
    +modifytime  = MODIFYTIME
    +
    + +

    These configurations would be placed in a type.properties file + inside the corresponding prototype directory, for example in + ./apps/addressbook/Person/type.properties, when following the + "addressbook" tutorial.

    + +

    To learn how Helma's relational database mapping is put to work and + how it relates and integrates with the other central aspects of the + framework, follow the + tutorial and build the full "addressbook" application.

    + +

    More information about the object/relational mapping of HopObject properties: +
    /docs/Properties+Files/db.properties/ +
    /docs/Object-Relational+Mapping/ +

    diff --git a/src/dist/apps/welcome/code/Guide/intro.hopobjects.skin b/src/dist/apps/welcome/code/Guide/intro.hopobjects.skin new file mode 100644 index 00000000..fc6835fa --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.hopobjects.skin @@ -0,0 +1,37 @@ +

    hopobjects

    + +

    HopObjects extend the standard Javascript object with Helma-specific + properties and functions. They are the central building blocks that allow + you to leverage the application framework Helma provides.

    + +

    The main HopObject of every application is the "root" object. Every + HopObject can have a collection of attached additional HopObjects. + Each requested URL is resolved to a particular HopObject according + to these collections.

    + +

    In the "welcome" application for example, a request to + + http://<% request.http_host %>/first/second/ will be resolved by + checking the "root" object's collection for a HopObject named "first" + and the "first" object's collection for a HopObject named "second".

    + +

    While this path resolution is by default performed based on the ID of + the attached HopObjects, collections can be custom configured to use + another property as access name. In this example, the HopObject prototype + is configured at ./apps/welcome/code/HopObject/type.properties to use the + "name" property for this purpose.

    + +
    +_children = collection(HopObject)
    +_children.accessname = name
    +name
    +
    + +

    When a new HopObject is added to such a collection, it is automatically + stored in Helma's embedded XML database. To see a detailed example of + how this works, go to + http://<% request.http_host %>/first/ and add additional HopObjects.

    + +

    Documentation of HopObject functions and built-in properties: +
    /reference/HopObject.html +

    diff --git a/src/dist/apps/welcome/code/Guide/intro.javapackages.skin b/src/dist/apps/welcome/code/Guide/intro.javapackages.skin new file mode 100644 index 00000000..ca17589e --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.javapackages.skin @@ -0,0 +1,33 @@ +

    java packages

    + +

    Helma puts the whole wealth of Java libraries at your fingertips. + The "Packages" object in Helma's Javascript environment serves as + the doorway to leverage any Java packages in the CLASSPATH. You can + add any Java packages to the + CLASSPATH simply by putting the jar files in the ./lib/ext/ directory.

    + +

    Any public methods that these Java classes define become callable from + your application's Javascript environment and you can create and work + with Java objects just like you do with Javascript objects. For example, + you could create a Java StringBuffer object and then append data to it + as follows:

    + +
    +var buffer = new Packages.java.lang.StringBuffer();
    +buffer.append('hello');
    +
    + +

    If your application makes extensive use of a Java class, it might be a + good idea to wrap that class in a Javascript prototype. That way, the + objects your applications works with become true Javascript objects, you + can control exactly which class methods are exposed to your application + and you can abstract the implementation, allowing you to change the Java + classes you use without requiring modifications to your application.

    + +

    Various examples of such wrappers around Java classes can be found in the + helmaLib, which makes Mail, File, Ftp, Image, Search, SSH and Zip + functionality available in this way.

    + +

    More information on how Helma makes Java scriptable: +
    /rhino/ScriptingJava +

    diff --git a/src/dist/apps/welcome/code/Guide/intro.macros.skin b/src/dist/apps/welcome/code/Guide/intro.macros.skin new file mode 100644 index 00000000..e6c4e913 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.macros.skin @@ -0,0 +1,52 @@ +

    macros

    + +

    Macros are methods of application logic that can be called through + custom macro tags contained in skins. Macros allow skins to pull + data from application logic, while other macro tags only push + pre-determined data to the skins.

    + +

    You will find an example for such a skin in the "welcome" application + at ./apps/welcome/code/Root/example_using_macro.skin

    + +
    +<p>This is an example of a skin calling a macro.</p>
    +<p>You will find this skin at 
    +    ./apps/welcome/code/Root/example_using_macro.skin</p>
    +<p>This skin is rendered by the action defined at 
    +    ./apps/welcome/code/Root/example_using_macro.hac</p>
    +<p>The macro this skin calls is defined in 
    +    ./apps/welcome/code/Root/example.js</p>
    +<p>You can test it via the URL 
    +    <a href="<% this.pullLink part="url" %>">
    +        <% this.pullLink part="text" %>
    +    </a>
    +</p>
    +
    + +

    In this example, the skin calls a "pullLink" macro twice, using a different + "part" parameter. Macro methods are defined using a corresponding function + name with a "_macro" suffix. The pullLink macro used in this example, you + will find defined in ./apps/welcome/code/Root/example.js

    + +
    +function pullLink_macro(params) {
    +    switch (params.part) {
    +        case 'text' : 
    +            return '/example_using_macro';
    +        case 'url'  : 
    +            return this.href('example_using_macro');;
    +    }
    +}
    +
    + +

    You can test this macro and see the skin rendered via the URL + + http://<% request.http_host %>/example_using_macro

    + +

    Note that macros can again make use of skins, which may again contain + macro calls. This combination of skins and macros allows actions to + delegate the response generation through multiple tiers of "control" + and "presentation".

    + +

    More information about macro tags and ways in which you can use custom defined macros: +
    /docs/Request-Response-Cycle/

    diff --git a/src/dist/apps/welcome/code/Guide/intro.prototypes.skin b/src/dist/apps/welcome/code/Guide/intro.prototypes.skin new file mode 100644 index 00000000..d00742ce --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.prototypes.skin @@ -0,0 +1,41 @@ +

    prototypes

    + +

    Helma's coding conventions revolve around the prototype based object + inheritance of Javascript. While Helma does not force you to leverage + these coding conventions, doing so will increase productivity and you + will achieve better maintainability due to a clean and well organized + code structure.

    + +

    The HopObject prototype is the core prototype of every Helma application. + By default, other prototypes that you create will inherit from the + HopObject prototype. Every directory that you create inside your + application's code repository becomes automatically a prototype by that + name and will inherit the methods, actions, macros and skins that the + HopObject prototype provides.

    + +

    In the "welcome" application's code repository at ./apps/welcome/code/ + for example, you will find directories for the HopObject, Root and Guide + prototypes. Both the Root and Guide prototypes inherit automatically any + code from the HopObject prototype. Additionally, the Root prototype also + inherits from the Guide prototype, due to the "_extends" property that is + configured in ./apps/welcome/code/Root/type.properties

    + +
    +_extends = Guide
    +
    + +

    "Root" is the prototype of the application's root object. The root object + of the "welcome" application therefore uses the combined code from these + three prototypes, with code in "Root" overriding code from "Guide", which + in turn overrides code from "HopObject".

    + +

    When Helma receives a request to + http://<% request.http_host %>/ it will look for a "main" action to + handle the request. Since it will not find one in "Root", it will use the + one defined at ./apps/welcome/code/Guide/main.hac. Requests pointing to a + generic HopObject such as + http://<% request.http_host %>/first/ on the other hand, will use the + main action defined at ./apps/welcome/code/HopObject/main.hac.

    + +

    More information on how Helma puts prototypes to work: +
    /docs/Request-Response-Cycle/

    diff --git a/src/dist/apps/welcome/code/Guide/intro.skin b/src/dist/apps/welcome/code/Guide/intro.skin new file mode 100644 index 00000000..5328fd0a --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.skin @@ -0,0 +1,14 @@ +
    +

    Explore the introductions below and discover what you
    + can do with Helma and Javascript on the server-side.

    +
    + + +

    introductions

    + <% response.listintro %> + + + + + <% response.content %> + diff --git a/src/dist/apps/welcome/code/Guide/intro.skins.skin b/src/dist/apps/welcome/code/Guide/intro.skins.skin new file mode 100644 index 00000000..f2709074 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.skins.skin @@ -0,0 +1,44 @@ +

    skins

    + +

    Helma allows you to cleanly separate presentation from application logic + through the use of skins. The skins are segments of HTML markup that can + contain macro tags, which are replaced with dynamic content when the + skin is rendered.

    + +

    You will find an example for such a skin in the "welcome" application at + ./apps/welcome/code/Root/example.skin

    + +
    +<p>This is an example of a simple skin.</p>
    +<p>You will find this skin at 
    +    ./apps/welcome/code/Root/example.skin</p>
    +<p>This skin is rendered by the action defined at 
    +    ./apps/welcome/code/Root/example_using_skin.hac</p>
    +<p>You can test it via the URL 
    +    <a href="<% response.pushLink %>">
    +        <% response.pushLinkText %>
    +    </a>
    +</p>
    +
    + +

    The rendering of skins is controlled by an application's actions. In the + case of the "welcome" application, you will find an example of such an + action at ./apps/welcome/code/Root/example_using_skin.hac

    + +
    +res.data.pushLink = this.href('example_using_skin');
    +res.data.pushLinkText = '/example_using_skin';
    +this.renderSkin('example');
    +
    + +

    You can test this action and see the skin rendered via the URL + + http://<% request.http_host %>/example_using_skin + +

    Skins can contain various kinds of "macro tags" such as <% response.pushLink %> + used in this example skin, where the value of a dynamic URL is determined by the + action and made available to the skin by setting the req.data.pushLink property.

    + +

    More information about the way in which Helma defines and renders skins, and the + various kinds of available Macro Tags: +
    /docs/Request-Response-Cycle/

    diff --git a/src/dist/apps/welcome/code/Guide/intro.staticfiles.skin b/src/dist/apps/welcome/code/Guide/intro.staticfiles.skin new file mode 100644 index 00000000..2a957599 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/intro.staticfiles.skin @@ -0,0 +1,31 @@ +

    static files

    + +

    The default mountpoint of a Helma application is always a code repository, + which means that requests will be handled by the application's Javascript + environment and will not reference specific server pages. Static files on + the other hand are served from separate "static" mountpoints.

    + +

    In Helma's default installation, the "welcome" application is serving + static files from its "static" directory at ./apps/welcome/static/ + and makes them accessible through URLs starting with + + http://<% request.http_host %>/static/

    + +

    For example, you should be able to access the file named "test.txt" inside + the ./apps/welcome/static/ directory via the URL + + http://<% request.http_host %>/static/test.txt

    + +

    Inside the ./apps.properties file, you will find the following settings, + which control the related behavior:

    + +
    +welcome.static = apps/welcome/static
    +welcome.staticMountpoint = /static
    +welcome.staticHome = index.html,default.html
    +welcome.staticIndex = true
    +
    + +

    More information about these and additional settings related to serving static files: +
    /docs/Properties+Files/apps.properties/ +

    diff --git a/src/dist/apps/welcome/code/Guide/list.intro.skin b/src/dist/apps/welcome/code/Guide/list.intro.skin new file mode 100644 index 00000000..56993d9f --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/list.intro.skin @@ -0,0 +1,11 @@ + diff --git a/src/dist/apps/welcome/code/Guide/list.tools.skin b/src/dist/apps/welcome/code/Guide/list.tools.skin new file mode 100644 index 00000000..d65ec132 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/list.tools.skin @@ -0,0 +1,7 @@ + diff --git a/src/dist/apps/welcome/code/Guide/list.website.skin b/src/dist/apps/welcome/code/Guide/list.website.skin new file mode 100644 index 00000000..8a754f9b --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/list.website.skin @@ -0,0 +1,14 @@ + diff --git a/src/dist/apps/welcome/code/Guide/main.hac b/src/dist/apps/welcome/code/Guide/main.hac new file mode 100644 index 00000000..e156957b --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/main.hac @@ -0,0 +1,18 @@ +// Prepare some response values used by the skins +res.data.href = this.href(); +res.data.root = root.href(); + +// Render three nested skins +res.data.listtools = this.renderSkinAsString('list.tools'); +res.data.listintro = this.renderSkinAsString('list.intro'); +res.data.listwebsite = this.renderSkinAsString('list.website'); +if (this.parent && this.parent.name) { + res.data.title = 'Welcome to Helma - '+ this.parent.name +' - '+ this.name; + res.data.content = this.renderSkinAsString( this.parent.name +'.'+ this.name ); + res.data.body = this.renderSkinAsString( this.parent.name ); +} +if (!res.data.body) { + res.data.title = 'Welcome to Helma - Overview'; + res.data.body = this.renderSkinAsString('overview'); +} +this.renderSkin('page'); diff --git a/src/dist/apps/welcome/code/Guide/overview.skin b/src/dist/apps/welcome/code/Guide/overview.skin new file mode 100644 index 00000000..3e3d3df8 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/overview.skin @@ -0,0 +1,19 @@ +
    +

    Welcome to Helma! Explore the tools, introductions and resources below and + discover what you can do with Helma and Javascript on the server-side.

    +
    + + +

    tools

    + <% response.listtools %> + + + +

    introductions

    + <% response.listintro %> + + + +

    helma.org

    + <% response.listwebsite %> + diff --git a/src/dist/apps/welcome/code/Guide/tools.about_inspector.skin b/src/dist/apps/welcome/code/Guide/tools.about_inspector.skin new file mode 100644 index 00000000..8322d30c --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.about_inspector.skin @@ -0,0 +1,21 @@ +

    inspector

    + +

    The Inspector allows you to inspect and modify the properties of + HopObjects and to browse the HopObject tree. For example, you + can invoke the Inspector on the HopObject named "first" by + accessing the "inspector" action at + + http://<% request.http_host %>/first/inspector

    + + + +

    Note that access to the Inspector is restricted for obvious security + reasons. If you have not yet done so, you will be directed on how + to configure administrative access when you attempt to use + this tool.

    + +

    In order to be able to use the Inspector inside your own application, + you will need to add the helmaTools code repository to that + application. For example by adding modules/helmaTools.zip to the + list of its repositories in the + ./apps.properties file. diff --git a/src/dist/apps/welcome/code/Guide/tools.about_manage.skin b/src/dist/apps/welcome/code/Guide/tools.about_manage.skin new file mode 100644 index 00000000..40442bb2 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.about_manage.skin @@ -0,0 +1,18 @@ +

    manage

    + +

    The Manage application allows you to start and stop applications and + makes a variety of status information available. It also provides access + to the automatically generated API documentation of the application's + code repositories and libraries.

    + +

    In Helma's default installation, the Manage application can be accessed + using the + http://<% request.http_host %>/manage mountpoint.

    + + + +

    Note that access to the Manage application is restricted for obvious + security reasons. You will first need to edit the ./server.properties + file and set adminAccess to your IP address. You then will be + directed on how to configure administrative access when you attempt to + use this tool.

    diff --git a/src/dist/apps/welcome/code/Guide/tools.about_shell.skin b/src/dist/apps/welcome/code/Guide/tools.about_shell.skin new file mode 100644 index 00000000..fb4c9c76 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.about_shell.skin @@ -0,0 +1,31 @@ +

    shell

    + +

    The Shell allows you to run commands and evaluate scripts within + your running application. This may be useful for administrative + and maintenance tasks for which you may not want to build a GUI + or pre-defined scripts. Certainly, the Shell can become very + useful during development and debugging.

    + +

    By running commands you can inspect and manage data structures + beyond the capabilities of the Inspector. By running scripts you + can easily test and modify small portions of your application or + invoke actions, simulating specific circumstances and measuring + their performance.

    + +

    For example, you can invoke the Shell on the HopObject + named "second" by accessing the "shell" action at + + http://<% request.http_host %>/first/second/shell

    + + + +

    Note that access to the Shell is restricted for obvious security + reasons. If you have not yet done so, you will be directed on how + to configure administrative access when you attempt to use + this tool.

    + +

    In order to be able to use the Shell inside your own application, + you will need to add the helmaTools code repository to that + application. For example by adding modules/helmaTools.zip to the + list of its repositories in the + ./apps.properties file. diff --git a/src/dist/apps/welcome/code/Guide/tools.about_sqlshell.skin b/src/dist/apps/welcome/code/Guide/tools.about_sqlshell.skin new file mode 100644 index 00000000..7f1eeb29 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.about_sqlshell.skin @@ -0,0 +1,43 @@ +

    sqlshell

    + +

    The SQLshell allows you to query relational databases, explore + their schema, send SQL statements and create object/relational + mappings for your HopObject prototypes.

    + +

    In order to be able to use the SQLshell, you need to define at least + one datasource inside the ./db.properties file in Helma's home + directory or for application specific configurations in a db.properties + file inside the application's code repository. An example of such a + file can be found inside the welcome application at + ./apps/welcome/code/db.properties

    + +
    +myDataSource.url = jdbc:mysql://db.domain.com/space
    +myDataSource.driver = org.gjt.mm.mysql.Driver
    +myDataSource.user = username
    +myDataSource.password = xyz
    +
    + +

    In order to add the specified JDBC driver to the CLASSPATH, place it in + the ./lib/ext/ directory. Depending on the database system you are using, + you may want to + download an appropriate JDBC driver, for example a + driver for + MySQL.

    + +

    Now you should be able to use the SQLshell by accessing any URL + pointing to a HopObject with the added "sqlshell" action, such as + /sqlshell.

    + + + +

    Note that access to the SQLshell is restricted for obvious security + reasons. If you have not yet done so, you will be directed on how + to configure your administrative access when you attempt to use + this tool.

    + +

    In order to be able to use the SQLshell inside your own application, + you will need to add the helmaTools code repository to that + application. For example by adding modules/helmaTools.zip to the + list of its repositories in the + ./apps.properties file. diff --git a/src/dist/apps/welcome/code/Guide/tools.debugger.skin b/src/dist/apps/welcome/code/Guide/tools.debugger.skin new file mode 100644 index 00000000..844b5701 --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.debugger.skin @@ -0,0 +1,33 @@ +

    debugger

    + +

    The debugger can help you debug Helma applications, providing + facilities to set and clear breakpoints, control execution, view + variables, and evaluate arbitrary Javascript code in the current + scope, for example that of a request that is being processed.

    + +

    To enable the debugger, set the rhino.debug property in the + application's app.properties file as follows:

    + +
    +rhino.debug = true
    +
    + +

    If this property is set when an application is started, the debugger + will open in a separate window. Since this window will open on the + server the application is running on, using the debugger is only + suitable for local development.

    + + + +

    The "welcome" application comes with the debugger disabled. To enable + it and cause the debugger window to automatically open when Helma is + started, uncomment the corresponding property by removing the leading + hash in the ./apps/welcome/code/app.properties file:

    + +
    +#rhino.debug = true
    +
    + +

    More information on the functionality the debugger offers: +
    /rhino/debugger +

    diff --git a/src/dist/apps/welcome/code/Guide/tools.skin b/src/dist/apps/welcome/code/Guide/tools.skin new file mode 100644 index 00000000..d5e4e20e --- /dev/null +++ b/src/dist/apps/welcome/code/Guide/tools.skin @@ -0,0 +1,14 @@ +
    +

    Explore the tools below and discover what you
    + can do with Helma and Javascript on the server-side.

    +
    + + +

    tools

    + <% response.listtools %> + + + + + <% response.content %> + diff --git a/src/dist/apps/welcome/code/HopObject/add.hac b/src/dist/apps/welcome/code/HopObject/add.hac new file mode 100644 index 00000000..ddea9b58 --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/add.hac @@ -0,0 +1,19 @@ +if (req.data.add && req.data.name) { + var obj = new HopObject(); + obj.name = req.data.name; + this.add(obj); + res.redirect(obj.href()) +} +res.data.root = root.href(); +res.data.parenthref = this._parent.href(); +res.data.parentname = this._parent.name; +res.data.href = this.href(); +res.data.title = this.name; +res.data.list = '\ + '; +res.data.content = this.renderSkinAsString('add'); +res.data.body = this.renderSkinAsString('main'); + +this.renderSkin('page'); diff --git a/src/dist/apps/welcome/code/HopObject/add.skin b/src/dist/apps/welcome/code/HopObject/add.skin new file mode 100644 index 00000000..fd99e447 --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/add.skin @@ -0,0 +1,6 @@ +
    +

    In order to attach a new HopObject to "<% response.title %>", +
    please specify its name below.

    +

    Name: +

    +
    diff --git a/src/dist/apps/welcome/code/HopObject/hop.skin b/src/dist/apps/welcome/code/HopObject/hop.skin new file mode 100644 index 00000000..566e1a0a --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/hop.skin @@ -0,0 +1,24 @@ +

    This HopObject is named "<% response.title %>" and has the ID "<% response.id %>".

    + +

    It is attached to the HopObject + "<% response.parentname %>".

    + +
    +

    The access counter for + this Hop Object is at + <% response.counter %> + +

    +
    + +

    This HopObject is automatically persisted in Helma's + embedded XML database at ./db/welcome/<% response.id %>.xml

    + +

    To explore this HopObject and its properties in more detail you + may utilize the web-based shell. + In addition to the inspection of this HopObject, you will be able to + evaluate server-side Javascript in its scope.

    + +

    In case you are curious: This request has been handled by the action + defined at ./apps/welcome/code/HopObject/main.hac and this text was + rendered from the skin ./apps/welcome/code/HopObject/hop.skin

    diff --git a/src/dist/apps/welcome/code/HopObject/hoplist.js b/src/dist/apps/welcome/code/HopObject/hoplist.js new file mode 100644 index 00000000..8f919d3d --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/hoplist.js @@ -0,0 +1,8 @@ +function hoplist(){ + var list = ''; + for (var subnode in this.list()) { + list += '
  • '+ this.list()[subnode].name +'
  • '; + } + return '
      '+ list +'
    '; +} diff --git a/src/dist/apps/welcome/code/HopObject/main.hac b/src/dist/apps/welcome/code/HopObject/main.hac new file mode 100644 index 00000000..b726ae18 --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/main.hac @@ -0,0 +1,24 @@ +// Prepare some response values used by the skins +res.data.root = root.href(); +res.data.parenthref = this._parent.href(); +res.data.parentname = this._parent.name; +res.data.href = this.href(); +res.data.title = this.name; +res.data.id = this._id; +if (req.data.counter) + this.counter = 0; +else + this.counter = !this.counter ? 1 : this.counter + 1; +res.data.counter = this.counter; +res.data.list = this.hoplist(); +res.data.add = '\ +
    \ +
    \ + \ +
    \ +
    '; + +// Render three nested skins +res.data.content = this.renderSkinAsString('hop'); +res.data.body = this.renderSkinAsString('main'); +this.renderSkin('page'); diff --git a/src/dist/apps/welcome/code/HopObject/main.skin b/src/dist/apps/welcome/code/HopObject/main.skin new file mode 100644 index 00000000..256fe4b3 --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/main.skin @@ -0,0 +1,16 @@ +
    +

    HopObject - the central building blocks of your Helma applications.

    +
    + + + +

    <% response.title %>

    + <% response.list %> + <% response.add %> + + + + <% response.content %> + diff --git a/src/dist/apps/welcome/code/HopObject/page.skin b/src/dist/apps/welcome/code/HopObject/page.skin new file mode 100644 index 00000000..797ef03c --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/page.skin @@ -0,0 +1,23 @@ + + + + +<% response.title %> + + + + + + + + +
    +
    + <% response.body %> +
    +


    + + + diff --git a/src/dist/apps/welcome/code/HopObject/scripts_js.hac b/src/dist/apps/welcome/code/HopObject/scripts_js.hac new file mode 100644 index 00000000..8f543488 --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/scripts_js.hac @@ -0,0 +1,2 @@ +res.contentType="application/javascript"; +this.renderSkin('scripts_js'); diff --git a/src/dist/apps/welcome/code/HopObject/scripts_js.skin b/src/dist/apps/welcome/code/HopObject/scripts_js.skin new file mode 100644 index 00000000..cd63cebd --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/scripts_js.skin @@ -0,0 +1,22 @@ +function openbox(kind) { + document.write('\ +
    \ + \ + \ + '); + if (kind != 'content') document.write('\ +
    \ + '); + else document.write('\ +
    \ + '); +} + +function closebox(kind) { + document.write('\ +
    \ + \ + \ +
    \ + '); +} diff --git a/src/dist/apps/welcome/code/HopObject/styles_css.hac b/src/dist/apps/welcome/code/HopObject/styles_css.hac new file mode 100644 index 00000000..9412e83c --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/styles_css.hac @@ -0,0 +1,2 @@ +res.contentType="text/css"; +this.renderSkin('styles_css'); diff --git a/src/dist/apps/welcome/code/HopObject/styles_css.skin b/src/dist/apps/welcome/code/HopObject/styles_css.skin new file mode 100644 index 00000000..e07911bd --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/styles_css.skin @@ -0,0 +1,112 @@ +body { + background-color: #fff; + margin-top: 0px; + margin-left: 0px; +} + +a {text-decoration: none;} +a:link {color: #00f;} +a:visited {color: #00b;} +a:active {color: #f66;} +a:hover {color: #c33;} + +pre { + background: #ffe; + line-height:150%; + padding: 8px; +} + +h3 { + font-family: "Trebuchet MS", sans-serif; + font-size: 16px; + margin-left: 15px; +} + +ul { + font-family: "Trebuchet MS", sans-serif; + font-size: 13px; + color: #333; + // margin-left: 40px; +} + +.overview { + width: 755px; + heigth: 92px; +} +.tools { + float:left; + margin-left: 15px; + width: 222px; +} +.intro { + float:left; + margin-left: 27px; + margin-right: 27px; + width: 222px; +} +.website { + float:left; + width: 222px; +} +.pagetools, .pageintro, .pagewebsite { + float:left; + margin-left: 15px; + width: 195px; +} + +.frame { + width: 755px; + margin-top: 0px; + margin-right: auto; + margin-left: auto; + margin-bottom: 30px; +} +.lead { + font-family: "Trebuchet MS", sans-serif; + font-size: 16px; + color: #666; + margin-top: 20px; + margin-right: 45px; + margin-left: 125px; + margin-bottom: 25px; +} +.columnheight { + height: 300px; +} +.content { + font-family: "Trebuchet MS", sans-serif; + font-size: 13px; + line-height:135%; + float:left; + spacing: 10px; + margin-left: 25px; + width: 505px; +} +.contentmargin { + margin-left: 20px; + margin-right: 15px; +} + +.tools, .tools b.rtop b, .tools b.rbottom b, +.pagetools, .pagetools b.rtop b, .pagetools b.rbottom b + {background: #bf7} + +.intro, .intro b.rtop b, .intro b.rbottom b, +.pageintro, .pageintro b.rtop b, .pageintro b.rbottom b + {background: #fd6} + +.website, .website b.rtop b, .website b.rbottom b, +.pagewebsite, .pagewebsite b.rtop b, .pagewebsite b.rbottom b + {background: #7cf} + +.content, .content b.rtop b, .content b.rbottom b + {background: #eee} + +b.rtop, b.rbottom{display:block;background: #fff} +b.rtop b, b.rbottom b{display:block;height: 1px; + overflow: hidden;} +b.r1{margin: 0 5px} +b.r2{margin: 0 3px} +b.r3{margin: 0 2px} +b.r4{margin: 0 1px;height: 2px} +b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px} diff --git a/src/dist/apps/welcome/code/HopObject/type.properties b/src/dist/apps/welcome/code/HopObject/type.properties new file mode 100644 index 00000000..176ce08c --- /dev/null +++ b/src/dist/apps/welcome/code/HopObject/type.properties @@ -0,0 +1,3 @@ +_children = collection(HopObject) +_children.accessname = name +name diff --git a/src/dist/apps/welcome/code/Root/example.hac b/src/dist/apps/welcome/code/Root/example.hac new file mode 100644 index 00000000..76e98e56 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example.hac @@ -0,0 +1,2 @@ +res.write('Hello, this is the action defined \ + at ./apps/welcome/code/Root/example.hac'); diff --git a/src/dist/apps/welcome/code/Root/example.js b/src/dist/apps/welcome/code/Root/example.js new file mode 100644 index 00000000..b4d7b301 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example.js @@ -0,0 +1,11 @@ +function anotherexample_action() { + res.write('Hello again, this is the action \ + defined in ./apps/welcome/code/Root/example.js'); +} + +function pullLink_macro(params) { + switch (params.part) { + case 'text' : return '/example_using_macro'; + case 'url' : return this.href('example_using_macro');; + } +} diff --git a/src/dist/apps/welcome/code/Root/example.skin b/src/dist/apps/welcome/code/Root/example.skin new file mode 100644 index 00000000..c3fb292c --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example.skin @@ -0,0 +1,10 @@ +

    This is an example of a simple skin.

    +

    You will find this skin at + ./apps/welcome/code/Root/example.skin

    +

    This skin is rendered by the action defined at + ./apps/welcome/code/Root/example_using_skin.hac

    +

    You can test it via the URL + + <% response.pushLinkText %> + +

    diff --git a/src/dist/apps/welcome/code/Root/example_using_macro.hac b/src/dist/apps/welcome/code/Root/example_using_macro.hac new file mode 100644 index 00000000..cdcb86d7 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example_using_macro.hac @@ -0,0 +1 @@ +this.renderSkin('example_using_macro'); diff --git a/src/dist/apps/welcome/code/Root/example_using_macro.skin b/src/dist/apps/welcome/code/Root/example_using_macro.skin new file mode 100644 index 00000000..08023455 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example_using_macro.skin @@ -0,0 +1,12 @@ +

    This is an example of a skin that calls a macro.

    +

    You will find this skin at + ./apps/welcome/code/Root/example_using_macro.skin

    +

    This skin is rendered by the action defined at + ./apps/welcome/code/Root/example_using_macro.hac

    +

    The macro this skin calls is defined in + ./apps/welcome/code/Root/example.js

    +

    You can test it via the URL + "> + <% this.pullLink part="text" %> + +

    diff --git a/src/dist/apps/welcome/code/Root/example_using_skin.hac b/src/dist/apps/welcome/code/Root/example_using_skin.hac new file mode 100644 index 00000000..ec38ce97 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/example_using_skin.hac @@ -0,0 +1,3 @@ +res.data.pushLinkUrl = this.href('example_using_skin'); +res.data.pushLinkText = 'example_using_skin'; +this.renderSkin('example'); diff --git a/src/dist/apps/welcome/code/Root/type.properties b/src/dist/apps/welcome/code/Root/type.properties new file mode 100644 index 00000000..188d64d6 --- /dev/null +++ b/src/dist/apps/welcome/code/Root/type.properties @@ -0,0 +1,4 @@ +_extends = Guide +_children = collection(HopObject) +_children.accessname = name +name diff --git a/src/dist/apps/welcome/code/app.properties b/src/dist/apps/welcome/code/app.properties new file mode 100644 index 00000000..96715c17 --- /dev/null +++ b/src/dist/apps/welcome/code/app.properties @@ -0,0 +1 @@ +#rhino.debug = true diff --git a/src/dist/apps/welcome/static/guide/debugger.png b/src/dist/apps/welcome/static/guide/debugger.png new file mode 100644 index 00000000..c8cc3c06 Binary files /dev/null and b/src/dist/apps/welcome/static/guide/debugger.png differ diff --git a/src/dist/apps/welcome/static/guide/inspector.png b/src/dist/apps/welcome/static/guide/inspector.png new file mode 100644 index 00000000..b4d12339 Binary files /dev/null and b/src/dist/apps/welcome/static/guide/inspector.png differ diff --git a/src/dist/apps/welcome/static/guide/manage.png b/src/dist/apps/welcome/static/guide/manage.png new file mode 100644 index 00000000..2d5e21ef Binary files /dev/null and b/src/dist/apps/welcome/static/guide/manage.png differ diff --git a/src/dist/apps/welcome/static/guide/shell.png b/src/dist/apps/welcome/static/guide/shell.png new file mode 100644 index 00000000..15ff2bb5 Binary files /dev/null and b/src/dist/apps/welcome/static/guide/shell.png differ diff --git a/src/dist/apps/welcome/static/guide/sqlshell.png b/src/dist/apps/welcome/static/guide/sqlshell.png new file mode 100644 index 00000000..d3c92b50 Binary files /dev/null and b/src/dist/apps/welcome/static/guide/sqlshell.png differ diff --git a/src/dist/apps/welcome/static/helmaheader.png b/src/dist/apps/welcome/static/helmaheader.png new file mode 100644 index 00000000..9d45c048 Binary files /dev/null and b/src/dist/apps/welcome/static/helmaheader.png differ diff --git a/src/dist/apps/welcome/static/test.txt b/src/dist/apps/welcome/static/test.txt new file mode 100644 index 00000000..f4311c2f --- /dev/null +++ b/src/dist/apps/welcome/static/test.txt @@ -0,0 +1,4 @@ + + This file should appear at http://:/static/test.txt + if you use the embedded Web server (-w option on commandline). + diff --git a/build/main/db.properties b/src/dist/db.properties similarity index 100% rename from build/main/db.properties rename to src/dist/db.properties diff --git a/src/dist/db/manage/helma.xsl b/src/dist/db/manage/helma.xsl new file mode 100644 index 00000000..e69de29b diff --git a/src/dist/db/welcome/helma.xsl b/src/dist/db/welcome/helma.xsl new file mode 100644 index 00000000..e69de29b diff --git a/debian/README.Debian b/src/dist/extras/dpkg/README.Debian similarity index 100% rename from debian/README.Debian rename to src/dist/extras/dpkg/README.Debian diff --git a/debian/changelog b/src/dist/extras/dpkg/changelog similarity index 100% rename from debian/changelog rename to src/dist/extras/dpkg/changelog diff --git a/debian/compat b/src/dist/extras/dpkg/compat similarity index 100% rename from debian/compat rename to src/dist/extras/dpkg/compat diff --git a/debian/control b/src/dist/extras/dpkg/control similarity index 100% rename from debian/control rename to src/dist/extras/dpkg/control diff --git a/debian/copyright b/src/dist/extras/dpkg/copyright similarity index 100% rename from debian/copyright rename to src/dist/extras/dpkg/copyright diff --git a/debian/dirs b/src/dist/extras/dpkg/dirs similarity index 100% rename from debian/dirs rename to src/dist/extras/dpkg/dirs diff --git a/debian/helma1-docs.install b/src/dist/extras/dpkg/helma1-docs.install similarity index 100% rename from debian/helma1-docs.install rename to src/dist/extras/dpkg/helma1-docs.install diff --git a/debian/helma1-swarm.docs b/src/dist/extras/dpkg/helma1-swarm.docs similarity index 100% rename from debian/helma1-swarm.docs rename to src/dist/extras/dpkg/helma1-swarm.docs diff --git a/debian/helma1-swarm.install b/src/dist/extras/dpkg/helma1-swarm.install similarity index 100% rename from debian/helma1-swarm.install rename to src/dist/extras/dpkg/helma1-swarm.install diff --git a/debian/helma1.default b/src/dist/extras/dpkg/helma1.default similarity index 100% rename from debian/helma1.default rename to src/dist/extras/dpkg/helma1.default diff --git a/debian/helma1.dirs b/src/dist/extras/dpkg/helma1.dirs similarity index 100% rename from debian/helma1.dirs rename to src/dist/extras/dpkg/helma1.dirs diff --git a/debian/helma1.docs b/src/dist/extras/dpkg/helma1.docs similarity index 100% rename from debian/helma1.docs rename to src/dist/extras/dpkg/helma1.docs diff --git a/debian/helma1.init b/src/dist/extras/dpkg/helma1.init similarity index 100% rename from debian/helma1.init rename to src/dist/extras/dpkg/helma1.init diff --git a/debian/helma1.install b/src/dist/extras/dpkg/helma1.install similarity index 100% rename from debian/helma1.install rename to src/dist/extras/dpkg/helma1.install diff --git a/debian/helma1.links b/src/dist/extras/dpkg/helma1.links similarity index 100% rename from debian/helma1.links rename to src/dist/extras/dpkg/helma1.links diff --git a/debian/helma1.postinst b/src/dist/extras/dpkg/helma1.postinst similarity index 100% rename from debian/helma1.postinst rename to src/dist/extras/dpkg/helma1.postinst diff --git a/debian/patches/01_build_helmaswarm.diff b/src/dist/extras/dpkg/patches/01_build_helmaswarm.diff similarity index 100% rename from debian/patches/01_build_helmaswarm.diff rename to src/dist/extras/dpkg/patches/01_build_helmaswarm.diff diff --git a/debian/rules b/src/dist/extras/dpkg/rules similarity index 100% rename from debian/rules rename to src/dist/extras/dpkg/rules diff --git a/scripts/README.md b/src/dist/extras/upstart/README.md similarity index 100% rename from scripts/README.md rename to src/dist/extras/upstart/README.md diff --git a/scripts/helma b/src/dist/extras/upstart/helma similarity index 100% rename from scripts/helma rename to src/dist/extras/upstart/helma diff --git a/scripts/helma.conf b/src/dist/extras/upstart/helma.conf similarity index 100% rename from scripts/helma.conf rename to src/dist/extras/upstart/helma.conf diff --git a/build/main/server.properties b/src/dist/server.properties similarity index 74% rename from build/main/server.properties rename to src/dist/server.properties index d4386ad0..e0d8a647 100644 --- a/build/main/server.properties +++ b/src/dist/server.properties @@ -1,6 +1,6 @@ # Helma server configuration file. # More information about this file is available at -# http://helma.org/docs/guide/properties/server.properties/ +# http://helma.org/docs/guide/properties/server.properties/ # The SMTP server to use for sending mails. Set and uncomment the @@ -8,10 +8,10 @@ # # smtp=mail.yourdomain.com -# During development, you may want to uncomment the following line, which -# will cause errors to be logged directly to the console instead of writing +# During development, you may want to uncomment the following line, which +# will cause errors to be logged directly to the console instead of writing # to the log files inside the default ./log directory. -# +# # logDir = console # Some examples for server-wide locale settings @@ -31,6 +31,9 @@ # country = CZ # language = cs -# comma-separated list of ip addresses which are allowed to access +# Comma-separated list of ip addresses which are allowed to access # admin applications. Default is localhost for IPv4 and IPv6. -allowAdmin=127.0.0.1, ::1 +allowAdmin = 127.0.0.1, ::1 + +# Credentials for using administrative apps like manage, shell and inspector +adminAccess = 2e7e46fdfc6174e1330359be2e75e766 diff --git a/start.bat b/src/dist/start.bat old mode 100755 new mode 100644 similarity index 100% rename from start.bat rename to src/dist/start.bat diff --git a/start.sh b/src/dist/start.sh similarity index 95% rename from start.sh rename to src/dist/start.sh index 923133fe..fcda391e 100755 --- a/start.sh +++ b/src/dist/start.sh @@ -75,4 +75,4 @@ if [ "$HOP_HOME" ]; then fi # Invoke the Java VM -exec $JAVACMD $JAVA_OPTIONS -Dapple.awt.UIElement=true -jar "$INSTALL_DIR/launcher.jar" $SWITCHES $* +exec $JAVACMD $JAVA_OPTIONS -jar "$INSTALL_DIR/launcher.jar" $SWITCHES $* diff --git a/static/helma.gif b/src/dist/static/helma.gif similarity index 100% rename from static/helma.gif rename to src/dist/static/helma.gif diff --git a/static/helma2.gif b/src/dist/static/helma2.gif similarity index 100% rename from static/helma2.gif rename to src/dist/static/helma2.gif diff --git a/static/test.txt b/src/dist/static/test.txt similarity index 100% rename from static/test.txt rename to src/dist/static/test.txt diff --git a/src/helma/extensions/ConfigurationException.java b/src/main/java/helma/extensions/ConfigurationException.java similarity index 100% rename from src/helma/extensions/ConfigurationException.java rename to src/main/java/helma/extensions/ConfigurationException.java diff --git a/src/helma/extensions/HelmaExtension.java b/src/main/java/helma/extensions/HelmaExtension.java similarity index 100% rename from src/helma/extensions/HelmaExtension.java rename to src/main/java/helma/extensions/HelmaExtension.java diff --git a/src/helma/extensions/demo/DemoExtension.java b/src/main/java/helma/extensions/demo/DemoExtension.java similarity index 100% rename from src/helma/extensions/demo/DemoExtension.java rename to src/main/java/helma/extensions/demo/DemoExtension.java diff --git a/src/helma/framework/AbortException.java b/src/main/java/helma/framework/AbortException.java similarity index 100% rename from src/helma/framework/AbortException.java rename to src/main/java/helma/framework/AbortException.java diff --git a/src/helma/framework/ApplicationStoppedException.java b/src/main/java/helma/framework/ApplicationStoppedException.java similarity index 100% rename from src/helma/framework/ApplicationStoppedException.java rename to src/main/java/helma/framework/ApplicationStoppedException.java diff --git a/src/helma/framework/CookieTrans.java b/src/main/java/helma/framework/CookieTrans.java similarity index 100% rename from src/helma/framework/CookieTrans.java rename to src/main/java/helma/framework/CookieTrans.java diff --git a/src/helma/framework/FrameworkException.java b/src/main/java/helma/framework/FrameworkException.java similarity index 100% rename from src/helma/framework/FrameworkException.java rename to src/main/java/helma/framework/FrameworkException.java diff --git a/src/helma/framework/FutureResult.java b/src/main/java/helma/framework/FutureResult.java similarity index 100% rename from src/helma/framework/FutureResult.java rename to src/main/java/helma/framework/FutureResult.java diff --git a/src/helma/framework/IPathElement.java b/src/main/java/helma/framework/IPathElement.java similarity index 100% rename from src/helma/framework/IPathElement.java rename to src/main/java/helma/framework/IPathElement.java diff --git a/src/helma/framework/IRemoteApp.java b/src/main/java/helma/framework/IRemoteApp.java similarity index 100% rename from src/helma/framework/IRemoteApp.java rename to src/main/java/helma/framework/IRemoteApp.java diff --git a/src/helma/framework/NotFoundException.java b/src/main/java/helma/framework/NotFoundException.java similarity index 100% rename from src/helma/framework/NotFoundException.java rename to src/main/java/helma/framework/NotFoundException.java diff --git a/src/helma/framework/RedirectException.java b/src/main/java/helma/framework/RedirectException.java similarity index 100% rename from src/helma/framework/RedirectException.java rename to src/main/java/helma/framework/RedirectException.java diff --git a/src/helma/framework/RequestBean.java b/src/main/java/helma/framework/RequestBean.java similarity index 100% rename from src/helma/framework/RequestBean.java rename to src/main/java/helma/framework/RequestBean.java diff --git a/src/helma/framework/RequestTrans.java b/src/main/java/helma/framework/RequestTrans.java similarity index 100% rename from src/helma/framework/RequestTrans.java rename to src/main/java/helma/framework/RequestTrans.java diff --git a/src/helma/framework/ResponseBean.java b/src/main/java/helma/framework/ResponseBean.java similarity index 100% rename from src/helma/framework/ResponseBean.java rename to src/main/java/helma/framework/ResponseBean.java diff --git a/src/helma/framework/ResponseTrans.java b/src/main/java/helma/framework/ResponseTrans.java similarity index 100% rename from src/helma/framework/ResponseTrans.java rename to src/main/java/helma/framework/ResponseTrans.java diff --git a/src/helma/framework/TimeoutException.java b/src/main/java/helma/framework/TimeoutException.java similarity index 100% rename from src/helma/framework/TimeoutException.java rename to src/main/java/helma/framework/TimeoutException.java diff --git a/src/helma/framework/UploadStatus.java b/src/main/java/helma/framework/UploadStatus.java similarity index 100% rename from src/helma/framework/UploadStatus.java rename to src/main/java/helma/framework/UploadStatus.java diff --git a/src/helma/framework/core/AppClassLoader.java b/src/main/java/helma/framework/core/AppClassLoader.java similarity index 100% rename from src/helma/framework/core/AppClassLoader.java rename to src/main/java/helma/framework/core/AppClassLoader.java diff --git a/src/helma/framework/core/Application.java b/src/main/java/helma/framework/core/Application.java similarity index 100% rename from src/helma/framework/core/Application.java rename to src/main/java/helma/framework/core/Application.java diff --git a/src/helma/framework/core/ApplicationBean.java b/src/main/java/helma/framework/core/ApplicationBean.java similarity index 100% rename from src/helma/framework/core/ApplicationBean.java rename to src/main/java/helma/framework/core/ApplicationBean.java diff --git a/src/helma/framework/core/Prototype.java b/src/main/java/helma/framework/core/Prototype.java similarity index 100% rename from src/helma/framework/core/Prototype.java rename to src/main/java/helma/framework/core/Prototype.java diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/main/java/helma/framework/core/RequestEvaluator.java similarity index 100% rename from src/helma/framework/core/RequestEvaluator.java rename to src/main/java/helma/framework/core/RequestEvaluator.java diff --git a/src/helma/framework/core/RequestPath.java b/src/main/java/helma/framework/core/RequestPath.java similarity index 100% rename from src/helma/framework/core/RequestPath.java rename to src/main/java/helma/framework/core/RequestPath.java diff --git a/src/helma/framework/core/Session.java b/src/main/java/helma/framework/core/Session.java similarity index 100% rename from src/helma/framework/core/Session.java rename to src/main/java/helma/framework/core/Session.java diff --git a/src/helma/framework/core/SessionBean.java b/src/main/java/helma/framework/core/SessionBean.java similarity index 100% rename from src/helma/framework/core/SessionBean.java rename to src/main/java/helma/framework/core/SessionBean.java diff --git a/src/helma/framework/core/SessionManager.java b/src/main/java/helma/framework/core/SessionManager.java similarity index 100% rename from src/helma/framework/core/SessionManager.java rename to src/main/java/helma/framework/core/SessionManager.java diff --git a/src/helma/framework/core/Skin.java b/src/main/java/helma/framework/core/Skin.java similarity index 100% rename from src/helma/framework/core/Skin.java rename to src/main/java/helma/framework/core/Skin.java diff --git a/src/helma/framework/core/SkinManager.java b/src/main/java/helma/framework/core/SkinManager.java similarity index 100% rename from src/helma/framework/core/SkinManager.java rename to src/main/java/helma/framework/core/SkinManager.java diff --git a/src/helma/framework/core/TypeManager.java b/src/main/java/helma/framework/core/TypeManager.java similarity index 100% rename from src/helma/framework/core/TypeManager.java rename to src/main/java/helma/framework/core/TypeManager.java diff --git a/src/helma/framework/demo/SimplePathElement.java b/src/main/java/helma/framework/demo/SimplePathElement.java similarity index 100% rename from src/helma/framework/demo/SimplePathElement.java rename to src/main/java/helma/framework/demo/SimplePathElement.java diff --git a/src/helma/framework/repository/AbstractRepository.java b/src/main/java/helma/framework/repository/AbstractRepository.java similarity index 100% rename from src/helma/framework/repository/AbstractRepository.java rename to src/main/java/helma/framework/repository/AbstractRepository.java diff --git a/src/helma/framework/repository/AbstractResource.java b/src/main/java/helma/framework/repository/AbstractResource.java similarity index 100% rename from src/helma/framework/repository/AbstractResource.java rename to src/main/java/helma/framework/repository/AbstractResource.java diff --git a/src/helma/framework/repository/FileRepository.java b/src/main/java/helma/framework/repository/FileRepository.java similarity index 100% rename from src/helma/framework/repository/FileRepository.java rename to src/main/java/helma/framework/repository/FileRepository.java diff --git a/src/helma/framework/repository/FileResource.java b/src/main/java/helma/framework/repository/FileResource.java similarity index 100% rename from src/helma/framework/repository/FileResource.java rename to src/main/java/helma/framework/repository/FileResource.java diff --git a/src/helma/framework/repository/MultiFileRepository.java b/src/main/java/helma/framework/repository/MultiFileRepository.java similarity index 100% rename from src/helma/framework/repository/MultiFileRepository.java rename to src/main/java/helma/framework/repository/MultiFileRepository.java diff --git a/src/helma/framework/repository/Repository.java b/src/main/java/helma/framework/repository/Repository.java similarity index 100% rename from src/helma/framework/repository/Repository.java rename to src/main/java/helma/framework/repository/Repository.java diff --git a/src/helma/framework/repository/Resource.java b/src/main/java/helma/framework/repository/Resource.java similarity index 100% rename from src/helma/framework/repository/Resource.java rename to src/main/java/helma/framework/repository/Resource.java diff --git a/src/helma/framework/repository/ResourceComparator.java b/src/main/java/helma/framework/repository/ResourceComparator.java similarity index 100% rename from src/helma/framework/repository/ResourceComparator.java rename to src/main/java/helma/framework/repository/ResourceComparator.java diff --git a/src/helma/framework/repository/ResourceTracker.java b/src/main/java/helma/framework/repository/ResourceTracker.java similarity index 100% rename from src/helma/framework/repository/ResourceTracker.java rename to src/main/java/helma/framework/repository/ResourceTracker.java diff --git a/src/helma/framework/repository/SingleFileRepository.java b/src/main/java/helma/framework/repository/SingleFileRepository.java similarity index 100% rename from src/helma/framework/repository/SingleFileRepository.java rename to src/main/java/helma/framework/repository/SingleFileRepository.java diff --git a/src/helma/framework/repository/ZipRepository.java b/src/main/java/helma/framework/repository/ZipRepository.java similarity index 100% rename from src/helma/framework/repository/ZipRepository.java rename to src/main/java/helma/framework/repository/ZipRepository.java diff --git a/src/helma/framework/repository/ZipResource.java b/src/main/java/helma/framework/repository/ZipResource.java similarity index 100% rename from src/helma/framework/repository/ZipResource.java rename to src/main/java/helma/framework/repository/ZipResource.java diff --git a/src/helma/image/ColorQuantizer.java b/src/main/java/helma/image/ColorQuantizer.java similarity index 100% rename from src/helma/image/ColorQuantizer.java rename to src/main/java/helma/image/ColorQuantizer.java diff --git a/src/helma/image/DiffusionFilterOp.java b/src/main/java/helma/image/DiffusionFilterOp.java similarity index 100% rename from src/helma/image/DiffusionFilterOp.java rename to src/main/java/helma/image/DiffusionFilterOp.java diff --git a/src/helma/image/GIFEncoder.java b/src/main/java/helma/image/GIFEncoder.java similarity index 100% rename from src/helma/image/GIFEncoder.java rename to src/main/java/helma/image/GIFEncoder.java diff --git a/src/helma/image/ImageFilterOp.java b/src/main/java/helma/image/ImageFilterOp.java similarity index 100% rename from src/helma/image/ImageFilterOp.java rename to src/main/java/helma/image/ImageFilterOp.java diff --git a/src/helma/image/ImageGenerator.java b/src/main/java/helma/image/ImageGenerator.java similarity index 100% rename from src/helma/image/ImageGenerator.java rename to src/main/java/helma/image/ImageGenerator.java diff --git a/src/helma/image/ImageInfo.java b/src/main/java/helma/image/ImageInfo.java similarity index 100% rename from src/helma/image/ImageInfo.java rename to src/main/java/helma/image/ImageInfo.java diff --git a/src/helma/image/ImageWaiter.java b/src/main/java/helma/image/ImageWaiter.java similarity index 100% rename from src/helma/image/ImageWaiter.java rename to src/main/java/helma/image/ImageWaiter.java diff --git a/src/helma/image/ImageWrapper.java b/src/main/java/helma/image/ImageWrapper.java similarity index 100% rename from src/helma/image/ImageWrapper.java rename to src/main/java/helma/image/ImageWrapper.java diff --git a/src/helma/image/imageio/ImageIOGenerator.java b/src/main/java/helma/image/imageio/ImageIOGenerator.java similarity index 100% rename from src/helma/image/imageio/ImageIOGenerator.java rename to src/main/java/helma/image/imageio/ImageIOGenerator.java diff --git a/src/helma/image/imageio/gif/GIFImageWriteParam.java b/src/main/java/helma/image/imageio/gif/GIFImageWriteParam.java similarity index 100% rename from src/helma/image/imageio/gif/GIFImageWriteParam.java rename to src/main/java/helma/image/imageio/gif/GIFImageWriteParam.java diff --git a/src/helma/image/imageio/gif/GIFImageWriter.java b/src/main/java/helma/image/imageio/gif/GIFImageWriter.java similarity index 100% rename from src/helma/image/imageio/gif/GIFImageWriter.java rename to src/main/java/helma/image/imageio/gif/GIFImageWriter.java diff --git a/src/helma/image/imageio/gif/GIFImageWriterSpi.java b/src/main/java/helma/image/imageio/gif/GIFImageWriterSpi.java similarity index 100% rename from src/helma/image/imageio/gif/GIFImageWriterSpi.java rename to src/main/java/helma/image/imageio/gif/GIFImageWriterSpi.java diff --git a/src/helma/main/ApplicationManager.java b/src/main/java/helma/main/ApplicationManager.java similarity index 100% rename from src/helma/main/ApplicationManager.java rename to src/main/java/helma/main/ApplicationManager.java diff --git a/src/helma/main/CommandlineRunner.java b/src/main/java/helma/main/CommandlineRunner.java similarity index 100% rename from src/helma/main/CommandlineRunner.java rename to src/main/java/helma/main/CommandlineRunner.java diff --git a/src/helma/main/HelmaSecurityManager.java b/src/main/java/helma/main/HelmaSecurityManager.java similarity index 100% rename from src/helma/main/HelmaSecurityManager.java rename to src/main/java/helma/main/HelmaSecurityManager.java diff --git a/src/helma/main/HelmaShutdownHook.java b/src/main/java/helma/main/HelmaShutdownHook.java similarity index 100% rename from src/helma/main/HelmaShutdownHook.java rename to src/main/java/helma/main/HelmaShutdownHook.java diff --git a/src/helma/main/JettyServer.java b/src/main/java/helma/main/JettyServer.java similarity index 100% rename from src/helma/main/JettyServer.java rename to src/main/java/helma/main/JettyServer.java diff --git a/src/helma/main/Server.java b/src/main/java/helma/main/Server.java similarity index 100% rename from src/helma/main/Server.java rename to src/main/java/helma/main/Server.java diff --git a/src/helma/main/ServerConfig.java b/src/main/java/helma/main/ServerConfig.java similarity index 100% rename from src/helma/main/ServerConfig.java rename to src/main/java/helma/main/ServerConfig.java diff --git a/src/helma/main/launcher/Commandline.java b/src/main/java/helma/main/launcher/Commandline.java similarity index 100% rename from src/helma/main/launcher/Commandline.java rename to src/main/java/helma/main/launcher/Commandline.java diff --git a/src/helma/main/launcher/Main.java b/src/main/java/helma/main/launcher/Main.java similarity index 85% rename from src/helma/main/launcher/Main.java rename to src/main/java/helma/main/launcher/Main.java index 7a74d120..5413e6fa 100644 --- a/src/helma/main/launcher/Main.java +++ b/src/main/java/helma/main/launcher/Main.java @@ -34,28 +34,6 @@ import java.util.ArrayList; * be able to set up class and install paths. */ public class Main { - public static final String[] jars = { - "commons-codec-1-10.jar", - "commons-fileupload-1.4.jar", - "commons-io-2.2.jar", - "commons-logging-1.2.jar", - "commons-net-3.6.jar", - "helma.jar", - "javax.activation-1.2.0.jar", - "javax.servlet-api-4.0.1.jar", - "jetty-http-9.4.18.v20190429.jar", - "jetty-io-9.4.18.v20190429.jar", - "jetty-security-9.4.18.v20190429.jar", - "jetty-server-9.4.18.v20190429.jar", - "jetty-servlet-9.4.18.v20190429.jar", - "jetty-util-9.4.18.v20190429.jar", - "jetty-xml-9.4.18.v20190429.jar", - "javax.mail-api-1.6.2.jar", - "rhino-1.7.9.jar", - "tagsoup-1.2.1.jar", - "xmlrpc-2.0.1.jar" - }; - private Class serverClass; private Object server; @@ -132,6 +110,21 @@ public class Main { } } + static void addJars(ArrayList jarlist, File dir) throws MalformedURLException { + File[] files = dir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + String n = name.toLowerCase(); + return n.endsWith(".jar") || n.endsWith(".zip"); //$NON-NLS-1$//$NON-NLS-2$ + } + }); + + if (files != null) { + for (int i = 0; i < files.length; i++) { + jarlist.add(new URL("file:" + files[i].getAbsolutePath())); //$NON-NLS-1$ + } + } + } + /** * Create a server-wide ClassLoader from our install directory. * This will be used as parent ClassLoader for all application @@ -151,26 +144,11 @@ public class Main { File libdir = new File(installDir, "lib"); ArrayList jarlist = new ArrayList(); - for (int i = 0; i < jars.length; i++) { - File jar = new File(libdir, jars[i]); - jarlist.add(new URL("file:" + jar.getAbsolutePath())); - } + // add all jar files from the lib directory + addJars(jarlist, libdir); // add all jar files from the lib/ext directory - File extdir = new File(libdir, "ext"); - File[] files = extdir.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - String n = name.toLowerCase(); - return n.endsWith(".jar") || n.endsWith(".zip"); - } - }); - - if (files != null) { - for (int i = 0; i < files.length; i++) { - jarlist.add(new URL("file:" + files[i].getAbsolutePath())); - System.err.println("Adding to classpath: " + files[i].getAbsolutePath()); - } - } + addJars(jarlist, new File(libdir, "ext")); //$NON-NLS-1$ URL[] urls = new URL[jarlist.size()]; diff --git a/src/helma/main/launcher/manifest.txt b/src/main/java/helma/main/launcher/manifest.txt similarity index 100% rename from src/helma/main/launcher/manifest.txt rename to src/main/java/helma/main/launcher/manifest.txt diff --git a/src/helma/objectmodel/ConcurrencyException.java b/src/main/java/helma/objectmodel/ConcurrencyException.java similarity index 100% rename from src/helma/objectmodel/ConcurrencyException.java rename to src/main/java/helma/objectmodel/ConcurrencyException.java diff --git a/src/helma/objectmodel/DatabaseException.java b/src/main/java/helma/objectmodel/DatabaseException.java similarity index 100% rename from src/helma/objectmodel/DatabaseException.java rename to src/main/java/helma/objectmodel/DatabaseException.java diff --git a/src/helma/objectmodel/IDatabase.java b/src/main/java/helma/objectmodel/IDatabase.java similarity index 100% rename from src/helma/objectmodel/IDatabase.java rename to src/main/java/helma/objectmodel/IDatabase.java diff --git a/src/helma/objectmodel/INode.java b/src/main/java/helma/objectmodel/INode.java similarity index 100% rename from src/helma/objectmodel/INode.java rename to src/main/java/helma/objectmodel/INode.java diff --git a/src/helma/objectmodel/INodeState.java b/src/main/java/helma/objectmodel/INodeState.java similarity index 100% rename from src/helma/objectmodel/INodeState.java rename to src/main/java/helma/objectmodel/INodeState.java diff --git a/src/helma/objectmodel/IProperty.java b/src/main/java/helma/objectmodel/IProperty.java similarity index 100% rename from src/helma/objectmodel/IProperty.java rename to src/main/java/helma/objectmodel/IProperty.java diff --git a/src/helma/objectmodel/ITransaction.java b/src/main/java/helma/objectmodel/ITransaction.java similarity index 100% rename from src/helma/objectmodel/ITransaction.java rename to src/main/java/helma/objectmodel/ITransaction.java diff --git a/src/helma/objectmodel/NodeEvent.java b/src/main/java/helma/objectmodel/NodeEvent.java similarity index 100% rename from src/helma/objectmodel/NodeEvent.java rename to src/main/java/helma/objectmodel/NodeEvent.java diff --git a/src/helma/objectmodel/ObjectCache.java b/src/main/java/helma/objectmodel/ObjectCache.java similarity index 100% rename from src/helma/objectmodel/ObjectCache.java rename to src/main/java/helma/objectmodel/ObjectCache.java diff --git a/src/helma/objectmodel/ObjectNotFoundException.java b/src/main/java/helma/objectmodel/ObjectNotFoundException.java similarity index 100% rename from src/helma/objectmodel/ObjectNotFoundException.java rename to src/main/java/helma/objectmodel/ObjectNotFoundException.java diff --git a/src/helma/objectmodel/TransientNode.java b/src/main/java/helma/objectmodel/TransientNode.java similarity index 100% rename from src/helma/objectmodel/TransientNode.java rename to src/main/java/helma/objectmodel/TransientNode.java diff --git a/src/helma/objectmodel/TransientProperty.java b/src/main/java/helma/objectmodel/TransientProperty.java similarity index 100% rename from src/helma/objectmodel/TransientProperty.java rename to src/main/java/helma/objectmodel/TransientProperty.java diff --git a/src/helma/objectmodel/db/DbColumn.java b/src/main/java/helma/objectmodel/db/DbColumn.java similarity index 100% rename from src/helma/objectmodel/db/DbColumn.java rename to src/main/java/helma/objectmodel/db/DbColumn.java diff --git a/src/helma/objectmodel/db/DbKey.java b/src/main/java/helma/objectmodel/db/DbKey.java similarity index 100% rename from src/helma/objectmodel/db/DbKey.java rename to src/main/java/helma/objectmodel/db/DbKey.java diff --git a/src/helma/objectmodel/db/DbMapping.java b/src/main/java/helma/objectmodel/db/DbMapping.java similarity index 100% rename from src/helma/objectmodel/db/DbMapping.java rename to src/main/java/helma/objectmodel/db/DbMapping.java diff --git a/src/helma/objectmodel/db/DbSource.java b/src/main/java/helma/objectmodel/db/DbSource.java similarity index 100% rename from src/helma/objectmodel/db/DbSource.java rename to src/main/java/helma/objectmodel/db/DbSource.java diff --git a/src/helma/objectmodel/db/IDGenerator.java b/src/main/java/helma/objectmodel/db/IDGenerator.java similarity index 100% rename from src/helma/objectmodel/db/IDGenerator.java rename to src/main/java/helma/objectmodel/db/IDGenerator.java diff --git a/src/helma/objectmodel/db/Key.java b/src/main/java/helma/objectmodel/db/Key.java similarity index 100% rename from src/helma/objectmodel/db/Key.java rename to src/main/java/helma/objectmodel/db/Key.java diff --git a/src/helma/objectmodel/db/MultiKey.java b/src/main/java/helma/objectmodel/db/MultiKey.java similarity index 100% rename from src/helma/objectmodel/db/MultiKey.java rename to src/main/java/helma/objectmodel/db/MultiKey.java diff --git a/src/helma/objectmodel/db/Node.java b/src/main/java/helma/objectmodel/db/Node.java similarity index 100% rename from src/helma/objectmodel/db/Node.java rename to src/main/java/helma/objectmodel/db/Node.java diff --git a/src/helma/objectmodel/db/NodeChangeListener.java b/src/main/java/helma/objectmodel/db/NodeChangeListener.java similarity index 100% rename from src/helma/objectmodel/db/NodeChangeListener.java rename to src/main/java/helma/objectmodel/db/NodeChangeListener.java diff --git a/src/helma/objectmodel/db/NodeHandle.java b/src/main/java/helma/objectmodel/db/NodeHandle.java similarity index 100% rename from src/helma/objectmodel/db/NodeHandle.java rename to src/main/java/helma/objectmodel/db/NodeHandle.java diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/main/java/helma/objectmodel/db/NodeManager.java similarity index 100% rename from src/helma/objectmodel/db/NodeManager.java rename to src/main/java/helma/objectmodel/db/NodeManager.java diff --git a/src/helma/objectmodel/db/ParentInfo.java b/src/main/java/helma/objectmodel/db/ParentInfo.java similarity index 100% rename from src/helma/objectmodel/db/ParentInfo.java rename to src/main/java/helma/objectmodel/db/ParentInfo.java diff --git a/src/helma/objectmodel/db/Property.java b/src/main/java/helma/objectmodel/db/Property.java similarity index 100% rename from src/helma/objectmodel/db/Property.java rename to src/main/java/helma/objectmodel/db/Property.java diff --git a/src/helma/objectmodel/db/Relation.java b/src/main/java/helma/objectmodel/db/Relation.java similarity index 100% rename from src/helma/objectmodel/db/Relation.java rename to src/main/java/helma/objectmodel/db/Relation.java diff --git a/src/helma/objectmodel/db/SegmentedSubnodeList.java b/src/main/java/helma/objectmodel/db/SegmentedSubnodeList.java similarity index 100% rename from src/helma/objectmodel/db/SegmentedSubnodeList.java rename to src/main/java/helma/objectmodel/db/SegmentedSubnodeList.java diff --git a/src/helma/objectmodel/db/SubnodeList.java b/src/main/java/helma/objectmodel/db/SubnodeList.java similarity index 100% rename from src/helma/objectmodel/db/SubnodeList.java rename to src/main/java/helma/objectmodel/db/SubnodeList.java diff --git a/src/helma/objectmodel/db/SyntheticKey.java b/src/main/java/helma/objectmodel/db/SyntheticKey.java similarity index 100% rename from src/helma/objectmodel/db/SyntheticKey.java rename to src/main/java/helma/objectmodel/db/SyntheticKey.java diff --git a/src/helma/objectmodel/db/Transactor.java b/src/main/java/helma/objectmodel/db/Transactor.java similarity index 100% rename from src/helma/objectmodel/db/Transactor.java rename to src/main/java/helma/objectmodel/db/Transactor.java diff --git a/src/helma/objectmodel/db/WrappedNodeManager.java b/src/main/java/helma/objectmodel/db/WrappedNodeManager.java similarity index 100% rename from src/helma/objectmodel/db/WrappedNodeManager.java rename to src/main/java/helma/objectmodel/db/WrappedNodeManager.java diff --git a/src/helma/objectmodel/dom/XmlConstants.java b/src/main/java/helma/objectmodel/dom/XmlConstants.java similarity index 100% rename from src/helma/objectmodel/dom/XmlConstants.java rename to src/main/java/helma/objectmodel/dom/XmlConstants.java diff --git a/src/helma/objectmodel/dom/XmlConverter.java b/src/main/java/helma/objectmodel/dom/XmlConverter.java similarity index 100% rename from src/helma/objectmodel/dom/XmlConverter.java rename to src/main/java/helma/objectmodel/dom/XmlConverter.java diff --git a/src/helma/objectmodel/dom/XmlDatabase.java b/src/main/java/helma/objectmodel/dom/XmlDatabase.java similarity index 100% rename from src/helma/objectmodel/dom/XmlDatabase.java rename to src/main/java/helma/objectmodel/dom/XmlDatabase.java diff --git a/src/helma/objectmodel/dom/XmlDatabaseReader.java b/src/main/java/helma/objectmodel/dom/XmlDatabaseReader.java similarity index 100% rename from src/helma/objectmodel/dom/XmlDatabaseReader.java rename to src/main/java/helma/objectmodel/dom/XmlDatabaseReader.java diff --git a/src/helma/objectmodel/dom/XmlIDGenerator.java b/src/main/java/helma/objectmodel/dom/XmlIDGenerator.java similarity index 100% rename from src/helma/objectmodel/dom/XmlIDGenerator.java rename to src/main/java/helma/objectmodel/dom/XmlIDGenerator.java diff --git a/src/helma/objectmodel/dom/XmlReader.java b/src/main/java/helma/objectmodel/dom/XmlReader.java similarity index 100% rename from src/helma/objectmodel/dom/XmlReader.java rename to src/main/java/helma/objectmodel/dom/XmlReader.java diff --git a/src/helma/objectmodel/dom/XmlUtil.java b/src/main/java/helma/objectmodel/dom/XmlUtil.java similarity index 100% rename from src/helma/objectmodel/dom/XmlUtil.java rename to src/main/java/helma/objectmodel/dom/XmlUtil.java diff --git a/src/helma/objectmodel/dom/XmlWriter.java b/src/main/java/helma/objectmodel/dom/XmlWriter.java similarity index 100% rename from src/helma/objectmodel/dom/XmlWriter.java rename to src/main/java/helma/objectmodel/dom/XmlWriter.java diff --git a/src/helma/objectmodel/dom/helma.xsl b/src/main/java/helma/objectmodel/dom/helma.xsl similarity index 100% rename from src/helma/objectmodel/dom/helma.xsl rename to src/main/java/helma/objectmodel/dom/helma.xsl diff --git a/src/helma/scripting/ScriptingEngine.java b/src/main/java/helma/scripting/ScriptingEngine.java similarity index 100% rename from src/helma/scripting/ScriptingEngine.java rename to src/main/java/helma/scripting/ScriptingEngine.java diff --git a/src/helma/scripting/ScriptingException.java b/src/main/java/helma/scripting/ScriptingException.java similarity index 100% rename from src/helma/scripting/ScriptingException.java rename to src/main/java/helma/scripting/ScriptingException.java diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/main/java/helma/scripting/rhino/GlobalObject.java similarity index 100% rename from src/helma/scripting/rhino/GlobalObject.java rename to src/main/java/helma/scripting/rhino/GlobalObject.java diff --git a/src/helma/scripting/rhino/HacHspConverter.java b/src/main/java/helma/scripting/rhino/HacHspConverter.java similarity index 100% rename from src/helma/scripting/rhino/HacHspConverter.java rename to src/main/java/helma/scripting/rhino/HacHspConverter.java diff --git a/src/helma/scripting/rhino/HopObject.java b/src/main/java/helma/scripting/rhino/HopObject.java similarity index 100% rename from src/helma/scripting/rhino/HopObject.java rename to src/main/java/helma/scripting/rhino/HopObject.java diff --git a/src/helma/scripting/rhino/HopObjectCtor.java b/src/main/java/helma/scripting/rhino/HopObjectCtor.java similarity index 100% rename from src/helma/scripting/rhino/HopObjectCtor.java rename to src/main/java/helma/scripting/rhino/HopObjectCtor.java diff --git a/src/helma/scripting/rhino/JSAdapter.java b/src/main/java/helma/scripting/rhino/JSAdapter.java similarity index 100% rename from src/helma/scripting/rhino/JSAdapter.java rename to src/main/java/helma/scripting/rhino/JSAdapter.java diff --git a/src/helma/scripting/rhino/JavaObject.java b/src/main/java/helma/scripting/rhino/JavaObject.java similarity index 100% rename from src/helma/scripting/rhino/JavaObject.java rename to src/main/java/helma/scripting/rhino/JavaObject.java diff --git a/src/helma/scripting/rhino/MapWrapper.java b/src/main/java/helma/scripting/rhino/MapWrapper.java similarity index 100% rename from src/helma/scripting/rhino/MapWrapper.java rename to src/main/java/helma/scripting/rhino/MapWrapper.java diff --git a/src/helma/scripting/rhino/PathWrapper.java b/src/main/java/helma/scripting/rhino/PathWrapper.java similarity index 100% rename from src/helma/scripting/rhino/PathWrapper.java rename to src/main/java/helma/scripting/rhino/PathWrapper.java diff --git a/src/helma/scripting/rhino/PropertyRecorder.java b/src/main/java/helma/scripting/rhino/PropertyRecorder.java similarity index 100% rename from src/helma/scripting/rhino/PropertyRecorder.java rename to src/main/java/helma/scripting/rhino/PropertyRecorder.java diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/main/java/helma/scripting/rhino/RhinoCore.java similarity index 100% rename from src/helma/scripting/rhino/RhinoCore.java rename to src/main/java/helma/scripting/rhino/RhinoCore.java diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/main/java/helma/scripting/rhino/RhinoEngine.java similarity index 100% rename from src/helma/scripting/rhino/RhinoEngine.java rename to src/main/java/helma/scripting/rhino/RhinoEngine.java diff --git a/src/helma/scripting/rhino/SerializationProxy.java b/src/main/java/helma/scripting/rhino/SerializationProxy.java similarity index 100% rename from src/helma/scripting/rhino/SerializationProxy.java rename to src/main/java/helma/scripting/rhino/SerializationProxy.java diff --git a/src/helma/scripting/rhino/SkinKey.java b/src/main/java/helma/scripting/rhino/SkinKey.java similarity index 100% rename from src/helma/scripting/rhino/SkinKey.java rename to src/main/java/helma/scripting/rhino/SkinKey.java diff --git a/src/helma/scripting/rhino/debug/HelmaDebugger.java b/src/main/java/helma/scripting/rhino/debug/HelmaDebugger.java similarity index 100% rename from src/helma/scripting/rhino/debug/HelmaDebugger.java rename to src/main/java/helma/scripting/rhino/debug/HelmaDebugger.java diff --git a/src/helma/scripting/rhino/debug/Profiler.java b/src/main/java/helma/scripting/rhino/debug/Profiler.java similarity index 100% rename from src/helma/scripting/rhino/debug/Profiler.java rename to src/main/java/helma/scripting/rhino/debug/Profiler.java diff --git a/src/helma/scripting/rhino/debug/Tracer.java b/src/main/java/helma/scripting/rhino/debug/Tracer.java similarity index 100% rename from src/helma/scripting/rhino/debug/Tracer.java rename to src/main/java/helma/scripting/rhino/debug/Tracer.java diff --git a/src/helma/scripting/rhino/extensions/DatabaseObject.java b/src/main/java/helma/scripting/rhino/extensions/DatabaseObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/DatabaseObject.java rename to src/main/java/helma/scripting/rhino/extensions/DatabaseObject.java diff --git a/src/helma/scripting/rhino/extensions/FileObject.java b/src/main/java/helma/scripting/rhino/extensions/FileObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/FileObject.java rename to src/main/java/helma/scripting/rhino/extensions/FileObject.java diff --git a/src/helma/scripting/rhino/extensions/FtpObject.java b/src/main/java/helma/scripting/rhino/extensions/FtpObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/FtpObject.java rename to src/main/java/helma/scripting/rhino/extensions/FtpObject.java diff --git a/src/helma/scripting/rhino/extensions/ImageObject.java b/src/main/java/helma/scripting/rhino/extensions/ImageObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/ImageObject.java rename to src/main/java/helma/scripting/rhino/extensions/ImageObject.java diff --git a/src/helma/scripting/rhino/extensions/MailObject.java b/src/main/java/helma/scripting/rhino/extensions/MailObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/MailObject.java rename to src/main/java/helma/scripting/rhino/extensions/MailObject.java diff --git a/src/helma/scripting/rhino/extensions/XmlObject.java b/src/main/java/helma/scripting/rhino/extensions/XmlObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/XmlObject.java rename to src/main/java/helma/scripting/rhino/extensions/XmlObject.java diff --git a/src/helma/scripting/rhino/extensions/XmlRpcObject.java b/src/main/java/helma/scripting/rhino/extensions/XmlRpcObject.java similarity index 100% rename from src/helma/scripting/rhino/extensions/XmlRpcObject.java rename to src/main/java/helma/scripting/rhino/extensions/XmlRpcObject.java diff --git a/src/helma/servlet/AbstractServletClient.java b/src/main/java/helma/servlet/AbstractServletClient.java similarity index 100% rename from src/helma/servlet/AbstractServletClient.java rename to src/main/java/helma/servlet/AbstractServletClient.java diff --git a/src/helma/servlet/EmbeddedServletClient.java b/src/main/java/helma/servlet/EmbeddedServletClient.java similarity index 100% rename from src/helma/servlet/EmbeddedServletClient.java rename to src/main/java/helma/servlet/EmbeddedServletClient.java diff --git a/src/helma/servlet/StandaloneServletClient.java b/src/main/java/helma/servlet/StandaloneServletClient.java similarity index 100% rename from src/helma/servlet/StandaloneServletClient.java rename to src/main/java/helma/servlet/StandaloneServletClient.java diff --git a/src/helma/util/Base64.java b/src/main/java/helma/util/Base64.java similarity index 100% rename from src/helma/util/Base64.java rename to src/main/java/helma/util/Base64.java diff --git a/src/helma/util/CacheMap.java b/src/main/java/helma/util/CacheMap.java similarity index 100% rename from src/helma/util/CacheMap.java rename to src/main/java/helma/util/CacheMap.java diff --git a/src/helma/util/CopyOnWriteMap.java b/src/main/java/helma/util/CopyOnWriteMap.java similarity index 100% rename from src/helma/util/CopyOnWriteMap.java rename to src/main/java/helma/util/CopyOnWriteMap.java diff --git a/src/helma/util/CronJob.java b/src/main/java/helma/util/CronJob.java similarity index 100% rename from src/helma/util/CronJob.java rename to src/main/java/helma/util/CronJob.java diff --git a/src/helma/util/Crypt.java b/src/main/java/helma/util/Crypt.java similarity index 100% rename from src/helma/util/Crypt.java rename to src/main/java/helma/util/Crypt.java diff --git a/src/helma/util/CryptFile.java b/src/main/java/helma/util/CryptFile.java similarity index 100% rename from src/helma/util/CryptFile.java rename to src/main/java/helma/util/CryptFile.java diff --git a/src/helma/util/CryptResource.java b/src/main/java/helma/util/CryptResource.java similarity index 100% rename from src/helma/util/CryptResource.java rename to src/main/java/helma/util/CryptResource.java diff --git a/src/helma/util/Diff.java b/src/main/java/helma/util/Diff.java similarity index 100% rename from src/helma/util/Diff.java rename to src/main/java/helma/util/Diff.java diff --git a/src/helma/util/EmptyEnumeration.java b/src/main/java/helma/util/EmptyEnumeration.java similarity index 100% rename from src/helma/util/EmptyEnumeration.java rename to src/main/java/helma/util/EmptyEnumeration.java diff --git a/src/helma/util/FileLogger.java b/src/main/java/helma/util/FileLogger.java similarity index 100% rename from src/helma/util/FileLogger.java rename to src/main/java/helma/util/FileLogger.java diff --git a/src/helma/util/HtmlEncoder.java b/src/main/java/helma/util/HtmlEncoder.java similarity index 100% rename from src/helma/util/HtmlEncoder.java rename to src/main/java/helma/util/HtmlEncoder.java diff --git a/src/helma/util/InetAddressFilter.java b/src/main/java/helma/util/InetAddressFilter.java similarity index 100% rename from src/helma/util/InetAddressFilter.java rename to src/main/java/helma/util/InetAddressFilter.java diff --git a/src/helma/util/Logger.java b/src/main/java/helma/util/Logger.java similarity index 100% rename from src/helma/util/Logger.java rename to src/main/java/helma/util/Logger.java diff --git a/src/helma/util/Logging.java b/src/main/java/helma/util/Logging.java similarity index 100% rename from src/helma/util/Logging.java rename to src/main/java/helma/util/Logging.java diff --git a/src/helma/util/Logo.java b/src/main/java/helma/util/Logo.java similarity index 100% rename from src/helma/util/Logo.java rename to src/main/java/helma/util/Logo.java diff --git a/src/helma/util/MD5Encoder.java b/src/main/java/helma/util/MD5Encoder.java similarity index 100% rename from src/helma/util/MD5Encoder.java rename to src/main/java/helma/util/MD5Encoder.java diff --git a/src/helma/util/MarkdownProcessor.java b/src/main/java/helma/util/MarkdownProcessor.java similarity index 100% rename from src/helma/util/MarkdownProcessor.java rename to src/main/java/helma/util/MarkdownProcessor.java diff --git a/src/helma/util/MimePart.java b/src/main/java/helma/util/MimePart.java similarity index 100% rename from src/helma/util/MimePart.java rename to src/main/java/helma/util/MimePart.java diff --git a/src/helma/util/MimePartDataSource.java b/src/main/java/helma/util/MimePartDataSource.java similarity index 100% rename from src/helma/util/MimePartDataSource.java rename to src/main/java/helma/util/MimePartDataSource.java diff --git a/src/helma/util/ParanoidServerSocket.java b/src/main/java/helma/util/ParanoidServerSocket.java similarity index 100% rename from src/helma/util/ParanoidServerSocket.java rename to src/main/java/helma/util/ParanoidServerSocket.java diff --git a/src/helma/util/ResourceProperties.java b/src/main/java/helma/util/ResourceProperties.java similarity index 100% rename from src/helma/util/ResourceProperties.java rename to src/main/java/helma/util/ResourceProperties.java diff --git a/src/helma/util/StringUtils.java b/src/main/java/helma/util/StringUtils.java similarity index 100% rename from src/helma/util/StringUtils.java rename to src/main/java/helma/util/StringUtils.java diff --git a/src/helma/util/SystemMap.java b/src/main/java/helma/util/SystemMap.java similarity index 100% rename from src/helma/util/SystemMap.java rename to src/main/java/helma/util/SystemMap.java diff --git a/src/helma/util/SystemProperties.java b/src/main/java/helma/util/SystemProperties.java similarity index 100% rename from src/helma/util/SystemProperties.java rename to src/main/java/helma/util/SystemProperties.java diff --git a/src/helma/util/Timer.java b/src/main/java/helma/util/Timer.java similarity index 100% rename from src/helma/util/Timer.java rename to src/main/java/helma/util/Timer.java diff --git a/src/helma/util/UrlEncoded.java b/src/main/java/helma/util/UrlEncoded.java similarity index 100% rename from src/helma/util/UrlEncoded.java rename to src/main/java/helma/util/UrlEncoded.java diff --git a/src/helma/util/WeakCacheMap.java b/src/main/java/helma/util/WeakCacheMap.java similarity index 100% rename from src/helma/util/WeakCacheMap.java rename to src/main/java/helma/util/WeakCacheMap.java diff --git a/src/helma/util/WrappedMap.java b/src/main/java/helma/util/WrappedMap.java similarity index 100% rename from src/helma/util/WrappedMap.java rename to src/main/java/helma/util/WrappedMap.java diff --git a/src/helma/util/XmlUtils.java b/src/main/java/helma/util/XmlUtils.java similarity index 100% rename from src/helma/util/XmlUtils.java rename to src/main/java/helma/util/XmlUtils.java diff --git a/src/META-INF/services/javax.imageio.spi.ImageWriterSpi b/src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi similarity index 100% rename from src/META-INF/services/javax.imageio.spi.ImageWriterSpi rename to src/main/resources/META-INF/services/javax.imageio.spi.ImageWriterSpi