/*
Tiamat - a role-playing game framework
NamedObjectTreeNode.java - implementation of a TreeNode that stored NamedObjects
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
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 com.huguesjohnson.tiamat;

import java.lang.String;
import java.lang.StringBuffer;
import com.huguesjohnson.tiamat.NamedObject;
import com.huguesjohnson.tiamat.TreeNode;

/** NamedObjectTreeNode - implementation of a TreeNode that stored NamedObjects
 * @author Hugues Johnson
 */
public class NamedObjectTreeNode extends TreeNode{

/* begin protected properties */
    //override name property to use object.name
    /* (non-Javadoc)
     * @see com.huguesjohnson.tiamat.TreeNode#getName()
     */
    public String getName(){ 
        NamedObject namedObject=(NamedObject)this.getObject();
        return(namedObject.getName());
    }
    /* (non-Javadoc)
     * @see com.huguesjohnson.tiamat.TreeNode#setName(java.lang.String)
     */
    public void setName(String name){ 
        NamedObject namedObject=(NamedObject)this.getObject();
        namedObject.setName(name);
        this.setObject(namedObject);
    }    
/* end protected properties */
    
    
/* begin constructors */
    /** 
     * Create new instance of NamedObjectTreeNode, uses TreeNode.DEFAULT_PATH_DELIMITER.
     * @param namedObject The NamedObject stored in TreeNode.
     */
    public NamedObjectTreeNode(NamedObject namedObject){
        super(namedObject.getName(),namedObject);
    }
    /** 
     * Create new instance of NamedObjectTreeNode.
     * @param namedObject The NamedObject stored in TreeNode.
     * @param pathDelimiter The path delimiter to use.
     */
    public NamedObjectTreeNode(NamedObject namedObject,String pathDelimiter){
        super(namedObject.getName(),pathDelimiter,namedObject);
    }
    /** 
     * Create new instance of NamedObjectTreeNode, uses TreeNode.DEFAULT_PATH_DELIMITER.
     * @param namedObject The NamedObject stored in TreeNode.
     * @param parent The parent to this TreeNode.
     */
    public NamedObjectTreeNode(NamedObject namedObject,NamedObjectTreeNode parent){
        super(namedObject.getName(),namedObject,parent);
    }
    /** 
     * Create new instance of NamedObjectTreeNode.
     * @param namedObject The NamedObject stored in TreeNode.
     * @param parent The parent to this TreeNode.
     * @param pathDelimiter The path delimiter to use.
     */
    public NamedObjectTreeNode(NamedObject namedObject,String pathDelimiter,NamedObjectTreeNode parent){
        super(namedObject.getName(),pathDelimiter,namedObject,parent);
    }
/* begin constructors */
    
/* begin public methods */
    /** 
     * Returns a string representation of the object.
     * @return A string representation of the object.
     */
    public String toString(){
        StringBuffer tostring=new StringBuffer(this.getClass().getName());
        //TreeNode contains everything needed
        tostring.append(super.toString());
        return(tostring.toString());
    }
/* end public methods */
}