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.

PageSegment.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.afp.modca;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import java.util.List;
  22. /**
  23. * A page segment is a MO:DCA-P resource object. It may be stored in an
  24. * external resource library or it may be carried in a resource group.
  25. * Page segments contain any combination of IOCA image objects and
  26. * GOCA graphics objects.
  27. */
  28. public class PageSegment extends AbstractNamedAFPObject {
  29. private List/*<AbstractAFPObject>*/ objects;
  30. /**
  31. * Main constructor
  32. *
  33. * @param name the name of this object
  34. */
  35. public PageSegment(String name) {
  36. super(name);
  37. }
  38. /**
  39. * Returns a list of objects contained withing this page segment
  40. *
  41. * @return a list of objects contained within this page segment
  42. */
  43. public List/*<AbstractAFPObject>*/ getObjects() {
  44. if (objects == null) {
  45. objects = new java.util.ArrayList();
  46. }
  47. return objects;
  48. }
  49. /**
  50. * Adds a resource object (image/graphic) to this page segment
  51. *
  52. * @param object the resource objec to add to this page segment
  53. */
  54. public void addObject(AbstractAFPObject object) {
  55. getObjects().add(object);
  56. }
  57. /** {@inheritDoc} */
  58. protected void writeStart(OutputStream os) throws IOException {
  59. byte[] data = new byte[17];
  60. copySF(data, Type.BEGIN, Category.PAGE_SEGMENT);
  61. os.write(data);
  62. }
  63. /** {@inheritDoc} */
  64. protected void writeContent(OutputStream os) throws IOException {
  65. super.writeContent(os);
  66. writeObjects(objects, os);
  67. }
  68. /** {@inheritDoc} */
  69. protected void writeEnd(OutputStream os) throws IOException {
  70. byte[] data = new byte[17];
  71. copySF(data, Type.END, Category.PAGE_SEGMENT);
  72. os.write(data);
  73. }
  74. /** {@inheritDoc} */
  75. public String toString() {
  76. return this.name;
  77. }
  78. }