1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.reactive.beans.factory.config;
18
19 import java.util.List;
20 import java.util.Set;
21 import java.util.Map;
22 import java.util.Properties;
23
24 /***
25 * An abstract placeholder evaluator whos {@link #evaluate(Placeholder)} method delegates off the an appropriate evaluate
26 * method based on the type returned from {@link Placeholder#getType()}.
27 *
28 * @author Dan Washusen
29 * @version $Id: AbstractPlaceholderEvaluator.java,v 1.1 2004/12/30 07:35:29 dan_washusen Exp $
30 * @since 30/12/2004
31 */
32 public abstract class AbstractPlaceholderEvaluator
33 implements PlaceholderEvaluator {
34 /***
35 * This method delegates off to the appropriate evaluate method.
36 * @param placeholder The placeholder to be evaluated
37 * @return The value retrieved from the configuration agent based on the placeholder
38 * @see #evaluateString(Placeholder)
39 * @see #evaluateArray(Placeholder)
40 * @see #evaluateList(Placeholder)
41 * @see #evaluateSet(Placeholder)
42 * @see #evaluateMap(Placeholder)
43 * @see #evaluateProperties(Placeholder)
44 * @see #evaluateObject(Placeholder)
45 */
46 public Object evaluate(Placeholder placeholder) {
47 if (String.class.equals(placeholder.getType())) {
48 return evaluateString(placeholder);
49 }
50 else if (String[].class.equals(placeholder.getType())) {
51 return evaluateArray(placeholder);
52 }
53 else if (List.class.equals(placeholder.getType())) {
54 return evaluateList(placeholder);
55 }
56 else if (Set.class.equals(placeholder.getType())) {
57 return evaluateSet(placeholder);
58 }
59 else if (Map.class.equals(placeholder.getType())) {
60 return evaluateMap(placeholder);
61 }
62 else if (Properties.class.equals(placeholder.getType())) {
63 return evaluateProperties(placeholder);
64 }
65 else if (Object.class.equals(placeholder.getType())) {
66 return evaluateObject(placeholder);
67 }
68
69 throw new InvalidPlaceholderException("A valid placeholder type was not specified");
70 }
71
72 /***
73 * Evaluate a String placeholder.
74 * @param placeholder The placeholder to evaluate
75 * @return The value retrieved from the configuration agent based on the placeholder
76 */
77 abstract protected String evaluateString(Placeholder placeholder);
78 /***
79 * Evaluate a String[] placeholder.
80 * @param placeholder The placeholder to evaluate
81 * @return The value retrieved from the configuration agent based on the placeholder
82 */
83 abstract protected String[] evaluateArray(Placeholder placeholder);
84 /***
85 * Evaluate a List placeholder.
86 * @param placeholder The placeholder to evaluate
87 * @return The value retrieved from the configuration agent based on the placeholder
88 */
89 abstract protected List evaluateList(Placeholder placeholder);
90 /***
91 * Evaluate a Set placeholder.
92 * @param placeholder The placeholder to evaluate
93 * @return The value retrieved from the configuration agent based on the placeholder
94 */
95 abstract protected Set evaluateSet(Placeholder placeholder);
96 /***
97 * Evaluate a Map placeholder.
98 * @param placeholder The placeholder to evaluate
99 * @return The value retrieved from the configuration agent based on the placeholder
100 */
101 abstract protected Map evaluateMap(Placeholder placeholder);
102 /***
103 * Evaluate a Properties placeholder.
104 * @param placeholder The placeholder to evaluate
105 * @return The value retrieved from the configuration agent based on the placeholder
106 */
107 abstract protected Properties evaluateProperties(Placeholder placeholder);
108 /***
109 * Evaluate a Object placeholder.
110 * @param placeholder The placeholder to evaluate
111 * @return The value retrieved from the configuration agent based on the placeholder
112 */
113 abstract protected Object evaluateObject(Placeholder placeholder);
114 }