Source Code Cross Referenced for AbstractSequentialList.java in  » Apache-Harmony-Java-SE » java-package » java » util » 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 » Apache Harmony Java SE » java package » java.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package java.util;
019:
020:        /**
021:         * AbstractSequentialList is an abstract implementation of the List interface.
022:         * This implementation does not support adding. A subclass must implement the
023:         * abstract method listIterator().
024:         * 
025:         * @since 1.2
026:         */
027:        public abstract class AbstractSequentialList<E> extends AbstractList<E> {
028:
029:            /**
030:             * Constructs a new instance of this AbstractSequentialList.
031:             */
032:            protected AbstractSequentialList() {
033:                super ();
034:            }
035:
036:            /**
037:             * Inserts the specified object into this List at the specified location.
038:             * The object is inserted before any previous element at the specified
039:             * location. If the location is equal to the size of this List, the object
040:             * is added at the end.
041:             * 
042:             * @param location
043:             *            the index at which to insert
044:             * @param object
045:             *            the object to add
046:             * 
047:             * @exception UnsupportedOperationException
048:             *                when adding to this List is not supported
049:             * @exception ClassCastException
050:             *                when the class of the object is inappropriate for this
051:             *                List
052:             * @exception IllegalArgumentException
053:             *                when the object cannot be added to this List
054:             * @exception IndexOutOfBoundsException
055:             *                when <code>location < 0 || >= size()</code>
056:             * @exception NullPointerException
057:             *                when the object is null and this List does not support
058:             *                null elements
059:             */
060:            @Override
061:            public void add(int location, E object) {
062:                listIterator(location).add(object);
063:            }
064:
065:            /**
066:             * Inserts the objects in the specified Collection at the specified location
067:             * in this List. The objects are added in the order they are returned from
068:             * the Collection iterator.
069:             * 
070:             * @param location
071:             *            the index at which to insert
072:             * @param collection
073:             *            the Collection of objects
074:             * @return true if this List is modified, false otherwise
075:             * 
076:             * @exception UnsupportedOperationException
077:             *                when adding to this List is not supported
078:             * @exception ClassCastException
079:             *                when the class of an object is inappropriate for this List
080:             * @exception IllegalArgumentException
081:             *                when an object cannot be added to this List
082:             * @exception IndexOutOfBoundsException
083:             *                when <code>location < 0 || >= size()</code>
084:             */
085:            @Override
086:            public boolean addAll(int location,
087:                    Collection<? extends E> collection) {
088:                ListIterator<E> it = listIterator(location);
089:                Iterator<? extends E> colIt = collection.iterator();
090:                int next = it.nextIndex();
091:                while (colIt.hasNext()) {
092:                    it.add(colIt.next());
093:                }
094:                return next != it.nextIndex();
095:            }
096:
097:            /**
098:             * Answers the element at the specified location in this List.
099:             * 
100:             * @param location
101:             *            the index of the element to return
102:             * @return the element at the specified location
103:             * 
104:             * @exception IndexOutOfBoundsException
105:             *                when <code>location < 0 || >= size()</code>
106:             */
107:            @Override
108:            public E get(int location) {
109:                try {
110:                    return listIterator(location).next();
111:                } catch (NoSuchElementException e) {
112:                    throw new IndexOutOfBoundsException();
113:                }
114:            }
115:
116:            /**
117:             * Answers an Iterator on the elements of this List. The elements are
118:             * iterated in the same order that they occur in the List.
119:             * 
120:             * @return an Iterator on the elements of this List
121:             * 
122:             * @see Iterator
123:             */
124:            @Override
125:            public Iterator<E> iterator() {
126:                return listIterator(0);
127:            }
128:
129:            /**
130:             * Answers a ListIterator on the elements of this List. The elements are
131:             * iterated in the same order that they occur in the List. The iteration
132:             * starts at the specified location.
133:             * 
134:             * @param location
135:             *            the index at which to start the iteration
136:             * @return a ListIterator on the elements of this List
137:             * 
138:             * @exception IndexOutOfBoundsException
139:             *                when <code>location < 0 || >= size()</code>
140:             * 
141:             * @see ListIterator
142:             */
143:            @Override
144:            public abstract ListIterator<E> listIterator(int location);
145:
146:            /**
147:             * Removes the object at the specified location from this List.
148:             * 
149:             * @param location
150:             *            the index of the object to remove
151:             * @return the removed object
152:             * 
153:             * @exception UnsupportedOperationException
154:             *                when removing from this List is not supported
155:             * @exception IndexOutOfBoundsException
156:             *                when <code>location < 0 || >= size()</code>
157:             */
158:            @Override
159:            public E remove(int location) {
160:                try {
161:                    ListIterator<E> it = listIterator(location);
162:                    E result = it.next();
163:                    it.remove();
164:                    return result;
165:                } catch (NoSuchElementException e) {
166:                    throw new IndexOutOfBoundsException();
167:                }
168:            }
169:
170:            /**
171:             * Replaces the element at the specified location in this List with the
172:             * specified object.
173:             * 
174:             * @param location
175:             *            the index at which to put the specified object
176:             * @param object
177:             *            the object to add
178:             * @return the previous element at the index
179:             * 
180:             * @exception UnsupportedOperationException
181:             *                when replacing elements in this List is not supported
182:             * @exception ClassCastException
183:             *                when the class of an object is inappropriate for this List
184:             * @exception IllegalArgumentException
185:             *                when an object cannot be added to this List
186:             * @exception IndexOutOfBoundsException
187:             *                when <code>location < 0 || >= size()</code>
188:             */
189:            @Override
190:            public E set(int location, E object) {
191:                ListIterator<E> it = listIterator(location);
192:                if (!it.hasNext()) {
193:                    throw new IndexOutOfBoundsException();
194:                }
195:                E result = it.next();
196:                it.set(object);
197:                return result;
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.