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.

AbstractAFPObject.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.render.afp.modca;
  18. import java.io.IOException;
  19. import java.io.OutputStream;
  20. import java.util.Iterator;
  21. import java.util.List;
  22. import org.apache.commons.logging.Log;
  23. import org.apache.commons.logging.LogFactory;
  24. /**
  25. * This is the base class for all data stream objects. Page objects are
  26. * responsible for building and generating the binary datastream in an
  27. * AFP format.
  28. *
  29. */
  30. public abstract class AbstractAFPObject {
  31. /**
  32. * Static logging instance
  33. */
  34. protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
  35. /**
  36. * DataStream objects must implement the writeDataStream()
  37. * method to write its data to the given OutputStream
  38. * @param os The outputsteam stream
  39. * @throws java.io.IOException
  40. */
  41. public abstract void writeDataStream(OutputStream os) throws IOException;
  42. /**
  43. * Help method to write a set of AFPObjects to the AFP datastream.
  44. * @afpObjects a list of AFPObjects
  45. * @param os The stream to write to
  46. * @throws java.io.IOException
  47. */
  48. protected void writeObjectList(List afpObjects, OutputStream os)
  49. throws IOException {
  50. for (Iterator it = afpObjects.iterator(); it.hasNext(); ) {
  51. ((AbstractAFPObject)it.next()).writeDataStream(os);
  52. }
  53. }
  54. }