package com.fuse.storage.sql.data_objects;

/*
	FUSE Light Server - multiuser server application
	Copyright (C) 2000 Aapo Kyrola / Sulake Oy  Helsinki, Finland

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


import java.io.*;
import java.util.Vector;
import java.sql.*;

import com.fuse.storage.DatabaseException;
import com.fuse.storage.sql.*;

/**
  * SQLFindUserOfName is an ObjectQueryBean which
  * finds an user of given name.
  */
public class SQLFindUserOfName implements SQLObjectQueryBean {
	private String name;
	
	SQLFindUserOfName(String name) {
		this.name = name;
	}
	
    /* Interface: SQLObjectQueryBean */

    // readFromDB palauttaa false, jos käyttäjää ei ole. Yhtenevaisempi
    // filesystemin kanssa 9.2. Jani
    public Vector execute(Connection con) throws DatabaseException {
	Vector results = new Vector();
	SQLFUSEUser user = new SQLFUSEUser();
	if (!user.readFromDB(con, name)) {
	    return new Vector(0);
	}
	
	results.addElement(user);
	return results;
    }
    
    public String toString() {
	return "sql impl. of FindUserOfName; name=" + name;
    }
}
