KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > widgets > browser > BrowserCategory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.common.widgets.browser;
22
23
24 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
25
26
27 /**
28  * A BrowserCategory is the top-level node in the browser widget.
29  * There are three types: DIT categories, searches categories
30  * and bookmarks categories.
31  *
32  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
33  * @version $Rev$, $Date$
34  */

35 public class BrowserCategory
36 {
37
38     /** The Constant TYPE_DIT identifies DIT categories. */
39     public static final int TYPE_DIT = 0;
40
41     /** The Constant TYPE_SEARCHES identifies searches categories. */
42     public static final int TYPE_SEARCHES = 1;
43
44     /** The Constant TYPE_BOOKMARKS identifies bookmark categories. */
45     public static final int TYPE_BOOKMARKS = 2;
46
47     /** The title for the DIT categoy */
48     public static final String JavaDoc TITLE_DIT = "DIT";
49
50     /** The title for the searches categoy */
51     public static final String JavaDoc TITLE_SEARCHES = "Searches";
52
53     /** The title for the bookmarks categoy */
54     public static final String JavaDoc TITLE_BOOKMARKS = "Bookmarks";
55
56     /** The category's connection */
57     private IConnection parent;
58
59     /** The category's type */
60     private int type;
61
62
63     /**
64      * Creates a new instance of BrowserCategory.
65      *
66      * @param type the category's type, one of TYPE_DIT, TYPE_SEARCHES or TYPE_BOOKMARKS
67      * @param parent the category's connection
68      */

69     public BrowserCategory( int type, IConnection parent )
70     {
71         this.parent = parent;
72         this.type = type;
73     }
74
75
76     /**
77      * Gets the category's parent, which is always a connection.
78      *
79      * @return the parent connection
80      */

81     public IConnection getParent()
82     {
83         return parent;
84     }
85
86
87     /**
88      * Gets the category's type, one of TYPE_DIT, TYPE_SEARCHES or TYPE_BOOKMARKS.
89      *
90      * @return the category's type.
91      */

92     public int getType()
93     {
94         return type;
95     }
96
97
98     /**
99      * Gets the category's title.
100      *
101      * @return the category's title
102      */

103     public String JavaDoc getTitle()
104     {
105         switch ( type )
106         {
107             case TYPE_DIT:
108                 return TITLE_DIT;
109
110             case TYPE_SEARCHES:
111                 return TITLE_SEARCHES;
112
113             case TYPE_BOOKMARKS:
114                 return TITLE_BOOKMARKS;
115
116             default:
117                 return "ERROR";
118         }
119     }
120
121 }
122
Popular Tags