KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > io > Encoding


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: Encoding.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23 package org.enhydra.xml.io;
24
25
26
27 /**
28  * Do mapping between Java and XML encodings.
29  * @deprecated Use org.enhydra.xml.io.Encodings
30  * @see org.enhydra.xml.io.Encodings
31  */

32 public class Encoding {
33     /**
34      * Disallow instantiation.
35      */

36     private Encoding() {
37     }
38
39     /**
40      * Determine if an encoding is a supported Java encoding.
41      */

42     public static boolean isValidJavaEncoding(String JavaDoc javaEncoding) {
43         return Encodings.getEncodings().isValid(javaEncoding);
44     }
45
46     /**
47      * Convert a Java encoding to a XML encoding.
48      * @return the XML encoding, or null if the encoding couldn't
49      * be converted.
50      */

51     public static String JavaDoc java2XmlEncoding(String JavaDoc javaEncoding) {
52         return Encodings.getEncodings().getMIMEPreferred(javaEncoding);
53     }
54
55     /**
56      * Determine if an encoding is a supported XML encoding.
57      */

58     public static boolean isValidXMLEncoding(String JavaDoc xmlEncoding) {
59         return Encodings.getEncodings().isValid(xmlEncoding);
60     }
61
62     /**
63      * Convert a XML encoding to a Java encoding.
64      * @return the Java encoding, or null if the encoding couldn't
65      * be converted.
66      */

67     public static String JavaDoc xml2JavaEncoding(String JavaDoc xmlEncoding) {
68         return Encodings.getEncodings().getName(xmlEncoding);
69     }
70
71     /**
72      * Get the maximum value of an unicode character in an XML encoding.
73      * This checks for 7 and 8 bit encodings; everyting else is considered
74      * to require 16 bits. Logic for this method stolen from
75      * org.apache.xml.serialize.OutputFormat.
76      */

77     public static int getMaxCharacterValue(String JavaDoc xmlEncoding) {
78         return Encodings.getEncodings().getMaxCharacterValue(xmlEncoding);
79     }
80 }
81
Popular Tags