01: package org.conform.mdl;
02:
03: import org.xml.sax.*;
04:
05: import java.beans.ExceptionListener;
06:
07: import org.conform.*;
08:
09: public class MandatoryHandler extends ScopeHandler {
10: private boolean mandatory;
11:
12: public MandatoryHandler(ExceptionListener exceptionListener) {
13: super (exceptionListener);
14: }
15:
16: public void startElement(String name, AttributeList attributes)
17: throws SAXException {
18: if (!"mandatory".equals(name))
19: exceptionListener.exceptionThrown(new SAXParseException(
20: "mandatory doesn't have nested elements", locator));
21: mandatory = true;
22: }
23:
24: public void endElement(String name) throws SAXException {
25: if ("mandatory".equals(name))
26: ((PropertyMeta) getScope()).setMandatory(mandatory);
27: }
28:
29: public void characters(char ch[], int start, int length)
30: throws SAXException {
31: String string = new String(ch, start, length);
32: if ("true".equalsIgnoreCase(string))
33: mandatory = true;
34: else if ("false".equalsIgnoreCase(string))
35: mandatory = false;
36: else
37: exceptionListener.exceptionThrown(new SAXParseException(
38: "true or false expected: " + string, locator));
39: }
40: }
|