KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > inspectors > techstack > BasicDescriptor


1 /*
2  * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Hammurapi Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.hammurapi.org
21  * e-Mail: support@hammurapi.biz
22  */

23 package org.hammurapi.inspectors.techstack;
24
25 import java.util.Collection JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.TreeSet JavaDoc;
28
29 import javax.xml.transform.TransformerException JavaDoc;
30
31 import org.apache.xpath.CachedXPathAPI;
32 import org.w3c.dom.Element JavaDoc;
33
34 import com.pavelvlasov.xml.dom.AbstractDomObject;
35 import com.pavelvlasov.xml.dom.DomSerializable;
36
37 /**
38  * @author Pavel Vlasov
39  * @version $Revision: 1.1 $
40  */

41 public class BasicDescriptor extends AbstractDomObject implements DomSerializable {
42     private String JavaDoc key=getClass().getName()+":"+Long.toString(counter++, Character.MAX_RADIX);;
43     private String JavaDoc name;
44     private String JavaDoc description;
45     private String JavaDoc url;
46     private String JavaDoc category;
47     private static long counter=System.currentTimeMillis();
48         
49     public BasicDescriptor() {
50     }
51     
52     public BasicDescriptor(Element JavaDoc holder, CachedXPathAPI cxpa) throws TransformerException JavaDoc {
53         if (holder.hasAttribute("key")) {
54             key=holder.getAttribute("key");
55         }
56         name=getElementText(holder, "name", cxpa);
57         description=getElementText(holder, "description", cxpa);
58         url=getElementText(holder, "url", cxpa);
59         this.category=getElementText(holder, "category", cxpa);
60     }
61     
62     public String JavaDoc getDescription() {
63         return description;
64     }
65     public void setDescription(String JavaDoc description) {
66         this.description = description;
67     }
68     public String JavaDoc getKey() {
69         return key;
70     }
71     public void setKey(String JavaDoc key) {
72         this.key = key;
73     }
74     public String JavaDoc getName() {
75         return name;
76     }
77     public void setName(String JavaDoc name) {
78         this.name = name;
79     }
80     public String JavaDoc getUrl() {
81         return url;
82     }
83     public void setUrl(String JavaDoc url) {
84         this.url = url;
85     }
86
87     public void toDom(Element JavaDoc holder) {
88         if (key!=null) {
89             holder.setAttribute("key", key);
90         }
91         
92         addTextElement(holder, "name", name);
93         addTextElement(holder, "description", description);
94         addTextElement(holder, "url", url);
95         addTextElement(holder, "category", category);
96         
97         Iterator JavaDoc it=clients.iterator();
98         while (it.hasNext()) {
99             addTextElement(holder, "client", it.next().toString());
100         }
101     }
102
103     private Collection JavaDoc clients = new TreeSet JavaDoc();
104
105     /**
106      * @param client Compilation unit name with path.
107      */

108     public void addClient(String JavaDoc client) {
109         clients.add(client);
110     }
111     public String JavaDoc getCategory() {
112         return category;
113     }
114     public void setCategory(String JavaDoc category) {
115         this.category = category;
116     }
117 }
118
Popular Tags