Source Code Cross Referenced for DxAbstractCollection.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: DxAbstractCollection.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:         * Common super class of all collection classes.
015:         */
016:        public abstract class DxAbstractCollection extends DxObject implements 
017:                DxCollection, Externalizable {
018:
019:            final static long serialVersionUID = 2L;
020:
021:            public DxAbstractCollection() {
022:            }
023:
024:            /**
025:             * Construct the collection out of an array of objects.
026:             */
027:            //    public DxAbstractCollection (Object[] objs) {
028:            //        for (int i=0; i<objs.length; i++)
029:            //            add (objs[i]);
030:            //        }
031:
032:            public Object clone(DxCollection newInstance) {
033:                try {
034:                    DxIterator it = iterator();
035:                    Object obj;
036:                    while ((obj = it.next()) != null) {
037:                        newInstance.add(obj);
038:                    }
039:                    return newInstance;
040:                } catch (Exception e) {
041:                    throw new RuntimeException(e.toString());
042:                }
043:            }
044:
045:            /**
046:             * erzeugt einen clone der collection und der objekte;
047:             * Achtung: alle objekte in der collection muessen DxCompatible sein
048:             */
049:            public DxCollection valueClone() {
050:                try {
051:                    DxCollection coll = (DxCollection) getClass().newInstance();
052:                    DxIterator it = iterator();
053:                    while (it.next() != null) {
054:                        Object obj = it.object();
055:
056:                        if (obj instanceof  DxCompatible) {
057:                            coll.add(((DxCompatible) obj).clone());
058:                        } else if (obj instanceof  Serializable) {
059:
060:                            ByteArrayOutputStream bout = new ByteArrayOutputStream(
061:                                    4096);
062:                            ObjectOutputStream out = new ObjectOutputStream(
063:                                    bout);
064:                            out.writeObject(obj);
065:                            out.close();
066:
067:                            ObjectInputStream in = new ObjectInputStream(
068:                                    new ByteArrayInputStream(bout.toByteArray()));
069:                            coll.add(in.readObject());
070:                        } else {
071:
072:                            throw new CloneNotSupportedException();
073:                        }
074:                    }
075:                    return coll;
076:                } catch (Exception e) {
077:                    throw new RuntimeException(e.toString());
078:                }
079:            }
080:
081:            public Object[] toArray() {
082:                Object[] result = new Object[count()];
083:                DxIterator it = iterator();
084:                Object obj;
085:                for (int i = 0; (obj = it.next()) != null; i++) {
086:                    result[i] = obj;
087:                }
088:                return result;
089:            }
090:
091:            /**
092:             * Compares two collections for equality.
093:             * You have to override this method in the implementation of an actual
094:             * collections in order to provide another behaviour than the one implemented in
095:             * Objects.equals().
096:             */
097:            public boolean equals(Object obj) {
098:                return super .equals(obj);
099:
100:                //        if (obj instanceof DxCollection && obj != null) {
101:                //
102:                //            if (this == obj)
103:                //                return true;
104:                //
105:                //            boolean answer = true;
106:                //            DxIterator it = iterator();
107:                //            while (it.next() != null) {
108:                //                if (!((DxCollection)obj).contains (it.object())) {
109:                //                    answer = false;
110:                //                    break;
111:                //                    }
112:                //                }
113:                //            if (answer) {
114:                //                it = ((DxCollection)obj).iterator();
115:                //                while (it.next() != null) {
116:                //                    if (!contains (it.object())) {
117:                //                        answer = false;
118:                //                        break;
119:                //                        }
120:                //                    }
121:                //                }
122:                //            return answer;
123:                //            }
124:                //        else
125:                //            return false;
126:            }
127:
128:            public synchronized boolean addAll(DxCollection coll) {
129:                boolean answer = false;
130:                DxIterator it = coll.iterator();
131:                Object obj;
132:                while ((obj = it.next()) != null) {
133:                    if (add(obj)) {
134:                        answer = true;
135:                    }
136:                }
137:                return answer;
138:            }
139:
140:            public synchronized boolean addAll(Object[] objs) {
141:                boolean answer = false;
142:                for (int i = 0; i < objs.length; i++) {
143:                    if (add(objs[i])) {
144:                        answer = true;
145:                    }
146:                }
147:                return answer;
148:            }
149:
150:            /**
151:             * Remove the first occurence of an object that equals the the
152:             * specified object.
153:             */
154:            public synchronized boolean remove(Object obj) {
155:                boolean answer = false;
156:                DxIterator it = iterator();
157:                Object cursor;
158:                while ((cursor = it.next()) != null) {
159:                    if (obj.equals(cursor)) {
160:                        it.removeObject();
161:                        answer = true;
162:                    }
163:                }
164:                return answer;
165:            }
166:
167:            public synchronized boolean removeAll(DxCollection coll) {
168:                boolean answer = false;
169:                if (!coll.isEmpty() && !isEmpty()) {
170:                    DxIterator it = coll.iterator();
171:                    Object obj;
172:                    while ((obj = it.next()) != null) {
173:                        if (remove(obj)) {
174:                            answer = true;
175:                        }
176:                    }
177:                }
178:                return answer;
179:            }
180:
181:            /**
182:             * Returns true is this collection contains an object that equals
183:             * to the specified object.
184:             */
185:            public boolean contains(Object obj) {
186:                DxIterator it = iterator();
187:                Object cursor;
188:                while ((cursor = it.next()) != null) {
189:                    if (obj.equals(cursor)) {
190:                        return true;
191:                    }
192:                }
193:                return false;
194:            }
195:
196:            public boolean containsAll(DxCollection coll) {
197:                DxIterator it = coll.iterator();
198:                Object cursor;
199:                while ((cursor = it.next()) != null) {
200:                    if (!contains(cursor)) {
201:                        return false;
202:                    }
203:                }
204:                return true;
205:            }
206:
207:            public void writeExternal(ObjectOutput out) throws IOException {
208:                // System.out.println (getClass().getName() + ".writeExternal()...");
209:                out.writeInt(count());
210:                DxIterator it = iterator();
211:                Object obj;
212:                while ((obj = it.next()) != null) {
213:                    out.writeObject(obj);
214:                }
215:            }
216:
217:            public synchronized void readExternal(ObjectInput in)
218:                    throws IOException, ClassNotFoundException {
219:                int count = in.readInt();
220:                for (; count > 0; count--) {
221:                    add(in.readObject());
222:                }
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.