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 ReadableHandler extends ScopeHandler {
10: private boolean readable;
11:
12: public ReadableHandler(ExceptionListener exceptionListener) {
13: super (exceptionListener);
14: }
15:
16: public void startElement(String name, AttributeList attributes)
17: throws SAXException {
18: if (!"readable".equals(name))
19: exceptionListener.exceptionThrown(new SAXParseException(
20: "readable doesn't have nested elements", locator));
21: readable = true;
22: }
23:
24: public void endElement(String name) throws SAXException {
25: if ("readable".equals(name))
26: ((PropertyMeta) getScope()).setReadable(readable);
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: readable = true;
34: else if ("false".equalsIgnoreCase(string))
35: readable = false;
36: else
37: exceptionListener.exceptionThrown(new SAXParseException(
38: "true or false expected: " + string, locator));
39: }
40: }
|