Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Numeric.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /**
  20. * An interface for classes that can participate in numeric operations.
  21. * All the numeric operation (+, -, *, ...) are expressed in terms of
  22. * this Numeric interface.
  23. * Numerics has a value (getNumericValue) and a dimension (getDimension).
  24. * Numerics can be either absolute or relative. Relative numerics
  25. * must be resolved against base value before the value can be used.
  26. * <p>
  27. * To support relative numerics internally in the expression parser and
  28. * during evaluation one additional methods exists: isAbsolute() which
  29. * return true for absolute numerics and false for relative numerics.
  30. */
  31. public interface Numeric {
  32. /**
  33. * Return the value of this Numeric
  34. * @return the computed value.
  35. */
  36. double getNumericValue();
  37. /**
  38. * Return the value of this Numeric
  39. * @param context The context for the length calculation (for percentage based lengths)
  40. * @return the computed value.
  41. */
  42. double getNumericValue(PercentBaseContext context);
  43. /**
  44. * Return the dimension of this numeric. Plain numbers has a dimension of
  45. * 0 and length has a dimension of 1. Other dimension can occur as a result
  46. * of multiplications and divisions.
  47. * @return the dimension.
  48. */
  49. int getDimension();
  50. /**
  51. * Return true if the numeric is an absolute value. Relative values are
  52. * percentages and table-column-units. All other numerics are absolute.
  53. * @return true when the numeric is absolute.
  54. */
  55. boolean isAbsolute();
  56. /**
  57. * Returns the value of this numeric as an int.
  58. * @return the value as an integer.
  59. */
  60. int getValue();
  61. /**
  62. * Returns the value of this numeric as an int.
  63. * @param context the context for the length calculation (for percentage based lengths)
  64. * @return the value as an integer.
  65. */
  66. int getValue(PercentBaseContext context);
  67. /**
  68. * Return the resolved value. This method will be called during evaluation
  69. * of the expression tree and relative numerics can then return a
  70. * resolved absolute Numeric. Absolute numerics can just return themselves.
  71. *
  72. * @return A resolved value.
  73. * @throws PropertyException
  74. */
  75. //Numeric getResolved() throws PropertyException;
  76. /**
  77. * Return the enum value that is stored in this numeric.
  78. * @return the enum value
  79. */
  80. int getEnum();
  81. }