⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hierarchynode.java

📁 老外的在线考试
💻 JAVA
字号:
/* * SchoolEJB - CyberDemia's library of EJBs for educational related services. * Copyright (C) 2003 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA  02111-1307, USA. * * See the COPYING file located in the top-level-directory of * the archive of this library for complete text of license. */package com.cyberdemia.school;import java.util.*;/*** HierarchyNode models a hierarchy tree node.* The hierarchy is configured in <i>school.xml</i>.* HierarchyNode instances are not persisted to the underlying database.* It is only created by SchoolConfig, not by client code.** @author Alexander Yap* @see com.cyberdemia.school.SchoolConfig*/public class HierarchyNode implements IHierarchy,java.io.Serializable{	/**	* Creates a HierarchyNode.	* @param id  Unique ID.	* @param nm  Name for user interface display.	*/	public HierarchyNode(int id, String nm, String type, int level, IHierarchy parent, boolean deepest)	{		m_id = new Integer(id);		m_name = nm;		m_type = type;		m_level = level;		m_parent = parent;		m_deepest = deepest;		m_hierarchyId = ( (m_parent!=null) ? (m_parent.getHierarchyId()+HIERARCHY_ID_SEPARATOR) : "")+getId();	}		/**	* Sets the unique ID.	* @param id  Unique ID.	*/	public void setId(Integer id)	{		m_id = id;	}	/**	* Gets the unique ID.	* @return Unique ID.	*/	public Integer getId()	{		return m_id;	}		/**	* Gets the name intended for display in user interface.	* @return Name of this HierarchyNode.	*/	public String getName()	{		return m_name;	}		/**	* Sets the name intended for display in user interface.	* @param nm  Name of this HierarchyNode.	*/	public void setName(String nm)	{		m_name = nm;	}	/**	* Performs equality comparison with another HierarchyNode.	* @return true if obj has the same unique ID as this HierarchyNode, otherwise false. 	*/	public boolean equals(Object obj)	{		if (!(obj instanceof HierarchyNode))			return false;		return m_id.equals(((HierarchyNode)obj).m_id);	}	/**	 * Gets the type of this node, based on the depth within the hierarchy.	 * All the nodes at a certain level are of the same type.	 * A set of templates are defined in <i>school.xml</i> to map 	 * the node levels to types.	 * @return Node type.	 */	public String getType()	{		return m_type;	}		/**	 * Gets the level of this node within the hierarchy.	 * The root node has level 0.	 * @return Node level.	 */	public int getLevel()	{		return m_level;	}		/**	 * Gets the parent of this node.	 * @return Parent node.	 */	public IHierarchy getParent()	{		return m_parent;	}		/**	 * Gets the children of this node.	 * @return Array of all children nodes.	 */	public IHierarchy[] getChildren()	{		return (IHierarchy[])m_childrenMap.values().toArray(new IHierarchy[0]);	}		/**	 * Checks if this node has any children.	 * @return true if this node has one or mode children, otherwise false.	 */	public boolean hasChildren()	{		return !m_childrenMap.isEmpty();	}		/**	 * Gets a child of this node.	 * @param id Child node ID.	 * @return Child node, or null if no child with the ID.	 */	public IHierarchy getChild(Integer id)	{		return (IHierarchy)m_childrenMap.get(id);	}			/**	 * Adds a child to this node.	 * @param child Child node to add.	 */	public void addChild(IHierarchy child)	{		m_childrenMap.put(child.getId(), child);	}		/**	* Gets a String that encodes the hierarchy from the	* root node to this node.	* Each node has its own unique "hierarchy identifier" String.	* @return The hierarchy identifier of this node.	*/	public String getHierarchyId()	{		return m_hierarchyId;	}		/**	 * Checks if this hierarchy node is the deepest node.	 * @return true if this node is the deepest, otherwise false.	 */	public boolean isDeepest()	{		return m_deepest;	}	private Integer m_id=null;	private String m_name=null;	private String m_type = null;	private int m_level = -1;	private IHierarchy m_parent = null;	private String m_hierarchyId = null;	private boolean m_deepest = false;	private Map m_childrenMap = new HashMap(); 	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -