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.

Property.java 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 java.util.List;
  20. import java.awt.Color;
  21. import org.apache.commons.logging.Log;
  22. import org.apache.commons.logging.LogFactory;
  23. import org.apache.fop.apps.FOUserAgent;
  24. import org.apache.fop.datatypes.Length;
  25. import org.apache.fop.datatypes.Numeric;
  26. import org.apache.fop.fo.Constants;
  27. /**
  28. * Base class for all property objects
  29. */
  30. public class Property {
  31. /** Logger for all property classes */
  32. protected static final Log log = LogFactory.getLog(PropertyMaker.class);
  33. /**
  34. * The original specified value for properties which inherit
  35. * specified values.
  36. */
  37. private String specVal;
  38. /**
  39. * Set the original value specified for the property attribute.
  40. * @param value The specified value.
  41. */
  42. public void setSpecifiedValue(String value) {
  43. this.specVal = value;
  44. }
  45. /**
  46. * Return the original value specified for the property attribute.
  47. * @return The specified value as a String.
  48. */
  49. public String getSpecifiedValue() {
  50. return specVal;
  51. }
  52. /*
  53. * This section contains accessor functions for all possible Property datatypes
  54. */
  55. /**
  56. * This method expects to be overridden by subclasses
  57. * @return Length property value
  58. */
  59. public Length getLength() {
  60. return null;
  61. }
  62. /**
  63. * This method expects to be overridden by subclasses
  64. * @param foUserAgent FOP user agent
  65. * @return ColorType property value
  66. */
  67. public Color getColor(FOUserAgent foUserAgent) {
  68. return null;
  69. }
  70. /**
  71. * This method expects to be overridden by subclasses
  72. * @return CondLength property value
  73. */
  74. public CondLengthProperty getCondLength() {
  75. return null;
  76. }
  77. /**
  78. * This method expects to be overridden by subclasses
  79. * @return LenghtRange property value
  80. */
  81. public LengthRangeProperty getLengthRange() {
  82. return null;
  83. }
  84. /**
  85. * This method expects to be overridden by subclasses
  86. * @return LengthPair property value
  87. */
  88. public LengthPairProperty getLengthPair() {
  89. return null;
  90. }
  91. /**
  92. * This method expects to be overridden by subclasses
  93. * @return Space property value
  94. */
  95. public SpaceProperty getSpace() {
  96. return null;
  97. }
  98. /**
  99. * This method expects to be overridden by subclasses
  100. * @return Keep property value
  101. */
  102. public KeepProperty getKeep() {
  103. return null;
  104. }
  105. /**
  106. * This method expects to be overridden by subclasses
  107. * @return integer equivalent of enumerated property value
  108. */
  109. public int getEnum() {
  110. return 0;
  111. }
  112. /** @return true if the property is an enum and has value 'auto' */
  113. public boolean isAuto() {
  114. return (getEnum() == Constants.EN_AUTO);
  115. }
  116. /**
  117. * This method expects to be overridden by subclasses
  118. * @return char property value
  119. */
  120. public char getCharacter() {
  121. return 0;
  122. }
  123. /**
  124. * This method expects to be overridden by subclasses
  125. * @return collection of other property (sub-property) objects
  126. */
  127. public List getList() {
  128. return null;
  129. }
  130. /**
  131. * This method expects to be overridden by subclasses
  132. * @return Number property value
  133. */
  134. public Number getNumber() {
  135. return null;
  136. }
  137. /**
  138. * This method expects to be overridden by subclasses
  139. * @return Numeric property value
  140. */
  141. public Numeric getNumeric() {
  142. return null;
  143. }
  144. /**
  145. * This method expects to be overridden by subclasses
  146. * @return NCname property value
  147. */
  148. public String getNCname() {
  149. return null;
  150. }
  151. /**
  152. * This method expects to be overridden by subclasses
  153. * @return Object property value
  154. */
  155. public Object getObject() {
  156. return null;
  157. }
  158. /**
  159. * This method expects to be overridden by subclasses.
  160. * @return String property value
  161. */
  162. public String getString() {
  163. return null;
  164. }
  165. /** {@inheritDoc} */
  166. public String toString() {
  167. Object obj = getObject();
  168. if (obj != this) {
  169. return obj.toString();
  170. }
  171. return "";
  172. }
  173. }