org.apache.commons.collections
Class StringStack
java.lang.Object
org.apache.commons.collections.StringStack
- Serializable
public class StringStack
extends java.lang.Object
implements Serializable
This class implements a stack for String objects.
This class provides a way to collect a list of unique strings and join
them with an optional separator.
$Id: StringStack.java,v 1.3.2.1 2004/05/22 12:14:01 scolebourne Exp $
StringStack | add(String s) - Adds the String to the collection if it does not already
contain it.
|
StringStack | addAll(StringStack ss) - Adds all Strings in the given StringStack to the collection
(skipping those it already contains)
|
void | clear() - Clears the stack.
|
boolean | contains(String s) - Returns whether this stack contain the specified text.
|
boolean | empty() - Whether the stack is empty.
|
boolean | equals(Object ssbuf) - Compares two StringStacks.
|
String | get(int i) - Get a string off the stack at a certain position.
|
int | size() - Returns the size of the stack.
|
String | toString() - Converts the stack to a single
java.lang.String with no
separator.
|
String | toString(String separator) - Converts the stack to a single
java.lang.String .
|
String[] | toStringArray() - Turns this stack into an array.
|
StringStack
public StringStack()
Creates an empty instance.
add
public StringStack add(String s)
Adds the String to the collection if it does not already
contain it.
s
- The String
object to add to this stack
(if it is not null
and doesn't already exist in
the stack).
- A reference to this stack (useful for when this method
is called repeatedly).
addAll
public StringStack addAll(StringStack ss)
Adds all Strings in the given StringStack to the collection
(skipping those it already contains)
ss
- The stack of String
objects to add to
this stack (if it is not null
and doesn't already
exist in the stack).
- A reference to this stack (useful for when this method
is called repeatedly).
clear
public void clear()
Clears the stack.
contains
public boolean contains(String s)
Returns whether this stack contain the specified text.
s
- The text to search for.
- Whether the stack contains the text.
empty
public final boolean empty()
Whether the stack is empty.
- Whether the stack is empty.
equals
public boolean equals(Object ssbuf)
Compares two StringStacks. Considered equal if the
toString()
method returns such.
get
public String get(int i)
Get a string off the stack at a certain position.
- A the string from the specified position.
size
public final int size()
Returns the size of the stack.
toString
public String toString()
Converts the stack to a single java.lang.String
with no
separator.
- The stack elements as a single block of text.
toString
public String toString(String separator)
Converts the stack to a single java.lang.String
.
separator
- The text to use as glue between elements in
the stack.
- The stack elements--glued together by
separator
--as a single block of text.
toStringArray
public String[] toStringArray()
Turns this stack into an array.
Copyright © 2001-2004 Apache Software Foundation. Documenation generated ${TODAY}.