/** * @see java.io.ObjectInputStream#defaultReadObject() */ public void defaultReadObject() throws IOException, ClassNotFoundException { Object currentObject = stack.peek(); if (!defaultRead.contains(currentObject)) { defaultRead.add(currentObject); currentStreamHandler.readFields(this, currentObject); } }
/** * Returns the 1-based position where an object is on this stack. If the object <tt>o</tt> * occurs as an item in this stack, this method returns the distance from the top of the stack * of the occurrence nearest the top of the stack; the topmost item on the stack is considered * to be at distance <tt>1</tt>. The <tt>equals</tt> method is used to compare <tt>o</tt> * to the items in this stack. * * @param o * the desired object. * @return the 1-based position from the top of the stack where the object is located; the * return value <code>-1</code> indicates that the object is not on the stack. */ public final int search(final Object o) { int i = lastIndexOf(o); if (i >= 0) { return size() - i; } return -1; } }
/** * Pushes an item onto the top of this stack. * * @param item * the item to be pushed onto this stack. */ public final void push(final T item) { add(item); }
/** * Tests if this stack is empty. * * @return <code>true</code> if and only if this stack contains no items; <code>false</code> * otherwise. */ public final boolean empty() { return size() == 0; }
/** * @see java.io.ObjectOutputStream#close() */ public void close() throws IOException { classHandler = null; curObject = null; curPut = null; handledObjects.clear(); defaultWrite.clear(); out.close(); }
/** * Pushes an item onto the top of this stack. * * @param item * the item to be pushed onto this stack. */ public final void push(final Object item) { add(item); }
/** * Tests if this stack is empty. * * @return <code>true</code> if and only if this stack contains no items; <code>false</code> * otherwise. */ public final boolean empty() { return size() == 0; }
/** * @see java.io.ObjectOutputStream#close() */ @Override public void close() throws IOException { classHandlerStack.clear(); curObject = null; curPut = null; handledObjects.clear(); defaultWrite.clear(); out.close(); }
/** * Looks at the object at the top of this stack without removing it. * * @return The object at the top of this stack * @exception EmptyStackException * If this stack is empty. */ public final Object peek() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return get(size - 1); }
/** * @see java.io.ObjectInputStream#defaultReadObject() */ @Override public void defaultReadObject() throws IOException, ClassNotFoundException { Object currentObject = stack.peek(); if (!defaultRead.contains(currentObject)) { defaultRead.add(currentObject); currentStreamHandler.readFields(this, currentObject); } }
/** * Returns the 1-based position where an object is on this stack. If the object <tt>o</tt> * occurs as an item in this stack, this method returns the distance from the top of the stack * of the occurrence nearest the top of the stack; the topmost item on the stack is considered * to be at distance <tt>1</tt>. The <tt>equals</tt> method is used to compare <tt>o</tt> to the * items in this stack. * * @param o * the desired object. * @return the 1-based position from the top of the stack where the object is located; the * return value <code>-1</code> indicates that the object is not on the stack. */ public final int search(final Object o) { int i = lastIndexOf(o); if (i >= 0) { return size() - i; } return -1; } }
/** * Looks at the object at the top of this stack without removing it. * * @return The object at the top of this stack * @exception EmptyStackException * If this stack is empty. */ public final T peek() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return get(size - 1); }