Source Code Cross Referenced for HandleArrayListStack.java in  » J2EE » wicket » org » apache » wicket » util » io » 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 » J2EE » wicket » org.apache.wicket.util.io 
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:        package org.apache.wicket.util.io;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.EmptyStackException;
022:
023:        /**
024:         * TODO document me.
025:         * 
026:         * @author jcompagner
027:         */
028:        final class HandleArrayListStack extends ArrayList {
029:            private static final long serialVersionUID = 1L;
030:
031:            /**
032:             * Construct.
033:             */
034:            public HandleArrayListStack() {
035:                this (10);
036:            }
037:
038:            /**
039:             * Construct.
040:             * 
041:             * @param collection
042:             *            The collection to add
043:             */
044:            public HandleArrayListStack(final Collection collection) {
045:                super (collection);
046:            }
047:
048:            /**
049:             * Construct.
050:             * 
051:             * @param initialCapacity
052:             *            Initial capacity of the stack
053:             */
054:            public HandleArrayListStack(final int initialCapacity) {
055:                super (initialCapacity);
056:            }
057:
058:            /**
059:             * Tests if this stack is empty.
060:             * 
061:             * @return <code>true</code> if and only if this stack contains no items;
062:             *         <code>false</code> otherwise.
063:             */
064:            public final boolean empty() {
065:                return size() == 0;
066:            }
067:
068:            /**
069:             * @see java.util.ArrayList#indexOf(java.lang.Object)
070:             */
071:            public int indexOf(Object elem) {
072:                int size = size();
073:                if (elem == null) {
074:                    for (int i = 0; i < size; i++) {
075:                        if (get(i) == null) {
076:                            return i;
077:                        }
078:                    }
079:                } else {
080:                    for (int i = 0; i < size; i++) {
081:                        if (elem == get(i)) {
082:                            return i;
083:                        }
084:                    }
085:                }
086:                return -1;
087:            }
088:
089:            /**
090:             * @see java.util.ArrayList#lastIndexOf(java.lang.Object)
091:             */
092:            public int lastIndexOf(Object elem) {
093:                if (elem == null) {
094:                    for (int i = size() - 1; i >= 0; i--) {
095:                        if (get(i) == null) {
096:                            return i;
097:                        }
098:                    }
099:                } else {
100:                    for (int i = size() - 1; i >= 0; i--) {
101:                        if (elem == get(i)) {
102:                            return i;
103:                        }
104:                    }
105:                }
106:                return -1;
107:            }
108:
109:            /**
110:             * Looks at the object at the top of this stack without removing it.
111:             * 
112:             * @return The object at the top of this stack
113:             * @exception EmptyStackException
114:             *                If this stack is empty.
115:             */
116:            public final Object peek() {
117:                int size = size();
118:                if (size == 0) {
119:                    throw new EmptyStackException();
120:                }
121:                return get(size - 1);
122:            }
123:
124:            /**
125:             * Removes the object at the top of this stack and returns that object.
126:             * 
127:             * @return The object at the top of this stack
128:             * @exception EmptyStackException
129:             *                If this stack is empty.
130:             */
131:            public final Object pop() {
132:                final Object top = peek();
133:                remove(size() - 1);
134:                return top;
135:            }
136:
137:            /**
138:             * Pushes an item onto the top of this stack.
139:             * 
140:             * @param item
141:             *            the item to be pushed onto this stack.
142:             */
143:            public final void push(final Object item) {
144:                add(item);
145:            }
146:
147:            /**
148:             * Returns the 1-based position where an object is on this stack. If the
149:             * object <tt>o</tt> occurs as an item in this stack, this method returns
150:             * the distance from the top of the stack of the occurrence nearest the top
151:             * of the stack; the topmost item on the stack is considered to be at
152:             * distance <tt>1</tt>. The <tt>equals</tt> method is used to compare
153:             * <tt>o</tt> to the items in this stack.
154:             * 
155:             * @param o
156:             *            the desired object.
157:             * @return the 1-based position from the top of the stack where the object
158:             *         is located; the return value <code>-1</code> indicates that the
159:             *         object is not on the stack.
160:             */
161:            public final int search(final Object o) {
162:                int i = lastIndexOf(o);
163:                if (i >= 0) {
164:                    return size() - i;
165:                }
166:                return -1;
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.