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.

AbstractResourceEnvironmentGroupContainer.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.afp.modca;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import org.apache.fop.afp.Factory;
  22. /**
  23. * An abstract class which encapsulates the common features of
  24. * Document and PageGroup resource containers
  25. */
  26. public abstract class AbstractResourceEnvironmentGroupContainer
  27. extends AbstractResourceGroupContainer {
  28. /**
  29. * The resource environment group used to store complex resources
  30. */
  31. protected ResourceEnvironmentGroup resourceEnvironmentGroup = null;
  32. /**
  33. * Main constructor
  34. *
  35. * @param factory the object factory
  36. * @param name the name of this resource container
  37. */
  38. public AbstractResourceEnvironmentGroupContainer(
  39. Factory factory, String name) {
  40. super(factory, name);
  41. }
  42. /**
  43. * Adds a page to the resource container.
  44. *
  45. * @param page - the Page object
  46. */
  47. public void addPage(PageObject page) {
  48. addObject(page);
  49. }
  50. /**
  51. * Adds a PageGroup to the resource container.
  52. *
  53. * @param pageGroup the PageGroup object
  54. */
  55. public void addPageGroup(PageGroup pageGroup) {
  56. addObject(pageGroup);
  57. }
  58. /**
  59. * Creates an InvokeMediaMap on the page.
  60. *
  61. * @param name
  62. * the name of the media map
  63. */
  64. public void createInvokeMediumMap(String name) {
  65. InvokeMediumMap invokeMediumMap = factory.createInvokeMediumMap(name);
  66. addObject(invokeMediumMap);
  67. }
  68. /** {@inheritDoc} */
  69. protected void writeContent(OutputStream os) throws IOException {
  70. super.writeContent(os);
  71. if (resourceEnvironmentGroup != null) {
  72. resourceEnvironmentGroup.writeToStream(os);
  73. }
  74. }
  75. /**
  76. * Returns the resource environment group
  77. *
  78. * @return the resource environment group
  79. */
  80. protected ResourceEnvironmentGroup getResourceEnvironmentGroup() {
  81. if (resourceEnvironmentGroup == null) {
  82. this.resourceEnvironmentGroup = factory.createResourceEnvironmentGroup();
  83. }
  84. return this.resourceEnvironmentGroup;
  85. }
  86. }