/** * Trim the body of the script. * In this case, trim the whitespace from the start of the first element * and from the end of the last element. */ public void trimWhitespace() { List list = getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } } } }
/** * Trim the body of the script. * In this case, trim the whitespace from the start of the first element * and from the end of the last element. */ public void trimWhitespace() { List list = getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } } } }
/** * Trim the body of the script. * In this case, trim the whitespace from the start of the first element * and from the end of the last element. */ public void trimWhitespace() { List list = getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimWhitespace(); } } } }
/** Trims the whitespace from a script and its children. * */ public static void trimScript(Script body) { synchronized(body) { if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof TextScript ) { TextScript textScript = (TextScript) body; textScript.trimWhitespace(); } } }
/** Trims the whitespace from a script and its children. * */ public static void trimScript(Script body) { synchronized(body) { if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof TextScript ) { TextScript textScript = (TextScript) body; textScript.trimWhitespace(); } } }
/** Trims the whitespace from a script and its children. * */ public static void trimScript(Script body) { synchronized(body) { if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof TextScript ) { TextScript textScript = (TextScript) body; textScript.trimWhitespace(); } } }
/** Trims the whitespace from a script and its children. * */ public static void trimScript(Script body) { synchronized(body) { if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) body; block.trimWhitespace(); } else if ( body instanceof TextScript ) { TextScript textScript = (TextScript) body; textScript.trimWhitespace(); } } }
public void testTrim() throws Exception { TextScript script = new TextScript( " foo " ); script.trimWhitespace(); assertEquals( "foo", script.getText() ); script = new TextScript( " foo " ); script.trimWhitespace(); assertEquals( "foo", script.getText() ); script = new TextScript( "foo" ); script.trimWhitespace(); assertEquals( "foo", script.getText() ); }