| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.jelly.impl.CompositeTextScriptBlock |
|
|
| 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.impl; |
|
| 17 | ||
| 18 | import java.util.List; |
|
| 19 | ||
| 20 | import org.apache.commons.jelly.Script; |
|
| 21 | ||
| 22 | ||
| 23 | /** |
|
| 24 | * <p><code>CompositeTextScriptBlock</code> represents a text body of a |
|
| 25 | * a tag which contains expressions, so that whitespace trimming |
|
| 26 | * can be handled differently.</p> |
|
| 27 | * |
|
| 28 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> |
|
| 29 | * @version $Revision: 155420 $ |
|
| 30 | */ |
|
| 31 | public class CompositeTextScriptBlock extends ScriptBlock { |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Create an instance. |
|
| 35 | */ |
|
| 36 | 208 | public CompositeTextScriptBlock() { |
| 37 | 208 | } |
| 38 | ||
| 39 | ||
| 40 | /** |
|
| 41 | * Trim the body of the script. |
|
| 42 | * In this case, trim the whitespace from the start of the first element |
|
| 43 | * and from the end of the last element. |
|
| 44 | */ |
|
| 45 | public void trimWhitespace() { |
|
| 46 | 65 | List list = getScriptList(); |
| 47 | 65 | int size = list.size(); |
| 48 | 65 | if ( size > 0 ) { |
| 49 | 65 | Script script = (Script) list.get(0); |
| 50 | 65 | if ( script instanceof TextScript ) { |
| 51 | 65 | TextScript textScript = (TextScript) script; |
| 52 | 65 | textScript.trimStartWhitespace(); |
| 53 | } |
|
| 54 | 65 | if ( size > 1 ) { |
| 55 | 65 | script = (Script) list.get(size - 1); |
| 56 | 65 | if ( script instanceof TextScript ) { |
| 57 | 65 | TextScript textScript = (TextScript) script; |
| 58 | 65 | textScript.trimEndWhitespace(); |
| 59 | } |
|
| 60 | } |
|
| 61 | } |
|
| 62 | 65 | } |
| 63 | ||
| 64 | ||
| 65 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |