Class StringListBucket

java.lang.Object
com.mckoi.util.StringListBucket

public class StringListBucket extends Object
A 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 Details

    • StringListBucket

      public StringListBucket()
      Constructs the bucket.
    • StringListBucket

      public StringListBucket(String list)
  • Method Details

    • 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(String element)
      Adds a string to the end of the list.
    • add

      public void add(String element, int index)
      Adds a string to the given index of the list.
    • get

      public 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(String element)
      Returns true if the list contains the given element string.
    • indexOfVar

      public int indexOfVar(String element)
      Returns the index of the given string in the bucket, or -1 if not found.
    • toStringBuffer

      public StringBuffer toStringBuffer()
      Returns the bucket as a StringBuffer. This can be exported to a file or to a database, etc.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromString

      public void fromString(String list)
      Imports from a String into this bucket. This is used to transform a previously exported bucket via 'toStringBuffer()'.