org.directwebremoting
Class ScriptBuffer

java.lang.Object
  extended by org.directwebremoting.ScriptBuffer

public class ScriptBuffer
extends java.lang.Object

A ScriptBuffer is like a StringBuffer except that it is used to create Javascript commands. There are 2 version of the append() method:

The first is appendScript(String) which assumes that the parameter is to be inserted literally into the output.

The second is appendData(String) (and variants for Object and primitive types) which assumes that the parameter is a variable which should be properly converted, escaped and quoted.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
ScriptBuffer()
          Create an empty ScriptBuffer.
ScriptBuffer(java.lang.String str)
          Create a ScriptBuffer with some initial content.
 
Method Summary
 ScriptBuffer appendAll(ScriptBuffer buffer)
           
 ScriptBuffer appendCall(java.lang.String funcName, java.lang.Object... params)
          Call a named function with one parameter.
 ScriptBuffer appendData(boolean b)
           
 ScriptBuffer appendData(char c)
           
 ScriptBuffer appendData(double d)
           
 ScriptBuffer appendData(float f)
           
 ScriptBuffer appendData(int i)
           
 ScriptBuffer appendData(long l)
           
 ScriptBuffer appendData(java.lang.Object obj)
           
 ScriptBuffer appendData(java.lang.String str)
           
 ScriptBuffer appendScript(java.lang.String str)
           
 java.util.List<?> getParts()
          For DWR use only - This method is not part of the public API.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptBuffer

public ScriptBuffer()
Create an empty ScriptBuffer.


ScriptBuffer

public ScriptBuffer(java.lang.String str)
Create a ScriptBuffer with some initial content. appendScript(String) is called with the passed string

Parameters:
str - The initial string to place in the buffer
Method Detail

appendAll

public ScriptBuffer appendAll(ScriptBuffer buffer)
Parameters:
buffer - The ScriptBuffer to merge into this script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(java.lang.String)

appendScript

public ScriptBuffer appendScript(java.lang.String str)
Parameters:
str - The String to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(java.lang.String)

appendData

public ScriptBuffer appendData(boolean b)
Parameters:
b - The boolean to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(boolean)

appendData

public ScriptBuffer appendData(char c)
Parameters:
c - The char to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(char)

appendData

public ScriptBuffer appendData(double d)
Parameters:
d - The double to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(double)

appendData

public ScriptBuffer appendData(float f)
Parameters:
f - The float to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(float)

appendData

public ScriptBuffer appendData(int i)
Parameters:
i - The int to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(int)

appendData

public ScriptBuffer appendData(long l)
Parameters:
l - The long to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(long)

appendData

public ScriptBuffer appendData(java.lang.Object obj)
Parameters:
obj - The Object to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(java.lang.Object)

appendData

public ScriptBuffer appendData(java.lang.String str)
Parameters:
str - The String to add to the script
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
StringBuffer.append(java.lang.String)

appendCall

public ScriptBuffer appendCall(java.lang.String funcName,
                               java.lang.Object... params)
Call a named function with one parameter.

Parameters:
funcName - The name of the function to call
params - The parameters to the above function
Returns:
this. To allow buffer.append(x).append(y).append(z);
See Also:
ScriptSessions.addFunctionCall(java.lang.String, java.lang.Object...)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getParts

public java.util.List<?> getParts()
For DWR use only - This method is not part of the public API. Do not use it without understanding the implications for future proofing.

Returns:
The list of parts of the final output script

Copyright 2008