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

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

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.

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

package gecco.client;

/**
 *  This represents a property of a Piece. A property has a name and a value
 *  (both Strings).
 *
 * @author     Andreas Enblom
 * @created    June 27, 2001
 */

public class Property implements Comparable {
    /**
     *  Description of the Field
     */
    String name;
    /**
     *  Description of the Field
     */
    String value;


    /**
     *  Constructor for the Property object
     */
    public Property() {
        this("", "");
    }


    /**
     *  Constructor for the Property object
     *
     * @param  name   Description of Parameter
     * @param  value  Description of Parameter
     */
    public Property(String name, String value) {
        setName(name);
        setValue(value);
    }


    /**
     *  Constructor for the Property object
     *
     * @param  p  Description of Parameter
     */
    public Property(Property p) {
        this(p.getName(), p.getValue());
    }


    /**
     *  Sets the Name attribute of the Property object
     *
     * @param  name  The new Name value
     */
    public void setName(String name) {
        this.name = new String(name);
    }


    /**
     *  Sets the Value attribute of the Property object
     *
     * @param  value  The new Value value
     */
    public void setValue(String value) {
        this.value = new String(value);
    }


    /**
     *  Gets the Name attribute of the Property object
     *
     * @return    The Name value
     */
    public String getName() {
        return new String(name);
    }


    /**
     *  Gets the Value attribute of the Property object
     *
     * @return    The Value value
     */
    public String getValue() {
        return new String(value);
    }


    /**
     *  Description of the Method
     *
     * @param  o  Description of Parameter
     * @return    Description of the Returned Value
     */
    public int compareTo(Object o) {
        Property p = (Property) o;
        return name.toLowerCase().compareTo(p.getName().toLowerCase());
    }


    /**
     *  Description of the Method
     *
     * @return    Description of the Returned Value
     */
    public String toString() {
        return getName() + ": " + getValue();
    }
}
