KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > util > TagUtils


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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             }
41             else
42             if ( body instanceof ScriptBlock ) {
43                 ScriptBlock block = (ScriptBlock) body;
44                 block.trimWhitespace();
45             }
46             else if ( body instanceof TextScript ) {
47                 TextScript textScript = (TextScript) body;
48                 textScript.trimWhitespace();
49             }
50         }
51     }
52
53 }
Popular Tags