Source Code Cross Referenced for PCList.java in  » Testing » PolePosition-0.20 » com » versant » core » common » 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 » Testing » PolePosition 0.20 » com.versant.core.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.common;
012:
013:        import com.versant.core.jdo.JDOListIterator;
014:
015:        import java.util.*;
016:
017:        /**
018:         * This is an non-mutable list implementation used for Query results.
019:         */
020:        public class PCList implements  List {
021:            /** The underlying array used for storing the data. */
022:            private final Object[] m_baseArray;
023:
024:            private final int startIndex;
025:            private final int endIndex;
026:
027:            private final int calculatedSize;
028:
029:            public PCList(Object[] m_baseArray) {
030:                this .m_baseArray = m_baseArray;
031:                startIndex = 0;
032:                endIndex = m_baseArray.length;
033:                calculatedSize = m_baseArray.length;
034:            }
035:
036:            public PCList(Object[] m_baseArray, int startIndex, int endIndex) {
037:                if (startIndex > endIndex)
038:                    throw BindingSupportImpl.getInstance().indexOutOfBounds(
039:                            "The startIndex is greater than end index");
040:                if (m_baseArray.length < endIndex)
041:                    throw BindingSupportImpl.getInstance().indexOutOfBounds(
042:                            "The endIndex to big");
043:                if (startIndex < 0)
044:                    throw BindingSupportImpl.getInstance().indexOutOfBounds(
045:                            "The startIndex is negative");
046:
047:                this .m_baseArray = m_baseArray;
048:                this .startIndex = startIndex;
049:                this .endIndex = endIndex;
050:
051:                calculatedSize = endIndex - startIndex;
052:            }
053:
054:            public final boolean add(Object value) {
055:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
056:            }
057:
058:            public void add(int index, Object value) {
059:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
060:            }
061:
062:            public final Object get(int index) {
063:                if (index < calculatedSize) {
064:                    return m_baseArray[index + startIndex];
065:                } else {
066:                    throw BindingSupportImpl.getInstance().indexOutOfBounds(
067:                            "Invalid index value");
068:                }
069:            }
070:
071:            public final Object set(int index, Object value) {
072:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
073:            }
074:
075:            public final Iterator iterator() {
076:                return new InternalListIter(0);
077:            }
078:
079:            public Object[] toArray() {
080:                final Object[] values = m_baseArray;
081:                int size = size();
082:                Object[] a = new Object[size];
083:
084:                for (int i = startIndex; i < size; i++) {
085:                    a[i] = values[i];
086:                }
087:
088:                return a;
089:            }
090:
091:            public Object[] toArray(Object a[]) {
092:                final Object[] values = m_baseArray;
093:                int size = size();
094:
095:                if (size > a.length) {
096:                    a = (Object[]) java.lang.reflect.Array.newInstance(a
097:                            .getClass().getComponentType(), size);
098:                }
099:
100:                for (int i = startIndex; i < size; i++) {
101:                    a[i] = values[i];
102:                }
103:
104:                if (a.length > size)
105:                    a[size] = null;
106:                return a;
107:            }
108:
109:            public boolean contains(Object o) {
110:                final Object[] values = m_baseArray;
111:                final int n = size();
112:                for (int i = startIndex; i < n; i++) {
113:                    if (values[i].equals(o))
114:                        return true;
115:                }
116:                return false;
117:            }
118:
119:            public int indexOf(Object o) {
120:                final Object[] values = m_baseArray;
121:                final int n = size();
122:                for (int i = startIndex; i < n; i++) {
123:                    if (values[i].equals(o))
124:                        return i;
125:                }
126:                return -1;
127:            }
128:
129:            public ListIterator listIterator(int index) {
130:                return new InternalListIter(index + startIndex);
131:            }
132:
133:            public boolean retainAll(Collection c) {
134:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
135:            }
136:
137:            public boolean containsAll(Collection c) {
138:                for (Iterator iterator = c.iterator(); iterator.hasNext();) {
139:                    if (!contains(iterator.next()))
140:                        return false;
141:                }
142:                return true;
143:            }
144:
145:            public boolean addAll(int index, Collection c) {
146:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
147:            }
148:
149:            public boolean addAll(Collection c) {
150:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
151:            }
152:
153:            public int lastIndexOf(Object o) {
154:                //we don't contain null's
155:                if (o == null)
156:                    return -1;
157:
158:                final Object[] values = m_baseArray;
159:                for (int i = (endIndex - 1); i >= startIndex; i--) {
160:                    if (values[i].equals(o))
161:                        return i;
162:                }
163:                return -1;
164:            }
165:
166:            public boolean isEmpty() {
167:                return (size() == 0);
168:            }
169:
170:            public boolean removeAll(Collection c) {
171:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
172:            }
173:
174:            public List subList(int fromIndex, int toIndex) {
175:                return new PCList(m_baseArray, startIndex + fromIndex,
176:                        startIndex + toIndex);
177:            }
178:
179:            public int hashCode() {
180:                int hashCode = 1;
181:
182:                final Object[] values = m_baseArray;
183:                final int n = size();
184:                for (int i = startIndex; i < n; i++) {
185:                    hashCode = 31 * hashCode + values[i].hashCode();
186:                }
187:                return hashCode;
188:            }
189:
190:            public ListIterator listIterator() {
191:                return new InternalListIter(startIndex);
192:            }
193:
194:            public void clear() {
195:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
196:            }
197:
198:            public int size() {
199:                return calculatedSize;
200:            }
201:
202:            public Object remove(int index) {
203:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
204:            }
205:
206:            public boolean remove(Object o) {
207:                throw BindingSupportImpl.getInstance().unsupportedOperation("");
208:            }
209:
210:            public boolean equals(Object o) {
211:                if (o == this )
212:                    return true;
213:                if (!(o instanceof  List))
214:                    return false;
215:
216:                ListIterator e1 = listIterator();
217:                ListIterator e2 = ((List) o).listIterator();
218:                while (e1.hasNext() && e2.hasNext()) {
219:                    Object o1 = e1.next();
220:                    Object o2 = e2.next();
221:                    if (!(o1 == null ? o2 == null : o1.equals(o2)))
222:                        return false;
223:                }
224:                return !(e1.hasNext() || e2.hasNext());
225:            }
226:
227:            private class InternalListIter implements  ListIterator,
228:                    JDOListIterator {
229:                private int nextIndex;
230:                private boolean closed;
231:
232:                public InternalListIter(int nextIndex) {
233:                    this .nextIndex = nextIndex;
234:                }
235:
236:                public boolean hasNext() {
237:                    if (closed)
238:                        return false;
239:                    return nextIndex < calculatedSize;
240:                }
241:
242:                public void add(Object o) {
243:                    throw BindingSupportImpl.getInstance()
244:                            .unsupportedOperation("");
245:                }
246:
247:                public Object next() {
248:                    if (closed) {
249:                        throw BindingSupportImpl.getInstance()
250:                                .noSuchElement("");
251:                    }
252:                    if (nextIndex >= calculatedSize) {
253:                        throw BindingSupportImpl.getInstance().noSuchElement(
254:                                "Iterated past end of Collection with size '"
255:                                        + calculatedSize + "'");
256:                    }
257:                    try {
258:                        return m_baseArray[nextIndex++];
259:                    } catch (ArrayIndexOutOfBoundsException e) {
260:                        throw BindingSupportImpl.getInstance().noSuchElement(
261:                                "Iterated past end of Collection with size '"
262:                                        + calculatedSize + "'");
263:                    }
264:                }
265:
266:                public void remove() {
267:                    throw BindingSupportImpl.getInstance()
268:                            .unsupportedOperation("");
269:                }
270:
271:                public int previousIndex() {
272:                    if (closed) {
273:                        throw BindingSupportImpl.getInstance()
274:                                .noSuchElement("");
275:                    }
276:                    return nextIndex - 1;
277:                }
278:
279:                public void set(Object o) {
280:                    throw BindingSupportImpl.getInstance()
281:                            .unsupportedOperation("");
282:                }
283:
284:                public Object previous() {
285:                    if (closed) {
286:                        throw BindingSupportImpl.getInstance()
287:                                .noSuchElement("");
288:                    }
289:                    return m_baseArray[nextIndex-- - 1];
290:                }
291:
292:                public boolean hasPrevious() {
293:                    if (closed)
294:                        return false;
295:                    return nextIndex > 0;
296:                }
297:
298:                public int nextIndex() {
299:                    if (closed) {
300:                        throw BindingSupportImpl.getInstance()
301:                                .noSuchElement("");
302:                    }
303:                    return nextIndex;
304:                }
305:
306:                public void close() {
307:                    closed = true;
308:                }
309:            }
310:
311:            public String toString() {
312:                StringBuffer buf = new StringBuffer();
313:                buf.append("[");
314:
315:                Iterator i = iterator();
316:                boolean hasNext = i.hasNext();
317:                while (hasNext) {
318:                    Object o = i.next();
319:                    buf.append(o == this  ? "(this Collection)" : String
320:                            .valueOf(o));
321:                    hasNext = i.hasNext();
322:                    if (hasNext)
323:                        buf.append(", ");
324:                }
325:
326:                buf.append("]");
327:                return buf.toString();
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.