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.

EnumLength.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.fo.properties;
  19. import org.apache.fop.datatypes.PercentBaseContext;
  20. import org.apache.fop.util.CompareUtil;
  21. /**
  22. * A length quantity in XSL which is specified as an enum, such as "auto"
  23. */
  24. public class EnumLength extends LengthProperty {
  25. private Property enumProperty;
  26. /**
  27. * Construct an enumerated length from an enum property.
  28. * @param enumProperty the enumeration property
  29. */
  30. public EnumLength(Property enumProperty) {
  31. this.enumProperty = enumProperty;
  32. }
  33. /**
  34. * {@inheritDoc}
  35. */
  36. public int getEnum() {
  37. return enumProperty.getEnum();
  38. }
  39. /** @return true if absolute */
  40. public boolean isAbsolute() {
  41. return false;
  42. }
  43. /**
  44. * {@inheritDoc}
  45. */
  46. public int getValue() {
  47. log.error("getValue() called on " + enumProperty + " length");
  48. return 0;
  49. }
  50. /**
  51. * {@inheritDoc}
  52. */
  53. public int getValue(PercentBaseContext context) {
  54. log.error("getValue() called on " + enumProperty + " length");
  55. return 0;
  56. }
  57. /**
  58. * {@inheritDoc}
  59. */
  60. public double getNumericValue() {
  61. log.error("getNumericValue() called on " + enumProperty + " number");
  62. return 0;
  63. }
  64. /**
  65. * {@inheritDoc}
  66. */
  67. public double getNumericValue(PercentBaseContext context) {
  68. log.error("getNumericValue() called on " + enumProperty + " number");
  69. return 0;
  70. }
  71. /**
  72. * {@inheritDoc}
  73. */
  74. public String getString() {
  75. return enumProperty.toString();
  76. }
  77. /**
  78. * {@inheritDoc}
  79. */
  80. public Object getObject() {
  81. return enumProperty.getObject();
  82. }
  83. @Override
  84. public int hashCode() {
  85. return enumProperty.hashCode();
  86. }
  87. @Override
  88. public boolean equals(Object obj) {
  89. if (this == obj) {
  90. return true;
  91. }
  92. if (!(obj instanceof EnumLength)) {
  93. return false;
  94. }
  95. EnumLength other = (EnumLength) obj;
  96. return CompareUtil.equal(enumProperty, other.enumProperty);
  97. }
  98. }