1 19 20 package org.netbeans.modules.tasklist.client; 21 22 import org.openide.util.NbBundle; 23 24 import java.util.ResourceBundle ; 25 26 31 final public class SuggestionPriority implements Comparable { 32 33 private final int priority; 34 35 36 private static final String [] PRIORITIES_KEYS = { 37 "PriorityHigh", "PriorityMediumHigh", "PriorityMedium", "PriorityMediumLow", "PriorityLow" }; 43 44 45 private static String [] PRIORITIES; 46 47 static { 48 PRIORITIES = new String [PRIORITIES_KEYS.length]; 49 ResourceBundle rb = NbBundle.getBundle(SuggestionPriority.class); 50 for (int i = 0; i < PRIORITIES_KEYS.length; i++) { 51 PRIORITIES[i] = rb.getString(PRIORITIES_KEYS[i]); 52 } 53 } 54 55 private SuggestionPriority(final int priority) { 56 this.priority = priority; 57 } 58 59 60 public static final SuggestionPriority HIGH = 61 new SuggestionPriority(1); 63 64 public static final SuggestionPriority MEDIUM_HIGH = 65 new SuggestionPriority(2); 67 68 public static final SuggestionPriority MEDIUM = 69 new SuggestionPriority(3); 71 72 public static final SuggestionPriority MEDIUM_LOW = 73 new SuggestionPriority(4); 75 76 public static final SuggestionPriority LOW = 77 new SuggestionPriority(5); 79 85 public int intValue() { 86 return priority; 87 } 88 89 93 public String toString() { 94 switch (priority) { 95 case 1: return "high priority"; case 2: return "medium-high priority"; case 3: return "normal priority"; case 4: return "medium-low priority"; case 5: return "low priority"; default: return "error"; } 102 } 103 104 public int compareTo(final Object o) { 105 return ((SuggestionPriority)o).priority - priority; 106 } 107 108 113 public static String [] getPriorityNames() { 114 return PRIORITIES; 115 } 116 117 122 public static SuggestionPriority getPriority(final int n) { 123 switch (n) { 124 case 1: 125 return HIGH; 126 case 2: 127 return MEDIUM_HIGH; 128 case 3: 129 return MEDIUM; 130 case 4: 131 return MEDIUM_LOW; 132 case 5: 133 return LOW; 134 default: 135 return MEDIUM; 136 } 137 } 138 } 139 | Popular Tags |