KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > parser > FragmentIdentifierParser


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.parser;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.batik.xml.XMLUtilities;
23
24 /**
25  * This class represents an event-based parser for the SVG
26  * fragment identifiers.
27  *
28  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
29  * @version $Id: FragmentIdentifierParser.java,v 1.14 2005/03/27 08:58:35 cam Exp $
30  */

31 public class FragmentIdentifierParser extends NumberParser {
32     
33     /**
34      * The buffer used for numbers.
35      */

36     protected char[] buffer = new char[16];
37
38     /**
39      * The buffer size.
40      */

41     protected int bufferSize;
42
43     /**
44      * The FragmentIdentifierHandler.
45      */

46     protected FragmentIdentifierHandler fragmentIdentifierHandler;
47
48     /**
49      * Creates a new FragmentIdentifier parser.
50      */

51     public FragmentIdentifierParser() {
52         fragmentIdentifierHandler =
53             DefaultFragmentIdentifierHandler.INSTANCE;
54     }
55
56     /**
57      * Allows an application to register a fragment identifier handler.
58      *
59      * <p>If the application does not register a handler, all
60      * events reported by the parser will be silently ignored.
61      *
62      * <p>Applications may register a new or different handler in the
63      * middle of a parse, and the parser must begin using the new
64      * handler immediately.</p>
65      * @param handler The transform list handler.
66      */

67     public void
68         setFragmentIdentifierHandler(FragmentIdentifierHandler handler) {
69         fragmentIdentifierHandler = handler;
70     }
71
72     /**
73      * Returns the points handler in use.
74      */

75     public FragmentIdentifierHandler getFragmentIdentifierHandler() {
76         return fragmentIdentifierHandler;
77     }
78
79     /**
80      * Parses the current reader.
81      */

82     protected void doParse() throws ParseException, IOException JavaDoc {
83         bufferSize = 0;
84                 
85         current = reader.read();
86
87         fragmentIdentifierHandler.startFragmentIdentifier();
88
89         ident: {
90             String JavaDoc id = null;
91
92             switch (current) {
93             case 'x':
94                 bufferize();
95                 current = reader.read();
96                 if (current != 'p') {
97                     parseIdentifier();
98                     break;
99                 }
100                 bufferize();
101                 current = reader.read();
102                 if (current != 'o') {
103                     parseIdentifier();
104                     break;
105                 }
106                 bufferize();
107                 current = reader.read();
108                 if (current != 'i') {
109                     parseIdentifier();
110                     break;
111                 }
112                 bufferize();
113                 current = reader.read();
114                 if (current != 'n') {
115                     parseIdentifier();
116                     break;
117                 }
118                 bufferize();
119                 current = reader.read();
120                 if (current != 't') {
121                     parseIdentifier();
122                     break;
123                 }
124                 bufferize();
125                 current = reader.read();
126                 if (current != 'e') {
127                     parseIdentifier();
128                     break;
129                 }
130                 bufferize();
131                 current = reader.read();
132                 if (current != 'r') {
133                     parseIdentifier();
134                     break;
135                 }
136                 bufferize();
137                 current = reader.read();
138                 if (current != '(') {
139                     parseIdentifier();
140                     break;
141                 }
142                 bufferSize = 0;
143                 current = reader.read();
144                 if (current != 'i') {
145                     reportError("character.expected",
146                                 new Object JavaDoc[] { new Character JavaDoc('i'),
147                                                 new Integer JavaDoc(current) });
148                     break ident;
149                 }
150                 current = reader.read();
151                 if (current != 'd') {
152                     reportError("character.expected",
153                                 new Object JavaDoc[] { new Character JavaDoc('d'),
154                                                new Integer JavaDoc(current) });
155                     break ident;
156                 }
157                 current = reader.read();
158                 if (current != '(') {
159                     reportError("character.expected",
160                                 new Object JavaDoc[] { new Character JavaDoc('('),
161                                                new Integer JavaDoc(current) });
162                     break ident;
163                 }
164                 current = reader.read();
165                 if (current != '"' && current != '\'') {
166                     reportError("character.expected",
167                                 new Object JavaDoc[] { new Character JavaDoc('\''),
168                                                new Integer JavaDoc(current) });
169                     break ident;
170                 }
171                 char q = (char)current;
172                 current = reader.read();
173                 parseIdentifier();
174
175                 id = getBufferContent();
176                 bufferSize = 0;
177                 fragmentIdentifierHandler.idReference(id);
178
179                 if (current != q) {
180                     reportError("character.expected",
181                                 new Object JavaDoc[] { new Character JavaDoc(q),
182                                                new Integer JavaDoc(current) });
183                     break ident;
184                 }
185                 current = reader.read();
186                 if (current != ')') {
187                     reportError("character.expected",
188                                 new Object JavaDoc[] { new Character JavaDoc(')'),
189                                                new Integer JavaDoc(current) });
190                     break ident;
191                 }
192                 current = reader.read();
193                 if (current != ')') {
194                     reportError("character.expected",
195                                 new Object JavaDoc[] { new Character JavaDoc(')'),
196                                                new Integer JavaDoc(current) });
197                 }
198                 break ident;
199
200             case 's':
201                 bufferize();
202                 current = reader.read();
203                 if (current != 'v') {
204                     parseIdentifier();
205                     break;
206                 }
207                 bufferize();
208                 current = reader.read();
209                 if (current != 'g') {
210                     parseIdentifier();
211                     break;
212                 }
213                 bufferize();
214                 current = reader.read();
215                 if (current != 'V') {
216                     parseIdentifier();
217                     break;
218                 }
219                 bufferize();
220                 current = reader.read();
221                 if (current != 'i') {
222                     parseIdentifier();
223                     break;
224                 }
225                 bufferize();
226                 current = reader.read();
227                 if (current != 'e') {
228                     parseIdentifier();
229                     break;
230                 }
231                 bufferize();
232                 current = reader.read();
233                 if (current != 'w') {
234                     parseIdentifier();
235                     break;
236                 }
237                 bufferize();
238                 current = reader.read();
239                 if (current != '(') {
240                     parseIdentifier();
241                     break;
242                 }
243                 bufferSize = 0;
244                 current = reader.read();
245                 parseViewAttributes();
246
247                 if (current != ')') {
248                     reportError("character.expected",
249                                 new Object JavaDoc[] { new Character JavaDoc(')'),
250                                                new Integer JavaDoc(current) });
251                 }
252                 break ident;
253
254             default:
255                 if (current == -1 ||
256                     !XMLUtilities.isXMLNameFirstCharacter((char)current)) {
257                     break ident;
258                 }
259                 bufferize();
260                 current = reader.read();
261                 parseIdentifier();
262             }
263             id = getBufferContent();
264             fragmentIdentifierHandler.idReference(id);
265         }
266
267         fragmentIdentifierHandler.endFragmentIdentifier();
268     }
269
270     /**
271      * Parses the svgView attributes.
272      */

273     protected void parseViewAttributes() throws ParseException, IOException JavaDoc {
274         boolean first = true;
275         loop: for (;;) {
276             switch (current) {
277             case -1:
278             case ')':
279                 if (first) {
280                     reportError("character.unexpected",
281                                 new Object JavaDoc[] { new Integer JavaDoc(current) });
282                     break loop;
283                 }
284             default:
285                 break loop;
286             case ';':
287                 if (first) {
288                     reportError("character.unexpected",
289                                 new Object JavaDoc[] { new Integer JavaDoc(current) });
290                     break loop;
291                 }
292                 current = reader.read();
293                 break;
294             case 'v':
295                 first = false;
296                 current = reader.read();
297                 if (current != 'i') {
298                     reportError("character.expected",
299                                 new Object JavaDoc[] { new Character JavaDoc('i'),
300                                                new Integer JavaDoc(current) });
301                     break loop;
302                 }
303                 current = reader.read();
304                 if (current != 'e') {
305                     reportError("character.expected",
306                                 new Object JavaDoc[] { new Character JavaDoc('e'),
307                                                new Integer JavaDoc(current) });
308                     break loop;
309                 }
310                 current = reader.read();
311                 if (current != 'w') {
312                     reportError("character.expected",
313                                 new Object JavaDoc[] { new Character JavaDoc('w'),
314                                                new Integer JavaDoc(current) });
315                     break loop;
316                 }
317                 current = reader.read();
318
319                 switch (current) {
320                 case 'B':
321                     current = reader.read();
322                     if (current != 'o') {
323                         reportError("character.expected",
324                                     new Object JavaDoc[] { new Character JavaDoc('o'),
325                                                    new Integer JavaDoc(current) });
326                         break loop;
327                     }
328                     current = reader.read();
329                     if (current != 'x') {
330                         reportError("character.expected",
331                                     new Object JavaDoc[] { new Character JavaDoc('x'),
332                                                    new Integer JavaDoc(current) });
333                         break loop;
334                     }
335                     current = reader.read();
336                     if (current != '(') {
337                         reportError("character.expected",
338                                     new Object JavaDoc[] { new Character JavaDoc('('),
339                                                    new Integer JavaDoc(current) });
340                         break loop;
341                     }
342                     current = reader.read();
343
344                     float x = parseFloat();
345                     if (current != ',') {
346                         reportError("character.expected",
347                                     new Object JavaDoc[] { new Character JavaDoc(','),
348                                                    new Integer JavaDoc(current) });
349                         break loop;
350                     }
351                     current = reader.read();
352                     
353                     float y = parseFloat();
354                     if (current != ',') {
355                         reportError("character.expected",
356                                     new Object JavaDoc[] { new Character JavaDoc(','),
357                                                    new Integer JavaDoc(current) });
358                         break loop;
359                     }
360                     current = reader.read();
361                     
362                     float w = parseFloat();
363                     if (current != ',') {
364                         reportError("character.expected",
365                                     new Object JavaDoc[] { new Character JavaDoc(','),
366                                                    new Integer JavaDoc(current) });
367                         break loop;
368                     }
369                     current = reader.read();
370                     
371                     float h = parseFloat();
372                     if (current != ')') {
373                         reportError("character.expected",
374                                     new Object JavaDoc[] { new Character JavaDoc(')'),
375                                                    new Integer JavaDoc(current) });
376                         break loop;
377                     }
378                     current = reader.read();
379                     fragmentIdentifierHandler.viewBox(x, y, w, h);
380                     if (current != ')' && current != ';') {
381                         reportError("character.expected",
382                                     new Object JavaDoc[] { new Character JavaDoc(')'),
383                                                    new Integer JavaDoc(current) });
384                         break loop;
385                     }
386                     break;
387
388                 case 'T':
389                     current = reader.read();
390                     if (current != 'a') {
391                         reportError("character.expected",
392                                     new Object JavaDoc[] { new Character JavaDoc('a'),
393                                                    new Integer JavaDoc(current) });
394                         break loop;
395                     }
396                     current = reader.read();
397                     if (current != 'r') {
398                         reportError("character.expected",
399                                     new Object JavaDoc[] { new Character JavaDoc('r'),
400                                                    new Integer JavaDoc(current) });
401                         break loop;
402                     }
403                     current = reader.read();
404                     if (current != 'g') {
405                         reportError("character.expected",
406                                     new Object JavaDoc[] { new Character JavaDoc('g'),
407                                                    new Integer JavaDoc(current) });
408                         break loop;
409                     }
410                     current = reader.read();
411                     if (current != 'e') {
412                         reportError("character.expected",
413                                     new Object JavaDoc[] { new Character JavaDoc('e'),
414                                                    new Integer JavaDoc(current) });
415                         break loop;
416                     }
417                     current = reader.read();
418                     if (current != 't') {
419                         reportError("character.expected",
420                                     new Object JavaDoc[] { new Character JavaDoc('t'),
421                                                    new Integer JavaDoc(current) });
422                         break loop;
423                     }
424                     current = reader.read();
425                     if (current != '(') {
426                         reportError("character.expected",
427                                     new Object JavaDoc[] { new Character JavaDoc('('),
428                                                    new Integer JavaDoc(current) });
429                         break loop;
430                     }
431                     current = reader.read();
432
433                     fragmentIdentifierHandler.startViewTarget();
434
435                     id: for (;;) {
436                         bufferSize = 0;
437                         if (current == -1 ||
438                             !XMLUtilities.isXMLNameFirstCharacter((char)current)) {
439                             reportError("character.unexpected",
440                                         new Object JavaDoc[] { new Integer JavaDoc(current) });
441                             break loop;
442                         }
443                         bufferize();
444                         current = reader.read();
445                         parseIdentifier();
446                         String JavaDoc s = getBufferContent();
447
448                         fragmentIdentifierHandler.viewTarget(s);
449
450                         bufferSize = 0;
451                         switch (current) {
452                         case ')':
453                             current = reader.read();
454                             break id;
455                         case ',':
456                         case ';':
457                             current = reader.read();
458                             break;
459                         default:
460                             reportError("character.unexpected",
461                                         new Object JavaDoc[] { new Integer JavaDoc(current) });
462                             break loop;
463                         }
464                     }
465
466                     fragmentIdentifierHandler.endViewTarget();
467                     break;
468
469                 default:
470                     reportError("character.unexpected",
471                                 new Object JavaDoc[] { new Integer JavaDoc(current) });
472                     break loop;
473                 }
474                 break;
475             case 'p':
476                 first = false;
477                 current = reader.read();
478                 if (current != 'r') {
479                     reportError("character.expected",
480                                 new Object JavaDoc[] { new Character JavaDoc('r'),
481                                                new Integer JavaDoc(current) });
482                     break loop;
483                 }
484                 current = reader.read();
485                 if (current != 'e') {
486                     reportError("character.expected",
487                                 new Object JavaDoc[] { new Character JavaDoc('e'),
488                                                new Integer JavaDoc(current) });
489                     break loop;
490                 }
491                 current = reader.read();
492                 if (current != 's') {
493                     reportError("character.expected",
494                                 new Object JavaDoc[] { new Character JavaDoc('s'),
495                                                new Integer JavaDoc(current) });
496                     break loop;
497                 }
498                 current = reader.read();
499                 if (current != 'e') {
500                     reportError("character.expected",
501                                 new Object JavaDoc[] { new Character JavaDoc('e'),
502                                                new Integer JavaDoc(current) });
503                     break loop;
504                 }
505                 current = reader.read();
506                 if (current != 'r') {
507                     reportError("character.expected",
508                                 new Object JavaDoc[] { new Character JavaDoc('r'),
509                                                new Integer JavaDoc(current) });
510                     break loop;
511                 }
512                 current = reader.read();
513                 if (current != 'v') {
514                     reportError("character.expected",
515                                 new Object JavaDoc[] { new Character JavaDoc('v'),
516                                                new Integer JavaDoc(current) });
517                     break loop;
518                 }
519                 current = reader.read();
520                 if (current != 'e') {
521                     reportError("character.expected",
522                                 new Object JavaDoc[] { new Character JavaDoc('e'),
523                                                new Integer JavaDoc(current) });
524                     break loop;
525                 }
526                 current = reader.read();
527                 if (current != 'A') {
528                     reportError("character.expected",
529                                 new Object JavaDoc[] { new Character JavaDoc('A'),
530                                                new Integer JavaDoc(current) });
531                     break loop;
532                 }
533                 current = reader.read();
534                 if (current != 's') {
535                     reportError("character.expected",
536                                 new Object JavaDoc[] { new Character JavaDoc('s'),
537                                                new Integer JavaDoc(current) });
538                     break loop;
539                 }
540                 current = reader.read();
541                 if (current != 'p') {
542                     reportError("character.expected",
543                                 new Object JavaDoc[] { new Character JavaDoc('p'),
544                                                new Integer JavaDoc(current) });
545                     break loop;
546                 }
547                 current = reader.read();
548                 if (current != 'e') {
549                     reportError("character.expected",
550                                 new Object JavaDoc[] { new Character JavaDoc('e'),
551                                                new Integer JavaDoc(current) });
552                     break loop;
553                 }
554                 current = reader.read();
555                 if (current != 'c') {
556                     reportError("character.expected",
557                                 new Object JavaDoc[] { new Character JavaDoc('c'),
558                                                new Integer JavaDoc(current) });
559                     break loop;
560                 }
561                 current = reader.read();
562                 if (current != 't') {
563                     reportError("character.expected",
564                                 new Object JavaDoc[] { new Character JavaDoc('t'),
565                                                new Integer JavaDoc(current) });
566                     break loop;
567                 }
568                 current = reader.read();
569                 if (current != 'R') {
570                     reportError("character.expected",
571                                 new Object JavaDoc[] { new Character JavaDoc('R'),
572                                                new Integer JavaDoc(current) });
573                     break loop;
574                 }
575                 current = reader.read();
576                 if (current != 'a') {
577                     reportError("character.expected",
578                                 new Object JavaDoc[] { new Character JavaDoc('a'),
579                                                new Integer JavaDoc(current) });
580                     break loop;
581                 }
582                 current = reader.read();
583                 if (current != 't') {
584                     reportError("character.expected",
585                                 new Object JavaDoc[] { new Character JavaDoc('t'),
586                                                new Integer JavaDoc(current) });
587                     break loop;
588                 }
589                 current = reader.read();
590                 if (current != 'i') {
591                     reportError("character.expected",
592                                 new Object JavaDoc[] { new Character JavaDoc('i'),
593                                                new Integer JavaDoc(current) });
594                     break loop;
595                 }
596                 current = reader.read();
597                 if (current != 'o') {
598                     reportError("character.expected",
599                                 new Object JavaDoc[] { new Character JavaDoc('o'),
600                                                new Integer JavaDoc(current) });
601                     break loop;
602                 }
603                 current = reader.read();
604                 if (current != '(') {
605                     reportError("character.expected",
606                                 new Object JavaDoc[] { new Character JavaDoc('('),
607                                                new Integer JavaDoc(current) });
608                     break loop;
609                 }
610                 current = reader.read();
611
612                 parsePreserveAspectRatio();
613
614                 if (current != ')') {
615                     reportError("character.expected",
616                                 new Object JavaDoc[] { new Character JavaDoc(')'),
617                                                new Integer JavaDoc(current) });
618                     break loop;
619                 }
620                 current = reader.read();
621                 break;
622
623             case 't':
624                 first = false;
625                 current = reader.read();
626                 if (current != 'r') {
627                     reportError("character.expected",
628                                 new Object JavaDoc[] { new Character JavaDoc('r'),
629                                                new Integer JavaDoc(current) });
630                     break loop;
631                 }
632                 current = reader.read();
633                 if (current != 'a') {
634                     reportError("character.expected",
635                                 new Object JavaDoc[] { new Character JavaDoc('a'),
636                                                new Integer JavaDoc(current) });
637                     break loop;
638                 }
639                 current = reader.read();
640                 if (current != 'n') {
641                     reportError("character.expected",
642                                 new Object JavaDoc[] { new Character JavaDoc('n'),
643                                                new Integer JavaDoc(current) });
644                     break loop;
645                 }
646                 current = reader.read();
647                 if (current != 's') {
648                     reportError("character.expected",
649                                 new Object JavaDoc[] { new Character JavaDoc('s'),
650                                                new Integer JavaDoc(current) });
651                     break loop;
652                 }
653                 current = reader.read();
654                 if (current != 'f') {
655                     reportError("character.expected",
656                                 new Object JavaDoc[] { new Character JavaDoc('f'),
657                                                new Integer JavaDoc(current) });
658                     break loop;
659                 }
660                 current = reader.read();
661                 if (current != 'o') {
662                     reportError("character.expected",
663                                 new Object JavaDoc[] { new Character JavaDoc('o'),
664                                                new Integer JavaDoc(current) });
665                     break loop;
666                 }
667                 current = reader.read();
668                 if (current != 'r') {
669                     reportError("character.expected",
670                                 new Object JavaDoc[] { new Character JavaDoc('r'),
671                                                new Integer JavaDoc(current) });
672                     break loop;
673                 }
674                 current = reader.read();
675                 if (current != 'm') {
676                     reportError("character.expected",
677                                 new Object JavaDoc[] { new Character JavaDoc('m'),
678                                                new Integer JavaDoc(current) });
679                     break loop;
680                 }
681                 current = reader.read();
682                 if (current != '(') {
683                     reportError("character.expected",
684                                 new Object JavaDoc[] { new Character JavaDoc('('),
685                                                new Integer JavaDoc(current) });
686                     break loop;
687                 }
688
689                 fragmentIdentifierHandler.startTransformList();
690
691                 tloop: for (;;) {
692                     try {
693                         current = reader.read();
694                         switch (current) {
695                         case ',':
696                             break;
697                         case 'm':
698                             parseMatrix();
699                             break;
700                         case 'r':
701                             parseRotate();
702                             break;
703                         case 't':
704                             parseTranslate();
705                             break;
706                         case 's':
707                             current = reader.read();
708                             switch (current) {
709                             case 'c':
710                                 parseScale();
711                                 break;
712                             case 'k':
713                                 parseSkew();
714                                 break;
715                             default:
716                                 reportError("character.unexpected",
717                                             new Object JavaDoc[] {
718                                                 new Integer JavaDoc(current) });
719                                 skipTransform();
720                             }
721                             break;
722                         default:
723                             break tloop;
724                         }
725                     } catch (ParseException e) {
726                         errorHandler.error(e);
727                         skipTransform();
728                     }
729                 }
730
731                 fragmentIdentifierHandler.endTransformList();
732                 break;
733
734             case 'z':
735                 first = false;
736                 current = reader.read();
737                 if (current != 'o') {
738                     reportError("character.expected",
739                                 new Object JavaDoc[] { new Character JavaDoc('o'),
740                                                new Integer JavaDoc(current) });
741                     break loop;
742                 }
743                 current = reader.read();
744                 if (current != 'o') {
745                     reportError("character.expected",
746                                 new Object JavaDoc[] { new Character JavaDoc('o'),
747                                                new Integer JavaDoc(current) });
748                     break loop;
749                 }
750                 current = reader.read();
751                 if (current != 'm') {
752                     reportError("character.expected",
753                                 new Object JavaDoc[] { new Character JavaDoc('m'),
754                                                new Integer JavaDoc(current) });
755                     break loop;
756                 }
757                 current = reader.read();
758                 if (current != 'A') {
759                     reportError("character.expected",
760                                 new Object JavaDoc[] { new Character JavaDoc('A'),
761                                                new Integer JavaDoc(current) });
762                     break loop;
763                 }
764                 current = reader.read();
765                 if (current != 'n') {
766                     reportError("character.expected",
767                                 new Object JavaDoc[] { new Character JavaDoc('n'),
768                                                new Integer JavaDoc(current) });
769                     break loop;
770                 }
771                 current = reader.read();
772                 if (current != 'd') {
773                     reportError("character.expected",
774                                 new Object JavaDoc[] { new Character JavaDoc('d'),
775                                                new Integer JavaDoc(current) });
776                     break loop;
777                 }
778                 current = reader.read();
779                 if (current != 'P') {
780                     reportError("character.expected",
781                                 new Object JavaDoc[] { new Character JavaDoc('P'),
782                                                new Integer JavaDoc(current) });
783                     break loop;
784                 }
785                 current = reader.read();
786                 if (current != 'a') {
787                     reportError("character.expected",
788                                 new Object JavaDoc[] { new Character JavaDoc('a'),
789                                                new Integer JavaDoc(current) });
790                     break loop;
791                 }
792                 current = reader.read();
793                 if (current != 'n') {
794                     reportError("character.expected",
795                                 new Object JavaDoc[] { new Character JavaDoc('n'),
796                                                new Integer JavaDoc(current) });
797                     break loop;
798                 }
799                 current = reader.read();
800                 if (current != '(') {
801                     reportError("character.expected",
802                                 new Object JavaDoc[] { new Character JavaDoc('('),
803                                                new Integer JavaDoc(current) });
804                     break loop;
805                 }
806                 current = reader.read();
807
808                 switch (current) {
809                 case 'm':
810                     current = reader.read();
811                     if (current != 'a') {
812                         reportError("character.expected",
813                                     new Object JavaDoc[] { new Character JavaDoc('a'),
814                                                    new Integer JavaDoc(current) });
815                         break loop;
816                     }
817                     current = reader.read();
818                     if (current != 'g') {
819                         reportError("character.expected",
820                                     new Object JavaDoc[] { new Character JavaDoc('g'),
821                                                    new Integer JavaDoc(current) });
822                         break loop;
823                     }
824                     current = reader.read();
825                     if (current != 'n') {
826                         reportError("character.expected",
827                                     new Object JavaDoc[] { new Character JavaDoc('n'),
828                                                    new Integer JavaDoc(current) });
829                         break loop;
830                     }
831                     current = reader.read();
832                     if (current != 'i') {
833                         reportError("character.expected",
834                                     new Object JavaDoc[] { new Character JavaDoc('i'),
835                                                    new Integer JavaDoc(current) });
836                         break loop;
837                     }
838                     current = reader.read();
839                     if (current != 'f') {
840                         reportError("character.expected",
841                                     new Object JavaDoc[] { new Character JavaDoc('f'),
842                                                    new Integer JavaDoc(current) });
843                         break loop;
844                     }
845                     current = reader.read();
846                     if (current != 'y') {
847                         reportError("character.expected",
848                                     new Object JavaDoc[] { new Character JavaDoc('y'),
849                                                    new Integer JavaDoc(current) });
850                         break loop;
851                     }
852                     current = reader.read();
853                     fragmentIdentifierHandler.zoomAndPan(true);
854                     break;
855
856                 case 'd':
857                     current = reader.read();
858                     if (current != 'i') {
859                         reportError("character.expected",
860                                     new Object JavaDoc[] { new Character JavaDoc('i'),
861                                                    new Integer JavaDoc(current) });
862                         break loop;
863                     }
864                     current = reader.read();
865                     if (current != 's') {
866                         reportError("character.expected",
867                                     new Object JavaDoc[] { new Character JavaDoc('s'),
868                                                    new Integer JavaDoc(current) });
869                         break loop;
870                     }
871                     current = reader.read();
872                     if (current != 'a') {
873                         reportError("character.expected",
874                                     new Object JavaDoc[] { new Character JavaDoc('a'),
875                                                    new Integer JavaDoc(current) });
876                         break loop;
877                     }
878                     current = reader.read();
879                     if (current != 'b') {
880                         reportError("character.expected",
881                                     new Object JavaDoc[] { new Character JavaDoc('b'),
882                                                    new Integer JavaDoc(current) });
883                         break loop;
884                     }
885                     current = reader.read();
886                     if (current != 'l') {
887                         reportError("character.expected",
888                                     new Object JavaDoc[] { new Character JavaDoc('l'),
889                                                    new Integer JavaDoc(current) });
890                         break loop;
891                     }
892                     current = reader.read();
893                     if (current != 'e') {
894                         reportError("character.expected",
895                                     new Object JavaDoc[] { new Character JavaDoc('e'),
896                                                    new Integer JavaDoc(current) });
897                         break loop;
898                     }
899                     current = reader.read();
900                     fragmentIdentifierHandler.zoomAndPan(false);
901                     break;
902
903                 default:
904                     reportError("character.unexpected",
905                                 new Object JavaDoc[] { new Integer JavaDoc(current) });
906                     break loop;
907                 }
908
909                 if (current != ')') {
910                     reportError("character.expected",
911                                 new Object JavaDoc[] { new Character JavaDoc(')'),
912                                                new Integer JavaDoc(current) });
913                     break loop;
914                 }
915                 current = reader.read();
916             }
917         }
918     }
919
920     /**
921      * Parses an identifier.
922      */

923     protected void parseIdentifier() throws ParseException, IOException JavaDoc {
924         for (;;) {
925             if (current == -1 ||
926                 !XMLUtilities.isXMLNameCharacter((char)current)) {
927                 break;
928             }
929             bufferize();
930             current = reader.read();
931         }
932     }
933
934     /**
935      * Returns the content of the buffer.
936      */

937     protected String JavaDoc getBufferContent() {
938         return new String JavaDoc(buffer, 0, bufferSize);
939     }
940
941     /**
942      * Adds the current character to the buffer.
943      */

944     protected void bufferize() {
945         if (bufferSize >= buffer.length) {
946             char[] t = new char[buffer.length * 2];
947             for (int i = 0; i < bufferSize; i++) {
948                 t[i] = buffer[i];
949             }
950             buffer = t;
951         }
952         buffer[bufferSize++] = (char)current;
953     }
954
955     /**
956      * Skips the whitespaces in the current reader.
957      */

958     protected void skipSpaces() throws IOException JavaDoc {
959         if (current == ',') {
960             current = reader.read();
961         }
962     }
963
964     /**
965      * Skips the whitespaces and an optional comma.
966      */

967     protected void skipCommaSpaces() throws IOException JavaDoc {
968         if (current == ',') {
969             current = reader.read();
970         }
971     }
972
973     /**
974      * Parses a matrix transform. 'm' is assumed to be the current character.
975      */

976     protected void parseMatrix() throws ParseException, IOException JavaDoc {
977         current = reader.read();
978
979         // Parse 'atrix wsp? ( wsp?'
980
if (current != 'a') {
981             reportError("character.expected",
982                         new Object JavaDoc[] { new Character JavaDoc('a'),
983                                        new Integer JavaDoc(current) });
984             skipTransform();
985             return;
986         }
987         current = reader.read();
988         if (current != 't') {
989             reportError("character.expected",
990                         new Object JavaDoc[] { new Character JavaDoc('t'),
991                                        new Integer JavaDoc(current) });
992             skipTransform();
993             return;
994         }
995         current = reader.read();
996         if (current != 'r') {
997             reportError("character.expected",
998                         new Object JavaDoc[] { new Character JavaDoc('r'),
999                                        new Integer JavaDoc(current) });
1000            skipTransform();
1001            return;
1002        }
1003        current = reader.read();
1004        if (current != 'i') {
1005            reportError("character.expected",
1006                        new Object JavaDoc[] { new Character JavaDoc('i'),
1007                                       new Integer JavaDoc(current) });
1008            skipTransform();
1009            return;
1010        }
1011        current = reader.read();
1012        if (current != 'x') {
1013            reportError("character.expected",
1014                        new Object JavaDoc[] { new Character JavaDoc('x'),
1015                                       new Integer JavaDoc(current) });
1016            skipTransform();
1017            return;
1018        }
1019        current = reader.read();
1020        skipSpaces();
1021        if (current != '(') {
1022            reportError("character.expected",
1023                        new Object JavaDoc[] { new Character JavaDoc('('),
1024                                       new Integer JavaDoc(current) });
1025            skipTransform();
1026            return;
1027        }
1028        current = reader.read();
1029        skipSpaces();
1030
1031        float a = parseFloat();
1032        skipCommaSpaces();
1033        float b = parseFloat();
1034        skipCommaSpaces();
1035        float c = parseFloat();
1036        skipCommaSpaces();
1037        float d = parseFloat();
1038        skipCommaSpaces();
1039        float e = parseFloat();
1040        skipCommaSpaces();
1041        float f = parseFloat();
1042        
1043        skipSpaces();
1044        if (current != ')') {
1045            reportError("character.expected",
1046                        new Object JavaDoc[] { new Character JavaDoc(')'),
1047                                       new Integer JavaDoc(current) });
1048            skipTransform();
1049            return;
1050        }
1051
1052        fragmentIdentifierHandler.matrix(a, b, c, d, e, f);
1053    }
1054
1055    /**
1056     * Parses a rotate transform. 'r' is assumed to be the current character.
1057     */

1058    protected void parseRotate() throws ParseException, IOException JavaDoc {
1059        current = reader.read();
1060
1061        // Parse 'otate wsp? ( wsp?'
1062
if (current != 'o') {
1063            reportError("character.expected",
1064                        new Object JavaDoc[] { new Character JavaDoc('o'),
1065                                       new Integer JavaDoc(current) });
1066            skipTransform();
1067            return;
1068        }
1069        current = reader.read();
1070        if (current != 't') {
1071            reportError("character.expected",
1072                        new Object JavaDoc[] { new Character JavaDoc('t'),
1073                                       new Integer JavaDoc(current) });
1074            skipTransform();
1075            return;
1076        }
1077        current = reader.read();
1078        if (current != 'a') {
1079            reportError("character.expected",
1080                        new Object JavaDoc[] { new Character JavaDoc('a'),
1081                                       new Integer JavaDoc(current) });
1082            skipTransform();
1083            return;
1084        }
1085        current = reader.read();
1086        if (current != 't') {
1087            reportError("character.expected",
1088                        new Object JavaDoc[] { new Character JavaDoc('t'),
1089                                       new Integer JavaDoc(current) });
1090            skipTransform();
1091            return;
1092        }
1093        current = reader.read();
1094        if (current != 'e') {
1095            reportError("character.expected",
1096                        new Object JavaDoc[] { new Character JavaDoc('e'),
1097                                       new Integer JavaDoc(current) });
1098            skipTransform();
1099            return;
1100        }
1101        current = reader.read();
1102        skipSpaces();
1103
1104        if (current != '(') {
1105            reportError("character.expected",
1106                        new Object JavaDoc[] { new Character JavaDoc('('),
1107                                       new Integer JavaDoc(current) });
1108            skipTransform();
1109            return;
1110        }
1111        current = reader.read();
1112        skipSpaces();
1113
1114        float theta = parseFloat();
1115        skipSpaces();
1116
1117        switch (current) {
1118        case ')':
1119            fragmentIdentifierHandler.rotate(theta);
1120            return;
1121        case ',':
1122            current = reader.read();
1123            skipSpaces();
1124        }
1125        
1126        float cx = parseFloat();
1127        skipCommaSpaces();
1128        float cy = parseFloat();
1129
1130        skipSpaces();
1131        if (current != ')') {
1132            reportError("character.expected",
1133                        new Object JavaDoc[] { new Character JavaDoc(')'),
1134                                       new Integer JavaDoc(current) });
1135            skipTransform();
1136            return;
1137        }
1138
1139        fragmentIdentifierHandler.rotate(theta, cx, cy);
1140    }
1141
1142    /**
1143     * Parses a translate transform. 't' is assumed to be
1144     * the current character.
1145     */

1146    protected void parseTranslate() throws ParseException, IOException JavaDoc {
1147        current = reader.read();
1148
1149        // Parse 'ranslate wsp? ( wsp?'
1150
if (current != 'r') {
1151            reportError("character.expected",
1152                        new Object JavaDoc[] { new Character JavaDoc('r'),
1153                                       new Integer JavaDoc(current) });
1154            skipTransform();
1155            return;
1156        }
1157        current = reader.read();
1158        if (current != 'a') {
1159            reportError("character.expected",
1160                        new Object JavaDoc[] { new Character JavaDoc('a'),
1161                                       new Integer JavaDoc(current) });
1162            skipTransform();
1163            return;
1164        }
1165        current = reader.read();
1166        if (current != 'n') {
1167            reportError("character.expected",
1168                        new Object JavaDoc[] { new Character JavaDoc('n'),
1169                                       new Integer JavaDoc(current) });
1170            skipTransform();
1171            return;
1172        }
1173        current = reader.read();
1174        if (current != 's') {
1175            reportError("character.expected",
1176                        new Object JavaDoc[] { new Character JavaDoc('s'),
1177                                       new Integer JavaDoc(current) });
1178            skipTransform();
1179            return;
1180        }
1181        current = reader.read();
1182        if (current != 'l') {
1183            reportError("character.expected",
1184                        new Object JavaDoc[] { new Character JavaDoc('l'),
1185                                       new Integer JavaDoc(current) });
1186            skipTransform();
1187            return;
1188        }
1189        current = reader.read();
1190        if (current != 'a') {
1191            reportError("character.expected",
1192                        new Object JavaDoc[] { new Character JavaDoc('a'),
1193                                       new Integer JavaDoc(current) });
1194            skipTransform();
1195            return;
1196        }
1197        current = reader.read();
1198        if (current != 't') {
1199            reportError("character.expected",
1200                        new Object JavaDoc[] { new Character JavaDoc('t'),
1201                                       new Integer JavaDoc(current) });
1202            skipTransform();
1203            return;
1204        }
1205        current = reader.read();
1206        if (current != 'e') {
1207            reportError("character.expected",
1208                        new Object JavaDoc[] { new Character JavaDoc('e'),
1209                                       new Integer JavaDoc(current) });
1210            skipTransform();
1211            return;
1212        }
1213        current = reader.read();
1214        skipSpaces();
1215        if (current != '(') {
1216            reportError("character.expected",
1217                        new Object JavaDoc[] { new Character JavaDoc('('),
1218                                       new Integer JavaDoc(current) });
1219            skipTransform();
1220            return;
1221        }
1222        current = reader.read();
1223        skipSpaces();
1224
1225        float tx = parseFloat();
1226        skipSpaces();
1227
1228        switch (current) {
1229        case ')':
1230            fragmentIdentifierHandler.translate(tx);
1231            return;
1232        case ',':
1233            current = reader.read();
1234            skipSpaces();
1235        }
1236
1237        float ty = parseFloat();
1238
1239        skipSpaces();
1240        if (current != ')') {
1241            reportError("character.expected",
1242                        new Object JavaDoc[] { new Character JavaDoc(')'),
1243                                       new Integer JavaDoc(current) });
1244            skipTransform();
1245            return;
1246        }
1247
1248        fragmentIdentifierHandler.translate(tx, ty);
1249    }
1250
1251    /**
1252     * Parses a scale transform. 'c' is assumed to be the current character.
1253     */

1254    protected void parseScale() throws ParseException, IOException JavaDoc {
1255        current = reader.read();
1256
1257        // Parse 'ale wsp? ( wsp?'
1258
if (current != 'a') {
1259            reportError("character.expected",
1260                        new Object JavaDoc[] { new Character JavaDoc('a'),
1261                                       new Integer JavaDoc(current) });
1262            skipTransform();
1263            return;
1264        }
1265        current = reader.read();
1266        if (current != 'l') {
1267            reportError("character.expected",
1268                        new Object JavaDoc[] { new Character JavaDoc('l'),
1269                                       new Integer JavaDoc(current) });
1270            skipTransform();
1271            return;
1272        }
1273        current = reader.read();
1274        if (current != 'e') {
1275            reportError("character.expected",
1276                        new Object JavaDoc[] { new Character JavaDoc('e'),
1277                                       new Integer JavaDoc(current) });
1278            skipTransform();
1279            return;
1280        }
1281        current = reader.read();
1282        skipSpaces();
1283        if (current != '(') {
1284            reportError("character.expected",
1285                        new Object JavaDoc[] { new Character JavaDoc('('),
1286                                       new Integer JavaDoc(current) });
1287            skipTransform();
1288            return;
1289        }
1290        current = reader.read();
1291        skipSpaces();
1292
1293        float sx = parseFloat();
1294        skipSpaces();
1295
1296        switch (current) {
1297        case ')':
1298            fragmentIdentifierHandler.scale(sx);
1299            return;
1300        case ',':
1301            current = reader.read();
1302            skipSpaces();
1303        }
1304
1305        float sy = parseFloat();
1306
1307        skipSpaces();
1308        if (current != ')') {
1309            reportError("character.expected",
1310                        new Object JavaDoc[] { new Character JavaDoc(')'),
1311                                       new Integer JavaDoc(current) });
1312            skipTransform();
1313            return;
1314        }
1315
1316        fragmentIdentifierHandler.scale(sx, sy);
1317    }
1318
1319    /**
1320     * Parses a skew transform. 'e' is assumed to be the current character.
1321     */

1322    protected void parseSkew() throws ParseException, IOException JavaDoc {
1323        current = reader.read();
1324
1325        // Parse 'ew[XY] wsp? ( wsp?'
1326
if (current != 'e') {
1327            reportError("character.expected",
1328                        new Object JavaDoc[] { new Character JavaDoc('e'),
1329                                       new Integer JavaDoc(current) });
1330            skipTransform();
1331            return;
1332        }
1333        current = reader.read();
1334        if (current != 'w') {
1335            reportError("character.expected",
1336                        new Object JavaDoc[] { new Character JavaDoc('w'),
1337                                       new Integer JavaDoc(current) });
1338            skipTransform();
1339            return;
1340        }
1341        current = reader.read();
1342
1343        boolean skewX = false;
1344        switch (current) {
1345        case 'X':
1346            skewX = true;
1347        case 'Y':
1348            break;
1349        default:
1350            reportError("character.expected",
1351                        new Object JavaDoc[] { new Character JavaDoc('X'),
1352                                       new Integer JavaDoc(current) });
1353            skipTransform();
1354            return;
1355        }
1356        current = reader.read();
1357        skipSpaces();
1358        if (current != '(') {
1359            reportError("character.expected",
1360                        new Object JavaDoc[] { new Character JavaDoc('('),
1361                                       new Integer JavaDoc(current) });
1362            skipTransform();
1363            return;
1364        }
1365        current = reader.read();
1366        skipSpaces();
1367
1368        float sk = parseFloat();
1369
1370        skipSpaces();
1371        if (current != ')') {
1372            reportError("character.expected",
1373                        new Object JavaDoc[] { new Character JavaDoc(')'),
1374                                       new Integer JavaDoc(current) });
1375            skipTransform();
1376            return;
1377        }
1378
1379        if (skewX) {
1380            fragmentIdentifierHandler.skewX(sk);
1381        } else {
1382            fragmentIdentifierHandler.skewY(sk);
1383        }
1384    }
1385
1386    /**
1387     * Skips characters in the given reader until a ')' is encountered.
1388     */

1389    protected void skipTransform() throws IOException JavaDoc {
1390        loop: for (;;) {
1391            current = reader.read();
1392            switch (current) {
1393                case ')':
1394                    break loop;
1395                default:
1396                    if (current == -1) {
1397                        break loop;
1398                    }
1399            }
1400        }
1401    }
1402
1403    /**
1404     * Parses a PreserveAspectRatio attribute.
1405     */

1406    protected void parsePreserveAspectRatio()
1407        throws ParseException, IOException JavaDoc {
1408        fragmentIdentifierHandler.startPreserveAspectRatio();
1409
1410        align: switch (current) {
1411        case 'n':
1412            current = reader.read();
1413            if (current != 'o') {
1414                reportError("character.expected",
1415                            new Object JavaDoc[] { new Character JavaDoc('o'),
1416                                           new Integer JavaDoc(current) });
1417                skipIdentifier();
1418                break align;
1419            }
1420            current = reader.read();
1421            if (current != 'n') {
1422                reportError("character.expected",
1423                            new Object JavaDoc[] { new Character JavaDoc('n'),
1424                                           new Integer JavaDoc(current) });
1425                skipIdentifier();
1426                break align;
1427            }
1428            current = reader.read();
1429            if (current != 'e') {
1430                reportError("character.expected",
1431                            new Object JavaDoc[] { new Character JavaDoc('e'),
1432                                           new Integer JavaDoc(current) });
1433                skipIdentifier();
1434                break align;
1435            }
1436            current = reader.read();
1437            skipSpaces();
1438            fragmentIdentifierHandler.none();
1439            break;
1440                
1441        case 'x':
1442            current = reader.read();
1443            if (current != 'M') {
1444                reportError("character.expected",
1445                            new Object JavaDoc[] { new Character JavaDoc('M'),
1446                                           new Integer JavaDoc(current) });
1447                skipIdentifier();
1448                break;
1449            }
1450            current = reader.read();
1451            switch (current) {
1452            case 'a':
1453                current = reader.read();
1454                if (current != 'x') {
1455                    reportError("character.expected",
1456                                new Object JavaDoc[] { new Character JavaDoc('x'),
1457                                                 new Integer JavaDoc(current) });
1458                    skipIdentifier();
1459                    break align;
1460                }
1461                current = reader.read();
1462                if (current != 'Y') {
1463                    reportError("character.expected",
1464                                new Object JavaDoc[] { new Character JavaDoc('Y'),
1465                                               new Integer JavaDoc(current) });
1466                    skipIdentifier();
1467                    break align;
1468                }
1469                current = reader.read();
1470                if (current != 'M') {
1471                    reportError("character.expected",
1472                                new Object JavaDoc[] { new Character JavaDoc('M'),
1473                                               new Integer JavaDoc(current) });
1474                    skipIdentifier();
1475                    break align;
1476                }
1477                current = reader.read();
1478                switch (current) {
1479                case 'a':
1480                    current = reader.read();
1481                    if (current != 'x') {
1482                        reportError("character.expected",
1483                                    new Object JavaDoc[] { new Character JavaDoc('x'),
1484                                                   new Integer JavaDoc(current) });
1485                        skipIdentifier();
1486                        break align;
1487                    }
1488                    fragmentIdentifierHandler.xMaxYMax();
1489                    current = reader.read();
1490                    break;
1491                case 'i':
1492                    current = reader.read();
1493                    switch (current) {
1494                    case 'd':
1495                        fragmentIdentifierHandler.xMaxYMid();
1496                        current = reader.read();
1497                        break;
1498                    case 'n':
1499                        fragmentIdentifierHandler.xMaxYMin();
1500                        current = reader.read();
1501                        break;
1502                    default:
1503                        reportError("character.unexpected",
1504                                    new Object JavaDoc[] { new Integer JavaDoc(current) });
1505                        skipIdentifier();
1506                        break align;
1507                    }
1508                }
1509                break;
1510            case 'i':
1511                current = reader.read();
1512                switch (current) {
1513                case 'd':
1514                    current = reader.read();
1515                    if (current != 'Y') {
1516                        reportError("character.expected",
1517                                    new Object JavaDoc[] { new Character JavaDoc('Y'),
1518                                                   new Integer JavaDoc(current) });
1519                        skipIdentifier();
1520                        break align;
1521                    }
1522                    current = reader.read();
1523                    if (current != 'M') {
1524                        reportError("character.expected",
1525                                    new Object JavaDoc[] { new Character JavaDoc('M'),
1526                                                   new Integer JavaDoc(current) });
1527                        skipIdentifier();
1528                        break align;
1529                    }
1530                    current = reader.read();
1531                    switch (current) {
1532                    case 'a':
1533                        current = reader.read();
1534                        if (current != 'x') {
1535                            reportError
1536                                ("character.expected",
1537                                 new Object JavaDoc[] { new Character JavaDoc('x'),
1538                                                    new Integer JavaDoc(current) });
1539                            skipIdentifier();
1540                            break align;
1541                        }
1542                        fragmentIdentifierHandler.xMidYMax();
1543                        current = reader.read();
1544                        break;
1545                    case 'i':
1546                        current = reader.read();
1547                        switch (current) {
1548                        case 'd':
1549                            fragmentIdentifierHandler.xMidYMid();
1550                            current = reader.read();
1551                            break;
1552                        case 'n':
1553                            fragmentIdentifierHandler.xMidYMin();
1554                            current = reader.read();
1555                            break;
1556                        default:
1557                            reportError("character.unexpected",
1558                                        new Object JavaDoc[] { new Integer JavaDoc(current) });
1559                            skipIdentifier();
1560                            break align;
1561                        }
1562                    }
1563                    break;
1564                case 'n':
1565                    current = reader.read();
1566                    if (current != 'Y') {
1567                        reportError("character.expected",
1568                                    new Object JavaDoc[] { new Character JavaDoc('Y'),
1569                                                   new Integer JavaDoc(current) });
1570                        skipIdentifier();
1571                        break align;
1572                    }
1573                    current = reader.read();
1574                    if (current != 'M') {
1575                        reportError("character.expected",
1576                                    new Object JavaDoc[] { new Character JavaDoc('M'),
1577                                                   new Integer JavaDoc(current) });
1578                        skipIdentifier();
1579                        break align;
1580                    }
1581                    current = reader.read();
1582                    switch (current) {
1583                    case 'a':
1584                        current = reader.read();
1585                        if (current != 'x') {
1586                            reportError
1587                                ("character.expected",
1588                                 new Object JavaDoc[] { new Character JavaDoc('x'),
1589                                                new Integer JavaDoc(current) });
1590                            skipIdentifier();
1591                            break align;
1592                        }
1593                        fragmentIdentifierHandler.xMinYMax();
1594                        current = reader.read();
1595                        break;
1596                    case 'i':
1597                        current = reader.read();
1598                        switch (current) {
1599                        case 'd':
1600                            fragmentIdentifierHandler.xMinYMid();
1601                            current = reader.read();
1602                            break;
1603                        case 'n':
1604                            fragmentIdentifierHandler.xMinYMin();
1605                            current = reader.read();
1606                            break;
1607                        default:
1608                            reportError
1609                                ("character.unexpected",
1610                                 new Object JavaDoc[] { new Integer JavaDoc(current) });
1611                            skipIdentifier();
1612                            break align;
1613                        }
1614                    }
1615                    break;
1616                default:
1617                    reportError("character.unexpected",
1618                                new Object JavaDoc[] { new Integer JavaDoc(current) });
1619                    skipIdentifier();
1620                    break align;
1621                }
1622                break;
1623            default:
1624                reportError("character.unexpected",
1625                            new Object JavaDoc[] { new Integer JavaDoc(current) });
1626                skipIdentifier();
1627            }
1628            break;
1629        default:
1630            if (current != -1) {
1631                reportError("character.unexpected",
1632                            new Object JavaDoc[] { new Integer JavaDoc(current) });
1633                skipIdentifier();
1634            }
1635        }
1636
1637        skipCommaSpaces();
1638
1639        switch (current) {
1640        case 'm':
1641            current = reader.read();
1642            if (current != 'e') {
1643                reportError("character.expected",
1644                            new Object JavaDoc[] { new Character JavaDoc('e'),
1645                                           new Integer JavaDoc(current) });
1646                skipIdentifier();
1647                break;
1648            }
1649            current = reader.read();
1650            if (current != 'e') {
1651                reportError("character.expected",
1652                            new Object JavaDoc[] { new Character JavaDoc('e'),
1653                                            new Integer JavaDoc(current) });
1654                skipIdentifier();
1655                break;
1656            }
1657            current = reader.read();
1658            if (current != 't') {
1659                reportError("character.expected",
1660                            new Object JavaDoc[] { new Character JavaDoc('t'),
1661                                           new Integer JavaDoc(current) });
1662                skipIdentifier();
1663                break;
1664            }
1665            fragmentIdentifierHandler.meet();
1666            current = reader.read();
1667            break;
1668        case 's':
1669            current = reader.read();
1670            if (current != 'l') {
1671                reportError("character.expected",
1672                            new Object JavaDoc[] { new Character JavaDoc('l'),
1673                                           new Integer JavaDoc(current) });
1674                skipIdentifier();
1675                break;
1676            }
1677            current = reader.read();
1678            if (current != 'i') {
1679                reportError("character.expected",
1680                            new Object JavaDoc[] { new Character JavaDoc('i'),
1681                                           new Integer JavaDoc(current) });
1682                skipIdentifier();
1683                break;
1684            }
1685            current = reader.read();
1686            if (current != 'c') {
1687                reportError("character.expected",
1688                            new Object JavaDoc[] { new Character JavaDoc('c'),
1689                                           new Integer JavaDoc(current) });
1690                skipIdentifier();
1691                break;
1692            }
1693            current = reader.read();
1694            if (current != 'e') {
1695                reportError("character.expected",
1696                            new Object JavaDoc[] { new Character JavaDoc('e'),
1697                                           new Integer JavaDoc(current) });
1698                skipIdentifier();
1699                break;
1700            }
1701            fragmentIdentifierHandler.slice();
1702            current = reader.read();
1703        }
1704
1705        fragmentIdentifierHandler.endPreserveAspectRatio();
1706    }
1707
1708    /**
1709     * Skips characters in the given reader until a white space is encountered.
1710     */

1711    protected void skipIdentifier() throws IOException JavaDoc {
1712        loop: for (;;) {
1713          current = reader.read();
1714          switch(current) {
1715              case 0xD: case 0xA: case 0x20: case 0x9:
1716                  current = reader.read();
1717              case -1:
1718                  break loop;
1719          }
1720      }
1721    }
1722}
1723
Popular Tags