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.

BookmarkTitle.java 3.4KB

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.pagination.bookmarks;
  19. import org.xml.sax.Locator;
  20. import org.apache.fop.apps.FOPException;
  21. import org.apache.fop.fo.FONode;
  22. import org.apache.fop.fo.FObj;
  23. import org.apache.fop.fo.PropertyList;
  24. import org.apache.fop.fo.ValidationException;
  25. import org.apache.fop.fo.properties.CommonAccessibility;
  26. import org.apache.fop.fo.properties.CommonAccessibilityHolder;
  27. /**
  28. * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_bookmark-title">
  29. * <code>fo:bookmark-title</code></a> object, first introduced in the
  30. * XSL 1.1 WD.
  31. */
  32. public class BookmarkTitle extends FObj implements CommonAccessibilityHolder {
  33. private CommonAccessibility commonAccessibility;
  34. private String title = "";
  35. /**
  36. * Create a new BookmarkTitle object that is a child
  37. * of the given {@link FONode}.
  38. *
  39. * @param parent the {@link FONode} parent
  40. */
  41. public BookmarkTitle(FONode parent) {
  42. super(parent);
  43. }
  44. @Override
  45. public void bind(PropertyList pList) throws FOPException {
  46. super.bind(pList);
  47. commonAccessibility = CommonAccessibility.getInstance(pList);
  48. }
  49. /**
  50. * Add the characters to this BookmarkTitle.
  51. * The text data inside the BookmarkTitle xml element
  52. * is used for the BookmarkTitle string.
  53. *
  54. * @param data the character data
  55. * @param start the start position in the data array
  56. * @param length the length of the character array
  57. * @param pList currently applicable PropertyList
  58. * @param locator location in fo source file.
  59. */
  60. protected void characters(char[] data, int start, int length,
  61. PropertyList pList,
  62. Locator locator) {
  63. title += new String(data, start, length);
  64. }
  65. /**
  66. * {@inheritDoc}
  67. * <br>XSL/FOP: empty
  68. */
  69. protected void validateChildNode(Locator loc, String nsURI, String localName)
  70. throws ValidationException {
  71. if (FO_URI.equals(nsURI)) {
  72. invalidChildError(loc, nsURI, localName);
  73. }
  74. }
  75. /** {@inheritDoc} */
  76. public CommonAccessibility getCommonAccessibility() {
  77. return commonAccessibility;
  78. }
  79. /**
  80. * Get the title for this BookmarkTitle.
  81. *
  82. * @return the bookmark title
  83. */
  84. public String getTitle() {
  85. return title;
  86. }
  87. /** {@inheritDoc} */
  88. public String getLocalName() {
  89. return "bookmark-title";
  90. }
  91. /**
  92. * {@inheritDoc}
  93. * @return {@link org.apache.fop.fo.Constants#FO_BOOKMARK_TITLE}
  94. */
  95. public int getNameId() {
  96. return FO_BOOKMARK_TITLE;
  97. }
  98. }