/***********************************************************************

	This file is part of JavaNPST, a Java library of NonParametric
	Statistical Tests.

	Copyright (C) 2011
	
	J. Derrac (jderrac@decsai.ugr.es)
	S. Garcia (sglopez@ujaen.es)
	F. Herrera (herrera@decsai.ugr.es)

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see http://www.gnu.org/licenses/
  
**********************************************************************/

package javanpst.data.structures.sequence;

import java.util.ArrayList;

import javanpst.data.readers.sequenceReaders.StringSequenceCSVReader;
import javanpst.data.readers.sequenceReaders.StringSequenceTXTReader;
import javanpst.data.readers.sequenceReaders.StringSequenceXMLReader;
import javanpst.data.writers.sequenceWriters.SequenceCSVWriter;
import javanpst.data.writers.sequenceWriters.SequenceTXTWriter;
import javanpst.data.writers.sequenceWriters.SequenceXMLWriter;

/**
 * A class representing string sequences
 * 
 * @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
 * @version 1.0
 */
public class StringSequence extends Sequence{

	/**
	 * Body of the sequence
	 */
	private ArrayList body;
	
	/**
	 * Default builder
	 */
	public StringSequence (){
		
		body=new ArrayList();
		
	}//end-method
	
	/**
	 * Builder. 
	 * 
	 * Creates a new string sequence from an ArrayList of elements.
	 * 
	 * @param contents array of elements
	 */
	public StringSequence (ArrayList contents){
		
		body= new ArrayList(contents);
		
	}//end-method
	
	/**
	 * Builder. 
	 * 
	 * Creates a new numeric sequence from an array of elements.
	 * 
	 * @param contents array of elements
	 */
	public StringSequence (String [] contents){
		
		body = new ArrayList();
		
		for(int i=0; i < contents.length;i++){
			body.add(contents[i]);
		}

	}//end-method
	
	/**
	 * Copy constructor
	 * 
	 * @param copy sequence to copy
	 */
	public StringSequence(StringSequence copy) {
		
	    this(copy.getSequence());
	    
	}//end-method
	
	/**
	 * Returns the contents of the sequence as an array
	 * 
	 * @return contents of the sequence
	 */
	public ArrayList getSequence(){
		
		return body;
		
	}//end-method
	
	/**
	 *  Adds an element to the end of the sequence
	 */
	public void append(Object text){	
		
		body.add(text.toString());
		
	}//end-method
	
	/**
	 *  Adds an element to the start of the sequence
	 */
	public void prepend(Object text){	
		
		body.add(0,text.toString());
		
	}//end-method
	
	/**
	 * Get an element of the sequence
	 * 
	 * @param index index of the element
	 * @return the element. "" if index out of range
	 */
	public String get(int index){
		
		if((index>-1)&&(index 

Ads help maintain this website.