KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > views > elements > AntNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.views.elements;
12
13
14 public abstract class AntNode {
15     
16     private AntNode parent= null;
17     private String JavaDoc name= null;
18     private String JavaDoc description= null;
19     
20     /**
21      * Creates a new node with no parent
22      */

23     private AntNode() {
24     }
25     
26     /**
27      * Creates a new node with the given name
28      *
29      * @param name the new node's name
30      */

31     public AntNode(String JavaDoc name) {
32         this(null, name);
33     }
34     
35     /**
36      * Creates a new node with the given parent and the given name
37      *
38      * @param parent the new node's parent node
39      * @param name the new node's name
40      */

41     public AntNode(AntNode parent, String JavaDoc name) {
42         this.parent= parent;
43         this.name= name;
44     }
45     
46     /**
47      * Returns this node's parent or <code>null</code> if none.
48      *
49      * @return AntNode this node's parent node
50      */

51     public AntNode getParent() {
52         return parent;
53     }
54     
55     /**
56      * Sets this node's parent node to the given node
57      *
58      * @param parent the parent node
59      */

60     public void setParent(AntNode parent) {
61         this.parent= parent;
62     }
63     
64     /**
65      * Returns this node's name or <code>null</code> if none. Subclasses which
66      * represent an ant build element that has a required name must override
67      * this method to never return <code>null</code>
68      *
69      * @return String this node's name or <code>null</code> if the name
70      * attribute is optional for this node.
71      */

72     public String JavaDoc getName() {
73         return name;
74     }
75     
76     /**
77      * Sets this node's name to the given name
78      *
79      * @param name the new name
80      */

81     public void setName(String JavaDoc name) {
82         this.name= name;
83     }
84     
85     public String JavaDoc toString() {
86         if (getName() != null) {
87             return getName();
88         }
89         return super.toString();
90     }
91     
92     /**
93      * Sets this node's description to the given description
94      *
95      * @param description the new description
96      */

97     public void setDescription(String JavaDoc description) {
98         this.description= description;
99     }
100     
101     /**
102      * Returns this node's description or <code>null</code> if none. Subclasses
103      * which represent an ant build element that has a required description must
104      * override this method to never return <code>null</code>
105      *
106      * @return String this node's description or <code>null</code> if the
107      * description attribute is optional for this node.
108      */

109     public String JavaDoc getDescription() {
110         return description;
111     }
112 }
113
Popular Tags