1 /*
2 * Copyright 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 jsp2.examples.el;
17
18 import java.util.*;
19
20 /**
21 * Defines the functions for the jsp2 example tag library.
22 *
23 * <p>Each function is defined as a static method.</p>
24 */
25 public class Functions {
26 public static String reverse( String text ) {
27 return new StringBuffer( text ).reverse().toString();
28 }
29
30 public static int numVowels( String text ) {
31 String vowels = "aeiouAEIOU";
32 int result = 0;
33 for( int i = 0; i < text.length(); i++ ) {
34 if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
35 result++;
36 }
37 }
38 return result;
39 }
40
41 public static String caps( String text ) {
42 return text.toUpperCase();
43 }
44 }