Source Code Cross Referenced for Decoder.java in  » Portal » Open-Portal » com » sun » portal » desktop » encode » 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 » Portal » Open Portal » com.sun.portal.desktop.encode 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.desktop.encode;
006:
007:        import java.util.Map;
008:        import java.util.HashMap;
009:        import java.util.Collections;
010:
011:        /**
012:         * This class provides a device-unaware means of decoding markup and 
013:         * other text. It is the front end for an decoder SPI, allowing different
014:         * encoding schemes to be plugged in to the system.
015:         * <br><br>
016:         * To encode text, use the <code>Encoder</code> class.
017:         * <br><br>
018:         * The pluggable components used by this class are called
019:         * type decoders. A type decoder is a class that implements
020:         * the simple <code>TypeDecoder</code> interface.
021:         * <br><br>
022:         * For cases where the encoding type is fixed and does not
023:         * change with the markup type, the static type decoder may be used: 
024:         * COOKIE_DECODER</code>. 
025:         * <br><br>
026:         * To add a new type decoder to the system, do the following:
027:         * <ul>
028:         * <li> Author a class that implements the <code>TypeDecoder</code>
029:         * interface.
030:         * <li> Add the class to the web container's class path.
031:         * </ul>
032:         * Now, the new type decoder may be referenced by naming its 
033:         * class name in either of the two methods in this class. 
034:         * <br><br>
035:         * The public methods and members in this class are static. This class
036:         * may not be instantiated.
037:         *
038:         * @see com.sun.portal.desktop.encode.TypeDecoder
039:         * @see com.sun.portal.desktop.encode.Encoder
040:         */
041:
042:        public class Decoder {
043:            private static Map decoders = Collections
044:                    .synchronizedMap(new HashMap());
045:
046:            /**
047:             * Cookie type decoder.
048:             */
049:            public static TypeDecoder COOKIE_DECODER = null;
050:
051:            static {
052:                try {
053:                    COOKIE_DECODER = get(EncoderClassNames.DECODER_COOKIE);
054:                } catch (EncoderException ee) {
055:                    throw new EncoderError(
056:                            "Decoder.<init>: error initializing standard decoder types",
057:                            ee);
058:                }
059:            }
060:
061:            private Decoder() {
062:            }
063:
064:            /**
065:             * Gets an instance for the named type decoder.
066:             *
067:             * @param decoderClassName a <code>String</code> value indicating 
068:             * the type decoder class name. The named class must implement
069:             * the <code>TypeDecoder</code> interface.
070:             * @return a <code>TypeDecoder</code> value, the type decoder instance.
071:             * @exception EncoderException if there is an error instantiating the 
072:             * type decoder object.
073:             */
074:            public static TypeDecoder get(String decoderClassName)
075:                    throws EncoderException {
076:                TypeDecoder decoder = (TypeDecoder) decoders
077:                        .get(decoderClassName);
078:                if (decoder == null) {
079:                    try {
080:                        decoder = (TypeDecoder) Class.forName(decoderClassName)
081:                                .newInstance();
082:                    } catch (ClassNotFoundException cnfe) {
083:                        throw new EncoderException("Decoder.decode()", cnfe);
084:                    } catch (InstantiationException ie) {
085:                        throw new EncoderException("Decoder.decode()", ie);
086:                    } catch (IllegalAccessException iae) {
087:                        throw new EncoderException("Decoder.decode()", iae);
088:                    }
089:                    decoders.put(decoderClassName, decoder);
090:                }
091:
092:                return decoder;
093:            }
094:
095:            /**
096:             * Encodes text with the named type encoder. This method is a 
097:             * convenience wrapper for calling <code>get()</code> and
098:             * <code>TypeDecoder.decode()</code>.
099:             *
100:             * @param decoderClassName a <code>String</code> value indicating 
101:             * the type decoder class name. The named class must implement
102:             * the <code>TypeDecoder</code> interface.
103:             * @param text a <code>String</code> value, the text to be
104:             * decoded.
105:             * @return a <code>String</code> value, the decoded text.
106:             * @exception EncoderException if an error occurs instantiating the named
107:             * type decoder.
108:             */
109:            public static String decode(String decoderClassName, String text)
110:                    throws EncoderException {
111:                TypeDecoder decoder = get(decoderClassName);
112:                return decoder.decode(text);
113:            }
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.