/*
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.util.*;

public class IRCLine extends SupaVector{
	public boolean addressed=false;
	public static final int NICK_LIST=1;

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

	public void checkAddressed(String botName) {
		if (this.size() > 0) {
			String NameTest = this.elementAt(0).toString();
			if ((NameTest.startsWith(botName))&&!(NameTest.equals(botName+"'s"))) {
				addressed = true;
				this.remove(0);
			}
		}
	}

	public boolean starts(String test) {
		if (test.indexOf(" ")!=-1) return this.starts(test.split(" "));
		if (test.equalsIgnoreCase((String)this.elementAt(0))) return true;
		return false;
	}

	public boolean starts(String[] test) {
		int i=0;

		if (test.length>this.size()) {
			return false;
		}
		if (!test[0].equalsIgnoreCase((String)this.elementAt(0))) {
			return false;
		}
		for (i=1;i<test.length;i++) {
			if (!test[i].equals(this.elementAt(i))) {
				return false;
			}
		}
		return true;
	}

	public boolean equals(String test) {
		if (test.equalsIgnoreCase(this.toString())) return true;
		return false;
	}
}
