(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source)
| 36 | private static final Class<Kit> KIT_CLASS = Kit.class; |
| 37 | |
| 38 | @Override |
| 39 | public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) |
| 40 | throws PrerequisiteException |
| 41 | { |
| 42 | int runningTotal = 0; |
| 43 | |
| 44 | final int number; |
| 45 | try |
| 46 | { |
| 47 | number = Integer.parseInt(prereq.getOperand()); |
| 48 | } |
| 49 | catch (NumberFormatException exceptn) |
| 50 | { |
| 51 | throw new PrerequisiteException( |
| 52 | LanguageBundle.getFormattedString("PreKit.error", prereq.toString()), exceptn); //$NON-NLS-1$ |
| 53 | } |
| 54 | |
| 55 | String kitKey = prereq.getKey().toUpperCase(); |
| 56 | final int wildCard = kitKey.indexOf('%'); |
| 57 | //handle wildcards (always assume they end the line) |
| 58 | if (wildCard >= 0) |
| 59 | { |
| 60 | kitKey = kitKey.substring(0, wildCard); |
| 61 | for (Kit kit : display.getKitInfo()) |
| 62 | { |
| 63 | if (kit.getKeyName().toUpperCase().startsWith(kitKey)) |
| 64 | { |
| 65 | runningTotal++; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | Kit kit = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(KIT_CLASS, kitKey); |
| 72 | if (display.hasKit(kit)) |
| 73 | { |
| 74 | runningTotal++; |
| 75 | } |
| 76 | } |
| 77 | runningTotal = prereq.getOperator().compare(runningTotal, number); |
| 78 | return countedTotal(prereq, runningTotal); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Get the type of prerequisite handled by this token. |
nothing calls this directly
no test coverage detected