01: package org.uispec4j;
02:
03: /**
04: * Thrown by UIComponents when a search cannot identify a single result.
05: */
06: class ItemAmbiguityException extends RuntimeException {
07: public ItemAmbiguityException(String searchedValue,
08: String[] foundItems) {
09: super (computeMessage(foundItems, searchedValue));
10: }
11:
12: private static String computeMessage(String[] foundItems,
13: String searchedValue) {
14: StringBuffer buffer = new StringBuffer(Integer
15: .toString(foundItems.length)).append(
16: " items are matching the same pattern '").append(
17: searchedValue).append("': [");
18: for (int i = 0; i < foundItems.length; i++) {
19: buffer.append(foundItems[i]);
20: buffer.append((i < foundItems.length - 1) ? "," : "]");
21: }
22: return buffer.toString();
23: }
24: }
|