KickJava   Java API By Example, From Geeks To Geeks.

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


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.StringUtils;
20
21 /**
22  * Reverses a delimited String. One example would be changing
23  * org.apache.taglib to taglib.apache.org. The delimiter to use
24  * is settable.
25  *
26  * <dl>
27  * <dt>delimiter</dt><dd>
28  * Character to use as the delimiter in the qualified name.
29  * Default is a dot character.
30  * </dd>
31  * </dl>
32  *
33  * @author bayard@generationjava.com
34  */

35 public class ReverseDelimitedStringTag extends StringTagSupport {
36
37     private char delimiter;
38
39     public ReverseDelimitedStringTag() {
40         super();
41     }
42
43     /**
44      * Get the delimiter property
45      *
46      * @return String property
47      */

48     public char getDelimiter() {
49         return this.delimiter;
50     }
51
52     /**
53      * Set the delimiter property
54      *
55      * @param delimiter String property
56      */

57     public void setDelimiter(char delimiter) {
58         this.delimiter = delimiter;
59     }
60
61
62
63     public String JavaDoc changeString(String JavaDoc text) throws JspException JavaDoc {
64         return StringUtils.reverseDelimited(text, delimiter);
65     }
66
67     public void initAttributes() {
68
69         this.delimiter = '.';
70
71     }
72
73 }
74
Popular Tags