View Javadoc

1   /*
2    * @(#) Category.java Feb 27, 2004
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  
14  package nl.tudelft.simulation.yellowpage;
15  
16  /***
17   * A Category to be used in storing and finding 'topics' in the YellowPage. <br>
18   * <br>
19   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
20   * Delft, the Netherlands. All rights reserved.
21   * 
22   * See for project information <a href="http://www.simulation.tudelft.nl/">
23   * www.simulation.tudelft.nl </a>.
24   * 
25   * The source code and binary code of this software is proprietary information
26   * of Delft University of Technology.
27   * 
28   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
29   *         Jacobs </a>
30   * @version $$Revision: 1.3 $$ $$Date: 2005/04/08 11:29:13 $$
31   */
32  public class Category
33  {
34  	/*** the serial version uid */
35  	private static final long serialVersionUID = 12L;
36  
37  	/*** the parent category */
38  	private Category parent = null;
39  
40  	/*** the description of the category */
41  	private String description = null;
42  
43  	/***
44  	 * constructs a new Category
45  	 * 
46  	 * @param description the description of the category
47  	 */
48  	public Category(final String description)
49  	{
50  		super();
51  		this.description = description;
52  	}
53  
54  	/***
55  	 * returns the parent of this category
56  	 * 
57  	 * @return Category the parent
58  	 */
59  	public Category getParent()
60  	{
61  		return this.parent;
62  	}
63  
64  	/***
65  	 * determines whether cat1 is a specialization of cat2
66  	 * 
67  	 * @param cat1 the first category
68  	 * @param cat2 the second category
69  	 * @return boolean succes
70  	 */
71  	public static boolean specializationOf(final Category cat1,
72  			final Category cat2)
73  	{
74  		if (cat1 == null || cat2 == null)
75  		{
76  			return false;
77  		}
78  		if (cat1.equals(cat2))
79  		{
80  			return true;
81  		}
82  		return Category.specializationOf(cat1.getParent(), cat2);
83  	}
84  
85  	/***
86  	 * @see java.lang.Object#toString()
87  	 */
88  	public String toString()
89  	{
90  		return this.description;
91  	}
92  }