Source Code Cross Referenced for HashtableState.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » com » sun » media » jai » rmi » 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 » 6.0 JDK Modules » Java Advanced Imaging » com.sun.media.jai.rmi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: HashtableState.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:56:50 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.rmi;
013:
014:        import java.awt.RenderingHints;
015:        import java.io.IOException;
016:        import java.io.ObjectInputStream;
017:        import java.io.ObjectOutputStream;
018:        import java.io.Serializable;
019:        import java.util.Enumeration;
020:        import java.util.Hashtable;
021:        import java.util.Iterator;
022:        import java.util.Set;
023:        import javax.media.jai.JAI;
024:        import javax.media.jai.remote.SerializerFactory;
025:        import javax.media.jai.remote.SerializableState;
026:
027:        /**
028:         * This class is a serializable proxy for a Hashtable object.
029:         * <br>(entries which are neither <code>Serializable</code> nor supported by
030:         * <code>SerializerFactory</code> are omitted);
031:         *
032:         *
033:         * @since 1.1
034:         */
035:        public class HashtableState extends SerializableStateImpl {
036:            /** 
037:             * Returns the classes supported by this SerializableState.
038:             */
039:            public static Class[] getSupportedClasses() {
040:                return new Class[] { Hashtable.class };
041:            }
042:
043:            /**
044:             * Constructs a <code>HashtableState</code> from a
045:             * <code>Hashtable</code> object.
046:             *
047:             * @param c The <code>Class</code> of the object to be serialized.
048:             * @param o The <code>Hashtable</code> object to be serialized.
049:             * @param h The <code>RenderingHints</code> for this serialization.
050:             */
051:            public HashtableState(Class c, Object o, RenderingHints h) {
052:                super (c, o, h);
053:            }
054:
055:            /**
056:             * Serialize the HashtableState.
057:             */
058:            private void writeObject(ObjectOutputStream out) throws IOException {
059:                // -- Create a serializable form of the Hashtable object. --
060:                Hashtable table = (Hashtable) theObject;
061:
062:                Hashtable serializableTable = new Hashtable();
063:
064:                // If there are hints, add them to the table.
065:                if (table != null && !table.isEmpty()) {
066:                    // Get a view of the hints' keys.
067:                    Set keySet = table.keySet();
068:
069:                    // Proceed if the key set is non-empty.
070:                    if (!keySet.isEmpty()) {
071:                        // Get an iterator for the key set.
072:                        Iterator keyIterator = keySet.iterator();
073:
074:                        // Loop over the keys.
075:                        while (keyIterator.hasNext()) {
076:                            // Get the next key.
077:                            Object key = keyIterator.next();
078:                            Object serializableKey = getSerializableForm(key);
079:
080:                            if (serializableKey == null)
081:                                continue;
082:
083:                            // Get the next value.
084:                            Object value = table.get(key);
085:
086:                            Object serializableValue = getSerializableForm(value);
087:
088:                            if (serializableValue == null)
089:                                continue;
090:
091:                            serializableTable.put(serializableKey,
092:                                    serializableValue);
093:                        }
094:                    }
095:                }
096:
097:                // Write serialized form to the stream.
098:                out.writeObject(serializableTable);
099:            }
100:
101:            /**
102:             * Deserialize the HashtableState.
103:             */
104:            private void readObject(ObjectInputStream in) throws IOException,
105:                    ClassNotFoundException {
106:                // Read serialized form from the stream.
107:                Hashtable serializableTable = (Hashtable) in.readObject();
108:
109:                // Create an empty Hashtable object.
110:                Hashtable table = new Hashtable();
111:                theObject = table;
112:
113:                // If the table is empty just return.
114:                if (serializableTable.isEmpty()) {
115:                    return;
116:                }
117:
118:                // Get an enumeration of the table keys.
119:                Enumeration keys = serializableTable.keys();
120:
121:                // Loop over the table keys.
122:                while (keys.hasMoreElements()) {
123:                    // Get the next key element.
124:                    Object serializableKey = keys.nextElement();
125:                    Object key = getDeserializedFrom(serializableKey);
126:
127:                    // Get the value element.
128:                    Object serializableValue = serializableTable
129:                            .get(serializableKey);
130:                    Object value = getDeserializedFrom(serializableValue);
131:
132:                    // Add an entry to the table.
133:                    table.put(key, value);
134:                }
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.