You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2007/02/01 10:26:52 UTC
svn commit: r502167 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/
Author: dvholten
Date: Thu Feb 1 01:26:51 2007
New Revision: 502167
URL: http://svn.apache.org/viewvc?view=rev&rev=502167
Log:
simplify error-exceptions
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AbstractParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AngleParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/FragmentIdentifierParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthListParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthPairListParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberListParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PathParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PreserveAspectRatioParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingSpecifierListParser.java
xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TransformListParser.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AbstractParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AbstractParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AbstractParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AbstractParser.java Thu Feb 1 01:26:51 2007
@@ -188,6 +188,17 @@
}
+ /**
+ * simple api to call often reported error.
+ * Just a wrapper for reportError().
+ *
+ * @param currentChar what the caller found and didnt expect
+ */
+ protected void reportUnexpectedCharacterError( int currentChar ){
+ reportError("character.unexpected",
+ new Object[] { new Integer( currentChar ) });
+
+ }
/**
* Returns a localized error message.
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AngleParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AngleParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AngleParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/AngleParser.java Thu Feb 1 01:26:51 2007
@@ -125,8 +125,7 @@
current = reader.read();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexptedCharacterError( current );
}
}
@@ -136,8 +135,7 @@
new Object[] { new Integer(current) });
}
} catch (NumberFormatException e) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexptedCharacterError( current );
}
angleHandler.endAngle();
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/FragmentIdentifierParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/FragmentIdentifierParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/FragmentIdentifierParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/FragmentIdentifierParser.java Thu Feb 1 01:26:51 2007
@@ -1441,16 +1441,4 @@
}
}
- /**
- * Convenience method to simplify error-reporting.
- * We just wrap the data into a call to
- * {@link #reportError(String,Object[])}.
- *
- * @param actual the actual current character
- */
- private void reportUnexpectedCharacterError( int actual ){
- reportError("character.unexpected",
- new Object[] { new Integer( actual ) });
- }
-
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthListParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthListParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthListParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthListParser.java Thu Feb 1 01:26:51 2007
@@ -66,7 +66,7 @@
current = reader.read();
skipSpaces();
-
+
try {
for (;;) {
lengthHandler.startLength();
@@ -78,8 +78,7 @@
}
}
} catch (NumberFormatException e) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
((LengthListHandler)lengthHandler).endLengthList();
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthPairListParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthPairListParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthPairListParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthPairListParser.java Thu Feb 1 01:26:51 2007
@@ -53,15 +53,13 @@
break;
}
if (current != ';') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
skipSpaces();
}
} catch (NumberFormatException e) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
((LengthListHandler) lengthHandler).endLengthList();
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/LengthParser.java Thu Feb 1 01:26:51 2007
@@ -104,8 +104,7 @@
m1: switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
case '.':
@@ -151,8 +150,7 @@
default:
case 'e': case 'E':
if (!mantRead) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
}
break;
@@ -199,21 +197,18 @@
current = reader.read();
switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
case 'm':
if (!le) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
}
unitState = 1;
break es;
case 'x':
if (!le) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
}
unitState = 2;
@@ -224,8 +219,7 @@
current = reader.read();
switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -301,8 +295,7 @@
current = reader.read();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
break;
@@ -322,15 +315,14 @@
current = reader.read();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
break;
case 'i':
current = reader.read();
if (current != 'n') {
- reportCharacterExpectedError( 'n',current );
+ reportCharacterExpectedError( 'n', current );
break;
}
lengthHandler.in();
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberListParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberListParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberListParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberListParser.java Thu Feb 1 01:26:51 2007
@@ -82,8 +82,7 @@
}
}
} catch (NumberFormatException e) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
numberListHandler.endNumberList();
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/NumberParser.java Thu Feb 1 01:26:51 2007
@@ -52,9 +52,8 @@
m1: switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
- return 0f;
+ reportUnexpectedCharacterError( current );
+ return 0.0f;
case '.':
break;
@@ -70,7 +69,7 @@
case '.': case 'e': case 'E':
break m1;
default:
- return 0f;
+ return 0.0f;
case '0':
}
}
@@ -101,9 +100,8 @@
default:
case 'e': case 'E':
if (!mantRead) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
- return 0f;
+ reportUnexpectedCharacterError( current );
+ return 0.0f;
}
break;
@@ -118,7 +116,7 @@
break l;
default:
if (!mantRead) {
- return 0f;
+ return 0.0f;
}
break m2;
case '0':
@@ -149,8 +147,7 @@
current = reader.read();
switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return 0f;
case '-':
expPos = false;
@@ -158,8 +155,7 @@
current = reader.read();
switch (current) {
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
return 0f;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PathParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PathParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PathParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PathParser.java Thu Feb 1 01:26:51 2007
@@ -205,7 +205,7 @@
float x = parseFloat();
skipCommaSpaces();
float y = parseFloat();
-
+
pathHandler.linetoAbs(x, y);
expectNumber = skipCommaSpaces2();
}
@@ -700,9 +700,9 @@
}
}
- protected void reportUnexpected(int ch)
+ protected void reportUnexpected(int ch)
throws ParseException, IOException {
- reportError("character.unexpected", new Object[] { new Integer(ch) });
+ reportUnexpectedCharacterError( current );
skipSubPath();
}
@@ -719,7 +719,7 @@
current = reader.read();
}
- if (current != ',')
+ if (current != ',')
return false; // no comma.
wsp2: for (;;) {
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PreserveAspectRatioParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PreserveAspectRatioParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PreserveAspectRatioParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/PreserveAspectRatioParser.java Thu Feb 1 01:26:51 2007
@@ -159,8 +159,7 @@
current = reader.read();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
break align;
}
@@ -206,8 +205,7 @@
current = reader.read();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
break align;
}
@@ -250,31 +248,26 @@
current = reader.read();
break;
default:
- reportError
- ("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
break align;
}
}
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
break align;
}
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
}
break;
default:
if (current != -1) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
}
}
@@ -334,8 +327,7 @@
break;
default:
if (current != -1) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipIdentifier();
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingParser.java Thu Feb 1 01:26:51 2007
@@ -98,8 +98,7 @@
} else if (XMLUtilities.isXMLNameFirstCharacter((char) current)) {
ret = parseIDValue(escaped);
} else {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
return ret;
}
@@ -134,8 +133,7 @@
|| id.equals("accesskey"))
&& !escaped) {
if (current != '(') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
if (current == -1) {
@@ -144,8 +142,7 @@
char key = (char) current;
current = reader.read();
if (current != ')') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
skipSpaces();
@@ -158,8 +155,7 @@
new Character(key) };
} else if (id.equals("accessKey") && useSVG12AccessKeys && !escaped) {
if (current != '(') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
StringBuffer keyName = new StringBuffer();
@@ -171,8 +167,7 @@
current = reader.read();
}
if (current != ')') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
skipSpaces();
@@ -185,8 +180,7 @@
keyName.toString() };
} else if (id.equals("wallclock") && !escaped) {
if (current != '(') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
skipSpaces();
@@ -208,8 +202,7 @@
current = reader.read();
}
if (!XMLUtilities.isXMLNameFirstCharacter((char) current)) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
String id2 = parseName();
if ((id2.equals("begin") || id2.equals("end")) && !escaped) {
@@ -228,8 +221,7 @@
current = reader.read();
repeatIteration = new Integer(parseDigits());
if (current != ')') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
}
@@ -244,13 +236,11 @@
repeatIteration };
} else if (id2.equals("marker") && !escaped) {
if (current != '(') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
String markerName = parseName();
if (current != ')') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
return new Object[] { new Integer(TIME_MEDIA_MARKER),
@@ -335,8 +325,7 @@
protected int parseDigits() throws ParseException, IOException {
int value = 0;
if (current < '0' || current > '9') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
do {
value = value * 10 + (current - '0');
@@ -351,8 +340,7 @@
protected float parseFraction() throws ParseException, IOException {
float value = 0;
if (current < '0' || current > '9') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
float weight = 0.1f;
do {
@@ -375,8 +363,7 @@
if (current == 'i') {
current = reader.read();
if (current != 'n') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
return 60;
@@ -384,8 +371,7 @@
current = reader.read();
return 0.001f;
} else {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
} else if (current == 's') {
current = reader.read();
@@ -414,8 +400,7 @@
current = reader.read();
M = parseDigits();
if (current != '-') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
current = reader.read();
d = parseDigits();
@@ -425,8 +410,7 @@
current = reader.read();
digits1 = parseDigits();
if (current != ':') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
}
if (current == ':') {
@@ -462,8 +446,7 @@
}
tznb.append(tzh);
if (current != ':') {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
tznb.append(':');
current = reader.read();
@@ -477,8 +460,7 @@
}
} while (false);
if (!dateSpecified && !timeSpecified) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
Calendar wallclockTime;
if (tzSpecified) {
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingSpecifierListParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingSpecifierListParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingSpecifierListParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TimingSpecifierListParser.java Thu Feb 1 01:26:51 2007
@@ -80,16 +80,14 @@
current = reader.read();
continue;
}
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
}
skipSpaces();
if (current != -1) {
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
}
((TimingSpecifierListHandler) timingSpecifierHandler)
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TransformListParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TransformListParser.java?view=diff&rev=502167&r1=502166&r2=502167
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TransformListParser.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/parser/TransformListParser.java Thu Feb 1 01:26:51 2007
@@ -98,16 +98,14 @@
parseSkew();
break;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipTransform();
}
break;
case -1:
break loop;
default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
+ reportUnexpectedCharacterError( current );
skipTransform();
}
} catch (ParseException e) {
@@ -436,6 +434,7 @@
switch (current) {
case 'X':
skewX = true;
+ // fall through
case 'Y':
break;
default: