001: /*
002: * Hammurapi
003: * Automated Java code review system.
004: * Copyright (C) 2004 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.org
021: * e-Mail: support@hammurapi.biz
022: */
023: package org.hammurapi.inspectors.techstack;
024:
025: import java.util.Collection;
026: import java.util.Iterator;
027: import java.util.TreeSet;
028:
029: import javax.xml.transform.TransformerException;
030:
031: import org.apache.xpath.CachedXPathAPI;
032: import org.w3c.dom.Element;
033:
034: import com.pavelvlasov.xml.dom.AbstractDomObject;
035: import com.pavelvlasov.xml.dom.DomSerializable;
036:
037: /**
038: * @author Pavel Vlasov
039: * @version $Revision: 1.1 $
040: */
041: public class BasicDescriptor extends AbstractDomObject implements
042: DomSerializable {
043: private String key = getClass().getName() + ":"
044: + Long.toString(counter++, Character.MAX_RADIX);;
045: private String name;
046: private String description;
047: private String url;
048: private String category;
049: private static long counter = System.currentTimeMillis();
050:
051: public BasicDescriptor() {
052: }
053:
054: public BasicDescriptor(Element holder, CachedXPathAPI cxpa)
055: throws TransformerException {
056: if (holder.hasAttribute("key")) {
057: key = holder.getAttribute("key");
058: }
059: name = getElementText(holder, "name", cxpa);
060: description = getElementText(holder, "description", cxpa);
061: url = getElementText(holder, "url", cxpa);
062: this .category = getElementText(holder, "category", cxpa);
063: }
064:
065: public String getDescription() {
066: return description;
067: }
068:
069: public void setDescription(String description) {
070: this .description = description;
071: }
072:
073: public String getKey() {
074: return key;
075: }
076:
077: public void setKey(String key) {
078: this .key = key;
079: }
080:
081: public String getName() {
082: return name;
083: }
084:
085: public void setName(String name) {
086: this .name = name;
087: }
088:
089: public String getUrl() {
090: return url;
091: }
092:
093: public void setUrl(String url) {
094: this .url = url;
095: }
096:
097: public void toDom(Element holder) {
098: if (key != null) {
099: holder.setAttribute("key", key);
100: }
101:
102: addTextElement(holder, "name", name);
103: addTextElement(holder, "description", description);
104: addTextElement(holder, "url", url);
105: addTextElement(holder, "category", category);
106:
107: Iterator it = clients.iterator();
108: while (it.hasNext()) {
109: addTextElement(holder, "client", it.next().toString());
110: }
111: }
112:
113: private Collection clients = new TreeSet();
114:
115: /**
116: * @param client Compilation unit name with path.
117: */
118: public void addClient(String client) {
119: clients.add(client);
120: }
121:
122: public String getCategory() {
123: return category;
124: }
125:
126: public void setCategory(String category) {
127: this.category = category;
128: }
129: }
|