Browse Source

Make property function class names more consistent.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1328964 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Glenn Adams 12 years ago
parent
commit
c15b4a103d

+ 1
- 1
src/java/org/apache/fop/fo/expr/BodyStartFunction.java View File

@@ -33,7 +33,7 @@ public class BodyStartFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {
return 1;
return 0;
}

/** {@inheritDoc} */

src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java → src/java/org/apache/fop/fo/expr/CMYKColorFunction.java View File

@@ -25,7 +25,7 @@ import org.apache.fop.fo.properties.Property;
/**
* Implements the cmyk() function.
*/
class CMYKcolorFunction extends FunctionBase {
class CMYKColorFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {

src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java → src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java View File

@@ -26,7 +26,7 @@ import org.apache.fop.fo.properties.Property;
* Class modelling the from-nearest-specified-value function. See Sec. 5.10.4
* of the XSL-FO standard.
*/
public class NearestSpecPropFunction extends FunctionBase {
public class FromNearestSpecifiedValueFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {

+ 6
- 4
src/java/org/apache/fop/fo/expr/FunctionBase.java View File

@@ -20,6 +20,8 @@
package org.apache.fop.fo.expr;

import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.StringProperty;

/**
* Abstract Base class for XSL-FO functions
@@ -32,9 +34,9 @@ public abstract class FunctionBase implements Function {
}

/** {@inheritDoc} */
public Property getOptionalArgDefault(int index, PropertyInfo pi) new PropertyException {
public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException {
if ( index >= getOptionalArgsCount() ) {
PropertyException e = new PropertyException ( new IndexOutOfBoundException ( "illegal optional argument index" ) );
PropertyException e = new PropertyException ( new IndexOutOfBoundsException ( "illegal optional argument index" ) );
e.setPropertyInfo ( pi );
throw e;
} else {
@@ -43,7 +45,7 @@ public abstract class FunctionBase implements Function {
}

/** {@inheritDoc} */
public int hasVariableArgs() {
public boolean hasVariableArgs() {
return false;
}

@@ -57,6 +59,6 @@ public abstract class FunctionBase implements Function {
* @return string property whose value is name of property being evaluated
*/
protected final Property getPropertyName ( PropertyInfo pi ) {
return StringProperty.getInstance ( pi.getPropertMaker().getName() );
return StringProperty.getInstance ( pi.getPropertyMaker().getName() );
}
}

+ 26
- 78
src/java/org/apache/fop/fo/expr/PropertyParser.java View File

@@ -60,16 +60,15 @@ public final class PropertyParser extends PropertyTokenizer {
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("from-nearest-specified-value", new NearestSpecPropFunction());
FUNCTION_TABLE.put("from-page-master-region", new FromPageMasterRegionFunction());
FUNCTION_TABLE.put("from-nearest-specified-value", new FromNearestSpecifiedValueFunction());
FUNCTION_TABLE.put("from-parent", new FromParentFunction());
FUNCTION_TABLE.put("proportional-column-width", new PPColWidthFunction());
FUNCTION_TABLE.put("proportional-column-width", new ProportionalColumnWidthFunction());
FUNCTION_TABLE.put("label-end", new LabelEndFunction());
FUNCTION_TABLE.put("body-start", new BodyStartFunction());
FUNCTION_TABLE.put("rgb-icc", new ICCColorFunction());
FUNCTION_TABLE.put("rgb-named-color", new NamedColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("rgb-icc", new RGBICCColorFunction());
FUNCTION_TABLE.put("rgb-named-color", new RGBNamedColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("cie-lab-color", new CIELabColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("cmyk", new CMYKcolorFunction()); //non-standard!!!
FUNCTION_TABLE.put("cmyk", new CMYKColorFunction()); //non-standard!!!

/**
* * NOT YET IMPLEMENTED!!!
@@ -339,12 +338,7 @@ public final class PropertyParser extends PropertyTokenizer {
next();
// Push new function (for function context: getPercentBase())
propInfo.pushFunction(function);
if (function.nbArgs() < 0) {
// Negative nbArgs --> function with variable number of arguments
prop = function.eval(parseVarArgs(function), propInfo);
} else {
prop = function.eval(parseArgs(function), propInfo);
}
prop = function.eval(parseArgs(function), propInfo);
propInfo.popFunction();
return prop;

@@ -360,26 +354,27 @@ public final class PropertyParser extends PropertyTokenizer {
* Parse a comma separated list of function arguments. Each argument
* may itself be an expression. This method consumes the closing right
* parenthesis of the argument list.
* @param function The function object for which the arguments are
* collected.
* @return An array of Property objects representing the arguments
* found.
* @param function The function object for which the arguments are collected.
* @return An array of Property objects representing the arguments found.
* @throws PropertyException If the number of arguments found isn't equal
* to the number expected.
* to the number expected or if another argument parsing error occurs.
*/
Property[] parseArgs(Function function) throws PropertyException {
int nbArgs = function.nbArgs();
Property[] args = new Property[nbArgs];
Property prop;
int i = 0;
int numReq = function.getRequiredArgsCount(); // # required args
int numOpt = function.getOptionalArgsCount(); // # optional args
boolean hasVar = function.hasVariableArgs(); // has variable args
List<Property> args = new java.util.ArrayList<Property>(numReq + numOpt);
if (currentToken == TOK_RPAR) {
// No args: func()
next();
} else {
while (true) {
prop = parseAdditiveExpr();
if (i < nbArgs) {
args[i++] = prop;
Property p = parseAdditiveExpr();
int i = args.size();
if ( ( i < numReq ) || ( ( i - numReq ) < numOpt ) || hasVar ) {
args.add ( p );
} else {
throw new PropertyException ( "Unexpected function argument at index " + i );
}
// ignore extra args
if (currentToken != TOK_COMMA) {
@@ -389,66 +384,19 @@ public final class PropertyParser extends PropertyTokenizer {
}
expectRpar();
}
if (i == nbArgs - 1 && function.padArgsWithPropertyName()) {
args[i++] = StringProperty.getInstance(
propInfo.getPropertyMaker().getName());
}
if (nbArgs != i) {
throw new PropertyException("Expected " + nbArgs
+ ", but got " + i + " args for function");
}
return args;
}

/**
*
* Parse a comma separated list of function arguments. Each argument
* may itself be an expression. This method consumes the closing right
* parenthesis of the argument list.
*
* The method differs from parseArgs in that it accepts a variable
* number of arguments.
*
* @param function The function object for which the arguments are
* collected.
* @return An array of Property objects representing the arguments
* found.
* @throws PropertyException If the number of arguments found isn't equal
* to the number expected.
*
* TODO Merge this with parseArgs?
*/
Property[] parseVarArgs(Function function) throws PropertyException {
// For variable argument functions the minimum number of arguments is returned as a
// negative integer from the nbArgs method
int nbArgs = -function.nbArgs();
List args = new LinkedList();
Property prop;
if (currentToken == TOK_RPAR) {
// No args: func()
next();
int numArgs = args.size();
if ( numArgs < numReq ) {
throw new PropertyException("Expected " + numReq + " required arguments, but only " + numArgs + " specified");
} else {
while (true) {
prop = parseAdditiveExpr();
args.add(prop);
// ignore extra args
if (currentToken != TOK_COMMA) {
break;
for ( int i = 0; i < numOpt; i++ ) {
if ( args.size() < ( numReq + i + 1 ) ) {
args.add ( function.getOptionalArgDefault ( i, propInfo ) );
}
next();
}
expectRpar();
}
if (nbArgs > args.size()) {
throw new PropertyException("Expected at least " + nbArgs
+ ", but got " + args.size() + " args for function");
}
Property[] propArray = new Property[args.size()];
args.toArray(propArray);
return propArray;
return (Property[]) args.toArray ( new Property [ args.size() ] );
}


/**
* Evaluate an addition operation. If either of the arguments is null,
* this means that it wasn't convertible to a Numeric value.

src/java/org/apache/fop/fo/expr/PPColWidthFunction.java → src/java/org/apache/fop/fo/expr/ProportionalColumnWidthFunction.java View File

@@ -30,7 +30,7 @@ import org.apache.fop.fo.properties.TableColLength;
* Class modelling the proportional-column-width function. See Sec. 5.10.4 of
* the XSL-FO standard.
*/
public class PPColWidthFunction extends FunctionBase {
public class ProportionalColumnWidthFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {
@@ -40,7 +40,7 @@ public class PPColWidthFunction extends FunctionBase {
@Override
/** {@inheritDoc} */
public PercentBase getPercentBase() {
return new PPColWidthPercentBase();
return new ProportionalColumnWidthPercentBase();
}

/** {@inheritDoc} */
@@ -65,7 +65,7 @@ public class PPColWidthFunction extends FunctionBase {
return new TableColLength(d.doubleValue(), pInfo.getFO());
}

private static class PPColWidthPercentBase implements PercentBase {
private static class ProportionalColumnWidthPercentBase implements PercentBase {

/** {@inheritDoc} */
public int getBaseLength(PercentBaseContext context) throws PropertyException {

src/java/org/apache/fop/fo/expr/ICCColorFunction.java → src/java/org/apache/fop/fo/expr/RGBICCColorFunction.java View File

@@ -29,7 +29,7 @@ import org.apache.fop.util.ColorUtil;
/**
* Implements the rgb-icc() function.
*/
class ICCColorFunction extends FunctionBase {
class RGBICCColorFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {
@@ -38,7 +38,7 @@ class ICCColorFunction extends FunctionBase {

@Override
/** {@inheritDoc} */
public int hasVariableArgs() {
public boolean hasVariableArgs() {
return true;
}


src/java/org/apache/fop/fo/expr/NamedColorFunction.java → src/java/org/apache/fop/fo/expr/RGBNamedColorFunction.java View File

@@ -29,7 +29,7 @@ import org.apache.fop.fo.properties.Property;
* Implements the rgb-named-color() function.
* @since XSL-FO 2.0
*/
class NamedColorFunction extends FunctionBase {
class RGBNamedColorFunction extends FunctionBase {

/** {@inheritDoc} */
public int getRequiredArgsCount() {
@@ -39,7 +39,7 @@ class NamedColorFunction extends FunctionBase {
/** {@inheritDoc} */
@Override
public PercentBase getPercentBase() {
return new NamedPercentBase();
return new RGBNamedPercentBase();
}

/** {@inheritDoc} */
@@ -92,7 +92,7 @@ class NamedColorFunction extends FunctionBase {
return ColorProperty.getInstance(pInfo.getUserAgent(), sb.toString());
}

private static final class NamedPercentBase implements PercentBase {
private static final class RGBNamedPercentBase implements PercentBase {

/** {@inheritDoc} */
public int getBaseLength(PercentBaseContext context) throws PropertyException {

Loading…
Cancel
Save