KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > BuildConfigNode


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.ajde.ui;
27
28 import java.util.List JavaDoc;
29 import java.io.*;
30
31 import org.aspectj.asm.StructureNode;
32
33 /**
34  * @author Mik Kersten
35  */

36 public class BuildConfigNode extends StructureNode {
37
38     private String JavaDoc resourcePath;
39     private Kind kind;
40     private boolean isActive = true;
41         
42     public BuildConfigNode(String JavaDoc name, Kind kind, String JavaDoc resourcePath) {
43         super(name, kind.toString());
44         this.kind = kind;
45         this.resourcePath = resourcePath;
46     }
47
48     public BuildConfigNode(String JavaDoc name, String JavaDoc kind, String JavaDoc resourcePath, List JavaDoc children) {
49         super(name, kind, children);
50         this.resourcePath = resourcePath;
51     }
52     
53     public String JavaDoc getResourcePath() {
54         return resourcePath;
55     }
56
57     public void setResourcePath(String JavaDoc resourcePath) {
58         this.resourcePath = resourcePath;
59     }
60     
61     public boolean isValidResource() {
62         return name.endsWith(".java")
63             || name.endsWith(".aj")
64             || name.endsWith(".lst");
65     }
66     
67     public boolean isActive() {
68         return isActive;
69     }
70
71     public void setActive(boolean isActive) {
72         this.isActive = isActive;
73     }
74
75     /**
76      * Uses "typesafe enum" pattern.
77      */

78     public static class Kind implements Serializable {
79         
80         public static final Kind FILE_JAVA = new Kind("Java source file");
81         public static final Kind FILE_ASPECTJ = new Kind("AspectJ source file");
82         public static final Kind FILE_LST = new Kind("build configuration file");
83         public static final Kind ERROR = new Kind("error");
84         public static final Kind DIRECTORY = new Kind("directory");
85
86
87         public static final Kind[] ALL = { FILE_JAVA, FILE_ASPECTJ, FILE_LST, DIRECTORY };
88         
89         private final String JavaDoc name;
90         
91         private Kind(String JavaDoc name) {
92             this.name = name;
93         }
94         
95         public String JavaDoc toString() {
96             return name;
97         }
98         
99         public boolean equals(Object JavaDoc o) {
100             return o.equals(name);
101         }
102         
103         public boolean isDeclareKind() {
104             return name.startsWith("declare");
105         }
106
107         // The 4 declarations below are necessary for serialization
108
private static int nextOrdinal = 0;
109         private final int ordinal = nextOrdinal++;
110         private Object JavaDoc readResolve() throws ObjectStreamException {
111             return ALL[ordinal];
112         }
113     }
114     
115     public Kind getBuildConfigNodeKind() {
116         return kind;
117     }
118 }
119
120
121
122
Popular Tags