KickJava   Java API By Example, From Geeks To Geeks.

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


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: ISO8859CharacterSet.java,v 1.2 2003/06/29 05:58:48 jkjome Exp $
22  */

23 package org.enhydra.xml.io;
24
25 /**
26  * Information and operations associated with the ISO-8859-* group of character sets.
27  */

28 class ISO8859CharacterSet extends CharacterSet {
29     /** Constructor */
30     public ISO8859CharacterSet(String JavaDoc name,
31                                 int charSize,
32                                 String JavaDoc mimePreferred,
33                                 String JavaDoc[] aliases) {
34         super(name, charSize, mimePreferred, aliases);
35     }
36
37     /**
38      * Basic implementation for ISO 8859 character sets. Considers all
39      * characters in the range of 0x0081 through 0x0099 to be invalid.
40      * Note: Acdcording to the specs, these characters <em>are</em> valid.
41      * But they are control characters and rarely ever used on purpose.
42      * In most cases, these characters are encountered by confusing the Windows
43      * CP 1252 character set with ISO-8859-1.
44      * @see CharacterSet#isValid
45      */

46     public boolean isValid(char ch) {
47         return super.isValid(ch) && (ch <= 0x80 || ch >= 0xA0);
48     }
49
50     /**
51      * @see CharacterSet#isCompatible
52      */

53     public boolean sameValidCharRange(CharacterSet otherSet) {
54         // Only valid if otherSet has the same character range and if none of
55
// the control characters in the rang 0x81 through 0x99 are valid in otherSet
56
if (!super.isCompatible(otherSet)) { return false; }
57         
58         for (char c = 0x81; c < 0xA0; c++) {
59             if (otherSet.isValid(c)) return false;
60         }
61         return true;
62     }
63 }
64
65
Popular Tags