Package com.mckoi.util
Class StringListBucket
- java.lang.Object
-
- com.mckoi.util.StringListBucket
-
public class StringListBucket extends java.lang.ObjectA utility container class for holding a list of strings. This method provides a convenient way of exporting and importing the list as a string itself. This is useful if we need to represent a variable array of strings.- Author:
- Tobias Downer
-
-
Constructor Summary
Constructors Constructor Description StringListBucket()Constructs the bucket.StringListBucket(java.lang.String list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String element)Adds a string to the end of the list.voidadd(java.lang.String element, int index)Adds a string to the given index of the list.voidclear()Clears the list of all string elements.booleancontains(java.lang.String element)Returns true if the list contains the given element string.voidfromString(java.lang.String list)Imports from a String into this bucket.java.lang.Stringget(int index)Returns the string at the given index of the list.intindexOfVar(java.lang.String element)Returns the index of the given string in the bucket, or -1 if not found.voidremove(int index)Removes the string at the given index of the list.intsize()Returns the number of string elements in the list.java.lang.StringtoString()java.lang.StringBuffertoStringBuffer()Returns the bucket as a StringBuffer.
-
-
-
Method Detail
-
size
public int size()
Returns the number of string elements in the list.
-
clear
public void clear()
Clears the list of all string elements.
-
add
public void add(java.lang.String element)
Adds a string to the end of the list.
-
add
public void add(java.lang.String element, int index)Adds a string to the given index of the list.
-
get
public java.lang.String get(int index)
Returns the string at the given index of the list.
-
remove
public void remove(int index)
Removes the string at the given index of the list.
-
contains
public boolean contains(java.lang.String element)
Returns true if the list contains the given element string.
-
indexOfVar
public int indexOfVar(java.lang.String element)
Returns the index of the given string in the bucket, or -1 if not found.
-
toStringBuffer
public java.lang.StringBuffer toStringBuffer()
Returns the bucket as a StringBuffer. This can be exported to a file or to a database, etc.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fromString
public void fromString(java.lang.String list)
Imports from a String into this bucket. This is used to transform a previously exported bucket via 'toStringBuffer()'.
-
-