You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbsFunction.java 777B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo.expr;
  8. import org.apache.fop.fo.Property;
  9. public class AbsFunction extends FunctionBase {
  10. public int nbArgs() {
  11. return 1;
  12. }
  13. public Property eval(Property[] args,
  14. PropertyInfo propInfo) throws PropertyException {
  15. Numeric num = args[0].getNumeric();
  16. if (num == null) {
  17. throw new PropertyException("Non numeric operand to abs function");
  18. }
  19. // What if has relative composants (percent, table-col units)?
  20. return new NumericProperty(num.abs());
  21. }
  22. }