diff options
author | Finn Bock <bckfnn@apache.org> | 2004-10-28 10:00:25 +0000 |
---|---|---|
committer | Finn Bock <bckfnn@apache.org> | 2004-10-28 10:00:25 +0000 |
commit | b0e76bca6ec366023f5f98d8e07aa77dbfabafe1 (patch) | |
tree | ffd62fd750c33c6083daad85feb38a5dbd709de8 /src/java/org/apache/fop/fo/expr | |
parent | 13fdba00ab86701f8e0b4057ecc5bc36375c8ee0 (diff) | |
download | xmlgraphics-fop-b0e76bca6ec366023f5f98d8e07aa77dbfabafe1.tar.gz xmlgraphics-fop-b0e76bca6ec366023f5f98d8e07aa77dbfabafe1.zip |
New exception hierarchy rooted in SAXException and throw clauses on
property parsing and retrieval.
PR: 31899
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198106 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/expr')
5 files changed, 43 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/fo/expr/NumericProperty.java b/src/java/org/apache/fop/fo/expr/NumericProperty.java index 347fc8f84..6f337e0f5 100644 --- a/src/java/org/apache/fop/fo/expr/NumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/NumericProperty.java @@ -104,7 +104,7 @@ public class NumericProperty extends Property implements Numeric, Length { if (dim == 1) { return this; } - System.err.print("Can't create length with dimension " + dim); + log.error("Can't create length with dimension " + dim); return null; } diff --git a/src/java/org/apache/fop/fo/expr/PropertyException.java b/src/java/org/apache/fop/fo/expr/PropertyException.java index 50a8c79e7..9ce3224b8 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyException.java +++ b/src/java/org/apache/fop/fo/expr/PropertyException.java @@ -18,10 +18,13 @@ package org.apache.fop.fo.expr; +import org.apache.fop.apps.FOPException; + /** * Class for managing exceptions that are raised in Property processing. */ -public class PropertyException extends Exception { +public class PropertyException extends FOPException { + private String propertyName; /** * Constructor @@ -31,4 +34,24 @@ public class PropertyException extends Exception { super(detail); } + /** + */ + public void setPropertyInfo(PropertyInfo propInfo) { + setLocator(propInfo.getFO().locator); + propertyName = propInfo.getPropertyMaker().getName(); + } + + /** + */ + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public String getMessage() { + if (propertyName != null) { + return super.getMessage() + "; property:'" + propertyName + "'"; + } else { + return super.getMessage(); + } + } } diff --git a/src/java/org/apache/fop/fo/expr/PropertyInfo.java b/src/java/org/apache/fop/fo/expr/PropertyInfo.java index 100b523c6..fb59332de 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyInfo.java +++ b/src/java/org/apache/fop/fo/expr/PropertyInfo.java @@ -65,7 +65,7 @@ public class PropertyInfo { /** * @return the current font-size value as base units (milli-points). */ - public int currentFontSize() { + public int currentFontSize() throws PropertyException { return plist.get(Constants.PR_FONT_SIZE).getLength().getValue(); } @@ -86,6 +86,14 @@ public class PropertyInfo { } /** + * accessor for PropertyMaker + * @return PropertyMaker object + */ + public PropertyMaker getPropertyMaker() { + return maker; + } + + /** * push a function onto the function stack * @param func function to push onto stack */ diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index 51f87f10a..7d77d7f9b 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -85,7 +85,12 @@ public class PropertyParser extends PropertyTokenizer { */ public static Property parse(String expr, PropertyInfo propInfo) throws PropertyException { - return new PropertyParser(expr, propInfo).parseProperty(); + try { + return new PropertyParser(expr, propInfo).parseProperty(); + } catch (PropertyException exc) { + exc.setPropertyInfo(propInfo); + throw exc; + } } @@ -314,6 +319,7 @@ public class PropertyParser extends PropertyTokenizer { return prop; } default: + // TODO: add the token or the expr to the error message. throw new PropertyException("syntax error"); } next(); diff --git a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java index 02d7b4f9c..c20017f85 100755 --- a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java @@ -154,7 +154,7 @@ public class RelativeNumericProperty extends Property implements Numeric, Length if (dimension == 1) { return this; } - System.err.print("Can't create length with dimension " + dimension); + log.error("Can't create length with dimension " + dimension); return null; } @@ -169,7 +169,7 @@ public class RelativeNumericProperty extends Property implements Numeric, Length try { return (int) getNumericValue(); } catch (PropertyException exc) { - exc.printStackTrace(); + log.error(exc); } return 0; } |