1 11 package org.eclipse.jface.text.contentassist; 12 13 import org.eclipse.swt.graphics.Image; 14 15 import org.eclipse.core.runtime.Assert; 16 17 18 19 22 public final class ContextInformation implements IContextInformation { 23 24 25 private final String fContextDisplayString; 26 27 private final String fInformationDisplayString; 28 29 private final Image fImage; 30 31 37 public ContextInformation(String contextDisplayString, String informationDisplayString) { 38 this(null, contextDisplayString, informationDisplayString); 39 } 40 41 49 public ContextInformation(Image image, String contextDisplayString, String informationDisplayString) { 50 51 Assert.isNotNull(informationDisplayString); 52 53 fImage= image; 54 fContextDisplayString= contextDisplayString; 55 fInformationDisplayString= informationDisplayString; 56 } 57 58 61 public boolean equals(Object object) { 62 if (object instanceof IContextInformation) { 63 IContextInformation contextInformation= (IContextInformation) object; 64 boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString()); 65 if (fContextDisplayString != null) 66 equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString()); 67 return equals; 68 } 69 return false; 70 } 71 72 76 public int hashCode() { 77 int low= fContextDisplayString != null ? fContextDisplayString.hashCode() : 0; 78 return (fInformationDisplayString.hashCode() << 16) | low; 79 } 80 81 84 public String getInformationDisplayString() { 85 return fInformationDisplayString; 86 } 87 88 91 public Image getImage() { 92 return fImage; 93 } 94 95 98 public String getContextDisplayString() { 99 if (fContextDisplayString != null) 100 return fContextDisplayString; 101 return fInformationDisplayString; 102 } 103 } 104 | Popular Tags |