KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > lang > jpath > encoding > OutputEncoder


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
17 package org.apache.taglibs.standard.lang.jpath.encoding;
18
19 /**
20  *<p>The <tt>OutputEncoder</tt> provides methods to encode output
21  */

22 public class OutputEncoder {
23
24     public static int HTML = 1;
25
26     /**
27      * <p>Encode the given text with html.</p>
28      *
29      * @param string the text to encode
30      * @return the encoded string
31      *
32      */

33     public static String JavaDoc encode(String JavaDoc string, int encodingMethod) {
34         String JavaDoc encoded = null;
35         if (encodingMethod == OutputEncoder.HTML) {
36             encoded = HtmlEncoder.encode(string);
37         }
38         return encoded;
39     }
40
41     public static int getEncodingMethod(String JavaDoc encodingMethodText) {
42         int encodingMethod;
43         if (encodingMethodText.equals("html")) {
44             encodingMethod = OutputEncoder.HTML;
45         } else {
46             encodingMethod = OutputEncoder.HTML;
47         }
48         return encodingMethod;
49     }
50
51 }
52
53
Popular Tags