diff options
author | Keiron Liddle <keiron@apache.org> | 2002-10-25 09:29:48 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-10-25 09:29:48 +0000 |
commit | f4277e55a8810a0badd3a0dbb233178b678d0119 (patch) | |
tree | 9563455dd2f825ac8c0a24d19e99da70f2d7ec10 /src/org/apache/fop/fo/expr | |
parent | 40209c4fc88254b792d07b63be3955c8288b3e7a (diff) | |
download | xmlgraphics-fop-f4277e55a8810a0badd3a0dbb233178b678d0119.tar.gz xmlgraphics-fop-f4277e55a8810a0badd3a0dbb233178b678d0119.zip |
more style fixes
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/expr')
-rw-r--r-- | src/org/apache/fop/fo/expr/AbsFunction.java | 7 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/CeilingFunction.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/FloorFunction.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/MaxFunction.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/MinFunction.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/Numeric.java | 43 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/PropertyInfo.java | 5 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/PropertyParser.java | 45 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/PropertyTokenizer.java | 33 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/RoundFunction.java | 9 |
10 files changed, 101 insertions, 65 deletions
diff --git a/src/org/apache/fop/fo/expr/AbsFunction.java b/src/org/apache/fop/fo/expr/AbsFunction.java index 7a40c9d39..85847796d 100644 --- a/src/org/apache/fop/fo/expr/AbsFunction.java +++ b/src/org/apache/fop/fo/expr/AbsFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -18,9 +18,10 @@ public class AbsFunction extends FunctionBase { public Property eval(Property[] args, PropertyInfo propInfo) throws PropertyException { Numeric num = args[0].getNumeric(); - if (num == null) + if (num == null) { throw new PropertyException("Non numeric operand to abs function"); - // What if has relative composants (percent, table-col units)? + } + // What if has relative composants (percent, table-col units)? return new NumericProperty(num.abs()); } diff --git a/src/org/apache/fop/fo/expr/CeilingFunction.java b/src/org/apache/fop/fo/expr/CeilingFunction.java index 9f4200415..b02a260f2 100644 --- a/src/org/apache/fop/fo/expr/CeilingFunction.java +++ b/src/org/apache/fop/fo/expr/CeilingFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -19,9 +19,11 @@ class CeilingFunction extends FunctionBase { public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); - if (dbl == null) + if (dbl == null) { throw new PropertyException("Non number operand to ceiling function"); + } return new NumberProperty(Math.ceil(dbl.doubleValue())); } } + diff --git a/src/org/apache/fop/fo/expr/FloorFunction.java b/src/org/apache/fop/fo/expr/FloorFunction.java index 868067bd7..6b26d6224 100644 --- a/src/org/apache/fop/fo/expr/FloorFunction.java +++ b/src/org/apache/fop/fo/expr/FloorFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -20,9 +20,11 @@ class FloorFunction extends FunctionBase { public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); - if (dbl == null) + if (dbl == null) { throw new PropertyException("Non number operand to floor function"); + } return new NumberProperty(Math.floor(dbl.doubleValue())); } } + diff --git a/src/org/apache/fop/fo/expr/MaxFunction.java b/src/org/apache/fop/fo/expr/MaxFunction.java index 1a145a567..80b1a6bbe 100644 --- a/src/org/apache/fop/fo/expr/MaxFunction.java +++ b/src/org/apache/fop/fo/expr/MaxFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -20,9 +20,11 @@ public class MaxFunction extends FunctionBase { PropertyInfo pInfo) throws PropertyException { Numeric n1 = args[0].getNumeric(); Numeric n2 = args[1].getNumeric(); - if (n1 == null || n2 == null) + if (n1 == null || n2 == null) { throw new PropertyException("Non numeric operands to max function"); + } return new NumericProperty(n1.max(n2)); } } + diff --git a/src/org/apache/fop/fo/expr/MinFunction.java b/src/org/apache/fop/fo/expr/MinFunction.java index 4691e7588..097d80db5 100644 --- a/src/org/apache/fop/fo/expr/MinFunction.java +++ b/src/org/apache/fop/fo/expr/MinFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -20,9 +20,11 @@ public class MinFunction extends FunctionBase { PropertyInfo pInfo) throws PropertyException { Numeric n1 = args[0].getNumeric(); Numeric n2 = args[1].getNumeric(); - if (n1 == null || n2 == null) + if (n1 == null || n2 == null) { throw new PropertyException("Non numeric operands to min function"); + } return new NumericProperty(n1.min(n2)); } } + diff --git a/src/org/apache/fop/fo/expr/Numeric.java b/src/org/apache/fop/fo/expr/Numeric.java index 68a8d15a7..98eb9529c 100644 --- a/src/org/apache/fop/fo/expr/Numeric.java +++ b/src/org/apache/fop/fo/expr/Numeric.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -123,7 +123,7 @@ public class Numeric { */ public Length asLength() { if (dim == 1) { - Vector len = new Vector(3); + Vector len = new Vector(3); if ((valType & ABS_LENGTH) != 0) { len.add(new FixedLength((int)absValue)); } @@ -133,12 +133,11 @@ public class Numeric { if ((valType & TCOL_LENGTH) != 0) { len.add(new TableColLength(tcolValue)); } - if (len.size() == 1) { - return (Length)len.elementAt(0); - } - else { - return new MixedLength(len); - } + if (len.size() == 1) { + return (Length)len.elementAt(0); + } else { + return new MixedLength(len); + } } else { // or throw exception??? // can't make Length if dimension != 1 @@ -192,8 +191,9 @@ public class Numeric { private boolean isMixedType() { int ntype = 0; for (int t = valType; t != 0; t = t >> 1) { - if ((t & 1) != 0) + if ((t & 1) != 0) { ++ntype; + } } return ntype > 1; } @@ -333,16 +333,18 @@ public class Numeric { double rslt = 0.0; // Only compare if have same dimension and value type! if (dim == op.dim && valType == op.valType &&!isMixedType()) { - if (valType == ABS_LENGTH) + if (valType == ABS_LENGTH) { rslt = absValue - op.absValue; - else if (valType == PC_LENGTH) + } else if (valType == PC_LENGTH) { rslt = pcValue - op.pcValue; - else if (valType == TCOL_LENGTH) + } else if (valType == TCOL_LENGTH) { rslt = tcolValue - op.tcolValue; - if (rslt > 0.0) + } + if (rslt > 0.0) { return this; - else + } else { return op; + } } throw new PropertyException("Arguments to max() must have same dimension and value type."); } @@ -357,18 +359,21 @@ public class Numeric { double rslt = 0.0; // Only compare if have same dimension and value type! if (dim == op.dim && valType == op.valType &&!isMixedType()) { - if (valType == ABS_LENGTH) + if (valType == ABS_LENGTH) { rslt = absValue - op.absValue; - else if (valType == PC_LENGTH) + } else if (valType == PC_LENGTH) { rslt = pcValue - op.pcValue; - else if (valType == TCOL_LENGTH) + } else if (valType == TCOL_LENGTH) { rslt = tcolValue - op.tcolValue; - if (rslt > 0.0) + } + if (rslt > 0.0) { return op; - else + } else { return this; + } } throw new PropertyException("Arguments to min() must have same dimension and value type."); } } + diff --git a/src/org/apache/fop/fo/expr/PropertyInfo.java b/src/org/apache/fop/fo/expr/PropertyInfo.java index 747ec17af..5424abf7f 100644 --- a/src/org/apache/fop/fo/expr/PropertyInfo.java +++ b/src/org/apache/fop/fo/expr/PropertyInfo.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -77,8 +77,9 @@ public class PropertyInfo { } public void popFunction() { - if (stkFunction != null) + if (stkFunction != null) { stkFunction.pop(); + } } private PercentBase getFunctionPercentBase() { diff --git a/src/org/apache/fop/fo/expr/PropertyParser.java b/src/org/apache/fop/fo/expr/PropertyParser.java index aa113834a..50e16e8c9 100644 --- a/src/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/org/apache/fop/fo/expr/PropertyParser.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -25,9 +25,9 @@ import java.util.HashMap; public class PropertyParser extends PropertyTokenizer { private PropertyInfo propInfo; // Maker and propertyList related info - static private final String RELUNIT = "em"; - static private final Numeric negOne = new Numeric(new Double(-1.0)); - static final private HashMap functionTable = new HashMap(); + private static final String RELUNIT = "em"; + private static final Numeric negOne = new Numeric(new Double(-1.0)); + private static final HashMap functionTable = new HashMap(); static { // Initialize the HashMap of XSL-defined functions @@ -107,8 +107,9 @@ public class PropertyParser extends PropertyTokenizer { if (propList != null) { propList.addProperty(prop); return propList; - } else + } else { return prop; + } } else { if (propList == null) { propList = new ListProperty(prop); @@ -129,7 +130,7 @@ public class PropertyParser extends PropertyTokenizer { // Evaluate and put result on the operand stack Property prop = parseMultiplicativeExpr(); loop: - for (; ; ) { + for (; ;) { switch (currentToken) { case TOK_PLUS: next(); @@ -156,7 +157,7 @@ public class PropertyParser extends PropertyTokenizer { private Property parseMultiplicativeExpr() throws PropertyException { Property prop = parseUnaryExpr(); loop: - for (; ; ) { + for (; ;) { switch (currentToken) { case TOK_DIV: next(); @@ -198,8 +199,9 @@ public class PropertyParser extends PropertyTokenizer { * and throws an exception if this isn't the case. */ private final void expectRpar() throws PropertyException { - if (currentToken != TOK_RPAR) + if (currentToken != TOK_RPAR) { throw new PropertyException("expected )"); + } next(); } @@ -272,13 +274,15 @@ public class PropertyParser extends PropertyTokenizer { if (unitPart.equals(RELUNIT)) { length = new FixedLength(numPart.doubleValue(), propInfo.currentFontSize()); - } else + } else { length = new FixedLength(numPart.doubleValue(), unitPart); + } if (length == null) { throw new PropertyException("unrecognized unit name: " + currentTokenValue); - } else + } else { prop = new LengthProperty(length); + } break; case TOK_COLORSPEC: @@ -331,8 +335,9 @@ public class PropertyParser extends PropertyTokenizer { args[i++] = prop; } // ignore extra args - if (currentToken != TOK_COMMA) + if (currentToken != TOK_COMMA) { break; + } next(); } expectRpar(); @@ -355,8 +360,9 @@ public class PropertyParser extends PropertyTokenizer { */ private Property evalAddition(Numeric op1, Numeric op2) throws PropertyException { - if (op1 == null || op2 == null) + if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in addition"); + } return new NumericProperty(op1.add(op2)); } @@ -371,8 +377,9 @@ public class PropertyParser extends PropertyTokenizer { */ private Property evalSubtraction(Numeric op1, Numeric op2) throws PropertyException { - if (op1 == null || op2 == null) + if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in subtraction"); + } return new NumericProperty(op1.subtract(op2)); } @@ -385,8 +392,9 @@ public class PropertyParser extends PropertyTokenizer { * @throws PropertyException If the operand is null. */ private Property evalNegate(Numeric op) throws PropertyException { - if (op == null) + if (op == null) { throw new PropertyException("Non numeric operand to unary minus"); + } return new NumericProperty(op.multiply(negOne)); } @@ -401,8 +409,9 @@ public class PropertyParser extends PropertyTokenizer { */ private Property evalMultiply(Numeric op1, Numeric op2) throws PropertyException { - if (op1 == null || op2 == null) + if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in multiplication"); + } return new NumericProperty(op1.multiply(op2)); } @@ -418,8 +427,9 @@ public class PropertyParser extends PropertyTokenizer { */ private Property evalDivide(Numeric op1, Numeric op2) throws PropertyException { - if (op1 == null || op2 == null) + if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in division"); + } return new NumericProperty(op1.divide(op2)); } @@ -434,8 +444,9 @@ public class PropertyParser extends PropertyTokenizer { */ private Property evalModulo(Number op1, Number op2) throws PropertyException { - if (op1 == null || op2 == null) + if (op1 == null || op2 == null) { throw new PropertyException("Non number operand to modulo"); + } return new NumberProperty(op1.doubleValue() % op2.doubleValue()); } diff --git a/src/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/org/apache/fop/fo/expr/PropertyTokenizer.java index 025c68695..573670631 100644 --- a/src/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/org/apache/fop/fo/expr/PropertyTokenizer.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -71,7 +71,7 @@ class PropertyTokenizer { boolean currentMaybeOperator = recognizeOperator; boolean bSawDecimal; recognizeOperator = true; - for (; ; ) { + for (; ;) { if (exprIndex >= exprLength) { currentToken = TOK_EOF; return; @@ -145,8 +145,9 @@ class PropertyTokenizer { exprIndex++; scanDigits(); } - } else + } else { bSawDecimal = false; + } if (exprIndex < exprLength && expr.charAt(exprIndex) == '%') { exprIndex++; currentToken = TOK_PERCENT; @@ -195,14 +196,16 @@ class PropertyTokenizer { exprIndex); // Probably should have some multiple of 3 for length! return; - } else + } else { throw new PropertyException("illegal character '#'"); + } default: --exprIndex; scanName(); - if (exprIndex == currentTokenStartIndex) + if (exprIndex == currentTokenStartIndex) { throw new PropertyException("illegal character"); + } currentTokenValue = expr.substring(currentTokenStartIndex, exprIndex); // if (currentMaybeOperator) { @@ -236,9 +239,10 @@ class PropertyTokenizer { * Attempt to recognize a valid NAME token in the input expression. */ private void scanName() { - if (exprIndex < exprLength && isNameStartChar(expr.charAt(exprIndex))) + if (exprIndex < exprLength && isNameStartChar(expr.charAt(exprIndex))) { while (++exprIndex < exprLength - && isNameChar(expr.charAt(exprIndex))); + && isNameChar(expr.charAt(exprIndex))) { } + } } /** @@ -246,8 +250,9 @@ class PropertyTokenizer { * input expression. */ private void scanDigits() { - while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex))) + while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex))) { exprIndex++; + } } /** @@ -255,8 +260,9 @@ class PropertyTokenizer { * input expression. */ private void scanHexDigits() { - while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex))) + while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex))) { exprIndex++; + } } /** @@ -282,11 +288,11 @@ class PropertyTokenizer { } - static private final String nameStartChars = + private static final String nameStartChars = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static private final String nameChars = ".-0123456789"; - static private final String digits = "0123456789"; - static private final String hexchars = digits + "abcdefABCDEF"; + private static final String nameChars = ".-0123456789"; + private static final String digits = "0123456789"; + private static final String hexchars = digits + "abcdefABCDEF"; /** * Return a boolean value indicating whether the argument is a @@ -342,3 +348,4 @@ class PropertyTokenizer { } } + diff --git a/src/org/apache/fop/fo/expr/RoundFunction.java b/src/org/apache/fop/fo/expr/RoundFunction.java index 81d51b113..d5fcd23d9 100644 --- a/src/org/apache/fop/fo/expr/RoundFunction.java +++ b/src/org/apache/fop/fo/expr/RoundFunction.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -19,13 +19,16 @@ class RoundFunction extends FunctionBase { public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { Number dbl = args[0].getNumber(); - if (dbl == null) + if (dbl == null) { throw new PropertyException("Non number operand to round function"); + } double n = dbl.doubleValue(); double r = Math.floor(n + 0.5); - if (r == 0.0 && n < 0.0) + if (r == 0.0 && n < 0.0) { r = -r; // round(-0.2) returns -0 not 0 + } return new NumberProperty(r); } } + |