You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/08/31 21:55:33 UTC
svn commit: r1892768 [1/2] - in
/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex: IntStack.java
RegularExpression.java
Author: fanningpj
Date: Tue Aug 31 21:55:33 2021
New Revision: 1892768
URL: http://svn.apache.org/viewvc?rev=1892768&view=rev
Log:
[XMLBEANS-495] use copy of xerces RegularExpression.java
Added:
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/IntStack.java
Modified:
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/RegularExpression.java
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/IntStack.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/IntStack.java?rev=1892768&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/IntStack.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/IntStack.java Tue Aug 31 21:55:33 2021
@@ -0,0 +1,113 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.regex;
+
+/**
+ * A simple integer based stack.
+ *
+ * This is copied from https://raw.githubusercontent.com/apache/xerces2-j/trunk/src/org/apache/xerces/util/IntStack.java
+ * and is used by RegularExpression.java
+ *
+ * @author Andy Clark, IBM
+ *
+ * @version $Id$
+ */
+final class IntStack {
+
+ //
+ // Data
+ //
+
+ /** Stack depth. */
+ private int fDepth;
+
+ /** Stack data. */
+ private int[] fData;
+
+ //
+ // Public methods
+ //
+
+ /** Returns the size of the stack. */
+ public int size() {
+ return fDepth;
+ }
+
+ /** Pushes a value onto the stack. */
+ public void push(int value) {
+ ensureCapacity(fDepth + 1);
+ fData[fDepth++] = value;
+ }
+
+ /** Peeks at the top of the stack. */
+ public int peek() {
+ return fData[fDepth - 1];
+ }
+
+ /** Returns the element at the specified depth in the stack. */
+ public int elementAt(int depth) {
+ return fData[depth];
+ }
+
+ /** Pops a value off of the stack. */
+ public int pop() {
+ return fData[--fDepth];
+ }
+
+ /** Clears the stack. */
+ public void clear() {
+ fDepth = 0;
+ }
+
+ // debugging
+
+ /** Prints the stack. */
+ public void print() {
+ System.out.print('(');
+ System.out.print(fDepth);
+ System.out.print(") {");
+ for (int i = 0; i < fDepth; i++) {
+ if (i == 3) {
+ System.out.print(" ...");
+ break;
+ }
+ System.out.print(' ');
+ System.out.print(fData[i]);
+ if (i < fDepth - 1) {
+ System.out.print(',');
+ }
+ }
+ System.out.print(" }");
+ System.out.println();
+ }
+
+ //
+ // Private methods
+ //
+
+ /** Ensures capacity. */
+ private void ensureCapacity(int size) {
+ if (fData == null) {
+ fData = new int[32];
+ }
+ else if (fData.length <= size) {
+ int[] newdata = new int[fData.length * 2];
+ System.arraycopy(fData, 0, newdata, 0, fData.length);
+ fData = newdata;
+ }
+ }
+
+} // class IntStack
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org