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.

PageSequence.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.area;
  19. import java.util.List;
  20. /**
  21. * Represents a page sequence in the area tree.
  22. */
  23. public class PageSequence extends AreaTreeObject {
  24. private List pages = new java.util.ArrayList();
  25. private LineArea title;
  26. private String language;
  27. private String country;
  28. /**
  29. * Main constructor
  30. * @param title the title for the page-sequence, may be null
  31. */
  32. public PageSequence(LineArea title) {
  33. setTitle(title);
  34. }
  35. /**
  36. * @return the title of the page sequence in form of a line area, or null if there's no title
  37. */
  38. public LineArea getTitle() {
  39. return this.title;
  40. }
  41. /**
  42. * Sets the page sequence's title.
  43. * @param title the title
  44. */
  45. public void setTitle(LineArea title) {
  46. this.title = title;
  47. }
  48. /**
  49. * Adds a new page to the page sequence
  50. * @param page the page to be added
  51. */
  52. public void addPage(PageViewport page) {
  53. this.pages.add(page);
  54. }
  55. /**
  56. * @return the number of pages currently in this page sequence
  57. */
  58. public int getPageCount() {
  59. return this.pages.size();
  60. }
  61. /**
  62. * Returns the page at the given index.
  63. * @param idx the index of the requested page
  64. * @return the requested page or null if it was not found
  65. */
  66. public PageViewport getPage(int idx) {
  67. return (PageViewport)this.pages.get(idx);
  68. }
  69. /**
  70. * Indicates whether a page is the first in this page sequence.
  71. * @param page the page to be inspected
  72. * @return true if the page is the first in this page sequence, false otherwise
  73. */
  74. public boolean isFirstPage(PageViewport page) {
  75. return page.equals(getPage(0));
  76. }
  77. /**
  78. * Returns the language of the page-sequence.
  79. * @return the language (the value of the language property, "none" is mapped to null)
  80. */
  81. public String getLanguage() {
  82. return this.language;
  83. }
  84. /**
  85. * Sets the language that applies to this page-sequence.
  86. * @param language the language to set ("none" is mapped to null)
  87. */
  88. public void setLanguage(String language) {
  89. if ("none".equals(language)) {
  90. this.language = null;
  91. } else {
  92. this.language = language;
  93. }
  94. }
  95. /**
  96. * Returns the country of the page-sequence.
  97. * @return the country (the value of the country property, "none" is mapped to null)
  98. */
  99. public String getCountry() {
  100. return this.country;
  101. }
  102. /**
  103. * Sets the country that applies to this page-sequence.
  104. * @param country the country to set ("none" is mapped to null)
  105. */
  106. public void setCountry(String country) {
  107. if ("none".equals(country)) {
  108. this.country = null;
  109. } else {
  110. this.country = country;
  111. }
  112. }
  113. }