// #### should refactor this code into
// #### trimWhitespace() methods on the Script objects
if ( body instanceof CompositeTextScriptBlock ) {
CompositeTextScriptBlock block = (CompositeTextScriptBlock) body;
List list = block.getScriptList();
int size = list.size();
if ( size > 0 ) {
Script script = (Script) list.get(0);
if ( script instanceof TextScript ) {
TextScript textScript = (TextScript) script;
textScript.trimStartWhitespace();
}
if ( size > 1 ) {
script = (Script) list.get(size - 1);
if ( script instanceof TextScript ) {
TextScript textScript = (TextScript) script;
textScript.trimEndWhitespace();
}
}
}
}
else
if ( body instanceof ScriptBlock ) {
ScriptBlock block = (ScriptBlock) body;
List list = block.getScriptList();
for ( int i = list.size() - 1; i >= 0; i-- ) {
Script script = (Script) list.get(i);
if ( script instanceof TextScript ) {
TextScript textScript = (TextScript) script;
String text = textScript.getText();