001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004:
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008:
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * This file creation date: Mar 3, 2003 / 11:29:45 AM
040: * net.jforum.view.GroupNode.java
041: * The JForum Project
042: * http://www.jforum.net
043: *
044: * $Id: GroupNode.java,v 1.5 2006/08/23 02:13:44 rafaelsteil Exp $
045: */
046: package net.jforum.util;
047:
048: import java.util.ArrayList;
049:
050: /**
051: * Represents a node in the group hierarchy.
052: * Every single group has a name and an ID, and each group may have
053: * unlimited subgroups. which may have sub-subgroups and so on.
054: * This class represents a specific group, supplying methods to add new
055: * groups and get information about them, as well all related sugroups.
056: * <p>
057: * This class is also used toghether with <code>TreeGroup</code>.
058: *
059: * @author Rafael Steil
060: */
061: public class GroupNode {
062: private String name;
063: private int id;
064:
065: /**
066: * Subgroups of the instantiated group
067: */
068: private ArrayList extraNodes;
069:
070: /**
071: * Default Constructor
072: */
073: public GroupNode() {
074: this .extraNodes = new ArrayList();
075: }
076:
077: /**
078: * Gets a node.
079: *
080: * @param pos Node position to retrieve
081: * @return <code>GroupNode</code>
082: * */
083: public GroupNode getNode(int pos) {
084: return (GroupNode) this .extraNodes.get(pos);
085: }
086:
087: /**
088: * Adds a new node.
089: *
090: * @param n Node to add
091: * */
092: public void addNode(GroupNode n) {
093: this .extraNodes.add(n);
094: }
095:
096: /**
097: * Gets the total number of nodes
098: *
099: * @return Quantidade de nos.
100: * */
101: public int size() {
102: return this .extraNodes.size();
103: }
104:
105: /**
106: * Sets the node's name
107: *
108: * @param name Node name
109: * */
110: public void setName(String name) {
111: this .name = name;
112: }
113:
114: /**
115: * Sets the node's ID
116: *
117: * @param id Node ID
118: * */
119: public void setId(int id) {
120: this .id = id;
121: }
122:
123: /**
124: * Gets the name of the node
125: *
126: * @return String with the name
127: * */
128: public String getName() {
129: return this .name;
130: }
131:
132: /**
133: * Gets the ID
134: *
135: * @return Node ID
136: * */
137: public int getId() {
138: return this.id;
139: }
140: }
|