Ajocado API 1.0.0.Alpha2

org.jboss.arquillian.ajocado.encapsulated
Class JavaScript

java.lang.Object
  extended by org.jboss.arquillian.ajocado.encapsulated.JavaScript

public class JavaScript
extends Object

Encapsulates JavaScript definitions.

Able to load JavaScript code from file or from classpath resource.

Version:
$Revision$
Author:
Lukas Fryc

Constructor Summary
JavaScript(String javaScript)
          Instantiates a new java script.
 
Method Summary
 JavaScript append(String javaScriptPartToAppend)
          Append the JavaScript part to end of the this JavaScript
static JavaScript fromFile(File sourceFile)
          Loads the JavaScript from file.
static JavaScript fromResource(String resourceName)
          Loads the JavaScript from classpath resource.
 String getAsString()
          Gets the JavaScript as string
 String getIdentification()
           Gets a identification for this script based on script's hashcode.
 JavaScript join(JavaScript javaScriptToJoin)
          Joins this JavaScript object with another JavaScript object to single JavaScript.
static JavaScript js(String javaScript)
          The factory method for JavaScript object
 JavaScript parametrize(Object... parameters)
          Fills the parameters to placeholders in simplified format (look for Simplified format) to this JavaScript code and returns the result.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaScript

public JavaScript(String javaScript)
Instantiates a new java script.

Parameters:
javaScript - the java script code
Method Detail

js

public static JavaScript js(String javaScript)
The factory method for JavaScript object

Parameters:
javaScript - code
Returns:
the new JavaScript object with predefined JavaScript code

getAsString

public String getAsString()
Gets the JavaScript as string

Returns:
the JavaScript as string

toString

public String toString()
Overrides:
toString in class Object

join

public JavaScript join(JavaScript javaScriptToJoin)
Joins this JavaScript object with another JavaScript object to single JavaScript.

Parameters:
javaScriptToJoin - the JavaScript object we want to join with
Returns:
the joined JavaScript object

append

public JavaScript append(String javaScriptPartToAppend)
Append the JavaScript part to end of the this JavaScript

Parameters:
javaScriptPartToAppend - javaScript to append on the end of this JavaScript
Returns:
this JavaScript with javaScriptPartToAppend appended

getIdentification

public String getIdentification()

Gets a identification for this script based on script's hashcode.

It can be used to uniquely distinguish the script on the page.

Returns:
the unique identification for this script based on script's hashcode.

fromFile

public static JavaScript fromFile(File sourceFile)
Loads the JavaScript from file.

Parameters:
sourceFile - the source file
Returns:
the JavaScript object loaded from file
Throws:
RuntimeException - when failed to load a script

fromResource

public static JavaScript fromResource(String resourceName)
Loads the JavaScript from classpath resource.

Parameters:
resourceName - the resource name, e.g. "org/jboss/test/..."
Returns:
the JavaScript object loaded from classpath resource
Throws:
RuntimeException - when failed to load a script

parametrize

public JavaScript parametrize(Object... parameters)
Fills the parameters to placeholders in simplified format (look for Simplified format) to this JavaScript code and returns the result.

Parameters:
parameters - to parametrize this JavaScript code
Returns:
this JavaScript with parameters filled in place of placeholders in simplified format

Ajocado API 1.0.0.Alpha2

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.