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.

Numeric.java 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.datatypes;
  19. import org.apache.fop.fo.expr.PropertyException;
  20. /**
  21. * An interface for classes that can participate in numeric operations.
  22. * All the numeric operation (+, -, *, ...) are expressed in terms of
  23. * this Numeric interface.
  24. * Numerics has a value (getNumericValue) and a dimension (getDimension).
  25. * Numerics can be either absolute or relative. Relative numerics
  26. * must be resolved against base value before the value can be used.
  27. * <p>
  28. * To support relative numerics internally in the expresion parser and
  29. * during evaulation one additional methods exists: isAbsolute() which
  30. * return true for absolute numerics and false for relative numerics.
  31. */
  32. public interface Numeric {
  33. /**
  34. * Return the value of this Numeric
  35. * @return the computed value.
  36. * @throws PropertyException if a propert exception occurs
  37. */
  38. double getNumericValue() throws PropertyException;
  39. /**
  40. * Return the value of this Numeric
  41. * @param context The context for the length calculation (for percentage based lengths)
  42. * @return the computed value.
  43. * @throws PropertyException if a propert exception occurs
  44. */
  45. double getNumericValue(PercentBaseContext context) throws PropertyException;
  46. /**
  47. * Return the dimension of this numeric. Plain numbers has a dimension of
  48. * 0 and length has a dimension of 1. Other dimension can occur as a result
  49. * of multiplications and divisions.
  50. * @return the dimension.
  51. */
  52. int getDimension();
  53. /**
  54. * Return true if the numeric is an absolute value. Relative values are
  55. * percentages and table-column-units. All other numerics are absolute.
  56. * @return true when the numeric is absolute.
  57. */
  58. boolean isAbsolute();
  59. /**
  60. * Returns the value of this numeric as an int.
  61. * @return the value as an integer.
  62. */
  63. int getValue();
  64. /**
  65. * Returns the value of this numeric as an int.
  66. * @param context the context for the length calculation (for percentage based lengths)
  67. * @return the value as an integer.
  68. */
  69. int getValue(PercentBaseContext context);
  70. /**
  71. * Return the resolved value. This method will becalled during evaluation
  72. * of the expression tree and relative numerics can then return a
  73. * resolved absolute Numeric. Absolute numerics can just return themself.
  74. *
  75. * @return A resolved value.
  76. * @throws PropertyException
  77. */
  78. //Numeric getResolved() throws PropertyException;
  79. /**
  80. * Return the enum value that is stored in this numeric.
  81. * @return the enum value
  82. */
  83. int getEnum();
  84. }