You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/08/27 14:35:51 UTC

svn commit: r689459 [6/7] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop: pdf/ render/ render/afp/ render/afp/goca/ render/afp/ioca/ render/afp/modca/ render/afp/modca/resource/ render/afp/modca/triplets/ render/java2d/

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,11 +22,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.DataObjectInfo;
-import org.apache.fop.render.afp.ResourceInfo;
-import org.apache.fop.render.afp.ResourceLevel;
-import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
-import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -42,33 +37,33 @@
 
     /**
      * Main constructor
-     * 
+     *
      * @param dataObjectAccessor a data object accessor
      */
-    public MapDataResource(DataObjectAccessor dataObjectAccessor) {
-        AbstractNamedAFPObject namedDataObject = dataObjectAccessor.getDataObject();
-        DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo();
-        ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
-        ResourceLevel resourceLevel = resourceInfo.getLevel();
-        if (resourceLevel.isExternal()) {
-            String url = resourceLevel.getExternalFilePath();
-            if (url != null) {
-                super.setFullyQualifiedName(
-                        FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
-                        FullyQualifiedNameTriplet.FORMAT_CHARSTR, url);
-            }
-        } else {
-            String fqName = namedDataObject.getFullyQualifiedName();
-            super.setFullyQualifiedName(
-                    FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);            
-        }
-
-        // Set object classification
-        Registry.ObjectType objectType = dataObjectInfo.getObjectType();
-        super.setObjectClassification(
-                ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
-                objectType);
+    public MapDataResource() {
+//        AbstractNamedAFPObject namedDataObject = dataObjectAccessor.getDataObject();
+//        DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo();
+//        AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+//        AFPResourceLevel resourceLevel = resourceInfo.getLevel();
+//        if (resourceLevel.isExternal()) {
+//            String url = resourceLevel.getExternalFilePath();
+//            if (url != null) {
+//                super.setFullyQualifiedName(
+//                        FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
+//                        FullyQualifiedNameTriplet.FORMAT_CHARSTR, url);
+//            }
+//        } else {
+//            String fqName = namedDataObject.getFullyQualifiedName();
+//            super.setFullyQualifiedName(
+//                    FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
+//                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);
+//        }
+//
+//        // Set object classification
+//        Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+//        super.setObjectClassification(
+//                ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
+//                objectType);
     }
 
     /** {@inheritDoc} */
@@ -76,11 +71,11 @@
         super.writeStart(os);
         byte[] data = new byte[9];
         copySF(data, Type.MAP, Category.DATA_RESOURCE);
-        
+
         byte[] len = BinaryUtils.convert(10 + getTripletDataLength(), 2);
         data[1] = len[0];
         data[2] = len[1];
-        
+
         os.write(data);
     }
 
@@ -89,7 +84,7 @@
         // RGLength
         byte[] len = BinaryUtils.convert(2 + getTripletDataLength(), 2);
         os.write(len);
-        
+
         super.writeTriplets(os);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java Wed Aug 27 05:35:44 2008
@@ -82,7 +82,7 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         int oLayCount = getOverlays().size();
         int recordlength = oLayCount * 18;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java Wed Aug 27 05:35:44 2008
@@ -61,7 +61,7 @@
      * @param os The outputsteam stream
      * @throws java.io.IOException if an I/O exception occurs during processing
      */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] contentData = content.getBytes(AFPConstants.EBCIDIC_ENCODING);
         int contentLen = contentData.length;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java Wed Aug 27 05:35:44 2008
@@ -19,14 +19,14 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.triplets.DescriptorPositionTriplet;
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.fop.render.afp.modca.triplets.MeasurementUnitsTriplet;
 import org.apache.fop.render.afp.modca.triplets.ObjectAreaSizeTriplet;
 import org.apache.fop.render.afp.modca.triplets.PresentationSpaceResetMixingTriplet;
+import org.apache.fop.render.afp.modca.triplets.Triplet;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -38,11 +38,11 @@
     /**
      * Construct an object area descriptor for the specified object width
      * and object height.
-     * 
-     * @param width The page width.
-     * @param height The page height.
-     * @param widthRes The page width resolution.
-     * @param heightRes The page height resolution.
+     *
+     * @param width the object width.
+     * @param height the object height.
+     * @param widthRes the object width resolution.
+     * @param heightRes the object height resolution.
      */
     public ObjectAreaDescriptor(int width, int height, int widthRes, int heightRes) {
         super(width, height, widthRes, heightRes);
@@ -51,20 +51,24 @@
     /** {@inheritDoc} */
     protected byte[] getTripletData() throws IOException {
         if (tripletData == null) {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
             // Specifies the associated ObjectAreaPosition structured field
             final byte oapId = 0x01;
-            new DescriptorPositionTriplet(oapId).write(bos);
+            Triplet triplet = new Triplet(Triplet.DESCRIPTOR_POSITION, oapId);
+            triplet.writeToStream(baos);
+
+            triplet = new MeasurementUnitsTriplet(widthRes, heightRes);
+            triplet.writeToStream(baos);
+
+            triplet = new ObjectAreaSizeTriplet(width, height);
+            triplet.writeToStream(baos);
 
-            new MeasurementUnitsTriplet(widthRes, heightRes).write(bos);
+            triplet = new PresentationSpaceResetMixingTriplet(
+                    PresentationSpaceResetMixingTriplet.NOT_RESET);
+            triplet.writeToStream(baos);
 
-            new ObjectAreaSizeTriplet(width, height).write(bos);
-            
-            new PresentationSpaceResetMixingTriplet(
-                    PresentationSpaceResetMixingTriplet.NOT_RESET).write(bos);
-            
-            this.tripletData = bos.toByteArray();
+            this.tripletData = baos.toByteArray();
         }
         return this.tripletData;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java Wed Aug 27 05:35:44 2008
@@ -30,15 +30,15 @@
  */
 public class ObjectAreaPosition extends AbstractAFPObject {
 
-    private int x;
-    private int y;
-    private int rotation;
+    private final int x;
+    private final int y;
+    private final int rotation;
     private int xOffset;
     private int yOffset;
-    
+
     /**
      * Construct an object area position for the specified object y, y position.
-     * 
+     *
      * @param x The x coordinate.
      * @param y The y coordinate.
      * @param rotation The coordinate system rotation (must be 0, 90, 180, 270).
@@ -50,14 +50,14 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[33];
         copySF(data, Type.POSITION, Category.OBJECT_AREA);
 
         byte[] len = BinaryUtils.convert(32, 2);
         data[1] = len[0]; // Length
         data[2] = len[1];
-            
+
         data[9] = 0x01; // OAPosID = 1
         data[10] = 0x17; // RGLength = 23
 
@@ -70,10 +70,10 @@
         data[14] = ycoord[0]; // YoaOSet
         data[15] = ycoord[1];
         data[16] = ycoord[2];
-        
+
         byte xorient = (byte)(rotation / 2);
         data[17] = xorient; // XoaOrent
-        
+
         byte yorient = (byte)(rotation / 2 + 45);
         data[19] = yorient; // YoaOrent
 
@@ -89,12 +89,23 @@
 
         data[28] = 0x00; // XocaOrent
         data[29] = 0x00;
-        
+
         data[30] = 0x2D; // YocaOrent
         data[31] = 0x00;
 
         data[32] = 0x01; // RefCSys
-        
+
         os.write(data);
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "ObjectAreaPosition{"
+            + "x=" + x
+            + ", y=" + y
+            + ", rotation=" + rotation
+            + ", rotation=" + rotation
+            + ", xOffset=" + xOffset
+            + ", yOffset=" + yOffset;
+    }
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,131 +19,85 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.fop.render.afp.AFPDataObjectInfo;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
  * Object containers are MO:DCA objects that envelop and carry object data.
  */
-public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObjectAccessor*/ {
-                
-    private static final String DEFAULT_NAME = "OC000001";
-
-    /** the data object */
-    private AbstractDataObject dataObj = null;
-    
-    /** the object data */
-    private byte[] objectData = null;
+public class ObjectContainer extends AbstractDataObject {
 
-    /**
-     * Default constructor
-     */
-    public ObjectContainer() {
-        super(DEFAULT_NAME);
-    }
+    /** the object container data maximum length */
+    private static final int MAX_DATA_LEN = 32759;
+
+    /** the object data */
+    protected byte[] objectData;
 
     /**
      * Main constructor
-     * 
+     *
+     * @param factory the object factory
      * @param name the name of this object container
      */
-    public ObjectContainer(String name) {
-        super(name);        
-    }
-    
-    /**
-     * Sets the data object for this object container
-     * 
-     * @param dataObj the data object to reside within this object container
-     */
-    public void setDataObject(AbstractDataObject dataObj) {
-        this.dataObj = dataObj;        
+    public ObjectContainer(Factory factory, String name) {
+        super(factory, name);
     }
 
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
-        // create object data from data object
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        dataObj.write(bos);
-        this.objectData = bos.toByteArray();
-
-        byte[] data = new byte[17];
-        copySF(data, Type.BEGIN, Category.OBJECT_CONTAINER);
+        byte[] headerData = new byte[17];
+        copySF(headerData, Type.BEGIN, Category.OBJECT_CONTAINER);
 
         // Set the total record length
         byte[] len = BinaryUtils.convert(16 + getTripletDataLength(), 2);
-        data[1] = len[0]; // Length byte 1
-        data[2] = len[1]; // Length byte 2
-        
-        os.write(data);
+        headerData[1] = len[0]; // Length byte 1
+        headerData[2] = len[1]; // Length byte 2
+
+        os.write(headerData);
     }
-    
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
-        super.writeContent(os);
-        
-        // write out object data in chunks of object container data
-        for (int i = 0; i <= objectData.length; i += ObjectContainerData.MAX_DATA_LEN) {
-            new ObjectContainerData(objectData, i).write(os);
-        }
+        super.writeContent(os); // write OEG
+
+        // write OCD
+        byte[] dataHeader = new byte[9];
+        copySF(dataHeader, SF_CLASS, Type.DATA, Category.OBJECT_CONTAINER);
+        final int lengthOffset = 1;
+        writeChunksToStream(objectData, dataHeader, lengthOffset,
+                MAX_DATA_LEN, os);
     }
-    
+
     /** {@inheritDoc} */
     protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.END, Category.OBJECT_CONTAINER);
         os.write(data);
     }
-    
+
+    /** {@inheritDoc} */
+    public void setViewport(AFPDataObjectInfo dataObjectInfo) {
+        super.setViewport(dataObjectInfo);
+//        AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
+//
+//        int width = objectAreaInfo.getWidth();
+//        int height = objectAreaInfo.getHeight();
+//        int widthRes = objectAreaInfo.getWidthRes();
+//        int heightRes = objectAreaInfo.getHeightRes();
+//        ContainerDataDescriptor containerDataDescriptor
+//            = factory.createContainerDataDescriptor(width, height, widthRes, heightRes);
+//        getObjectEnvironmentGroup().setDataDescriptor(containerDataDescriptor);
+    }
+
     /**
-     * An Object Container Data holds a chunk of the data object
+     * Sets the object container data
+     *
+     * @param data the object container data
      */
-    private class ObjectContainerData extends AbstractPreparedAFPObject {
-        
-        /** The maximum object container data length */ 
-        private static final int MAX_DATA_LEN = 32759;
-        
-        private byte[] objData = null;
-        
-        private int startIndex;
-        
-        /**
-         * Main constructor
-         * 
-         * @param objData the object data
-         */
-        public ObjectContainerData(byte[] objData, int startIndex) {
-            this.objData = objData;
-            this.startIndex = startIndex;
-        }
-        
-        /** {@inheritDoc} */
-        public void write(OutputStream os) throws IOException {
-            int dataLen = MAX_DATA_LEN;
-            if (startIndex + MAX_DATA_LEN >= objData.length) {
-                dataLen = objData.length - startIndex - 1;
-            }
-            byte[] data = new byte[9 + dataLen];
-            copySF(data, Type.DATA, Category.OBJECT_CONTAINER);
-
-            byte[] len = BinaryUtils.convert(8 + dataLen, 2);
-            data[1] = len[0]; // Length byte 1
-            data[2] = len[1]; // Length byte 2
-            
-            // copy object data chunk
-            System.arraycopy(objData, startIndex, data, 9, dataLen);
-            os.write(data);
-        }
-        
-        /** {@inheritDoc} */
-        public String toString() {
-            return "ObjectContainerData("
-                + (data != null ? "" + (data.length - 2) : "null")
-                + ")";
-        }
-
+    public void setData(byte[] data) {
+        this.objectData = data;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java Wed Aug 27 05:35:44 2008
@@ -22,8 +22,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.ObjectAreaInfo;
-
+import org.apache.fop.render.afp.AFPObjectAreaInfo;
 
 /**
  * An Object Environment Group (OEG) may be associated with an object and is contained
@@ -38,116 +37,78 @@
  */
 public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
 
-    /**
-     * Default name for the object environment group
-     */
-    private static final String DEFAULT_NAME = "OEG00001";
+    private final Factory factory;
 
-    /**
-     * The ObjectAreaDescriptor for the object environment group
-     */
+    /** the ObjectAreaDescriptor for the object environment group */
     private ObjectAreaDescriptor objectAreaDescriptor = null;
 
-    /**
-     * The ObjectAreaPosition for the object environment group
-     */
+    /** the ObjectAreaPosition for the object environment group */
     private ObjectAreaPosition objectAreaPosition = null;
 
-    /**
-     * The ImageDataDescriptor for the object environment group
-     */
-    private ImageDataDescriptor imageDataDescriptor = null;
-
-    /**
-     * The GraphicsDataDescriptor for the object environment group
-     */
-    private GraphicsDataDescriptor graphicsDataDescriptor = null;
-
-    /**
-     * Default constructor for the ObjectEnvironmentGroup.
-     */
-    public ObjectEnvironmentGroup() {
-        this(DEFAULT_NAME);
-    }
+    /** the DataDescritpor for the object environment group */
+    private AbstractDescriptor dataDescriptor;
 
     /**
      * Constructor for the ObjectEnvironmentGroup, this takes a
      * name parameter which must be 8 characters long.
-     * 
+     *
+     * @param factory the object factory
      * @param name the object environment group name
      */
-    public ObjectEnvironmentGroup(String name) {
+    public ObjectEnvironmentGroup(Factory factory, String name) {
         super(name);
+        this.factory = factory;
     }
 
     /**
      * Sets the object area parameters.
-     * 
+     *
      * @param info the object area info
      */
-    public void setObjectArea(ObjectAreaInfo info) {
-        this.objectAreaDescriptor = new ObjectAreaDescriptor(
-                info.getWidth(), info.getHeight(),
-                info.getWidthRes(), info.getHeightRes());
-        this.objectAreaPosition = new ObjectAreaPosition(
+    public void setObjectArea(AFPObjectAreaInfo info) {
+        this.objectAreaDescriptor = factory.createObjectAreaDescriptor(
+                info.getWidth(), info.getHeight(), info.getWidthRes(), info.getHeightRes());
+        this.objectAreaPosition = factory.createObjectAreaPosition(
                 info.getX(), info.getY(), info.getRotation());
     }
 
-    /**
-     * Set the dimensions of the image.
-     * 
-     * @param xresol the x resolution of the image
-     * @param yresol the y resolution of the image
-     * @param width the image width
-     * @param height the image height
-     */
-    public void setImageData(int xresol, int yresol, int width, int height) {
-        this.imageDataDescriptor = new ImageDataDescriptor(xresol, yresol,  width, height);
-    }
-
-    /**
-     * Set the graphics data descriptor.
-     * 
-     * @param xresol the x resolution of the graphics window
-     * @param yresol the y resolution of the graphics window
-     * @param xlwind the left edge of the graphics window 
-     * @param xrwind the right edge of the graphics window
-     * @param ybwind the top edge of the graphics window
-     * @param ytwind the bottom edge of the graphics window
-     */
-    public void setGraphicsData(int xresol, int yresol,
-            int xlwind, int xrwind, int ybwind, int ytwind) {
-        this.graphicsDataDescriptor = new GraphicsDataDescriptor(xresol, yresol,
-                xlwind, xrwind, ybwind, ytwind);
-    }
-
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.BEGIN, Category.OBJECT_ENVIRONMENT_GROUP);
         os.write(data);
     }
-    
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
-        
-        objectAreaDescriptor.write(os);
-        objectAreaPosition.write(os);
 
-        if (imageDataDescriptor != null) {
-            imageDataDescriptor.write(os);
+        if (objectAreaDescriptor != null) {
+            objectAreaDescriptor.writeToStream(os);
+        }
+
+        if (objectAreaPosition != null) {
+            objectAreaPosition.writeToStream(os);
         }
 
-        if (graphicsDataDescriptor != null) {
-            graphicsDataDescriptor.write(os);
+        if (dataDescriptor != null) {
+            dataDescriptor.writeToStream(os);
         }
     }
-    
+
     /** {@inheritDoc} */
     protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.END, Category.OBJECT_ENVIRONMENT_GROUP);
         os.write(data);
     }
+
+    /**
+     * Sets the data descriptor
+     *
+     * @param dataDescriptor the data descriptor
+     */
+    public void setDataDescriptor(AbstractDescriptor dataDescriptor) {
+        this.dataDescriptor = dataDescriptor;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java Wed Aug 27 05:35:44 2008
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
 
 /**
  * An overlay is a MO:DCA-P resource object.
@@ -31,14 +30,14 @@
  * carried in a resource group. An overlay is similar to a page in
  * that it defines its own environment and carries the same data objects.
  */
-public class Overlay extends AbstractPageObject {
+public class Overlay extends PageObject {
 
     /**
      * Construct a new overlay object for the specified name argument, the overlay
      * name should be an 8 character identifier.
-     * 
-     * @param resourceManager the resource manager
      *
+     * @param factory
+     *            the resource manager of the page.
      * @param name
      *            the name of the page.
      * @param width
@@ -52,10 +51,10 @@
      * @param heightResolution
      *            the height resolution of the page.
      */
-    public Overlay(ResourceManager resourceManager,
+    public Overlay(Factory factory,
             String name, int width, int height, int rotation,
             int widthResolution, int heightResolution) {
-        super(resourceManager, name, width, height, rotation, widthResolution, heightResolution);
+        super(factory, name, width, height, rotation, widthResolution, heightResolution);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java Wed Aug 27 05:35:44 2008
@@ -33,7 +33,7 @@
     /**
      * Construct a page descriptor for the specified page width
      * and page height.
-     * 
+     *
      * @param width The page width.
      * @param height The page height.
      * @param widthResolution The page width resolution
@@ -44,23 +44,15 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
-
-        log.debug("width=" + width);
-        log.debug("height=" + height);
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[24];
-        data[0] = 0x5A;
-        data[1] = 0x00;
+        copySF(data, Type.DESCRIPTOR, Category.PAGE);
         data[2] = 0x17;
-        data[3] = (byte) 0xD3;
-        data[4] = (byte) 0xA6;
-        data[5] = (byte) 0xAF;
-
-        data[6] = 0x00; // Flags
-        data[7] = 0x00; // Reserved
-        data[8] = 0x00;  // Reserved
 
+        // XpgBase
         data[9] = 0x00; // XpgBase = 10 inches
+
+        // YpgBase
         data[10] = 0x00; // YpgBase = 10 inches
 
         // XpgUnits

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java Wed Aug 27 05:35:44 2008
@@ -21,10 +21,9 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Iterator;
 import java.util.List;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
-
 /**
  * A page group is used in the data stream to define a named, logical grouping
  * of sequential pages. Page groups are delimited by begin-end structured fields
@@ -39,17 +38,17 @@
     /** The tag logical elements contained within this group */
     private List tagLogicalElements = null;
 
-    /** The page state */
-    private boolean complete = false;
+    /** the page group started state */
+    private boolean started = false;
 
     /**
      * Constructor for the PageGroup.
-     * 
-     * @param manager the resource manager
+     *
+     * @param factory the resource manager
      * @param name the name of the page group
      */
-    public PageGroup(ResourceManager manager, String name) {
-        super(manager, name);
+    public PageGroup(Factory factory, String name) {
+        super(factory, name);
     }
 
     private List getTagLogicalElements() {
@@ -58,7 +57,7 @@
         }
         return this.tagLogicalElements;
     }
-    
+
     /**
      * Creates a TagLogicalElement on the page.
      *
@@ -68,7 +67,7 @@
      *            the value of the tag
      */
     public void createTagLogicalElement(String name, String value) {
-        TagLogicalElement tle = new TagLogicalElement(name, value);
+        TagLogicalElement tle = factory.createTagLogicalElement(name, value);
         if (!getTagLogicalElements().contains(tle)) {
             getTagLogicalElements().add(tle);
         }
@@ -81,14 +80,6 @@
         complete = true;
     }
 
-    /**
-     * Returns an indication if the page group is complete
-     * @return whether or not this page group is complete or not
-     */
-    public boolean isComplete() {
-        return complete;
-    }
-
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         writeObjects(tagLogicalElements, os);
@@ -108,7 +99,30 @@
         copySF(data, Type.END, Category.PAGE_GROUP);
         os.write(data);
     }
-    
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        if (!started) {
+            writeStart(os);
+            started = true;
+        }
+
+        Iterator it = objects.iterator();
+        while (it.hasNext()) {
+            AbstractAFPObject ao = (AbstractAFPObject)it.next();
+            if (ao instanceof PageObject && ((PageObject)ao).isComplete()) {
+                ao.writeToStream(os);
+                it.remove();
+            } else {
+                break;
+            }
+        }
+
+        if (complete) {
+            writeEnd(os);
+        }
+    }
+
     /** {@inheritDoc} */
     public String toString() {
         return this.getName();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java Wed Aug 27 05:35:44 2008
@@ -22,8 +22,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
-import org.apache.fop.render.afp.tools.StringUtils;
+import org.apache.fop.render.afp.ioca.ImageCellPosition;
+import org.apache.fop.render.afp.ioca.ImageInputDescriptor;
+import org.apache.fop.render.afp.ioca.ImageOutputControl;
+import org.apache.fop.render.afp.ioca.ImageRasterData;
+import org.apache.fop.render.afp.ioca.ImageRasterPattern;
 
 /**
  * Pages contain the data objects that comprise a presentation document. Each
@@ -50,8 +53,8 @@
     /**
      * Construct a new page object for the specified name argument, the page
      * name should be an 8 character identifier.
-     * 
-     * @param resourceManager the resource manager 
+     *
+     * @param factory the resource manager
      *
      * @param name
      *            the name of the page.
@@ -61,15 +64,15 @@
      *            the height of the page.
      * @param rotation
      *            the rotation of the page.
-     * @param widthResolution
+     * @param widthRes
      *            the width resolution of the page.
-     * @param heightResolution
+     * @param heightRes
      *            the height resolution of the page.
      */
-    public PageObject(ResourceManager resourceManager,
+    public PageObject(Factory factory,
             String name, int width, int height, int rotation,
-            int widthResolution, int heightResolution) {
-        super(resourceManager, name, width, height, rotation, widthResolution, heightResolution);
+            int widthRes, int heightRes) {
+        super(factory, name, width, height, rotation, widthRes, heightRes);
     }
 
     /**
@@ -147,11 +150,8 @@
 
         int grayscale = Math.round((shade / 255) * 16);
 
-        String imageName = "IMG"
-            + StringUtils.lpad(String.valueOf(getResourceCount() + 1),
-            '0', 5);
+        IMImageObject imImageObject = factory.createIMImageObject();
 
-        IMImageObject imImageObject = new IMImageObject(imageName);
         ImageOutputControl imageOutputControl = new ImageOutputControl(0, 0);
         ImageInputDescriptor imageInputDescriptor = new ImageInputDescriptor();
         ImageCellPosition imageCellPosition = new ImageCellPosition(xCoord, yCoord);
@@ -161,8 +161,8 @@
         imageCellPosition.setYSize(8);
 
         //defining this as a resource
-        ImageRasterData imageRasterData = new ImageRasterData(
-                ImageRasterPattern.getRasterData(grayscale));
+        byte[] rasterData = ImageRasterPattern.getRasterData(grayscale);
+        ImageRasterData imageRasterData = factory.createImageRasterData(rasterData);
 
         imImageObject.setImageOutputControl(imageOutputControl);
         imImageObject.setImageInputDescriptor(imageInputDescriptor);
@@ -184,7 +184,17 @@
         copySF(data, Type.END, Category.PAGE);
         os.write(data);
     }
-    
+
+    /**
+     * Adds an AFP object reference to this page
+     *
+     * @param obj an AFP object
+     */
+    public void addObject(Object obj) {
+        endPresentationObject();
+        super.addObject(obj);
+    }
+
     /** {@inheritDoc} */
     public String toString() {
         return this.getName();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java Wed Aug 27 05:35:44 2008
@@ -20,10 +20,10 @@
 package org.apache.fop.render.afp.modca;
 
 import java.awt.Color;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.fop.render.afp.LineDataInfo;
 import org.apache.fop.render.afp.TextDataInfo;
 import org.apache.fop.render.afp.tools.BinaryUtils;
@@ -35,18 +35,18 @@
  * that position them - modal control sequences that adjust the positions by
  * small amounts - other functions causing text to be presented with differences
  * in appearance.
- * 
+ *
  * The graphic characters are expected to conform to a coded font representation
  * so that they can be translated from the code point in the object data to the
  * character in the coded font. The units of measure for linear displacements
  * are derived from the PresentationTextDescriptor or from the hierarchical
  * defaults.
- * 
+ *
  * In addition to graphic character code points, Presentation Text data can
  * contain embedded control sequences. These are strings of two or more bytes
  * which signal an alternate mode of processing for the content of the current
  * Presentation Text data.
- * 
+ *
  */
 public class PresentationTextData extends AbstractAFPObject {
 
@@ -58,17 +58,17 @@
     /**
      * The afp data relating to this presentation text data.
      */
-    private ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+    private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
     /**
      * The current x coordinate.
      */
-    private int currentXCoordinate = -1;
+    private int currentX = -1;
 
     /**
      * The current y cooridnate
      */
-    private int currentYCoordinate = -1;
+    private int currentY = -1;
 
     /**
      * The current font
@@ -106,7 +106,7 @@
      * Constructor for the PresentationTextData, the boolean flag indicate
      * whether the control sequence prefix should be set to indicate the start
      * of a new control sequence.
-     * 
+     *
      * @param controlInd
      *            The control sequence indicator.
      */
@@ -133,7 +133,7 @@
      * The Set Coded Font Local control sequence activates a coded font and
      * specifies the character attributes to be used. This is a modal control
      * sequence.
-     * 
+     *
      * @param font
      *            The font local identifier.
      * @param afpdata
@@ -154,7 +154,7 @@
      * Establishes the current presentation position on the baseline at a new
      * I-axis coordinate, which is a specified number of measurement units from
      * the B-axis. There is no change to the current B-axis coordinate.
-     * 
+     *
      * @param coordinate
      *            The coordinate for the inline move.
      * @param afpdata
@@ -164,14 +164,14 @@
             ByteArrayOutputStream afpdata) {
         byte[] b = BinaryUtils.convert(coordinate, 2);
         afpdata.write(new byte[] {0x04, (byte) 0xC7, b[0], b[1]}, 0, 4);
-        currentXCoordinate = coordinate;
+        currentX = coordinate;
     }
 
     /**
      * Establishes the baseline and the current presentation position at a new
      * B-axis coordinate, which is a specified number of measurement units from
      * the I-axis. There is no change to the current I-axis coordinate.
-     * 
+     *
      * @param coordinate
      *            The coordinate for the baseline move.
      * @param afpdata
@@ -181,15 +181,15 @@
             ByteArrayOutputStream afpdata) {
         byte[] b = BinaryUtils.convert(coordinate, 2);
         afpdata.write(new byte[] {0x04, (byte) 0xD3, b[0], b[1]}, 0, 4);
-        currentYCoordinate = coordinate;
+        currentY = coordinate;
     }
 
     private static final int TRANSPARENT_MAX_SIZE = 253;
-    
+
     /**
      * The Transparent Data control sequence contains a sequence of code points
      * that are presented without a scan for embedded control sequences.
-     * 
+     *
      * @param data
      *            The text data to add.
      * @param afpdata
@@ -212,7 +212,7 @@
      * Draws a line of specified length and specified width in the B-direction
      * from the current presentation position. The location of the current
      * presentation position is unchanged.
-     * 
+     *
      * @param length
      *            The length of the rule.
      * @param width
@@ -240,7 +240,7 @@
      * Draws a line of specified length and specified width in the I-direction
      * from the current presentation position. The location of the current
      * presentation position is unchanged.
-     * 
+     *
      * @param length
      *            The length of the rule.
      * @param width
@@ -266,7 +266,7 @@
 
     /**
      * Create the presentation text data for the byte array of data.
-     * 
+     *
      * @param textDataInfo
      *            the afp text data
      * @throws MaximumSizeExceededException
@@ -280,18 +280,18 @@
         if (currentOrientation != textDataInfo.getOrientation()) {
             setTextOrientation(textDataInfo.getOrientation(), afpdata);
             currentOrientation = textDataInfo.getOrientation();
-            currentXCoordinate = -1;
-            currentYCoordinate = -1;
+            currentX = -1;
+            currentY = -1;
         }
 
         // Avoid unnecessary specification of the Y co-ordinate
-        if (textDataInfo.getY() != currentYCoordinate) {
+        if (textDataInfo.getY() != currentY) {
             absoluteMoveBaseline(textDataInfo.getY(), afpdata);
-            currentXCoordinate = -1;
+            currentX = -1;
         }
 
         // Avoid unnecessary specification of the X co-ordinate
-        if (textDataInfo.getX() != currentXCoordinate) {
+        if (textDataInfo.getX() != currentX) {
             absoluteMoveInline(textDataInfo.getX(), afpdata);
         }
 
@@ -320,11 +320,11 @@
 
         setCodedFont(BinaryUtils.convert(textDataInfo.getFontReference())[0],
                 afpdata);
-        
+
         // Add transparent data
         byte[] data = textDataInfo.getData();
         if (data.length <= TRANSPARENT_MAX_SIZE) {
-            addTransparentData(data, afpdata);            
+            addTransparentData(data, afpdata);
         } else {
             // data size greater than TRANSPARENT_MAX_SIZE so slice
             int numTransData = data.length / TRANSPARENT_MAX_SIZE;
@@ -337,16 +337,16 @@
             }
             int remainingTransData = data.length / TRANSPARENT_MAX_SIZE;
             buff = new byte[remainingTransData];
-            System.arraycopy(data, currIndex, buff, 0, remainingTransData);        
+            System.arraycopy(data, currIndex, buff, 0, remainingTransData);
             addTransparentData(buff, afpdata);
         }
-        currentXCoordinate = -1;
+        currentX = -1;
 
         int dataSize = afpdata.size();
 
         if (baos.size() + dataSize > MAX_SIZE) {
-            currentXCoordinate = -1;
-            currentYCoordinate = -1;
+            currentX = -1;
+            currentY = -1;
             throw new MaximumSizeExceededException();
         }
 
@@ -357,7 +357,7 @@
     /**
      * Drawing of lines using the starting and ending coordinates, thickness and
      * colour arguments.
-     * 
+     *
      * @param lineDataInfo the line data information.
      * @throws MaximumSizeExceededException
      *            thrown if the maximum number of line data has been exceeded
@@ -373,19 +373,19 @@
         int x2 = lineDataInfo.getX2();
         int y2 = lineDataInfo.getY2();
         Color col = lineDataInfo.getColor();
-        
+
         if (currentOrientation != orientation) {
             setTextOrientation(orientation, afpdata);
             currentOrientation = orientation;
         }
 
         // Avoid unnecessary specification of the Y coordinate
-        if (y1 != currentYCoordinate) {
+        if (y1 != currentY) {
             absoluteMoveBaseline(y1, afpdata);
         }
 
         // Avoid unnecessary specification of the X coordinate
-        if (x1 != currentXCoordinate) {
+        if (x1 != currentX) {
             absoluteMoveInline(x1, afpdata);
         }
 
@@ -405,8 +405,8 @@
         int dataSize = afpdata.size();
 
         if (baos.size() + dataSize > MAX_SIZE) {
-            currentXCoordinate = -1;
-            currentYCoordinate = -1;
+            currentX = -1;
+            currentY = -1;
             throw new MaximumSizeExceededException();
         }
 
@@ -417,12 +417,12 @@
     /**
      * The Set Text Orientation control sequence establishes the I-direction and
      * B-direction for the subsequent text. This is a modal control sequence.
-     * 
+     *
      * Semantics: This control sequence specifies the I-axis and B-axis
      * orientations with respect to the Xp-axis for the current Presentation
      * Text object. The orientations are rotational values expressed in degrees
      * and minutes.
-     * 
+     *
      * @param orientation
      *            The text orientation (0, 90, 180, 270).
      * @param afpdata
@@ -464,7 +464,7 @@
      * defines the color space and encoding for that value. The specified color
      * value is applied to foreground areas of the text presentation space. This
      * is a modal control sequence.
-     * 
+     *
      * @param col
      *            The color to be set.
      * @param afpdata
@@ -488,13 +488,13 @@
             (byte) (col.getGreen()), // Green intensity
             (byte) (col.getBlue()), // Blue intensity
         };
-        
+
         afpdata.write(colorData, 0, colorData.length);
     }
 
     /**
      * //TODO This is a modal control sequence.
-     * 
+     *
      * @param incr
      *            The increment to be set.
      * @param afpdata
@@ -513,7 +513,7 @@
 
     /**
      * //TODO This is a modal control sequence.
-     * 
+     *
      * @param incr
      *            The increment to be set.
      * @param afpdata
@@ -529,7 +529,7 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = baos.toByteArray();
         byte[] size = BinaryUtils.convert(data.length - 1, 2);
         data[1] = size[0];
@@ -543,7 +543,7 @@
      * and zero or more parameters. The control sequence can extend multiple
      * presentation text data objects, but must eventually be terminated. This
      * method terminates the control sequence.
-     * 
+     *
      * @throws MaximumSizeExceededException
      *       thrown in the event that maximum size has been exceeded
      */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java Wed Aug 27 05:35:44 2008
@@ -62,7 +62,7 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[23];
         
         copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java Wed Aug 27 05:35:44 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.awt.Color;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
@@ -41,16 +40,10 @@
  * collection of the graphic characters and control codes is called Presentation
  * Text, and the object that contains the Presentation Text is called the
  * PresentationText object.
- *
  */
 public class PresentationTextObject extends AbstractNamedAFPObject {
 
     /**
-     * Default name for the presentation text object
-     */
-    private static final String DEFAULT_NAME = "PTO00001";
-
-    /**
      * The current presentation text data
      */
     private PresentationTextData currentPresentationTextData = null;
@@ -61,15 +54,9 @@
     private List/*<PresentationTextData>*/ presentationTextDataList = null;
 
     /**
-     * Default constructor for the PresentationTextObject
-     */
-    public PresentationTextObject() {
-        this(DEFAULT_NAME);
-    }
-
-    /**
      * Construct a new PresentationTextObject for the specified name argument,
      * the name should be an 8 character identifier.
+     *
      * @param name the name of this presentation object
      */
     public PresentationTextObject(String name) {
@@ -134,27 +121,6 @@
         this.currentPresentationTextData = null;
     }
 
-    /**
-     * Accessor method to write the AFP datastream for the PresentationTextObject.
-     * 
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
-     */
-    public void write(OutputStream os) throws IOException {
-        writeStart(os);
-        writeObjects(this.presentationTextDataList, os);
-        writeEnd(os);
-    }
-
-    /**
-     * Returns the name of this presentation text object
-     * 
-     * @return the name of this presentation text object
-     */
-    public String getName() {
-        return name;
-    }
-
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
@@ -163,6 +129,11 @@
     }
 
     /** {@inheritDoc} */
+    protected void writeContent(OutputStream os) throws IOException {
+        writeObjects(this.presentationTextDataList, os);
+    }
+
+    /** {@inheritDoc} */
     protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.END, Category.PRESENTATION_TEXT);
@@ -187,7 +158,7 @@
             endControlSequence();
         }
     }
-    
+
     /** {@inheritDoc} */
     public String toString() {
         if (presentationTextDataList != null) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,33 +21,32 @@
 
 import java.util.Collections;
 
-import org.apache.fop.render.afp.DataObjectInfo;
 import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
- * MOD:CA Registry of object types 
+ * MOD:CA Registry of object types
  */
 public final class Registry {
-    /** IOB supported object types */    
-    private static final byte COMPID_GIF = 22;
-    private static final byte COMPID_JFIF = 23; // jpeg file interchange format 
-    private static final byte COMPID_PDF_SINGLE_PAGE = 25; 
-    private static final byte COMPID_PCL_PAGE_OBJECT = 34; 
-    
-    /** IOB unsupported object types */
+    /** IOB supported object types */
     private static final byte COMPID_EPS = 13;
     private static final byte COMPID_TIFF = 14;
+    private static final byte COMPID_GIF = 22;
+    private static final byte COMPID_JFIF = 23; // jpeg file interchange format
+    private static final byte COMPID_PDF_SINGLE_PAGE = 25;
+    private static final byte COMPID_PCL_PAGE_OBJECT = 34;
 
     /** mime type entry mapping */
-    private java.util.Map/*<String, Registry.ObjectType>*/ mimeObjectTypeMap
+    private final java.util.Map/*<String, ObjectType>*/ mimeObjectTypeMap
         = Collections.synchronizedMap(
-                new java.util.HashMap/*<String, Registry.ObjectType>*/());
+                new java.util.HashMap/*<String, ObjectType>*/());
 
     /** singleton instance */
     private static Registry instance = null;
 
     /**
-     * @return a single instance of an ObjectTypeRegistry
+     * Returns a single instance of a MO:DCA Registry
+     *
+     * @return a single instance of an MO:DCA Registry
      */
     public static Registry getInstance() {
         synchronized (Registry.class) {
@@ -57,11 +56,17 @@
         }
         return instance;
     }
-    
+
+    /**
+     * private constructor
+     */
     private Registry() {
         init();
     }
-    
+
+    /**
+     * Initializes the mimetype map
+     */
     private void init() {
         mimeObjectTypeMap.put(
                 MimeConstants.MIME_EPS,
@@ -69,7 +74,7 @@
                         COMPID_EPS,
                         new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0D},
                         "Encapsulated Postscript",
-                        false,
+                        true,
                         MimeConstants.MIME_EPS
                 )
         );
@@ -79,7 +84,7 @@
                         COMPID_TIFF,
                         new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0E},
                         "TIFF",
-                        false,
+                        true,
                         MimeConstants.MIME_TIFF
                 )
         );
@@ -111,7 +116,7 @@
                         true,
                         MimeConstants.MIME_PDF
                 )
-        );         
+        );
         mimeObjectTypeMap.put(
                 MimeConstants.MIME_PCL,
                 new ObjectType(
@@ -121,38 +126,32 @@
                         true,
                         MimeConstants.MIME_PCL
                 )
-        );        
+        );
     }
 
     /**
-     * Returns the Registry ObjectType for a given data object info
-     * or null if not registered
-     * 
-     * @param dataObjectInfo the data object info
-     * @return the Registry ObjectType for a given data object info
-     * or null if not registered
+     * Returns the MOD:CA object type given a mimetype
+     *
+     * @param mimeType the object mimetype
+     * @return the MOD:CA object type
      */
-    public Registry.ObjectType getObjectType(DataObjectInfo dataObjectInfo) {
-        String mimeType = dataObjectInfo.getMimeType();
-        if (mimeType != null) {
-            return (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
-        }
-        return null; 
+    public ObjectType getObjectType(String mimeType) {
+        return (ObjectType)mimeObjectTypeMap.get(mimeType);
     }
 
     /**
      * Encapsulates a MOD:CA Registry Object Type entry
      */
     public class ObjectType {
-        private byte componentId; 
-        private byte[] oid;
-        private String name;
-        private boolean includable;
-        private String mimeType;
+        private final byte componentId;
+        private final byte[] oid;
+        private final String name;
+        private final boolean includable;
+        private final String mimeType;
 
         /**
          * Main constructor
-         * 
+         *
          * @param componentId the component id of this object type
          * @param oid the object id of this object type
          * @param name the object type name
@@ -167,10 +166,10 @@
             this.componentId = componentId;
             this.oid = oid;
         }
-     
+
         /**
          * Returns a MOD:CA object type OID from a given a componentId
-         * 
+         *
          * @return the corresponding object type id for a given component id
          * or null if the component id is unknown and the object type OID was not found.
          */
@@ -180,8 +179,8 @@
 
         /**
          * Returns the object type name for the given componentId
-         * 
-         * @return the object type name for the given componentId 
+         *
+         * @return the object type name for the given componentId
          */
         public String getName() {
             return this.name;
@@ -189,7 +188,7 @@
 
         /**
          * Returns the compontentId for this entry
-         * 
+         *
          * @return the compontentId for this entry
          */
         public byte getComponentId() {
@@ -198,7 +197,7 @@
 
         /**
          * Returns true if this component can be included with an IOB structured field
-         * 
+         *
          * @return true if this component can be included with an IOB structured field
          */
         public boolean isIncludable() {
@@ -207,7 +206,7 @@
 
         /**
          * Returns the mime type associated with this object type
-         * 
+         *
          * @return the mime type associated with this object type
          */
         public String getMimeType() {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java Wed Aug 27 05:35:44 2008
@@ -24,163 +24,82 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
-import org.apache.fop.render.afp.modca.resource.ResourceStore;
-import org.apache.fop.render.afp.modca.resource.StoreInfo;
+import org.apache.fop.util.store.Streamable;
 
 /**
  * A Resource Group contains a set of overlays.
  */
-public final class ResourceGroup extends AbstractNamedAFPObject {
-    
-    /** Default name for the resource group */
-    private static final String DEFAULT_NAME = "RG000001";
+public class ResourceGroup extends AbstractNamedAFPObject {
 
     /** Set of resource uri */
-    private Set/*<String>*/ resourceSet = new java.util.HashSet/*<String>*/();
-
-    private ResourceManager resourceManager;
-    
-    /**
-     * Default constructor
-     */
-    public ResourceGroup(ResourceManager resourceManager) {
-        this(resourceManager, DEFAULT_NAME);
-    }
+    private final Set/*<String>*/ resourceSet = new java.util.HashSet/*<String>*/();
 
     /**
      * Constructor for the ResourceGroup, this takes a
      * name parameter which must be 8 characters long.
-     * 
+     *
      * @param name the resource group name
-     * @param resourceManager the resource group manager
      */
-    public ResourceGroup(ResourceManager resourceManager, String name) {
+    public ResourceGroup(String name) {
         super(name);
-        this.resourceManager = resourceManager;
     }
-    
-//    /**
-//     * Creates a data object in this resource group
-//     * 
-//     * @param dataObjectInfo the data object info
-//     * @return an include object reference
-//     */
-//    public IncludeObject createObject(DataObjectInfo dataObjectInfo) {
-//        String uri = dataObjectInfo.getUri();
-//        resourceSet.get();
-//        DataObjectAccessor dataObjectAccessor
-//            = (DataObjectAccessor)getResourceMap().getData(dataObjectInfo.getUri());
-//        ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
-//        ResourceLevel resourceLevel = resourceInfo.getLevel();
-//        AbstractDataObject dataObj;
-//        if (dataObjectAccessor == null) {
-//            dataObj = dataObjectFactory.createObject(dataObjectInfo);
-//            ObjectContainer objectContainer = null;
-//            String resourceName = resourceInfo.getName();
-//            if (resourceName != null) {
-//                objectContainer = new ObjectContainer(resourceName);
-//            } else {
-//                objectContainer = createObjectContainer();
-//                resourceName = objectContainer.getName();
-//            }
-//            objectContainer.setDataObject(dataObj);
-//            objectContainer.setDataObjectInfo(dataObjectInfo);
-//            
-//            // When located at print-file level or externally,
-//            // wrap the object container in a resource object
-//            if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) {
-//                ResourceObject resourceObject = new ResourceObject(resourceName);
-//                resourceObject.setDataObject(objectContainer);
-//                resourceObject.setDataObjectInfo(dataObjectInfo);
-//                dataObjectAccessor = resourceObject;
-//            } else { // Access data object through container
-//                dataObjectAccessor = objectContainer;
-//            }
-//            
-//            // Add to resource map
-//            getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor);            
-//        }
-//        String name = dataObjectAccessor.getName();
-//        IncludeObject includeObj = dataObjectFactory.createInclude(dataObjectInfo);
-//        return includeObj;
-//    }
-    
-//    /**
-//     * Checks if a named object is of a valid type to be added to a resource group
-//     * 
-//     * @param namedObj a named object
-//     * @return true if the named object is of a valid type to be added to a resource group
-//     */
-//    private boolean isValidObjectType(AbstractNamedAFPObject namedObj) {
-//        return (namedObj instanceof Overlay
-//                || namedObj instanceof ResourceObject
-//                || namedObj instanceof PageSegment
-//                || namedObj instanceof GraphicsObject
-//                || namedObj instanceof ImageObject
-//                || namedObj instanceof ObjectContainer
-//                || namedObj instanceof Document
-//                // || namedObj instanceof FormMap
-//                // || namedObj instanceof BarcodeObject 
-//                );
-//    }
 
     /**
-     * Add this object cache record to this resource group
-     * 
-     * @param record the cache record
+     * Add this named object to this resource group
+     *
+     * @param namedObject a named object
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
      */
-    public void addObject(StoreInfo record) {
-        resourceSet.add(record);
+    public void addObject(AbstractNamedAFPObject namedObject) throws IOException {
+        resourceSet.add(namedObject);
     }
-    
+
     /**
      * Returns the number of resources contained in this resource group
-     * 
+     *
      * @return the number of resources contained in this resource group
      */
     public int getResourceCount() {
-        return resourceSet.size(); 
+        return resourceSet.size();
     }
-    
+
     /**
      * Returns true if the resource exists within this resource group,
      * false otherwise.
-     * 
+     *
      * @param uri the uri of the resource
      * @return true if the resource exists within this resource group
      */
     public boolean resourceExists(String uri) {
         return resourceSet.contains(uri);
     }
-    
-    /** {@inheritDoc} */
-    public void writeContent(OutputStream os) throws IOException {
-        Iterator it = resourceSet.iterator();
-
-        if (it.hasNext()) {            
-            ResourceStore store = resourceManager.getStore();
-            do {
-                StoreInfo saveInfo = (StoreInfo)it.next();
-                store.writeToStream(saveInfo, os);
-            } while (it.hasNext());
-        }
-    }
 
     /** {@inheritDoc} */
-    protected void writeStart(OutputStream os) throws IOException {
+    public void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.BEGIN, Category.RESOURCE_GROUP);
         os.write(data);
     }
 
     /** {@inheritDoc} */
-    protected void writeEnd(OutputStream os) throws IOException {
+    public void writeContent(OutputStream os) throws IOException {
+        Iterator it = resourceSet.iterator();
+        while (it.hasNext()) {
+            Object object = it.next();
+            if (object instanceof Streamable) {
+                Streamable streamableObject = (Streamable)object;
+                streamableObject.writeToStream(os);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         copySF(data, Type.END, Category.RESOURCE_GROUP);
         os.write(data);
     }
-    
+
     /** {@inheritDoc} */
     public String toString() {
         return this.name + " " + resourceSet/*getResourceMap()*/;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,15 +27,15 @@
 
 /**
  * This resource structured field begins an envelope that is used to carry
- * resource objects in print-file-level (external) resource groups. 
+ * resource objects in print-file-level (external) resource groups.
  */
 public class ResourceObject extends AbstractPreparedAFPObject {
-    
+
     private AbstractNamedAFPObject namedObject;
-    
+
     /**
      * Default constructor
-     * 
+     *
      * @param name the name of this resource (reference id)
      */
     public ResourceObject(String name) {
@@ -44,13 +44,13 @@
 
     /**
      * Sets the data object referenced by this resource object
-     * 
+     *
      * @param obj the named data object
      */
     public void setDataObject(AbstractNamedAFPObject obj) {
         this.namedObject = obj;
     }
-        
+
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
         super.writeStart(os);
@@ -62,10 +62,11 @@
         byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2);
         data[1] = len[0]; // Length byte 1
         data[2] = len[1]; // Length byte 2
-            
+
         // Set reserved bits
         data[17] = 0x00; // Reserved
         data[18] = 0x00; // Reserved
+
         os.write(data);
     }
 
@@ -73,7 +74,7 @@
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os); // write triplets
         if (namedObject != null) {
-            namedObject.write(os);
+            namedObject.writeToStream(os);
         }
     }
 
@@ -83,15 +84,15 @@
         copySF(data, Type.END, Category.NAME_RESOURCE);
         os.write(data);
     }
-    
+
     /** {@inheritDoc} */
     public String toString() {
         return this.getName();
     }
-    
+
     /**
      * Sets Resource Object Type triplet
-     * 
+     *
      * @param type the resource object type
      */
     public void setType(byte type) {
@@ -100,17 +101,17 @@
 
     /** graphics object type */
     public static final byte TYPE_GRAPHIC = 0x03;
-    
+
     /** barcode object type */
     public static final byte BARCODE = 0x05;
 
     /** image object type */
     public static final byte TYPE_IMAGE = 0x06;
-    
+
 //    private static final byte FONT_CHARACTER_SET = 0x40;
 //    private static final byte CODE_PAGE = 0x41;
 //    private static final byte CODED_FONT = 0x42;
-    
+
     /** object container type */
     public static final byte TYPE_OBJECT_CONTAINER = (byte) 0x92;
 
@@ -122,7 +123,7 @@
 
     /** overlay object type */
     public static final byte TYPE_OVERLAY_OBJECT = (byte) 0xFC;
-    
+
 //    private static final byte PAGEDEF = (byte) 0xFD;
 //    private static final byte FORMDEF = (byte) 0xFE;
 
@@ -132,7 +133,7 @@
 
         /**
          * Main constructor
-         * 
+         *
          * @param type
          *            the resource objec type
          */

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A print-file resource group
+ */
+public class StreamedResourceGroup extends ResourceGroup {
+    /** the outputstream to write to */
+    private final OutputStream os;
+
+    private boolean started = false;
+
+    private boolean complete = false;
+
+    /**
+     * Main constructor
+     *
+     * @param name the resource group name
+     * @param os the outputstream
+     */
+    public StreamedResourceGroup(String name, OutputStream os) {
+        super(name);
+        this.os = os;
+    }
+
+    /**
+     * Adds a resource to the external resource group
+     *
+     * @param namedObject a named object
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
+     */
+    public void addObject(AbstractNamedAFPObject namedObject) throws IOException {
+        if (!started) {
+            writeStart(os);
+            started = true;
+        }
+        try {
+            namedObject.writeToStream(os);
+        } finally {
+            os.flush();
+        }
+    }
+
+    /**
+     * Closes this external resource group file
+     *
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
+     */
+    public void close() throws IOException {
+        writeEnd(os);
+        complete = true;
+    }
+
+    /**
+     * Returns true if this resource group is complete
+     *
+     * @return true if this resource group is complete
+     */
+    public boolean isComplete() {
+        return this.complete;
+    }
+
+    /**
+     * Returns the outputstream
+     *
+     * @return the outputstream
+     */
+    public OutputStream getOutputStream() {
+        return this.os;
+    }
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java Wed Aug 27 05:35:44 2008
@@ -69,7 +69,7 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
 
         byte[] data = new byte[17 + name.length() + value.length()];
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,43 +30,43 @@
  * The object data may or may not be defined by an IBM presentation architecture
  */
 public class ObjectClassificationTriplet extends Triplet {
-    
+
     /**
      * The scope of this object is the including page or overlay
      */
     public static final byte CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT = 0x01;
-    
+
     /**
      * The scope of this object is not defined
      */
     public static final byte CLASS_TIME_VARIANT_PRESENTATION_OBJECT = 0x10;
-    
+
     /**
      * This is not a presentation object, the scope of this object is not defined
      */
     public static final byte CLASS_EXECUTABLE_PROGRAM = 0x20;
-    
-    /** 
+
+    /**
      * Setup information file, document level.  This is not a presentation object,
-     */    
+     */
     public static final byte CLASS_SETUP_FILE = 0x30;
-    
+
     /**
      * This is a resource used by a presentation object that may itself be a resource.
      * The scope of the resource is the object that uses the resource.
      */
     public static final byte CLASS_SECONDARY_RESOURCE = 0x40;
 
-    /** 
+    /**
      * Data object font.  This is a non-FOCA font resource used to present
      * text in a data object.  The scope of the resource is the object that
      * uses the resource.
      */
     public static final byte CLASS_DATA_OBJECT_FONT = 0x41;
-        
+
     /**
      * Main constructor
-     * 
+     *
      * @param objectClass
      *             the object class type
      * @param objectType
@@ -79,15 +79,15 @@
         // no object level or company name specified
         this(objectClass, objectType, strucFlgs, null, null);
     }
-    
-    
+
+
     private static final int OBJECT_LEVEL_LEN = 8;
     private static final int OBJECT_TYPE_NAME_LEN = 32;
     private static final int COMPANY_NAME_LEN = 32;
-    
+
     /**
      * Fully parameterized constructor
-     * 
+     *
      * @param objectClass
      *             the object class type
      * @param objectType
@@ -104,7 +104,7 @@
         super(OBJECT_CLASSIFICATION);
 
         if (objectType == null) {
-            throw new UnsupportedOperationException("MO:DCA Registry object type is null");
+            throw new IllegalArgumentException("MO:DCA Registry object type is null");
         }
 
         byte[] data = new byte[94];
@@ -112,14 +112,14 @@
         data[1] = objectClass; // ObjClass
         data[2] = 0x00; // reserved (must be zero)
         data[3] = 0x00; // reserved (must be zero)
-        // StrucFlgs - Information on the structure of the object container        
+        // StrucFlgs - Information on the structure of the object container
         data[4] = strucFlgs.getValue();
         data[5] = 0x00; // StrucFlgs
-                
+
         byte[] oid = objectType.getOID();
         // RegObjId - MOD:CA-registered ASN.1 OID for object type (8-23)
         System.arraycopy(oid, 0, data, 6, oid.length);
-            
+
         // ObjTpName - name of object type (24-55)
         byte[] objTpName;
         try {
@@ -129,7 +129,7 @@
         } catch (UnsupportedEncodingException e) {
             throw new IllegalArgumentException("an encoding exception occurred");
         }
-             
+
         // ObjLev - release level or version number of object type (56-63)
         byte[] objectLevel;
         try {
@@ -138,9 +138,9 @@
         } catch (UnsupportedEncodingException e) {
             throw new IllegalArgumentException("an encoding exception occurred");
         }
-        System.arraycopy(objectLevel, 0, data, 54, objectLevel.length);        
-        
-        // CompName - name of company or org that owns object definition (64-95)
+        System.arraycopy(objectLevel, 0, data, 54, objectLevel.length);
+
+        // CompName - name of company or organization that owns object definition (64-95)
         byte[] companyName;
         try {
             companyName = StringUtils.rpad(compName, ' ', COMPANY_NAME_LEN).getBytes(
@@ -149,7 +149,8 @@
             throw new IllegalArgumentException("an encoding exception occurred");
         }
         System.arraycopy(companyName, 0, data, 62, companyName.length);
-        
+
         super.setData(data);
     }
+
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,46 +24,65 @@
  * information on the structure of the object and its container
  */
 public class StrucFlgs {
-    private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 1;
-    private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 2;
-    private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 3;
-    
-    private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 4;
+
+//    private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 1;
+//    private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 2;
+//    private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 3;
+//
+//    private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 4;
+//    private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
+//    private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 12;
+//
+//    private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 16;
+//    private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 32;
+//    private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 48;
+
+    private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 48;
+    private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 32;
+    private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 16;
+
+    private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 12;
     private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
-    private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 12;
-    
-    private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 16;
-    private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 32;
-    private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 48;
-    
-    private static StrucFlgs DEFAULT_STRUC_FLGS = null;
+    private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 4;
+
+    private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 3;
+    private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 2;
+    private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 1;
+
+    /**
+     * the default structured flags setting
+     * - data is in container with no object environment group and data in object container data
+     */
+    public static final StrucFlgs DEFAULT = new StrucFlgs(true, false, true);
+
+
+    private int value = 0;
 
-    private byte value = 0;
-    
     /**
      * Main constructor
+     *
      * @param dataInContainer true if the object data in carried in the object container
      * @param containerHasOEG true if the object container has an object environment group
-     * @param dataInOCD true if the object container data carries the object data 
+     * @param dataInOCD true if the object container data carries the object data
      */
     public StrucFlgs(boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) {
         if (dataInContainer) {
             this.value += OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER;
         } else {
-            this.value += OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER;                
+            this.value += OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER;
         }
         if (containerHasOEG) {
             this.value += OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP;
         } else {
-            this.value += OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP;                
+            this.value += OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP;
         }
         if (dataInOCD) {
             this.value += OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA;
         } else {
-            this.value += OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA;                
+            this.value += OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA;
         }
     }
-    
+
     /**
      * Default constructor
      */
@@ -74,27 +93,11 @@
     }
 
     /**
+     * Returns the value of structure flags value
+     *
      * @return the value of structure flags value
      */
     public byte getValue() {
-        return this.value;
-    }
-    
-    /**
-     * Returns the default strucflg setting
-     * (data in container, container without OEG, data in OCD)
-     * 
-     * @return the default strucflg settings
-     */
-    public static StrucFlgs getDefault() {
-        synchronized (StrucFlgs.class) {
-            if (DEFAULT_STRUC_FLGS == null) {
-                final boolean dataInContainer = true;
-                final boolean containerHasOEG = false;
-                final boolean dataInOCD = true;
-                DEFAULT_STRUC_FLGS = new StrucFlgs(dataInContainer, containerHasOEG, dataInOCD);
-            }   
-        }
-        return DEFAULT_STRUC_FLGS;
+        return (byte)this.value;
     }
 }
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org