Source Code Cross Referenced for Stack.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.common.Debug;
014:
015:        import com.versant.core.common.BindingSupportImpl;
016:
017:        /**
018:         * A Stack implementation used by QueryResultIterator to hold values returned for query.
019:         */
020:        public class Stack {
021:
022:            /**
023:             * The underlying array used for storing the data.
024:             */
025:            public Object[] m_baseArray;
026:            private int size;
027:            private int currentIndex;
028:
029:            /**
030:             * Default constructor.
031:             */
032:            public Stack() {
033:            }
034:
035:            /**
036:             * Pop a value from the stack.
037:             * 
038:             * @return value from top of stack
039:             * @throws ArrayIndexOutOfBoundsException on attempt to pop empty stack
040:             */
041:            public Object pop() {
042:                if (Debug.DEBUG) {
043:                    if (size <= 0) {
044:                        throw BindingSupportImpl.getInstance()
045:                                .arrayIndexOutOfBounds(
046:                                        "Attempt to pop empty stack");
047:                    }
048:                }
049:                size--;
050:                return m_baseArray[currentIndex++];
051:            }
052:
053:            /**
054:             * Pop multiple values from the stack.
055:             * 
056:             * @param count number of values to pop from stack (must be strictly
057:             *              positive)
058:             * @throws ArrayIndexOutOfBoundsException on attempt to pop past end of
059:             *                                        stack
060:             */
061:            public void pop(int count) {
062:                if (Debug.DEBUG) {
063:                    if (count > size) {
064:                        throw BindingSupportImpl.getInstance()
065:                                .arrayIndexOutOfBounds(
066:                                        "Attempt to pop past end of stack");
067:                    }
068:                    if (count <= 0) {
069:                        throw BindingSupportImpl.getInstance().illegalArgument(
070:                                "Count must be greater than 0");
071:                    }
072:                }
073:                currentIndex += count;
074:                size = size - count;
075:            }
076:
077:            public void add(Object[] data, int amountToAdd) {
078:                if (m_baseArray == null || size == 0) {
079:                    /**
080:                     * No data so just replace with supplied array
081:                     */
082:                    m_baseArray = data;
083:                    size = amountToAdd;
084:                    currentIndex = 0;
085:                } else {
086:                    /**
087:                     * There is current data so copy in.
088:                     */
089:                    if ((m_baseArray.length - size) < amountToAdd) {
090:                        Object[] tmpArray = new Object[m_baseArray.length
091:                                + amountToAdd];
092:                        System.arraycopy(m_baseArray, 0, tmpArray, 0, size);
093:                        System.arraycopy(data, 0, tmpArray, size - 1,
094:                                amountToAdd);
095:                        m_baseArray = tmpArray;
096:                        size += amountToAdd;
097:                    }
098:                    //array copy the new data and update the entry count.
099:                    System.arraycopy(data, 0, m_baseArray, size - 1,
100:                            amountToAdd);
101:                    size += amountToAdd;
102:                }
103:            }
104:
105:            public int size() {
106:                return size;
107:            }
108:
109:            public boolean isEmpty() {
110:                return size == 0;
111:            }
112:
113:            public void clear() {
114:                size = 0;
115:                currentIndex = 0;
116:            }
117:
118:            public void close() {
119:                m_baseArray = null;
120:                size = 0;
121:                currentIndex = 0;
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.