/** * Trim the body of the script. * In this case, trim all elements, removing any that are empty text. */ public void trimWhitespace() { List list = 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(); text = text.trim(); if ( text.length() == 0 ) { list.remove(i); } } } } }
/** * Trim the body of the script. * In this case, trim all elements, removing any that are empty text. */ public void trimWhitespace() { List list = 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(); text = text.trim(); if ( text.length() == 0 ) { list.remove(i); } } } } }
/** * Trim the body of the script. * In this case, trim all elements, removing any that are empty text. */ public void trimWhitespace() { List list = 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(); text = text.trim(); if ( text.length() == 0 ) { list.remove(i); } } } } }
/** * Helper method to determin if nested body needs to be parsed by (an * xml parser, i.e. its only text) to generate SAX events or not * * @return True if tag body should be parsed or false if invoked only * @throws JellyTagException */ private boolean shouldParseBody() throws JellyTagException { boolean result = false; // check to see if we need to parse the body or just invoke it Script bodyScript = this.tag.getBody(); if (bodyScript instanceof ScriptBlock) { ScriptBlock scriptBlock = (ScriptBlock) bodyScript; List scriptList = scriptBlock.getScriptList(); for (Iterator iter = scriptList.iterator(); iter.hasNext(); ) { Script script = (Script) iter.next(); if (script instanceof StaticTagScript) { result = true; break; } } } return result; }
/** * Trim the body of the script. * In this case, trim all elements, removing any that are empty text. */ public void trimWhitespace() { List list = 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(); text = text.trim(); if ( text.length() == 0 ) { list.remove(i); } else { textScript.setText(text); } } } } }
/** * Helper method to run any nested param tags * * @param output The destination for any SAX output (not actually used) */ private void doNestedParamTag(XMLOutput output) throws JellyTagException { // find any nested param tags and run them Script bodyScript = this.getBody(); if (bodyScript instanceof ScriptBlock) { ScriptBlock scriptBlock = (ScriptBlock) bodyScript; List scriptList = scriptBlock.getScriptList(); for (Iterator iter = scriptList.iterator(); iter.hasNext(); ) { Script script = (Script) iter.next(); if (script instanceof TagScript) { Tag tag = null; try { tag = ((TagScript) script).getTag(getContext()); } catch (JellyException e) { throw new JellyTagException(e); } if (tag instanceof ParamTag) { script.run(context, output); } } } } }