1 11 package org.eclipse.core.internal.content; 12 13 import org.eclipse.core.runtime.content.IContentType; 14 15 19 class FileSpec { 20 final static int BASIC_TYPE = IContentType.FILE_EXTENSION_SPEC | IContentType.FILE_NAME_SPEC; 21 private String text; 22 private int type; 23 24 public FileSpec(String text, int type) { 25 this.text = text; 26 this.type = type; 27 } 28 29 public String getText() { 30 return text; 31 } 32 33 public int getType() { 34 return type; 35 } 36 37 public static int getBasicType(int type) { 38 return BASIC_TYPE & type; 39 } 40 41 public boolean equals(Object other) { 42 if (!(other instanceof FileSpec)) 43 return false; 44 FileSpec otherFileSpec = (FileSpec) other; 45 return equals(text, otherFileSpec.getType(), false); 46 } 47 48 public boolean equals(final String text, final int otherType, final boolean strict) { 49 return ((!strict && getBasicType(type) == getBasicType(otherType)) || type == otherType) && this.text.equalsIgnoreCase(text); 50 } 51 52 public int hashCode() { 53 return text.hashCode(); 54 } 55 56 public static String getMappingKeyFor(String fileSpecText) { 57 return fileSpecText.toLowerCase(); 58 } 59 60 public String toString() { 61 return getText(); 62 } 63 } 64 | Popular Tags |