www.pudn.com > jsptree-1.0-b6-src.zip > JSPTreeNodeImpl.java


/* 
 * ==================================================================== 
 * The JSP Tree Software License, Version 1.1 
 * 
 * (this license is derived and fully compatible with the Apache Software 
 * License - see http://www.apache.org/LICENSE.txt) 
 * 
 * Copyright (c) 2002-2005 jsptree.sourceforge.net . All rights reserved. 
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met: 
 * 
 * 1. Redistributions of source code must retain the above copyright 
 *    notice, this list of conditions and the following disclaimer. 
 * 
 * 2. Redistributions in binary form must reproduce the above copyright 
 *    notice, this list of conditions and the following disclaimer in 
 *    the documentation and/or other materials provided with the 
 *    distribution. 
 * 
 * 3. The end-user documentation included with the redistribution, 
 *    if any, must include the following acknowledgment: 
 *       "This product includes software developed by 
 *        jsptree.sourceforge.net (http://jsptree.sourceforge.net/)." 
 *    Alternately, this acknowledgment may appear in the software itself, 
 *    if and wherever such third-party acknowledgments normally appear. 
 * 
 * 4. The name "JSP Tree" must not be used to endorse or promote 
 *    products derived from this software without prior written permission. 
 *    For written permission, please contact modano@users.sourceforge.net . 
 * 
 * 5. Products derived from this software may not be called "JSP Tree", 
 *    nor may "JSP Tree" appear in their name, without prior written 
 *    permission of jsptree.sourceforge.net. 
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
 * SUCH DAMAGE. 
 * ==================================================================== 
 */ 
 
package net.sf.jsptree.component; 
 
import java.util.Collections; 
import java.util.HashMap; 
import java.util.Map; 
 
/** 
 * @author Vladislav Kamensky 
 */ 
public class JSPTreeNodeImpl implements JSPTreeNode { 
 
    private String m_ID; 
 
    private String m_href; 
 
    private String m_target; 
 
    private String m_label; 
 
    private boolean m_isContextRelative = true; 
 
    private String m_skinName = null; 
 
    private Map m_values = new HashMap(); 
 
    public JSPTreeNodeImpl() { 
    } 
 
    public JSPTreeNodeImpl(String p_id) { 
        m_ID = p_id; 
    } 
 
    public JSPTreeNodeImpl(String p_id, String p_label) { 
        m_ID = p_id; 
        m_label = p_label; 
    } 
 
    public void setId(String p_id) { 
        m_ID = p_id; 
    } 
 
    public String getId() { 
        return m_ID; 
    } 
 
    public void setHref(String s) { 
        m_href = s; 
    } 
 
    public String getHref() { 
        return m_href; 
    } 
 
    public void setLabel(String s) { 
        m_label = s; 
    } 
 
    public String getLabel() { 
        return m_label; 
    } 
 
    public void setTarget(String s) { 
        m_target = s; 
    } 
 
    public String getTarget() { 
        return m_target; 
    } 
 
    public boolean isContextRelative() { 
        return m_isContextRelative; 
    } 
 
    public void setContextRelative(boolean p_contextRelative) { 
        m_isContextRelative = p_contextRelative; 
    } 
 
    public String getSkinName() { 
        return m_skinName; 
    } 
 
    public void setSkinName(String p_skinName) { 
        m_skinName = p_skinName; 
    } 
 
    public Map getValues() { 
        return Collections.unmodifiableMap(m_values); 
    } 
 
    public void addProperty(String name, String value) { 
        m_values.put(name, value); 
    } 
 
    public boolean equals(Object p_obj) { 
        if (!(p_obj instanceof JSPTreeNodeImpl)) { 
            return false; 
        } 
        JSPTreeNodeImpl a_treeNode = (JSPTreeNodeImpl) p_obj; 
        return m_ID.equals(a_treeNode.getId()); 
    } 
 
    public int hashCode() { 
        return 37 * m_ID.hashCode(); 
    } 
 
    /** 
     * Return a String representation of this object. 
     */ 
    public String toString() { 
        StringBuffer a_sb = new StringBuffer("JSPTreeNodeImpl["); 
        a_sb.append("id="); 
        a_sb.append(this.m_ID); 
        a_sb.append(",label="); 
        a_sb.append(this.m_label); 
        a_sb.append(",href="); 
        a_sb.append(this.m_href); 
        a_sb.append(",isContextRelative="); 
        a_sb.append(this.m_isContextRelative); 
        a_sb.append(",target="); 
        a_sb.append(this.m_target); 
        a_sb.append(",skin="); 
        a_sb.append(this.m_skinName); 
        a_sb.append("]"); 
        return (a_sb.toString()); 
    } 
 
    /** 
     * Creates and returns a copy of this object. 
     * 
     * @throws CloneNotSupportedException 
     */ 
    public Object clone() throws CloneNotSupportedException { 
        return super.clone(); 
    } 
}