Source Code Cross Referenced for DxObjectInputStream.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » DxLib » 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 » Database DBMS » Ozone 1.1 » org.ozoneDB.DxLib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Library License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: DxObjectInputStream.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009:        package org.ozoneDB.DxLib;
010:
011:        import java.io.*;
012:        import java.util.*;
013:
014:        /**
015:         * Dieser Stream ist ein Ersatz fuer den Java-ObjectInputStream. In
016:         * gewissen Situationen ist er weniger speicherintensiv. Es koennen
017:         * allerdings nur Objekte gelesen werden, die das
018:         * Externalizable-Interface implementieren.
019:         * 
020:         * 
021:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
022:         * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
023:         */
024:        public class DxObjectInputStream extends DataInputStream implements 
025:                ObjectInput {
026:            protected Hashtable table;
027:            protected Hashtable classes;
028:
029:            public DxObjectInputStream(InputStream in) {
030:                super (in);
031:                table = new Hashtable();
032:                classes = new Hashtable();
033:            }
034:
035:            public DxObjectInputStream(InputStream in, int bufferSize) {
036:                super (new BufferedInputStream(in, bufferSize));
037:                table = new Hashtable();
038:                classes = new Hashtable();
039:            }
040:
041:            public void reset() {
042:                table.clear();
043:                classes.clear();
044:                //System.out.println ("ObjInputStream.reset()");
045:            }
046:
047:            public String readClassName() throws IOException {
048:                String cName = readUTF();
049:
050:                // _R_ und _N_ wird kein Index zugeordnet
051:                if (cName.equals(">") || cName.equals("_")) {
052:                    return cName;
053:                }
054:
055:                // klassennamen-referenz aufloesen
056:                if (cName.equals("+")) {
057:                    Integer index = new Integer(readShort());
058:                    cName = (String) classes.get(index);
059:                } else {
060:                    classes.put(new Integer(classes.size()), cName);
061:                }
062:
063:                return cName;
064:            }
065:
066:            public Object readObject() throws IOException {
067:                try {
068:                    // classenanmen lesen
069:                    String cName = readClassName();
070:                    //System.out.println ("readObject(): className: " + cName);
071:                    Object newObj = null;
072:
073:                    if (cName.equals("_")) {
074:                        // null - referenz wurde gespeichert
075:                        //System.out.println ("readObject(): null");
076:                        return null;
077:                    } else if (cName.equals(">")) {
078:                        // ist Referenz, wurde also schon geladen, entspr. Wert aus table lesen
079:                        Integer hc = new Integer(readInt());
080:                        newObj = table.get(hc);
081:                        //System.out.println ("readObject(): hashCode ref " + hc + " from " + table.size());
082:                        if (newObj == null) {
083:                            throw new IOException(
084:                                    "Object not found in referenz table !!");
085:                        }
086:                    } else {
087:                        // neues objekt erzeugen
088:                        newObj = Class.forName(cName).newInstance();
089:                        // hashcode lesen
090:                        Integer hc = new Integer(readInt());
091:                        //System.out.println ("readObject(): class " + cName + " hashCode " + hc);
092:                        // objekt registrieren
093:                        table.put(hc, newObj);
094:                        // objektdaten lesen
095:                        if (newObj instanceof  Externalizable) {
096:                            ((Externalizable) newObj).readExternal(this );
097:                        } else {
098:                            throw new IOException(
099:                                    "Object doesn't implement Externalizable");
100:                        }
101:                    }
102:                    return newObj;
103:                } catch (IOException e) {
104:                    throw e;
105:                } catch (Exception e) {
106:                    throw new IOException(e.toString());
107:                }
108:            }
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.