Source Code Cross Referenced for DxMultiMap.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: DxMultiMap.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:
013:        /**
014:         * 
015:         * 
016:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
017:         * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
018:         */
019:        public class DxMultiMap extends DxAbstractCollection implements  DxMap,
020:                Externalizable {
021:
022:            final static long serialVersionUID = 1L;
023:
024:            protected transient DxMap map;
025:            protected transient DxCollection containerFactory;
026:            protected transient int multiItemCount = 0;
027:
028:            public DxMultiMap() {
029:                map = new DxHashMap();
030:                containerFactory = new DxArrayBag(8);
031:            }
032:
033:            public DxMultiMap(DxMap _map, DxCollection _containerFactory) {
034:                map = _map;
035:                containerFactory = _containerFactory;
036:            }
037:
038:            public Object clone() {
039:                try {
040:                    DxMultiMap answer = (DxMultiMap) getClass().newInstance();
041:                    answer.map = (DxMap) map.getClass().newInstance();
042:                    answer.containerFactory = (DxCollection) containerFactory
043:                            .getClass().newInstance();
044:
045:                    DxIterator it = iterator();
046:                    Object obj;
047:                    while ((obj = it.next()) != null) {
048:                        DxCollection newColl = (DxCollection) ((DxCollection) obj)
049:                                .clone();
050:                        answer.addForKey(newColl, it.key());
051:                    }
052:                    return answer;
053:                } catch (Exception e) {
054:                    throw new RuntimeException(e.toString());
055:                }
056:            }
057:
058:            public DxCollection valueClone() {
059:                throw new RuntimeException(getClass().getName()
060:                        + ".valueClone() not implemented.");
061:            }
062:
063:            /**
064:             * Compares two multimaps for equality.
065:             */
066:            public boolean equals(Object obj) {
067:                if (obj instanceof  DxMultiMap && obj != null) {
068:                    DxMultiMap rhs = (DxMultiMap) obj;
069:
070:                    if (this  == obj) {
071:                        return true;
072:                    }
073:
074:                    //FIXME: alle keys muessen mit gleichen containern da sein
075:                    return false;
076:                } else {
077:                    return false;
078:                }
079:            }
080:
081:            public DxSet keySet() {
082:                return map.keySet();
083:            }
084:
085:            public DxSet elementSet() {
086:                DxSet answer = new DxHashSet();
087:                answer.add(this );
088:                return answer;
089:            }
090:
091:            public synchronized boolean add(Object obj) {
092:                return addForKey(obj, buildKey(obj));
093:            }
094:
095:            public Object buildKey(Object obj) {
096:                return obj;
097:            }
098:
099:            public synchronized boolean addForKey(Object obj, Object key) {
100:                try {
101:                    DxCollection coll = (DxCollection) map.elementForKey(key);
102:                    if (coll == null) {
103:                        coll = (DxCollection) containerFactory.getClass()
104:                                .newInstance();
105:                        map.addForKey(coll, key);
106:                    }
107:                    coll.add(obj);
108:                    multiItemCount++;
109:                    return true;
110:                } catch (Exception e) {
111:                    throw new RuntimeException(e.toString());
112:                }
113:            }
114:
115:            public DxCollection elementsForKey(Object key) {
116:                return (DxCollection) map.elementForKey(key);
117:            }
118:
119:            public Object elementForKey(Object key) {
120:                return map.elementForKey(key);
121:            }
122:
123:            public Object keyForElement(Object obj) {
124:                DxIterator it = iterator();
125:                while (it.next() != null) {
126:                    DxIterator iit = iterator();
127:                    while (iit.next() != null) {
128:                        if (obj.equals(iit.object())) {
129:                            return iit.key();
130:                        }
131:                    }
132:                }
133:                return null;
134:            }
135:
136:            public synchronized Object removeForKey(Object key) {
137:                DxCollection answer = (DxCollection) map.removeForKey(key);
138:                if (answer != null) {
139:                    multiItemCount--;
140:                }
141:                return answer;
142:            }
143:
144:            public boolean removeAllKeys(DxCollection coll) {
145:                throw new RuntimeException(getClass().getName()
146:                        + ".removeAllKeys() not implemented.");
147:            }
148:
149:            public boolean containsKey(Object key) {
150:                return map.containsKey(key);
151:            }
152:
153:            /** */
154:            public DxIterator iterator() {
155:                return new DxMultiIterator(this );
156:            }
157:
158:            /** */
159:            public int count() {
160:                return multiItemCount;
161:            }
162:
163:            /** */
164:            public boolean isEmpty() {
165:                return multiItemCount == 0;
166:            }
167:
168:            public synchronized void clear() {
169:                map.clear();
170:                multiItemCount = 0;
171:            }
172:
173:            public void writeExternal(ObjectOutput out) throws IOException {
174:                out.writeInt(count());
175:                DxIterator it = iterator();
176:                Object obj;
177:                while ((obj = it.next()) != null) {
178:                    out.writeObject(obj);
179:                    out.writeObject(it.key());
180:                }
181:            }
182:
183:            public synchronized void readExternal(ObjectInput in)
184:                    throws IOException, ClassNotFoundException {
185:                int count = in.readInt();
186:                for (; count > 0; count--) {
187:                    addForKey(in.readObject(), in.readObject());
188:                }
189:            }
190:
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.