KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > string > SqueezeTag


1 /*
2  * Copyright 1999,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.taglibs.string;
17
18 import javax.servlet.jsp.JspException JavaDoc;
19 import org.apache.commons.lang.CharSetUtils;
20
21 /**
22  * Squeeze any characters from the body that match
23  * characters specified in the Set. Squeezing means that
24  * if it finds two adjoining characters that are the same,
25  * they are replaced with a single one of the characters.
26  * The syntax of a Set is described in the CountTag javadoc.
27  *
28  * <dl>
29  * <dt>set</dt><dd>
30  * Character Set to look for.
31  * Required.
32  * </dd>
33  * </dl>
34  *
35  * @author bayard@generationjava.com
36  */

37 public class SqueezeTag extends StringTagSupport {
38
39     private String JavaDoc set;
40
41     public SqueezeTag() {
42         super();
43     }
44
45     /**
46      * Get the set property
47      *
48      * @return String property
49      */

50     public String JavaDoc getSet() {
51         return this.set;
52     }
53
54     /**
55      * Set the set property
56      *
57      * @param set String property
58      */

59     public void setSet(String JavaDoc set) {
60         this.set = set;
61     }
62
63
64
65     public String JavaDoc changeString(String JavaDoc text) throws JspException JavaDoc {
66         return CharSetUtils.squeeze(text, set);
67     }
68
69     public void initAttributes() {
70
71         this.set = null;
72
73     }
74
75 }
76
Popular Tags