1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.document.schema;
13 import sk.uniba.euromath.document.schema.plug.IAttributeRuleP;
14 import sk.uniba.euromath.document.schema.plug.IBaseRuleP;
15 import sk.uniba.euromath.document.schema.plug.INewElementRuleP;
16 /***
17 * Represents a base rule. Not intended to be subclassed nor instantiated by
18 * clients.
19 * @author Martin Vysny
20 */
21 public class BaseRule {
22 /***
23 * Hidden constructor to prevent instantiation.
24 */
25 protected BaseRule() {
26 super();
27 }
28 /***
29 * Converts the <code>BaseRuleP</code> instance into appropriate
30 * <code>BaseRule</code> instance.
31 * @param rule the 'plug' rule
32 * @return the rule
33 */
34 public final static BaseRule valueOf(IBaseRuleP rule) {
35 return (rule instanceof INewElementRuleP ? (BaseRule) new NewElementRule(
36 (INewElementRuleP) rule)
37 : new AttributeRule((IAttributeRuleP) rule));
38 }
39 }