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