01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.jelly.util;
17:
18: import org.apache.commons.jelly.Script;
19: import org.apache.commons.jelly.impl.CompositeTextScriptBlock;
20: import org.apache.commons.jelly.impl.ScriptBlock;
21: import org.apache.commons.jelly.impl.TextScript;
22:
23: /** Contains static methods to help tag developers.
24: * @author Hans Gilde
25: *
26: */
27: public class TagUtils {
28: private TagUtils() {
29:
30: }
31:
32: /** Trims the whitespace from a script and its children.
33: *
34: */
35: public static void trimScript(Script body) {
36: synchronized (body) {
37: if (body instanceof CompositeTextScriptBlock) {
38: CompositeTextScriptBlock block = (CompositeTextScriptBlock) body;
39: block.trimWhitespace();
40: } else if (body instanceof ScriptBlock) {
41: ScriptBlock block = (ScriptBlock) body;
42: block.trimWhitespace();
43: } else if (body instanceof TextScript) {
44: TextScript textScript = (TextScript) body;
45: textScript.trimWhitespace();
46: }
47: }
48: }
49:
50: }
|