/*
Copyright 2002 Steve Jolly

This file is part of Scot

Scot 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; specifically version 2 of the License.

Scot 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 Scot; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.io.*;
import java.util.*;

public class SupaVector extends Vector {

	public SupaVector() {
	}

	public SupaVector (List elements) {
		this.addAll(elements);
	}

	public String toString() {
		int i=0;
		StringBuffer outstring = new StringBuffer(1024);
		for(i=0;i<this.size();i++) {
			if (i!=0) outstring.append(" ");
			outstring.append(this.elementAt(i));
		}
		return outstring.toString();
	}

	public boolean contains(String test) {
		int i=0;
		if (test.indexOf(" ")!=-1) return this.contains(test.split(" "));
		for(i=0;i<this.size();i++) {
			if (test.equalsIgnoreCase((String)this.elementAt(i))) return true;
		}
		return false;
	}

	public boolean contains(String[] test) {
		int i=0;
		int j=0;
	
		j = this.indexOf(test[0]);
		if (j==-1) {
			return false;
		}
		if (test.length>(this.size()-j)) return false;
		j++;
		for (i=1;i<test.length;i++,j++) {
			if (!test[i].equalsIgnoreCase((String)this.elementAt(j))) {
				return false;
			}
		}
		return true;
	}

	public void addAll(String line) {
		this.addAll(line.split("[\\s]+"));
	}

	public void addAll(String[] list) {
		int i;
		for (i=0;i<list.length;i++) {
			this.add(list[i]);
		}
	}
}
