1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.profiler.rules.impl;
18
19 import org.apache.jetspeed.profiler.rules.RuleCriterion;
20 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
21 import org.apache.jetspeed.request.RequestContext;
22
23 /***
24 * CountryCriterionResolver
25 * Resolve Rules:
26 * 1. Request Parameter (Standard)
27 * 2. Locale.CountryCode
28 *
29 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
30 * @version $Id: CountryCriterionResolver.java 516448 2007-03-09 16:25:47Z ate $
31 */
32 public class CountryCriterionResolver
33 extends StandardResolver
34 implements RuleCriterionResolver
35 {
36
37
38
39 public String resolve(RequestContext context, RuleCriterion criterion)
40 {
41
42 String value = super.resolve(context, criterion);
43 if (value != null)
44 {
45 return value.toUpperCase();
46 }
47
48 String country = context.getLocale().getCountry();
49 if (country != null)
50 country = country.toUpperCase();
51 return country;
52 }
53
54
55
56
57 public boolean isControl(RuleCriterion criterion)
58 {
59 return true;
60 }
61
62 }