diff options
author | Glenn Adams <gadams@apache.org> | 2012-04-22 20:09:42 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2012-04-22 20:09:42 +0000 |
commit | 41d337ba2c4ec959d33085507c0acdc0683db028 (patch) | |
tree | 0caa282c53fbd34a698331bd20b7161dfe98c97e /src/java/org/apache/fop | |
parent | 0b18292f887bb18afb46eb75ae92d7731ee5644b (diff) | |
download | xmlgraphics-fop-41d337ba2c4ec959d33085507c0acdc0683db028.tar.gz xmlgraphics-fop-41d337ba2c4ec959d33085507c0acdc0683db028.zip |
Snapshot commit - does not build!
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1328963 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
23 files changed, 203 insertions, 247 deletions
diff --git a/src/java/org/apache/fop/fo/expr/AbsFunction.java b/src/java/org/apache/fop/fo/expr/AbsFunction.java index 0e8355faa..9c266da76 100644 --- a/src/java/org/apache/fop/fo/expr/AbsFunction.java +++ b/src/java/org/apache/fop/fo/expr/AbsFunction.java @@ -27,22 +27,13 @@ import org.apache.fop.fo.properties.Property; */ public class AbsFunction extends FunctionBase { - /** - * @return 1 (the number of arguments required for the abs function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 1; } - /** - * @param args array of arguments to be evaluated, the first of which - * should be a numeric value - * @param propInfo the PropertyInfo object to be evaluated - * @return the absolute value of the input - * @throws PropertyException for non-numeric input - */ - public Property eval(Property[] args, - PropertyInfo propInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo propInfo) throws PropertyException { Numeric num = args[0].getNumeric(); if (num == null) { throw new PropertyException("Non numeric operand to abs function"); diff --git a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java index 5307e75b0..1b04ec9d1 100644 --- a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java +++ b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java @@ -31,22 +31,13 @@ import org.apache.fop.fo.properties.Property; */ public class BodyStartFunction extends FunctionBase { - /** - * @return 0 (there are no arguments for body-start) - */ - public int nbArgs() { - return 0; + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 1; } - /** - * @param args array of arguments (none are used, but this is required by - * the Function interface) - * @param pInfo PropertyInfo object to be evaluated - * @return numeric object containing the calculated body-start value - * @throws PropertyException if called from outside of an fo:list-item - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Numeric distance = pInfo.getPropertyList() .get(Constants.PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS).getNumeric(); diff --git a/src/java/org/apache/fop/fo/expr/CIELabColorFunction.java b/src/java/org/apache/fop/fo/expr/CIELabColorFunction.java index d027a9571..9783f5384 100644 --- a/src/java/org/apache/fop/fo/expr/CIELabColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/CIELabColorFunction.java @@ -30,29 +30,25 @@ import org.apache.fop.fo.properties.Property; */ class CIELabColorFunction extends FunctionBase { - /** - * cie-lab-color() takes 2 times 3 arguments. - * {@inheritDoc} - */ - public int nbArgs() { - return 2 * 3; + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 6; } + @Override + /** {@inheritDoc} */ public PercentBase getPercentBase() { return new CIELabPercentBase(); } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { float red = args[0].getNumber().floatValue(); float green = args[1].getNumber().floatValue(); float blue = args[2].getNumber().floatValue(); /* Verify sRGB replacement arguments */ - if ((red < 0 || red > 255) - || (green < 0 || green > 255) - || (blue < 0 || blue > 255)) { + if ((red < 0 || red > 255) || (green < 0 || green > 255) || (blue < 0 || blue > 255)) { throw new PropertyException("sRGB color values out of range. " + "Arguments to cie-lab-color() must be [0..255] or [0%..100%]"); } diff --git a/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java b/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java index fe86860f4..cf2d7bad0 100644 --- a/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java +++ b/src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java @@ -27,17 +27,13 @@ import org.apache.fop.fo.properties.Property; */ class CMYKcolorFunction extends FunctionBase { - /** - * cmyk takes four arguments. - * {@inheritDoc} - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 4; } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { StringBuffer sb = new StringBuffer(); sb.append("cmyk(" + args[0] + "," + args[1] + "," + args[2] + "," + args[3] + ")"); FOUserAgent ua = (pInfo == null) diff --git a/src/java/org/apache/fop/fo/expr/CeilingFunction.java b/src/java/org/apache/fop/fo/expr/CeilingFunction.java index 875c88751..9c69cd1bc 100644 --- a/src/java/org/apache/fop/fo/expr/CeilingFunction.java +++ b/src/java/org/apache/fop/fo/expr/CeilingFunction.java @@ -24,12 +24,13 @@ import org.apache.fop.fo.properties.Property; class CeilingFunction extends FunctionBase { - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 1; } - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); if (dbl == null) { throw new PropertyException("Non number operand to ceiling function"); diff --git a/src/java/org/apache/fop/fo/expr/FloorFunction.java b/src/java/org/apache/fop/fo/expr/FloorFunction.java index 043473140..501b8d59d 100644 --- a/src/java/org/apache/fop/fo/expr/FloorFunction.java +++ b/src/java/org/apache/fop/fo/expr/FloorFunction.java @@ -25,12 +25,13 @@ import org.apache.fop.fo.properties.Property; class FloorFunction extends FunctionBase { - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 1; } - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); if (dbl == null) { throw new PropertyException("Non number operand to floor function"); diff --git a/src/java/org/apache/fop/fo/expr/FromParentFunction.java b/src/java/org/apache/fop/fo/expr/FromParentFunction.java index b1e9d689d..e24074e9d 100644 --- a/src/java/org/apache/fop/fo/expr/FromParentFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromParentFunction.java @@ -29,29 +29,29 @@ import org.apache.fop.fo.properties.Property; */ public class FromParentFunction extends FunctionBase { - /** - * @return 1 (maximum arguments for the from-parent function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 0; + } + + @Override + /** {@inheritDoc} */ + public int getOptionalArgsCount() { return 1; } - /** - * @return true (allow padding of arglist with property name) - */ - public boolean padArgsWithPropertyName() { - return true; + @Override + /** {@inheritDoc} */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { + if ( index == 0 ) { + return getPropertyName ( pi ); + } else { + return super.getOptionalArgDefault ( index, pi ); + } } - /** - * @param args array of arguments, which should either be empty, or the - * first of which should contain an NCName corresponding to property name - * @param pInfo PropertyInfo object to be evaluated - * @return property containing the computed value - * @throws PropertyException if the arguments are incorrect - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { String propName = args[0].getString(); if (propName == null) { throw new PropertyException("Incorrect parameter to from-parent function"); diff --git a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java index 627459cf1..dc51c2670 100644 --- a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java @@ -37,32 +37,29 @@ import org.apache.fop.fo.properties.Property; */ public class FromTableColumnFunction extends FunctionBase { - /** - * @return 1 (maximum arguments for the from-table-column function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 0; + } + + @Override + /** {@inheritDoc} */ + public int getOptionalArgsCount() { return 1; } - /** - * @return true (allow padding of arglist with property name) - */ - public boolean padArgsWithPropertyName() { - return true; + @Override + /** {@inheritDoc} */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { + if ( index == 0 ) { + return getPropertyName ( pi ); + } else { + return super.getOptionalArgDefault ( index, pi ); + } } - /** - * - * @param args array of arguments, which should either be empty, or the - * first of which should contain an NCName corresponding to a property name - * @param pInfo PropertyInfo object to be evaluated - * @return the Property corresponding to the property name specified, or, if - * none, for the property for which the expression is being evaluated - * @throws PropertyException for incorrect arguments, and (for now) in all - * cases, because this function is not implemented - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args,PropertyInfo pInfo) throws PropertyException { FObj fo = pInfo.getPropertyList().getFObj(); diff --git a/src/java/org/apache/fop/fo/expr/Function.java b/src/java/org/apache/fop/fo/expr/Function.java index 82ec1b7fd..4a0331b66 100644 --- a/src/java/org/apache/fop/fo/expr/Function.java +++ b/src/java/org/apache/fop/fo/expr/Function.java @@ -28,11 +28,34 @@ import org.apache.fop.fo.properties.Property; public interface Function { /** - * @return the number of arguments that must be passed to this function. For - * example, if the function should determine the minimum of two numbers, it - * must be passed two arguments, one for each of the two values. + * @return the number of required (non-optional) arguments that must be specified + * in the argument list */ - int nbArgs(); + int getRequiredArgsCount(); + + /** + * @return the number of non-required (optional) arguments that may be specified + * in the argument list, which, if specified, must follow the required arguments + */ + int getOptionalArgsCount(); + + /** + * @param index of optional argument + * @param pi property information instance that applies to property being evaluated + * @return the default property value for the optional argument at INDEX, where + * INDEX is with respect to optional arguments; i.e., the first optional argument + * position is index 0; if no default for a given index, then null is returned + * @throws PropertyException if index is greater than or equal to optional args count + */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException; + + /** + * Determine if function allows variable arguments. If it does, then they must appear + * after required and optional arguments, and all optional arguments must be specified. + * @return true if function permits additional variable number of arguments after + * required and (completely specified) optional arguments + */ + boolean hasVariableArgs(); /** * @return the basis for percentage calculations @@ -42,16 +65,10 @@ public interface Function { /** * Evaluate the function * @param args an array of Properties that should be evaluated - * @param propInfo the PropertyInfo + * @param pi property information instance that applies to property being evaluated * @return the Property satisfying the function * @throws PropertyException for problems when evaluating the function */ - Property eval(Property[] args, - PropertyInfo propInfo) throws PropertyException; + Property eval(Property[] args, PropertyInfo pi) throws PropertyException; - /** - * @return if it is allowed to fill up the property list with - * the property name if only one arg is missing. - */ - boolean padArgsWithPropertyName(); } diff --git a/src/java/org/apache/fop/fo/expr/FunctionBase.java b/src/java/org/apache/fop/fo/expr/FunctionBase.java index b5040c635..019304858 100644 --- a/src/java/org/apache/fop/fo/expr/FunctionBase.java +++ b/src/java/org/apache/fop/fo/expr/FunctionBase.java @@ -26,17 +26,37 @@ import org.apache.fop.datatypes.PercentBase; */ public abstract class FunctionBase implements Function { - /** - * @return null (by default, functions have no percent-based arguments) - */ + /** {@inheritDoc} */ + public int getOptionalArgsCount() { + return 0; + } + + /** {@inheritDoc} */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) new PropertyException { + if ( index >= getOptionalArgsCount() ) { + PropertyException e = new PropertyException ( new IndexOutOfBoundException ( "illegal optional argument index" ) ); + e.setPropertyInfo ( pi ); + throw e; + } else { + return null; + } + } + + /** {@inheritDoc} */ + public int hasVariableArgs() { + return false; + } + + /** {@inheritDoc} */ public PercentBase getPercentBase() { return null; } /** - * @return false (by default don't pad arglist with property-name) + * @param pi property information instance that applies to property being evaluated + * @return string property whose value is name of property being evaluated */ - public boolean padArgsWithPropertyName() { - return false; + protected final Property getPropertyName ( PropertyInfo pi ) { + return StringProperty.getInstance ( pi.getPropertMaker().getName() ); } } diff --git a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java index 756de1b20..981be2830 100644 --- a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java @@ -31,24 +31,25 @@ import org.apache.fop.util.ColorUtil; */ class ICCColorFunction extends FunctionBase { - /** - * rgb-icc takes a variable number of arguments. - * At least 4 should be passed - returns -4 - * {@inheritDoc} - */ - public int nbArgs() { - return -4; + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 4; } + @Override /** {@inheritDoc} */ + public int hasVariableArgs() { + return true; + } + @Override + /** {@inheritDoc} */ public PercentBase getPercentBase() { return new ICCPercentBase(); } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { // Map color profile NCNAME to src from declarations/color-profile element String colorProfileName = args[3].getString(); Declarations decls = (pInfo.getFO() != null @@ -86,9 +87,7 @@ class ICCColorFunction extends FunctionBase { green = args[1].getNumber().floatValue(); blue = args[2].getNumber().floatValue(); /* Verify rgb replacement arguments */ - if ((red < 0 || red > 255) - || (green < 0 || green > 255) - || (blue < 0 || blue > 255)) { + if ((red < 0 || red > 255) || (green < 0 || green > 255) || (blue < 0 || blue > 255)) { throw new PropertyException("Color values out of range. " + "Arguments to rgb-icc() must be [0..255] or [0%..100%]"); } diff --git a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java index 94c4fdf22..6e982bd31 100644 --- a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java @@ -28,30 +28,29 @@ import org.apache.fop.fo.properties.Property; */ public class InheritedPropFunction extends FunctionBase { - /** - * @return 1 (maximum number of arguments for the inherited-property-value - * function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 0; + } + + @Override + /** {@inheritDoc} */ + public int getOptionalArgsCount() { return 1; } - /** - * @return true (allow padding of arglist with property name) - */ - public boolean padArgsWithPropertyName() { - return true; + @Override + /** {@inheritDoc} */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { + if ( index == 0 ) { + return getPropertyName ( pi ); + } else { + return super.getOptionalArgDefault ( index, pi ); + } } - /** - * - * @param args arguments to be evaluated - * @param pInfo PropertyInfo object to be evaluated - * @return Property satisfying the inherited-property-value - * @throws PropertyException for invalid parameter - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { String propName = args[0].getString(); if (propName == null) { throw new PropertyException("Incorrect parameter to inherited-property-value function"); diff --git a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java index 5deb3ae30..57facc058 100644 --- a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java @@ -34,23 +34,13 @@ import org.apache.fop.fo.properties.Property; */ public class LabelEndFunction extends FunctionBase { - /** - * @return 0 (the number of arguments required for the label-end function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 0; } - /** - * - * @param args array of arguments for the function (none are needed, but - * required for the Function interface) - * @param pInfo PropertyInfo object for the function - * @return the calculated label-end value for the list - * @throws PropertyException if called from outside of an fo:list-item - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Length distance = pInfo.getPropertyList().get( Constants.PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS).getLength(); diff --git a/src/java/org/apache/fop/fo/expr/MaxFunction.java b/src/java/org/apache/fop/fo/expr/MaxFunction.java index fd2fee0b1..442197de6 100644 --- a/src/java/org/apache/fop/fo/expr/MaxFunction.java +++ b/src/java/org/apache/fop/fo/expr/MaxFunction.java @@ -28,22 +28,13 @@ import org.apache.fop.fo.properties.Property; */ public class MaxFunction extends FunctionBase { - /** - * @return 2 (the number of arguments required for the max function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 2; } - /** - * Handle "numerics" if no proportional/percent parts - * @param args array of arguments to be processed - * @param pInfo PropertyInfo to be processed - * @return the maximum of the two args elements passed - * @throws PropertyException for invalid operands - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Numeric n1 = args[0].getNumeric(); Numeric n2 = args[1].getNumeric(); if (n1 == null || n2 == null) { diff --git a/src/java/org/apache/fop/fo/expr/MinFunction.java b/src/java/org/apache/fop/fo/expr/MinFunction.java index 979d16b27..19a06ada1 100644 --- a/src/java/org/apache/fop/fo/expr/MinFunction.java +++ b/src/java/org/apache/fop/fo/expr/MinFunction.java @@ -28,22 +28,13 @@ import org.apache.fop.fo.properties.Property; */ public class MinFunction extends FunctionBase { - /** - * @return 2 (the number of arguments required for the min function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 2; } - /** - * Handle "numerics" if no proportional/percent parts - * @param args array of arguments to be processed - * @param pInfo PropertyInfo to be processed - * @return the minimum of the two args elements passed - * @throws PropertyException for invalid operands - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Numeric n1 = args[0].getNumeric(); Numeric n2 = args[1].getNumeric(); if (n1 == null || n2 == null) { diff --git a/src/java/org/apache/fop/fo/expr/NamedColorFunction.java b/src/java/org/apache/fop/fo/expr/NamedColorFunction.java index f2ff19ef1..9ad87a980 100644 --- a/src/java/org/apache/fop/fo/expr/NamedColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/NamedColorFunction.java @@ -31,11 +31,8 @@ import org.apache.fop.fo.properties.Property; */ class NamedColorFunction extends FunctionBase { - /** - * rgb-named-color() takes a 5 arguments. - * {@inheritDoc} - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 5; } @@ -46,8 +43,7 @@ class NamedColorFunction extends FunctionBase { } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { // Map color profile NCNAME to src from declarations/color-profile element String colorProfileName = args[3].getString(); String colorName = args[4].getString(); diff --git a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java index 3e0dda565..bd02c30bc 100644 --- a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java @@ -28,30 +28,29 @@ import org.apache.fop.fo.properties.Property; */ public class NearestSpecPropFunction extends FunctionBase { - /** - * @return 1 (maximum number of arguments for from-nearest-specified-value - * function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { + return 0; + } + + @Override + /** {@inheritDoc} */ + public int getOptionalArgsCount() { return 1; } - /** - * @return true (allow padding of arglist with property name) - */ - public boolean padArgsWithPropertyName() { - return true; + @Override + /** {@inheritDoc} */ + public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException { + if ( index == 0 ) { + return getPropertyName ( pi ); + } else { + return super.getOptionalArgDefault ( index, pi ); + } } - /** - * - * @param args array of arguments for the function - * @param pInfo PropertyInfo for the function - * @return Property containing the nearest-specified-value - * @throws PropertyException for invalid arguments to the function - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { String propName = args[0].getString(); if (propName == null) { throw new PropertyException( diff --git a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java index 5defda0fe..4ae7065c4 100644 --- a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java +++ b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java @@ -32,32 +32,19 @@ import org.apache.fop.fo.properties.TableColLength; */ public class PPColWidthFunction extends FunctionBase { - /** - * @return 1 (the number of arguments for the proportional-column-width - * function) - */ - public int nbArgs() { + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 1; } - /** - * @return the {@link PercentBase} for the proportional-column-width() - * function - */ + @Override + /** {@inheritDoc} */ public PercentBase getPercentBase() { return new PPColWidthPercentBase(); } - /** - * - * @param args array of arguments for this function - * @param pInfo PropertyInfo for this function - * @return numeric Property containing the units of proportional measure - * for this column - * @throws PropertyException for non-numeric operand, or if the parent - * element is not a table-column - */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number d = args[0].getNumber(); if (d == null) { throw new PropertyException("Non numeric operand to " diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index 9ef45befe..a144431e8 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -59,13 +59,11 @@ public final class PropertyParser extends PropertyTokenizer { FUNCTION_TABLE.put("rgb", new RGBColorFunction()); FUNCTION_TABLE.put("system-color", new SystemColorFunction()); FUNCTION_TABLE.put("from-table-column", new FromTableColumnFunction()); - FUNCTION_TABLE.put("inherited-property-value", - new InheritedPropFunction()); + FUNCTION_TABLE.put("inherited-property-value", new InheritedPropFunction()); + FUNCTION_TABLE.put("from-nearest-specified-value", new NearestSpecPropFunction()); + FUNCTION_TABLE.put("from-page-master-region", new FromPageMasterRegionFunction()); FUNCTION_TABLE.put("from-parent", new FromParentFunction()); - FUNCTION_TABLE.put("from-nearest-specified-value", - new NearestSpecPropFunction()); - FUNCTION_TABLE.put("proportional-column-width", - new PPColWidthFunction()); + FUNCTION_TABLE.put("proportional-column-width", new PPColWidthFunction()); FUNCTION_TABLE.put("label-end", new LabelEndFunction()); FUNCTION_TABLE.put("body-start", new BodyStartFunction()); FUNCTION_TABLE.put("rgb-icc", new ICCColorFunction()); @@ -379,7 +377,6 @@ public final class PropertyParser extends PropertyTokenizer { next(); } else { while (true) { - prop = parseAdditiveExpr(); if (i < nbArgs) { args[i++] = prop; diff --git a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java index e07f3c433..3c9c81d27 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java @@ -67,7 +67,7 @@ class PropertyTokenizer { } /** - * Return the next token in the expression string. + * Parse the next token in the expression string. * This sets the following package visible variables: * currentToken An enumerated value identifying the recognized token * currentTokenValue A String containing the token contents diff --git a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java index 868b9a8bf..9f8a7f600 100644 --- a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java @@ -30,22 +30,18 @@ import org.apache.fop.fo.properties.Property; class RGBColorFunction extends FunctionBase { /** {@inheritDoc} */ - public int nbArgs() { + public int getRequiredArgsCount() { return 3; } - /** - * @return an object which implements the PercentBase interface. - * Percents in arguments to this function are interpreted relative - * to 255. - */ + @Override + /** {@inheritDoc} */ public PercentBase getPercentBase() { return new RGBPercentBase(); } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { return ColorProperty.getInstance(pInfo.getUserAgent(), "rgb(" + args[0] + "," + args[1] + "," + args[2] + ")"); diff --git a/src/java/org/apache/fop/fo/expr/RoundFunction.java b/src/java/org/apache/fop/fo/expr/RoundFunction.java index a29c33e5b..201039b5a 100644 --- a/src/java/org/apache/fop/fo/expr/RoundFunction.java +++ b/src/java/org/apache/fop/fo/expr/RoundFunction.java @@ -24,12 +24,14 @@ import org.apache.fop.fo.properties.NumberProperty; import org.apache.fop.fo.properties.Property; class RoundFunction extends FunctionBase { - public int nbArgs() { + + /** {@inheritDoc} */ + public int getRequiredArgsCount() { return 1; } - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + /** {@inheritDoc} */ + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); if (dbl == null) { throw new PropertyException("Non number operand to round function"); diff --git a/src/java/org/apache/fop/fo/expr/SystemColorFunction.java b/src/java/org/apache/fop/fo/expr/SystemColorFunction.java index eeb1870f7..8ec88e983 100644 --- a/src/java/org/apache/fop/fo/expr/SystemColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/SystemColorFunction.java @@ -29,13 +29,12 @@ import org.apache.fop.fo.properties.Property; class SystemColorFunction extends FunctionBase { /** {@inheritDoc} */ - public int nbArgs() { + public int getRequiredArgsCount() { return 1; } /** {@inheritDoc} */ - public Property eval(Property[] args, - PropertyInfo pInfo) throws PropertyException { + public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { FOUserAgent ua = (pInfo == null) ? null : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent()); |