Source Code Cross Referenced for BoolStack.java in  » XML » xalan » org » apache » xml » serializer » 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.serializer.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.1 2004/10/14 18:30:53 minchau Exp $
018:         */
019:        package org.apache.xml.serializer.utils;
020:
021:        /**
022:         * Simple stack for boolean values.
023:         * 
024:         * This class is a copy of the one in org.apache.xml.utils. 
025:         * It exists to cut the serializers dependancy on that package.
026:         * A minor changes from that package are:
027:         * doesn't implement Clonable
028:         *  
029:         * This class is not a public API, it is only public because it is 
030:         * used in org.apache.xml.serializer.
031:         * 
032:         * @xsl.usage internal
033:         */
034:        public final class BoolStack {
035:
036:            /** Array of boolean values          */
037:            private boolean m_values[];
038:
039:            /** Array size allocated           */
040:            private int m_allocatedSize;
041:
042:            /** Index into the array of booleans          */
043:            private int m_index;
044:
045:            /**
046:             * Default constructor.  Note that the default
047:             * block size is very small, for small lists.
048:             */
049:            public BoolStack() {
050:                this (32);
051:            }
052:
053:            /**
054:             * Construct a IntVector, using the given block size.
055:             *
056:             * @param size array size to allocate
057:             */
058:            public BoolStack(int size) {
059:
060:                m_allocatedSize = size;
061:                m_values = new boolean[size];
062:                m_index = -1;
063:            }
064:
065:            /**
066:             * Get the length of the list.
067:             *
068:             * @return Current length of the list
069:             */
070:            public final int size() {
071:                return m_index + 1;
072:            }
073:
074:            /**
075:             * Clears the stack.
076:             *
077:             */
078:            public final void clear() {
079:                m_index = -1;
080:            }
081:
082:            /**
083:             * Pushes an item onto the top of this stack.
084:             *
085:             *
086:             * @param val the boolean to be pushed onto this stack.
087:             * @return  the <code>item</code> argument.
088:             */
089:            public final boolean push(boolean val) {
090:
091:                if (m_index == m_allocatedSize - 1)
092:                    grow();
093:
094:                return (m_values[++m_index] = val);
095:            }
096:
097:            /**
098:             * Removes the object at the top of this stack and returns that
099:             * object as the value of this function.
100:             *
101:             * @return     The object at the top of this stack.
102:             * @throws  EmptyStackException  if this stack is empty.
103:             */
104:            public final boolean pop() {
105:                return m_values[m_index--];
106:            }
107:
108:            /**
109:             * Removes the object at the top of this stack and returns the
110:             * next object at the top as the value of this function.
111:             *
112:             *
113:             * @return Next object to the top or false if none there
114:             */
115:            public final boolean popAndTop() {
116:
117:                m_index--;
118:
119:                return (m_index >= 0) ? m_values[m_index] : false;
120:            }
121:
122:            /**
123:             * Set the item at the top of this stack  
124:             *
125:             *
126:             * @param b Object to set at the top of this stack
127:             */
128:            public final void setTop(boolean b) {
129:                m_values[m_index] = b;
130:            }
131:
132:            /**
133:             * Looks at the object at the top of this stack without removing it
134:             * from the stack.
135:             *
136:             * @return     the object at the top of this stack.
137:             * @throws  EmptyStackException  if this stack is empty.
138:             */
139:            public final boolean peek() {
140:                return m_values[m_index];
141:            }
142:
143:            /**
144:             * Looks at the object at the top of this stack without removing it
145:             * from the stack.  If the stack is empty, it returns false.
146:             *
147:             * @return     the object at the top of this stack.
148:             */
149:            public final boolean peekOrFalse() {
150:                return (m_index > -1) ? m_values[m_index] : false;
151:            }
152:
153:            /**
154:             * Looks at the object at the top of this stack without removing it
155:             * from the stack.  If the stack is empty, it returns true.
156:             *
157:             * @return     the object at the top of this stack.
158:             */
159:            public final boolean peekOrTrue() {
160:                return (m_index > -1) ? m_values[m_index] : true;
161:            }
162:
163:            /**
164:             * Tests if this stack is empty.
165:             *
166:             * @return  <code>true</code> if this stack is empty;
167:             *          <code>false</code> otherwise.
168:             */
169:            public boolean isEmpty() {
170:                return (m_index == -1);
171:            }
172:
173:            /**
174:             * Grows the size of the stack
175:             *
176:             */
177:            private void grow() {
178:
179:                m_allocatedSize *= 2;
180:
181:                boolean newVector[] = new boolean[m_allocatedSize];
182:
183:                System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
184:
185:                m_values = newVector;
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.