1 18 package org.apache.batik.parser; 19 20 import java.io.IOException ; 21 22 29 30 public class AngleParser extends NumberParser { 31 32 35 protected AngleHandler angleHandler = DefaultAngleHandler.INSTANCE; 36 37 48 public void setAngleHandler(AngleHandler handler) { 49 angleHandler = handler; 50 } 51 52 55 public AngleHandler getAngleHandler() { 56 return angleHandler; 57 } 58 59 62 protected void doParse() throws ParseException, IOException { 63 angleHandler.startAngle(); 64 65 current = reader.read(); 66 skipSpaces(); 67 68 try { 69 float f = parseFloat(); 70 71 angleHandler.angleValue(f); 72 73 s: if (current != -1) { 74 switch (current) { 75 case 0xD: case 0xA: case 0x20: case 0x9: 76 break s; 77 } 78 79 switch (current) { 80 case 'd': 81 current = reader.read(); 82 if (current != 'e') { 83 reportError("character.expected", 84 new Object [] { new Character ('e'), 85 new Integer (current) }); 86 break; 87 } 88 current = reader.read(); 89 if (current != 'g') { 90 reportError("character.expected", 91 new Object [] { new Character ('g'), 92 new Integer (current) }); 93 break; 94 } 95 angleHandler.deg(); 96 current = reader.read(); 97 break; 98 case 'g': 99 current = reader.read(); 100 if (current != 'r') { 101 reportError("character.expected", 102 new Object [] { new Character ('r'), 103 new Integer (current) }); 104 break; 105 } 106 current = reader.read(); 107 if (current != 'a') { 108 reportError("character.expected", 109 new Object [] { new Character ('a'), 110 new Integer (current) }); 111 break; 112 } 113 current = reader.read(); 114 if (current != 'd') { 115 reportError("character.expected", 116 new Object [] { new Character ('d'), 117 new Integer (current) }); 118 break; 119 } 120 angleHandler.grad(); 121 current = reader.read(); 122 break; 123 case 'r': 124 current = reader.read(); 125 if (current != 'a') { 126 reportError("character.expected", 127 new Object [] { new Character ('a'), 128 new Integer (current) }); 129 break; 130 } 131 current = reader.read(); 132 if (current != 'd') { 133 reportError("character.expected", 134 new Object [] { new Character ('d'), 135 new Integer (current) }); 136 break; 137 } 138 angleHandler.rad(); 139 current = reader.read(); 140 break; 141 default: 142 reportError("character.unexpected", 143 new Object [] { new Integer (current) }); 144 } 145 } 146 147 skipSpaces(); 148 if (current != -1) { 149 reportError("end.of.stream.expected", 150 new Object [] { new Integer (current) }); 151 } 152 } catch (NumberFormatException e) { 153 reportError("character.unexpected", 154 new Object [] { new Integer (current) }); 155 } 156 angleHandler.endAngle(); 157 } 158 } 159 | Popular Tags |