javanpst.data.structures.sequence
Class StringSequence
- java.lang.Object
-
- javanpst.data.structures.sequence.Sequence
-
- javanpst.data.structures.sequence.StringSequence
-
public class StringSequence extends Sequence
A class representing string sequences
-
-
Constructor Summary
Constructors Constructor and Description StringSequence()Default builderStringSequence(java.util.ArrayList<java.lang.String> contents)Builder.StringSequence(java.lang.String[] contents)Builder.StringSequence(StringSequence copy)Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidappend(java.lang.Object text)Adds an element to the end of the sequencevoidclear()Clear the sequencejava.lang.Stringget(int index)Get an element of the sequencejava.util.ArrayList<java.lang.String>getSequence()Returns the contents of the sequence as an arraybooleanisBinary()Checks is the sequence is binaryvoidprepend(java.lang.Object text)Adds an element to the start of the sequencevoidreadCSV(java.lang.String file)Loads a string sequence from a CSV filevoidreadTXT(java.lang.String file)Loads a string sequence from a TXT filevoidreadXML(java.lang.String file)Loads a string sequence from a XML fileintsize()Get the size of the sequencejava.lang.StringtoString()To String methodvoidwriteCSV(java.lang.String file, boolean useComma)Writes a string sequence to a CSV filevoidwriteTXT(java.lang.String file)Writes a string sequence to a TXT filevoidwriteXML(java.lang.String file)Writes a string sequence to a XML file
-
-
-
Constructor Detail
-
StringSequence
public StringSequence()
Default builder
-
StringSequence
public StringSequence(java.util.ArrayList<java.lang.String> contents)
Builder. Creates a new string sequence from an ArrayList of elements.- Parameters:
contents- array of elements
-
StringSequence
public StringSequence(java.lang.String[] contents)
Builder. Creates a new numeric sequence from an array of elements.- Parameters:
contents- array of elements
-
StringSequence
public StringSequence(StringSequence copy)
Copy constructor- Parameters:
copy- sequence to copy
-
-
Method Detail
-
getSequence
public java.util.ArrayList<java.lang.String> getSequence()
Returns the contents of the sequence as an array- Returns:
- contents of the sequence
-
append
public void append(java.lang.Object text)
Adds an element to the end of the sequence
-
prepend
public void prepend(java.lang.Object text)
Adds an element to the start of the sequence
-
get
public java.lang.String get(int index)
Get an element of the sequence- Parameters:
index- index of the element- Returns:
- the element. "" if index out of range
-
size
public int size()
Get the size of the sequence
-
toString
public java.lang.String toString()
To String method
-
isBinary
public boolean isBinary()
Checks is the sequence is binary- Returns:
- True if the sequence is binary.
-
readXML
public void readXML(java.lang.String file)
Loads a string sequence from a XML file
-
writeXML
public void writeXML(java.lang.String file)
Writes a string sequence to a XML file
-
readCSV
public void readCSV(java.lang.String file)
Loads a string sequence from a CSV file
-
writeCSV
public void writeCSV(java.lang.String file, boolean useComma)Writes a string sequence to a CSV file
-
readTXT
public void readTXT(java.lang.String file)
Loads a string sequence from a TXT file
-
-
DMelt 3.0 © DataMelt by jWork.ORG