View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the License); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  /*
13   * This file is protected by the Mozilla Public License
14   * located in euromath2-bin.zip file, downloadable from
15   * http://sourceforge.net/projects/euromath2/.
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  }