1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package sk.uniba.euromath.document.schema;
18 import sk.uniba.euromath.document.schema.plug.IAttributeRuleP;
19 /***
20 * Wraps the <code>IAttributeRuleP</code> instance.
21 *
22 * @author Martin Vysny
23 */
24 public class AttributeRule extends BaseRule {
25
26 private final IAttributeRuleP rule;
27 /***
28 * Constructor.
29 * @param rule wrap this rule.
30 */
31 AttributeRule(IAttributeRuleP rule) {
32 super();
33 this.rule = rule;
34 }
35 /***
36 * Checks whether this textual rule can contain given value.
37 * @param value value to check.
38 * @return true if the value is valid.
39 */
40 public boolean acceptsValue(String value) {
41 return rule.acceptsValue(value);
42 }
43 /***
44 * Returns human-readable name for the datatype, that is represented by this
45 * instance.
46 * @return Short displayable name (and description, if necessary) of
47 * datatype.
48 */
49 public String getDatatypeName() {
50 return rule.getDatatypeName();
51 }
52 /***
53 * Checks, whether this value rule accepts any non-empty string.
54 * @return true if this value rule accepts any non-empty string.
55 */
56 public boolean acceptsSomething() {
57 return rule.acceptsSomething();
58 }
59 /***
60 * Compose and return an error message, why given value was not accepted.
61 * @param value the value
62 * @return error message, possibly suggesting correct value whenever
63 * possible. If no error message is available then return empty string. If
64 * the value is acceptable return <code>null</code>.
65 */
66 public String getErrorMessage(String value) {
67 return rule.getErrorMessage(value);
68 }
69 }