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.

AbstractAction.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.render.intermediate.extensions;
  19. import org.apache.xmlgraphics.util.XMLizable;
  20. import org.apache.fop.accessibility.StructureTreeElement;
  21. /**
  22. * Abstract base class for document actions, like "go-to" actions with absolute page coordinates.
  23. */
  24. public abstract class AbstractAction implements XMLizable {
  25. private String id;
  26. private StructureTreeElement structureTreeElement;
  27. /**
  28. * Sets an ID to make the action referencable.
  29. * @param id the ID
  30. */
  31. public void setID(String id) {
  32. this.id = id;
  33. }
  34. /**
  35. * Returns an optional ID for this action.
  36. * @return the ID or null
  37. */
  38. public String getID() {
  39. return this.id;
  40. }
  41. /**
  42. * Sets the structure element corresponding to this action.
  43. * @param structureTreeElement a reference to the structure element
  44. */
  45. public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
  46. this.structureTreeElement = structureTreeElement;
  47. }
  48. /**
  49. * Returns the structure element corresponding to this action.
  50. * @return the reference to the structure element
  51. */
  52. public StructureTreeElement getStructureTreeElement() {
  53. return structureTreeElement;
  54. }
  55. /**
  56. * Indicates whether the action has an ID and is therefore referencable.
  57. * @return true if the action has an ID
  58. */
  59. public boolean hasID() {
  60. return this.id != null;
  61. }
  62. /**
  63. * Indicates whether two action are equal. Note: this is not the same as
  64. * {@link Object#equals(Object)}!
  65. * @param other the other action to compare to
  66. * @return true if the actions are equal
  67. */
  68. public abstract boolean isSame(AbstractAction other);
  69. /**
  70. * Indicates whether the action is complete, i.e has all the required information to be
  71. * rendered in the target format.
  72. * @return true if the action is complete
  73. */
  74. public boolean isComplete() {
  75. return true;
  76. }
  77. /**
  78. * Returns a string that is used to prefix a generated ID to make it unique.
  79. * @return the prefix string
  80. */
  81. public String getIDPrefix() {
  82. return null;
  83. }
  84. }