Source Code Cross Referenced for BoolStack.java in  » XML » xalan » org » apache » xml » utils » 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 » XML » xalan » org.apache.xml.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * $Id: BoolStack.java,v 1.10 2004/02/17 04:21:14 minchau Exp $
018:         */
019:        package org.apache.xml.utils;
020:
021:        /**
022:         * Simple stack for boolean values.
023:         * @xsl.usage internal
024:         */
025:        public final class BoolStack implements  Cloneable {
026:
027:            /** Array of boolean values          */
028:            private boolean m_values[];
029:
030:            /** Array size allocated           */
031:            private int m_allocatedSize;
032:
033:            /** Index into the array of booleans          */
034:            private int m_index;
035:
036:            /**
037:             * Default constructor.  Note that the default
038:             * block size is very small, for small lists.
039:             */
040:            public BoolStack() {
041:                this (32);
042:            }
043:
044:            /**
045:             * Construct a IntVector, using the given block size.
046:             *
047:             * @param size array size to allocate
048:             */
049:            public BoolStack(int size) {
050:
051:                m_allocatedSize = size;
052:                m_values = new boolean[size];
053:                m_index = -1;
054:            }
055:
056:            /**
057:             * Get the length of the list.
058:             *
059:             * @return Current length of the list
060:             */
061:            public final int size() {
062:                return m_index + 1;
063:            }
064:
065:            /**
066:             * Clears the stack.
067:             *
068:             */
069:            public final void clear() {
070:                m_index = -1;
071:            }
072:
073:            /**
074:             * Pushes an item onto the top of this stack.
075:             *
076:             *
077:             * @param val the boolean to be pushed onto this stack.
078:             * @return  the <code>item</code> argument.
079:             */
080:            public final boolean push(boolean val) {
081:
082:                if (m_index == m_allocatedSize - 1)
083:                    grow();
084:
085:                return (m_values[++m_index] = val);
086:            }
087:
088:            /**
089:             * Removes the object at the top of this stack and returns that
090:             * object as the value of this function.
091:             *
092:             * @return     The object at the top of this stack.
093:             * @throws  EmptyStackException  if this stack is empty.
094:             */
095:            public final boolean pop() {
096:                return m_values[m_index--];
097:            }
098:
099:            /**
100:             * Removes the object at the top of this stack and returns the
101:             * next object at the top as the value of this function.
102:             *
103:             *
104:             * @return Next object to the top or false if none there
105:             */
106:            public final boolean popAndTop() {
107:
108:                m_index--;
109:
110:                return (m_index >= 0) ? m_values[m_index] : false;
111:            }
112:
113:            /**
114:             * Set the item at the top of this stack  
115:             *
116:             *
117:             * @param b Object to set at the top of this stack
118:             */
119:            public final void setTop(boolean b) {
120:                m_values[m_index] = b;
121:            }
122:
123:            /**
124:             * Looks at the object at the top of this stack without removing it
125:             * from the stack.
126:             *
127:             * @return     the object at the top of this stack.
128:             * @throws  EmptyStackException  if this stack is empty.
129:             */
130:            public final boolean peek() {
131:                return m_values[m_index];
132:            }
133:
134:            /**
135:             * Looks at the object at the top of this stack without removing it
136:             * from the stack.  If the stack is empty, it returns false.
137:             *
138:             * @return     the object at the top of this stack.
139:             */
140:            public final boolean peekOrFalse() {
141:                return (m_index > -1) ? m_values[m_index] : false;
142:            }
143:
144:            /**
145:             * Looks at the object at the top of this stack without removing it
146:             * from the stack.  If the stack is empty, it returns true.
147:             *
148:             * @return     the object at the top of this stack.
149:             */
150:            public final boolean peekOrTrue() {
151:                return (m_index > -1) ? m_values[m_index] : true;
152:            }
153:
154:            /**
155:             * Tests if this stack is empty.
156:             *
157:             * @return  <code>true</code> if this stack is empty;
158:             *          <code>false</code> otherwise.
159:             */
160:            public boolean isEmpty() {
161:                return (m_index == -1);
162:            }
163:
164:            /**
165:             * Grows the size of the stack
166:             *
167:             */
168:            private void grow() {
169:
170:                m_allocatedSize *= 2;
171:
172:                boolean newVector[] = new boolean[m_allocatedSize];
173:
174:                System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
175:
176:                m_values = newVector;
177:            }
178:
179:            public Object clone() throws CloneNotSupportedException {
180:                return super.clone();
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.