modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java [169:305]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static class FastStack<T> extends ArrayList<T> {

        /** Ensure Serialization compatibility */
        private static final long serialVersionUID = 2130079159931574599L;

        /**
         * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
         * and is currently 10.
         */
        public FastStack() {
            super();
        }

        /**
         * Constructs a new empty <code>ArrayStack</code> with an initial size.
         * 
         * @param initialSize the initial size to use
         * @throws IllegalArgumentException if the specified initial size is negative
         */
        public FastStack(int initialSize) {
            super(initialSize);
        }

        /**
         * Return <code>true</code> if this stack is currently empty.
         * <p>
         * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
         * <code>isEmpty</code> instead.
         * 
         * @return true if the stack is currently empty
         */
        public boolean empty() {
            return isEmpty();
        }

        /**
         * Returns the top item off of this stack without removing it.
         * 
         * @return the top item on the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T peek() throws EmptyStackException {
            int n = size();
            if (n <= 0) {
                throw new EmptyStackException();
            } else {
                return get(n - 1);
            }
        }

        /**
         * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
         * 
         * @param n the number of items down to go
         * @return the n'th item on the stack, zero relative
         * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
         */
        public T peek(int n) throws EmptyStackException {
            int m = (size() - n) - 1;
            if (m < 0) {
                throw new EmptyStackException();
            } else {
                return get(m);
            }
        }

        /**
         * Pops the top item off of this stack and return it.
         * 
         * @return the top item on the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T pop() throws EmptyStackException {
            int n = size();
            if (n <= 0) {
                throw new EmptyStackException();
            } else {
                return remove(n - 1);
            }
        }

        /**
         * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
         * <code>add</code>.
         * 
         * @param item the item to be added
         * @return the item just pushed
         */
        public Object push(T item) {
            add(item);
            return item;
        }

        /**
         * Returns the top-most index for the object in the stack
         * 
         * @param object the object to be searched for
         * @return top-most index, or -1 if not found
         */
        public int search(T object) {
            int i = size() - 1; // Current index
            while (i >= 0) {
                T current = get(i);
                if ((object == null && current == null) || (object != null && object.equals(current))) {
                    return i;
                }
                i--;
            }
            return -1;
        }

        /**
         * Returns the element on the top of the stack.
         * 
         * @return the element on the top of the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T get() {
            int size = size();
            if (size == 0) {
                throw new EmptyStackException();
            }
            return get(size - 1);
        }

        /**
         * Removes the element on the top of the stack.
         * 
         * @return the removed element
         * @throws EmptyStackException if the stack is empty
         */
        public T remove() {
            int size = size();
            if (size == 0) {
                throw new EmptyStackException();
            }
            return remove(size - 1);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java [117:253]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static class FastStack<T> extends ArrayList<T> {

        /** Ensure Serialization compatibility */
        private static final long serialVersionUID = 2130079159931574599L;

        /**
         * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
         * and is currently 10.
         */
        public FastStack() {
            super();
        }

        /**
         * Constructs a new empty <code>ArrayStack</code> with an initial size.
         * 
         * @param initialSize the initial size to use
         * @throws IllegalArgumentException if the specified initial size is negative
         */
        public FastStack(int initialSize) {
            super(initialSize);
        }

        /**
         * Return <code>true</code> if this stack is currently empty.
         * <p>
         * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
         * <code>isEmpty</code> instead.
         * 
         * @return true if the stack is currently empty
         */
        public boolean empty() {
            return isEmpty();
        }

        /**
         * Returns the top item off of this stack without removing it.
         * 
         * @return the top item on the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T peek() throws EmptyStackException {
            int n = size();
            if (n <= 0) {
                throw new EmptyStackException();
            } else {
                return get(n - 1);
            }
        }

        /**
         * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
         * 
         * @param n the number of items down to go
         * @return the n'th item on the stack, zero relative
         * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
         */
        public T peek(int n) throws EmptyStackException {
            int m = (size() - n) - 1;
            if (m < 0) {
                throw new EmptyStackException();
            } else {
                return get(m);
            }
        }

        /**
         * Pops the top item off of this stack and return it.
         * 
         * @return the top item on the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T pop() throws EmptyStackException {
            int n = size();
            if (n <= 0) {
                throw new EmptyStackException();
            } else {
                return remove(n - 1);
            }
        }

        /**
         * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
         * <code>add</code>.
         * 
         * @param item the item to be added
         * @return the item just pushed
         */
        public Object push(T item) {
            add(item);
            return item;
        }

        /**
         * Returns the top-most index for the object in the stack
         * 
         * @param object the object to be searched for
         * @return top-most index, or -1 if not found
         */
        public int search(T object) {
            int i = size() - 1; // Current index
            while (i >= 0) {
                T current = get(i);
                if ((object == null && current == null) || (object != null && object.equals(current))) {
                    return i;
                }
                i--;
            }
            return -1;
        }

        /**
         * Returns the element on the top of the stack.
         * 
         * @return the element on the top of the stack
         * @throws EmptyStackException if the stack is empty
         */
        public T get() {
            int size = size();
            if (size == 0) {
                throw new EmptyStackException();
            }
            return get(size - 1);
        }

        /**
         * Removes the element on the top of the stack.
         * 
         * @return the removed element
         * @throws EmptyStackException if the stack is empty
         */
        public T remove() {
            int size = size();
            if (size == 0) {
                throw new EmptyStackException();
            }
            return remove(size - 1);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



