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.

Document.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 org.apache.fop.afp.Factory;
  22. /**
  23. * The document is the highest level of the MO:DCA data-stream document
  24. * component hierarchy. Documents can be made up of pages, and the pages, which
  25. * are at the intermediate level, can be made up of objects. Objects are at the
  26. * lowest level, and can be bar codes, graphics, images, and presentation text.
  27. *
  28. * At each level of the hierarchy certain sets of MO:DCA data structures, called
  29. * structured fields, are permissible. The document, pages and objects are
  30. * bounded by structured fields that define their beginnings and their ends.
  31. * These structured fields, called begin-end pairs, provide an envelope for the
  32. * data-stream components. This feature enables a processor of the data stream
  33. * that is not fully compliant with the architecture to bypass those objects
  34. * that are beyond its scope, and to process the data stream to the best of its
  35. * abilities.
  36. *
  37. * A presentation document is one that has been formatted and is intended for
  38. * presentation, usually on a printer or display device. A data stream
  39. * containing a presentation document should produce the same document content
  40. * in the same format on different printers or display devices dependent,
  41. * however, on the capabilities of each of the printers or display devices. A
  42. * presentation document can reference resources that are to be included as part
  43. * of the document to be presented.
  44. *
  45. */
  46. public final class Document extends AbstractResourceEnvironmentGroupContainer {
  47. /**
  48. * Constructor for the document object.
  49. *
  50. * @param factory
  51. * the object factory
  52. * @param name
  53. * the name of the document
  54. */
  55. public Document(Factory factory, String name) {
  56. super(factory, name);
  57. }
  58. /**
  59. * Method to mark the end of the page group.
  60. */
  61. public void endDocument() {
  62. complete = true;
  63. }
  64. /** {@inheritDoc} */
  65. public boolean isComplete() {
  66. return complete;
  67. }
  68. /** {@inheritDoc} */
  69. protected void writeStart(OutputStream os) throws IOException {
  70. byte[] data = new byte[17];
  71. copySF(data, Type.BEGIN, Category.DOCUMENT);
  72. os.write(data);
  73. }
  74. /** {@inheritDoc} */
  75. protected void writeEnd(OutputStream os) throws IOException {
  76. byte[] data = new byte[17];
  77. copySF(data, Type.END, Category.DOCUMENT);
  78. os.write(data);
  79. }
  80. /** {@inheritDoc} */
  81. public String toString() {
  82. return this.name;
  83. }
  84. }