xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acumis...@apache.org
Subject svn commit: r648675 [2/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp: ./ goca/ modca/ modca/triplets/
Date Wed, 16 Apr 2008 12:03:29 GMT
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=648675&r1=648674&r2=648675&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 Apr 16 05:03:15 2008
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.ResourceInfo;
 import org.apache.fop.render.afp.modca.triplets.Triplet;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
@@ -30,34 +29,17 @@
  * This resource structured field begins an envelope that is used to carry
  * resource objects in print-file-level (external) resource groups. 
  */
-public class ResourceObject extends AbstractPreparedAFPObject {
+public class ResourceObject extends AbstractPreparedAFPObject implements DataObjectAccessor
{
     
     /**
-     * Resource object types
+     * the object container of this resource object
      */
-    private static final byte GRAPHICS_OBJECT = 0x03;
-    private static final byte BARCODE_OBJECT = 0x05;
-    private static final byte IMAGE_OBJECT = 0x06;
-    private static final byte FONT_CHARACTER_SET_OBJECT = 0x40;
-    private static final byte CODE_PAGE_OBJECT = 0x41;
-    private static final byte CODED_FONT_OBJECT = 0x42;
-    private static final byte OBJECT_CONTAINER = (byte) 0x92;
-    private static final byte DOCUMENT_OBJECT = (byte) 0xA8;
-    private static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB;
-    private static final byte OVERLAY_OBJECT = (byte) 0xFC;
-    private static final byte PAGEDEF_OBJECT = (byte) 0xFD;
-    private static final byte FORMDEF_OBJECT = (byte) 0xFE;
-        
-    /**
-     * the referenced data object
-     */    
-    private AbstractNamedAFPObject dataObj = null;
+    private ObjectContainer objectContainer;
         
     /**
      * Default constructor
      * 
      * @param name the name of this resource (reference id)
-     * @param dataObj the resource object to be added
      */
     public ResourceObject(String name) {
         super(name);
@@ -65,32 +47,41 @@
         
     /**
      * Sets the data object referenced by this resource object
-     * @param dataObj the data object
+     * @param objectContainer the object container
      */
-    public void setReferencedObject(AbstractNamedAFPObject dataObj) {
-        this.dataObj = dataObj;
-        setResourceObjectType(dataObj);
+    public void setObjectContainer(ObjectContainer objectContainer) {
+        this.objectContainer = objectContainer;
+        setResourceObjectType(objectContainer);
     }
-
+    
     /**
-     * @return the resource object contained in this envelope 
+     * {@inheritDoc}
      */
-    public AbstractNamedAFPObject getReferencedObject() {
-        return this.dataObj;
+    public AbstractNamedAFPObject getDataObject() {
+        if (objectContainer != null) {
+            return objectContainer.getDataObject();
+        }
+        return null;
     }
     
-    private void setResourceObjectType(AbstractNamedAFPObject resourceObj) {
+    /**
+     * Sets the resource object type
+     * @param resourceObj the resource object
+     */
+    public void setResourceObjectType(AbstractNamedAFPObject resourceObj) {
         byte type;
-        if (resourceObj instanceof ImageObject) {
-            type = IMAGE_OBJECT;
+        if (resourceObj instanceof ObjectContainer) {
+            type = ResourceObjectTypeTriplet.OBJECT_CONTAINER;
+        } else if (resourceObj instanceof ImageObject) {
+            type = ResourceObjectTypeTriplet.IMAGE_OBJECT;
         } else if (resourceObj instanceof GraphicsObject) {
-            type = GRAPHICS_OBJECT;
+            type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT;
         } else if (resourceObj instanceof Document) {
-            type = DOCUMENT_OBJECT;
+            type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT;
         } else if (resourceObj instanceof PageSegment) {
-            type = PAGE_SEGMENT_OBJECT;
+            type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT;
         } else if (resourceObj instanceof Overlay) {
-            type = OVERLAY_OBJECT;
+            type = ResourceObjectTypeTriplet.OVERLAY_OBJECT;
         } else {
             throw new UnsupportedOperationException(
                     "Unsupported resource object type " + resourceObj);
@@ -135,8 +126,8 @@
      */
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os); // write triplets
-        if (dataObj != null) {
-            dataObj.writeDataStream(os);
+        if (objectContainer != null) {
+            objectContainer.writeDataStream(os);
         }
     }
 
@@ -176,6 +167,22 @@
     private class ResourceObjectTypeTriplet extends Triplet {
 
         private static final byte RESOURCE_OBJECT = 0x21;
+
+        /**
+         * Resource object types
+         */
+        private static final byte GRAPHICS_OBJECT = 0x03;
+//        private static final byte BARCODE_OBJECT = 0x05;
+        private static final byte IMAGE_OBJECT = 0x06;
+//        private static final byte FONT_CHARACTER_SET_OBJECT = 0x40;
+//        private static final byte CODE_PAGE_OBJECT = 0x41;
+//        private static final byte CODED_FONT_OBJECT = 0x42;
+        private static final byte OBJECT_CONTAINER = (byte) 0x92;
+        private static final byte DOCUMENT_OBJECT = (byte) 0xA8;
+        private static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB;
+        private static final byte OVERLAY_OBJECT = (byte) 0xFC;
+//        private static final byte PAGEDEF_OBJECT = (byte) 0xFD;
+//        private static final byte FORMDEF_OBJECT = (byte) 0xFE;
 
         /**
          * Main constructor

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
(original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
Wed Apr 16 05:03:15 2008
@@ -96,12 +96,15 @@
      */
     public FullyQualifiedNameTriplet(byte type, byte format, byte[] name) {
         super(FULLY_QUALIFIED_NAME);
+        
         this.nameBytes = name;
-        super.data = new byte[2 + name.length];
+        byte[] data = new byte[2 + name.length];
         data[0] = type;
         data[1] = format;
         // FQName
         System.arraycopy(name, 0, data, 2, name.length);
+        
+        super.setData(data);
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java
(original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java
Wed Apr 16 05:03:15 2008
@@ -38,7 +38,7 @@
         //TODO: units correct?
         byte[] xUnits = BinaryUtils.convert(1, 2);
         byte[] yUnits = BinaryUtils.convert(1, 2);
-        super.data = new byte[] {
+        byte[] data = new byte[] {
              TEN_INCHES, // XoaBase
              TEN_INCHES, // YoaBase
              xUnits[0], // XoaUnits (x units per unit base)                
@@ -46,5 +46,6 @@
              yUnits[0], // YoaUnits (y units per unit base)
              yUnits[1]
         };
+        super.setData(data);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java
(original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java
Wed Apr 16 05:03:15 2008
@@ -36,7 +36,7 @@
         super(Triplet.OBJECT_AREA_SIZE);
         byte[] xOASize = BinaryUtils.convert(x, 3);
         byte[] yOASize = BinaryUtils.convert(y, 3);
-        super.data = new byte[] {
+        byte[] data = new byte[] {
             0x02, // SizeType
             xOASize[0], // XoaSize - Object area extent for X axis
             xOASize[1],
@@ -45,5 +45,6 @@
             yOASize[1],
             yOASize[2]
         };
+        super.setData(data);
     }
 }

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=648675&r1=648674&r2=648675&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 Apr 16 05:03:15 2008
@@ -19,7 +19,11 @@
 
 package org.apache.fop.render.afp.modca.triplets;
 
-import org.apache.fop.render.afp.modca.ObjectTypeRegistry;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.modca.AFPConstants;
+import org.apache.fop.render.afp.modca.Registry;
+import org.apache.fop.render.afp.tools.StringUtils;
 
 /**
  * The Object Classification is used to classify and identify object data.
@@ -65,15 +69,45 @@
      * 
      * @param objectClass
      *             the object class type
-     * @param entry
+     * @param objectType
      *             the object type registry entry
      * @param strucFlgs
      *             the structured flags pertaining to this object classification triplet
      */
-    public ObjectClassificationTriplet(byte objectClass, ObjectTypeRegistry.ObjectType entry,
+    public ObjectClassificationTriplet(byte objectClass, Registry.ObjectType objectType,
             StrucFlgs strucFlgs) {
+        // 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
+     *             the object type registry entry
+     * @param strucFlgs
+     *             the structured flags pertaining to this object classification triplet
+     * @param objLev
+     *             the release level or version number of the object type
+     * @param compName
+     *             the name of the company or organization that owns the object definition
+     */
+    public ObjectClassificationTriplet(byte objectClass, Registry.ObjectType objectType,
+            StrucFlgs strucFlgs, String objLev, String compName) {
         super(OBJECT_CLASSIFICATION);
-        byte[] data = new byte[93];
+
+        if (objectType == null) {
+            throw new UnsupportedOperationException("MO:DCA Registry object type is null");
+        }
+
+        byte[] data = new byte[94];
         data[0] = 0x00; // reserved (must be zero)
         data[1] = objectClass; // ObjClass
         data[2] = 0x00; // reserved (must be zero)
@@ -81,21 +115,41 @@
         // StrucFlgs - Information on the structure of the object container        
         data[4] = strucFlgs.getValue();
         data[5] = 0x00; // StrucFlgs
-        
-        if (entry == null) {
-            throw new UnsupportedOperationException("Unknown registry entry");
-        }
-        
-        byte[] oid = entry.getOID();
+                
+        byte[] oid = objectType.getOID();
         // RegObjId - MOD:CA-registered ASN.1 OID for object type (8-23)
         System.arraycopy(oid, 0, data, 6, oid.length);
             
-        byte[] objectTypeName = entry.getName();
         // ObjTpName - name of object type (24-55)
-        System.arraycopy(objectTypeName, 0, data, 22, objectTypeName.length);
+        byte[] objTpName;
+        try {
+            objTpName = StringUtils.rpad(objectType.getName(), ' ', OBJECT_TYPE_NAME_LEN).getBytes(
+                    AFPConstants.EBCIDIC_ENCODING);
+            System.arraycopy(objTpName, 0, data, 22, objTpName.length);
+        } catch (UnsupportedEncodingException e) {
+            throw new IllegalArgumentException("an encoding exception occurred");
+        }
              
-        // ObjLev (not specified) - Release level or version number of object type (56-63)
-
-        // CompName (not specified) - Name of company or org that owns object definition
(64-95)
+        // ObjLev - release level or version number of object type (56-63)
+        byte[] objectLevel;
+        try {
+            objectLevel = StringUtils.rpad(objLev, ' ', OBJECT_LEVEL_LEN).getBytes(
+                    AFPConstants.EBCIDIC_ENCODING);
+        } 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)
+        byte[] companyName;
+        try {
+            companyName = StringUtils.rpad(compName, ' ', COMPANY_NAME_LEN).getBytes(
+                    AFPConstants.EBCIDIC_ENCODING);
+        } catch (UnsupportedEncodingException e) {
+            throw new IllegalArgumentException("an encoding exception occurred");
+        }
+        System.arraycopy(companyName, 0, data, 62, companyName.length);
+        
+        super.setData(data);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java?rev=648675&r1=648674&r2=648675&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java
(original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java
Wed Apr 16 05:03:15 2008
@@ -31,6 +31,8 @@
  */
 public class Triplet extends AbstractAFPObject {
     public static final byte CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER = 0x01;
+    
+    /** Triplet identifiers */
     public static final byte FULLY_QUALIFIED_NAME = 0x02;    
     public static final byte MAPPING_OPTION = 0x04;  
     public static final byte OBJECT_CLASSIFICATION = 0x10;    
@@ -89,21 +91,21 @@
     /**
      * the triplet identifier
      */
-    protected byte id;
+    private byte id;
 
     /**
      * the triplet's data contents
      */
-    protected byte[] data;
+    private byte[] data;
 
     /**
      * Main constructor
      * @param id the triplet identifier (see static definitions above)
-     * @param contents the data item contained in this triplet
+     * @param data the data item contained in this triplet
      */
-    public Triplet(byte id, byte[] contents) {
+    public Triplet(byte id, byte[] data) {
         this(id);
-        this.data = contents;
+        setData(data);
     }
 
     /**
@@ -150,9 +152,10 @@
     }
 
     /**
-     * @return the contents of the triplet
+     * Sets the data contents of this triplet
+     * @param data the data contents
      */
-    public byte[] getData() {
-        return this.data;
+    protected void setData(byte[] data) {
+        this.data = data;
     }
 }



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


Mime
View raw message