179 String outcome) {
180 // String nextViewId = null;
181 String viewId = context.getViewRoot().getViewId();
182 CaseStruct caseStruct = null;
183
184 synchronized (this) {
185 caseStruct = findExactMatch(viewId, fromAction, outcome);
186
187 if (caseStruct == null) {
188 caseStruct = findWildCardMatch(viewId, fromAction, outcome);
189 }
190
191 if (caseStruct == null) {
192 caseStruct = findDefaultMatch(fromAction, outcome);
193 }
194 }
195 return caseStruct;
196 }
197
198 /** *//**
199 * This method finds the List of cases for the current <code>view</code>
200 * identifier. After the cases are found, the <code>from-action</code> and
201 * <code>from-outcome</code> values are evaluated to determine the new
202 * <code>view</code> identifier. Refer to section 7.4.2 of the
203 * specification for more details.
204 *
205 * @param viewId
206 * The current <code>view</code> identifier.
207 * @param fromAction
208 * The action reference string.
209 * @param outcome
210 * The outcome string.
211 * @return The <code>view</code> identifier.
212 */
213
214 private synchronized CaseStruct findExactMatch(String viewId,
215 String fromAction, String outcome) {
216 // String returnViewId = null;
217 // if the user has elected to replace the Application instance
218 // entirely
219 if (null == associate) {
220 return null;
221 }
222 Map caseListMap = associate.getNavigationCaseListMappings();
223 Util.doAssert(null != caseListMap);
224 List caseList = (List) caseListMap.get(viewId);
225 if (caseList == null) {
226 return null;
227 }
228 // We've found an exact match for the viewId. Now we need to evaluate
229 // from-action/outcome in the following order:
230 // 1) elements specifying both from-action and from-outcome
231 // 2) elements specifying only from-outcome
232 // 3) elements specifying only from-action
233 // 4) elements where both from-action and from-outcome are null
234 return determineViewFromActionOutcome(caseList, fromAction, outcome);
235 }
236
237 /** *//**
238 * This method traverses the wild card match List (containing
239 * <code>from-view-id</code> strings and finds the List of cases for each
240 * <code>from-view-id</code> string. Refer to section 7.4.2 of the
241 * specification for more details.
242 *
243 * @param viewId
244 * The current <code>view</code> identifier.
245 * @param fromAction
246 * The action reference string.
247 * @param outcome
248 * The outcome string.
249 * @return The <code>view</code> identifier.
250 */
251 private synchronized CaseStruct findWildCardMatch(String viewId,
252 String fromAction, String outcome) {
253 CaseStruct result = null;
254
255 // if the user has elected to replace the Application instance
256 // entirely
257 if (null == associate) {
258 return null;
259 }
260
261 Map caseListMap = associate.getNavigationCaseListMappings();
262 Util.doAssert(null != caseListMap);
263 TreeSet wildcardMatchList = associate.getNavigationWildCardList();
264 Util.doAssert(null != wildcardMatchList);
265
266 Iterator iter = wildcardMatchList.iterator();
267 String fromViewId;
268 List caseList;
269 String wcFromViewId = null;
270 while (iter.hasNext()) {
271 fromViewId = (String) iter.next();
272 // See if the entire wildcard string (without the trailing "*" is
273 // contained in the incoming viewId. Ex: /foobar is contained with
274 // /foobarbaz
275 // If so, then we have found our largest pattern match..
276 // If not, then continue on to the next case;
277
278 if (viewId.indexOf(fromViewId, 0) == -1) {
279 continue;

