Source Code Cross Referenced for CharEncoding.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        package com.hp.hpl.jena.util;
007:
008:        import java.nio.charset.Charset;
009:        import java.util.*;
010:
011:        /**
012:         * 
013:         * This class provides a number of static methods which interact with
014:         * java.nio.charset.Charset to analyze and transform the strings identifing
015:         * character encodings.
016:         * 
017:         * @author Jeremy J. Carroll
018:         *  
019:         */
020:        abstract public class CharEncoding {
021:            static Set macEncodings = new HashSet();
022:            static {
023:                macEncodings.add("MacArabic");
024:                macEncodings.add("MacCentralEurope");
025:                macEncodings.add("MacCroatian");
026:                macEncodings.add("MacCyrillic");
027:                macEncodings.add("MacDingbat");
028:                macEncodings.add("MacGreek");
029:                macEncodings.add("MacHebrew");
030:                macEncodings.add("MacIceland");
031:                macEncodings.add("MacRoman");
032:                macEncodings.add("MacRomania");
033:                macEncodings.add("MacSymbol");
034:                macEncodings.add("MacThai");
035:                macEncodings.add("MacTurkish");
036:                macEncodings.add("MacUkraine");
037:            }
038:            private String name;
039:
040:            private CharEncoding() {
041:            }
042:
043:            private CharEncoding(String name) {
044:                this .name = name;
045:            }
046:
047:            /**
048:             * Gives the canonical name for this charset.
049:             * If {@link #isIANA()} returns true, then
050:             * this is the name registered at IANA.
051:             * If {@link #isInNIO()} returns true, and
052:             * {@link #isIANA()} returns false, then this name
053:             * will start with "x-".
054:             * The name is case insensitive, but not case
055:             * normalized.
056:             * @return Canonical name.
057:             */
058:            public String name() {
059:                return name;
060:            }
061:
062:            /**
063:             * Returns true if this charset
064:             * registered at IANA. 
065:             * Since the registry may change, the results of this
066:             * method may not be entirely up-to-date, 
067:             * and draws from the knowledge in
068:             * the Java java.nio.charset.Charset class. 
069:             * If {@link #isInNIO()} returns false, no information
070:             * is known, and this method returns false.
071:             * @return true if this character encoding is IANA registered.
072:             */
073:
074:            abstract public boolean isIANA();
075:
076:            /**
077:             * Returns true if this charset is supported by
078:             * java.nio.charset.Charset.
079:             * Without this support {@link #isIANA()}
080:             * does not work correctly.
081:             * @return true if this charset is supported by
082:             * java.nio.charset.Charset.
083:             */
084:            abstract public boolean isInNIO();
085:
086:            /**
087:             * If {@link #isIANA} or {@link #isInNIO}
088:             * return false, this returns a suggested warning
089:             * message. If {@link #isIANA} is true, then this
090:             * returns null.
091:             * @return A message (or null)
092:             */
093:            abstract public String warningMessage();
094:
095:            static private class IANAnioEncoding extends CharEncoding {
096:                IANAnioEncoding(String name) {
097:                    super (name);
098:                }
099:
100:                public boolean isIANA() {
101:                    return true;
102:                }
103:
104:                public boolean isInNIO() {
105:                    return true;
106:                }
107:
108:                public String warningMessage() {
109:                    return null;
110:                }
111:            }
112:
113:            static private class NonIANAnioEncoding extends CharEncoding {
114:                NonIANAnioEncoding(String name) {
115:                    super (name);
116:                }
117:
118:                public boolean isIANA() {
119:                    return false;
120:                }
121:
122:                public boolean isInNIO() {
123:                    return true;
124:                }
125:
126:                public String warningMessage() {
127:                    return "The encoding \""
128:                            + name()
129:                            + "\" is not registered with IANA, and hence not suitable for Web content.";
130:                }
131:            }
132:
133:            static private class NotNioEncoding extends CharEncoding {
134:                NotNioEncoding(String name) {
135:                    super (name);
136:                }
137:
138:                public boolean isIANA() {
139:                    return false;
140:                }
141:
142:                public boolean isInNIO() {
143:                    return false;
144:                }
145:
146:                public String warningMessage() {
147:                    return "The encoding \""
148:                            + name()
149:                            + "\" is not fully supported; maybe try using Java 1.5 or higher (if you are not already).";
150:                }
151:            }
152:
153:            /**
154:             * Create a new CharacterEncoding object,
155:             * given a name of a character encoding
156:             * identifying it.
157:             * @param enc A name.
158:             * @return The corresponding CharacterEncoding object.
159:             */
160:            static public CharEncoding create(String enc) {
161:                if (Charset.isSupported(enc)) {
162:                    String nm = Charset.forName(enc).name();
163:                    if (nm.charAt(1) == '-'
164:                            && (nm.charAt(0) == 'x' || nm.charAt(0) == 'X'))
165:                        return new NonIANAnioEncoding(nm);
166:                    else if (nm.startsWith("Mac") && macEncodings.contains(nm))
167:                        return new NonIANAnioEncoding(nm);
168:                    else
169:                        return new IANAnioEncoding(nm);
170:                } else {
171:                    return new NotNioEncoding(enc);
172:                }
173:            }
174:        }
175:
176:        /*
177:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
178:         * reserved.
179:         * 
180:         * Redistribution and use in source and binary forms, with or without
181:         * modification, are permitted provided that the following conditions are met:
182:         * 1. Redistributions of source code must retain the above copyright notice,
183:         * this list of conditions and the following disclaimer. 2. Redistributions in
184:         * binary form must reproduce the above copyright notice, this list of
185:         * conditions and the following disclaimer in the documentation and/or other
186:         * materials provided with the distribution. 3. The name of the author may not
187:         * be used to endorse or promote products derived from this software without
188:         * specific prior written permission.
189:         * 
190:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
191:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
192:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
193:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
194:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
195:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
196:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
197:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
198:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
199:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
200:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.