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.

FONode.java 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * $Id: FONode.java,v 1.34 2003/03/05 21:48:02 jeremias Exp $
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.fo;
  52. // Java
  53. import java.util.ListIterator;
  54. // XML
  55. import org.xml.sax.Attributes;
  56. // Avalon
  57. import org.apache.avalon.framework.logger.Logger;
  58. // FOP
  59. import org.apache.fop.apps.FOPException;
  60. import org.apache.fop.apps.StructureHandler;
  61. import org.apache.fop.util.CharUtilities;
  62. /**
  63. * base class for nodes in the XML tree
  64. *
  65. */
  66. public abstract class FONode {
  67. /** FO User Agent for this node (for logger etc.)*/
  68. protected FOUserAgent userAgent;
  69. /** Parent FO node */
  70. protected FONode parent;
  71. /** Name of the node */
  72. protected String name;
  73. /**
  74. * Main constructor.
  75. * @param parent parent of this node
  76. */
  77. protected FONode(FONode parent) {
  78. this.parent = parent;
  79. }
  80. /**
  81. * Sets the name of the node.
  82. * @param str the name
  83. */
  84. public void setName(String str) {
  85. name = str;
  86. }
  87. /**
  88. * Returns the logger for the node.
  89. * @return the logger
  90. */
  91. protected Logger getLogger() {
  92. return userAgent.getLogger();
  93. }
  94. /**
  95. * Sets the user agent for the node.
  96. * @param ua the user agent
  97. */
  98. public void setUserAgent(FOUserAgent ua) {
  99. userAgent = ua;
  100. }
  101. /**
  102. * Returns the user agent for the node.
  103. * @return FOUserAgent
  104. */
  105. protected FOUserAgent getUserAgent() {
  106. return userAgent;
  107. }
  108. /**
  109. * Sets the structure handler to send events to.
  110. * @param st StructureHandler instance
  111. */
  112. public void setStructHandler(StructureHandler st) {
  113. }
  114. public void handleAttrs(Attributes attlist) throws FOPException {
  115. }
  116. /**
  117. * Returns the name of the object
  118. * @return the name of this object
  119. */
  120. public String getName() {
  121. return this.name;
  122. }
  123. /**
  124. * Adds characters (does nothing here)
  125. * @param data text
  126. * @param start start position
  127. * @param length length of the text
  128. */
  129. protected void addCharacters(char data[], int start, int length) {
  130. // ignore
  131. }
  132. /**
  133. *
  134. */
  135. protected void start() {
  136. // do nothing by default
  137. }
  138. /**
  139. *
  140. */
  141. protected void end() {
  142. // do nothing by default
  143. }
  144. protected void addChild(FONode child) {
  145. }
  146. public FONode getParent() {
  147. return this.parent;
  148. }
  149. /**
  150. * Return an iterator over all the children of this FObj.
  151. * @return A ListIterator.
  152. */
  153. public ListIterator getChildren() {
  154. return null;
  155. }
  156. /**
  157. * Return an iterator over the object's children starting
  158. * at the pased node.
  159. * @param childNode First node in the iterator
  160. * @return A ListIterator or null if childNode isn't a child of
  161. * this FObj.
  162. */
  163. public ListIterator getChildren(FONode childNode) {
  164. return null;
  165. }
  166. public CharIterator charIterator() {
  167. return new OneCharIterator(CharUtilities.CODE_EOT);
  168. }
  169. /**
  170. * This is a quick check to see if it is a marker.
  171. * This is needed since there is no other quick way of checking
  172. * for a marker and not adding to the child list.
  173. *
  174. * @return true if this is a marker
  175. */
  176. protected boolean isMarker() {
  177. return false;
  178. }
  179. }