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 PriorityHandler extends ScopeHandler {
10: private int priority;
11:
12: public PriorityHandler(ExceptionListener exceptionListener) {
13: super (exceptionListener);
14: }
15:
16: public void startElement(String name, AttributeList attributes)
17: throws SAXException {
18: if (!"priority".equals(name))
19: exceptionListener.exceptionThrown(new SAXParseException(
20: "priority doesn't have nested elements", locator));
21: priority = 0;
22: }
23:
24: public void endElement(String name) throws SAXException {
25: if ("priority".equals(name))
26: ((PropertyMeta) getScope()).setPriority(priority);
27: }
28:
29: public void characters(char ch[], int start, int length)
30: throws SAXException {
31: String string = new String(ch, start, length);
32: try {
33: priority = Integer.parseInt(string);
34: } catch (NumberFormatException e) {
35: exceptionListener.exceptionThrown(new SAXParseException(
36: "number expected: " + string, locator));
37: }
38: }
39: }
|