1 19 20 package org.netbeans.modules.tasklist.bugs.scarab; 21 22 import java.io.*; 23 import java.net.URL ; 24 import java.util.*; 25 import java.util.Date ; 26 27 import javax.xml.parsers.SAXParserFactory ; 28 import javax.xml.parsers.SAXParser ; 29 import javax.xml.parsers.ParserConfigurationException ; 30 import org.xml.sax.SAXException ; 31 32 33 61 public final class Issue implements Comparable { 62 63 private HashMap attributes = new HashMap (49); 64 65 static final String ISSUE_TYPE = "issue_type"; 66 static final String ISSUE_ID = "issue_id"; 67 static final String REPORTER = "created_by"; 68 static final String ASSIGNED_TO = "assigned_to"; 69 static final String CREATED = "created"; 70 static final String SUMMARY = "Summary"; 71 static final String STATUS = "Status"; 72 static final String PRIORITY = "Priority"; 73 static final String COMPONENT = "Component"; 74 static final String SUBCOMPONENT = "Subomponent"; 75 static final String KEYWORDS = "Keywords"; 76 static final String TARGET = "Target"; 77 static final String VOTES = "Votes"; 78 79 84 public String getId() { 85 return string(ISSUE_ID); 86 } 87 88 91 public String getAssignedTo () { 92 return string (ASSIGNED_TO); 93 } 94 95 98 public String getReportedBy () { 99 return string (REPORTER); 100 } 101 102 103 106 public String getType () { 107 return string (ISSUE_TYPE); 108 } 109 110 111 114 public Date getCreated () { 115 Date d = (Date )getAttribute (CREATED); 116 return d == null ? new Date (0) : d; 117 } 118 119 121 private String string (String name) { 122 Object o = getAttribute (name); 123 return o instanceof String ? (String )o : ""; 124 } 125 126 128 private int[] ints (String name) { 129 List l = (List)getAttribute (name); 130 if (l == null) { 131 return new int[0]; 132 } 133 134 int[] arr = new int[l.size ()]; 135 for (int i = 0; i < arr.length; i++) { 136 arr[i] = Integer.parseInt ((String )l.get (i)); 137 } 138 return arr; 139 } 140 141 144 Object getAttribute(String name) { 145 return attributes.get(name); 146 } 147 148 149 150 void setAttribute(final String name, final Object value) { 151 attributes.put(name, value); 152 } 153 154 157 public String toString() { 158 StringBuffer buffer; 159 if (attributes == null) { 160 return java.util.ResourceBundle.getBundle("org/netbeans/modules/tasklist/bugs/scarab/Bundle").getString("Empty_BugBase"); 161 } 162 Iterator it = attributes.entrySet().iterator(); 163 buffer = new StringBuffer (); 164 buffer.append(this.getClass().getName() 165 + java.util.ResourceBundle.getBundle("org/netbeans/modules/tasklist/bugs/scarab/Bundle").getString("_containing_these_name/value_attribute_pairs:\n")); 166 while (it.hasNext()) { 167 Map.Entry entry = (Map.Entry) it.next(); 168 buffer.append(java.util.ResourceBundle.getBundle("org/netbeans/modules/tasklist/bugs/scarab/Bundle").getString("NAME__:_") + entry.getKey() + "\n"); 169 buffer.append(java.util.ResourceBundle.getBundle("org/netbeans/modules/tasklist/bugs/scarab/Bundle").getString("VALUE_:_") + entry.getValue() + "\n"); 170 } 171 return buffer.toString(); 172 } 173 174 176 public int compareTo (final Object o) { 177 final Issue i = (Issue)o; 178 return getId ().compareTo(i.getId ()); 179 } 180 181 public String getSummary() 182 { 183 return string(SUMMARY); 184 } 185 186 String getStatus() 187 { 188 return string(STATUS); 189 } 190 191 } 192 | Popular Tags |