01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.parser;
20:
21: import java.io.IOException;
22:
23: /**
24: * This class implements an event-based parser for semicolon separated
25: * length pair lists, as used in the 'values' attribute of the 'animateMotion'
26: * element.
27: *
28: * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
29: * @version $Id: LengthPairListParser.java 502167 2007-02-01 09:26:51Z dvholten $
30: */
31: public class LengthPairListParser extends LengthListParser {
32:
33: /**
34: * Parses the given reader.
35: */
36: protected void doParse() throws ParseException, IOException {
37: ((LengthListHandler) lengthHandler).startLengthList();
38:
39: current = reader.read();
40: skipSpaces();
41:
42: try {
43: for (;;) {
44: lengthHandler.startLength();
45: parseLength();
46: lengthHandler.endLength();
47: skipCommaSpaces();
48: lengthHandler.startLength();
49: parseLength();
50: lengthHandler.endLength();
51: skipSpaces();
52: if (current == -1) {
53: break;
54: }
55: if (current != ';') {
56: reportUnexpectedCharacterError(current);
57: }
58: current = reader.read();
59: skipSpaces();
60: }
61: } catch (NumberFormatException e) {
62: reportUnexpectedCharacterError(current);
63: }
64: ((LengthListHandler) lengthHandler).endLengthList();
65: }
66: }
|