1 11 package org.eclipse.ui.views.markers.internal; 12 13 import com.ibm.icu.text.CollationKey; 14 import com.ibm.icu.text.Collator; 15 16 import org.eclipse.core.resources.IMarker; 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.runtime.CoreException; 19 20 27 public class ConcreteMarker extends MarkerNode{ 28 29 private String description; 30 31 private String resourceName; 32 33 private String inFolder; 34 35 private CollationKey descriptionKey; 36 37 private CollationKey resourceNameKey; 38 39 private int line; 40 41 private String locationString; 42 43 private long creationTime; 44 45 private String type; 46 47 private IMarker marker; 48 49 52 private long id = -1L; 53 54 private MarkerNode markerCategory; 55 56 private String shortFolder; 57 58 private Object group; 59 60 public ConcreteMarker(IMarker toCopy) { 61 marker = toCopy; 62 refresh(); 63 } 64 65 70 public void clearCache() { 71 resourceNameKey = null; 72 descriptionKey = null; 73 } 74 75 78 public void refresh() { 79 clearCache(); 80 81 description = Util.getProperty(IMarker.MESSAGE, marker); 82 resourceName = Util.getResourceName(marker); 83 inFolder = Util.getContainerName(marker); 84 shortFolder = null; 85 line = marker.getAttribute(IMarker.LINE_NUMBER, -1); 86 locationString = marker.getAttribute(IMarker.LOCATION, 87 Util.EMPTY_STRING); 88 89 try { 90 creationTime = marker.getCreationTime(); 91 } catch (CoreException e) { 92 creationTime = 0; 93 } 94 95 try { 96 type = marker.getType(); 97 } catch (CoreException e1) { 98 type = Util.EMPTY_STRING; 99 } 100 101 id = marker.getId(); 103 } 104 105 public IResource getResource() { 106 return marker.getResource(); 107 } 108 109 public String getType() { 110 return type; 111 } 112 113 116 public String getDescription() { 117 return description; 118 } 119 120 public CollationKey getDescriptionKey() { 121 if (descriptionKey == null) { 122 descriptionKey = Collator.getInstance() 123 .getCollationKey(description); 124 } 125 126 return descriptionKey; 127 } 128 129 public String getResourceName() { 130 return resourceName; 131 } 132 133 public CollationKey getResourceNameKey() { 134 if (resourceNameKey == null) { 135 resourceNameKey = Collator.getInstance().getCollationKey( 136 resourceName); 137 } 138 return resourceNameKey; 139 } 140 141 public int getLine() { 142 return line; 143 } 144 145 public String getFolder() { 146 return inFolder; 147 } 148 149 public long getCreationTime() { 150 return creationTime; 151 } 152 153 157 public long getId() { 158 return id; 159 } 160 161 public IMarker getMarker() { 162 return marker; 163 } 164 165 public boolean equals(Object object) { 166 if (!(object instanceof ConcreteMarker)) { 167 return false; 168 } 169 170 ConcreteMarker other = (ConcreteMarker) object; 171 172 return other.getMarker().equals(getMarker()); 173 } 174 175 public int hashCode() { 176 return getMarker().hashCode(); 177 } 178 179 183 public void setCategory(MarkerNode category) { 184 markerCategory = category; 185 186 } 187 188 191 public MarkerNode[] getChildren() { 192 return Util.EMPTY_MARKER_ARRAY; 193 } 194 195 198 public MarkerNode getParent() { 199 return markerCategory; 200 } 201 202 205 public boolean isConcrete() { 206 return true; 207 } 208 209 213 public String getShortFolder() { 214 if(shortFolder == null) { 215 shortFolder = Util.getShortContainerName(marker); 216 } 217 return shortFolder; 218 } 219 220 221 226 public String getLocationString() { 227 return locationString; 228 } 229 230 231 235 public Object getGroup() { 236 return group; 237 } 238 239 243 public void setGroup(Object group) { 244 this.group = group; 245 } 246 247 250 public ConcreteMarker getConcreteRepresentative() { 251 return this; 252 } 253 } 254 | Popular Tags |