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 ph...@apache.org on 2012/07/03 18:03:10 UTC

svn commit: r1356804 [2/12] - in /xmlgraphics/fop/branches/Temp_RoundedCorners: ./ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/events/ examples/embedding/java/embedding/intermediate/ src...

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDataObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDataObjectInfo.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDataObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDataObjectInfo.java Tue Jul  3 16:01:48 2012
@@ -57,6 +57,8 @@ public class AFPDataObjectInfo {
     /** controls the mapping of the image data into the image area */
     private byte mappingOption = MappingOptionTriplet.SCALE_TO_FILL;
 
+    public static final byte DEFAULT_MAPPING_OPTION = 0x00;
+
     /**
      * Default constructor
      */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPDitheredRectanglePainter.java Tue Jul  3 16:01:48 2012
@@ -28,6 +28,7 @@ import java.io.IOException;
 import org.apache.xmlgraphics.image.loader.ImageSize;
 import org.apache.xmlgraphics.util.MimeConstants;
 
+import org.apache.fop.afp.AFPResourceLevel.ResourceType;
 import org.apache.fop.afp.modca.triplets.MappingOptionTriplet;
 import org.apache.fop.util.bitmap.DitherUtil;
 
@@ -66,7 +67,7 @@ public class AFPDitheredRectanglePainter
         AFPImageObjectInfo imageObjectInfo = new AFPImageObjectInfo();
         imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS10);
         //imageObjectInfo.setCreatePageSegment(true);
-        imageObjectInfo.getResourceInfo().setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE));
+        imageObjectInfo.getResourceInfo().setLevel(new AFPResourceLevel(ResourceType.INLINE));
         imageObjectInfo.getResourceInfo().setImageDimension(ditherSize);
         imageObjectInfo.setBitsPerPixel(1);
         imageObjectInfo.setColor(false);

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceInfo.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceInfo.java Tue Jul  3 16:01:48 2012
@@ -21,6 +21,7 @@ package org.apache.fop.afp;
 
 import java.awt.Dimension;
 
+import org.apache.fop.afp.AFPResourceLevel.ResourceType;
 
 /**
  * The level at which a resource is to reside in the AFP output
@@ -29,7 +30,7 @@ public class AFPResourceInfo {
 
     /** the general default resource level */
     public static final AFPResourceLevel DEFAULT_LEVEL
-        = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
+            = new AFPResourceLevel(ResourceType.PRINT_FILE);
 
     /** the URI of this resource */
     private String uri = null;

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevel.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevel.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevel.java Tue Jul  3 16:01:48 2012
@@ -19,46 +19,56 @@
 
 package org.apache.fop.afp;
 
+import java.net.URI;
+
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.DOCUMENT;
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.EXTERNAL;
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.INLINE;
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.PAGE;
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.PAGE_GROUP;
+import static org.apache.fop.afp.AFPResourceLevel.ResourceType.PRINT_FILE;
+
 /**
  * A resource level
  */
 public class AFPResourceLevel {
+    public enum ResourceType {
+        /** directly in page **/
+        INLINE("inline"),
+        /** page level **/
+        PAGE("page"),
+        /** page group level **/
+        PAGE_GROUP("page-group"),
+        /** document level **/
+        DOCUMENT("document"),
+        /** print file level **/
+        PRINT_FILE("print-file"),
+        /** external level **/
+        EXTERNAL("external");
 
-    /** directly in page **/
-    public static final int INLINE = 0;
-
-    /** page level **/
-    public static final int PAGE = 1;
-
-    /** page group level **/
-    public static final int PAGE_GROUP = 2;
-
-    /** document level **/
-    public static final int DOCUMENT = 3;
-
-    /** print file level **/
-    public static final int PRINT_FILE = 4;
+        private final String name;
 
-    /** external level **/
-    public static final int EXTERNAL = 5;
-
-    private static final String NAME_INLINE = "inline";
-    private static final String NAME_PAGE = "page";
-    private static final String NAME_PAGE_GROUP = "page-group";
-    private static final String NAME_DOCUMENT = "document";
-    private static final String NAME_PRINT_FILE = "print-file";
-    private static final String NAME_EXTERNAL = "external";
-
-    private static final String[] NAMES = new String[] {
-        NAME_INLINE, NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL
-    };
+        private ResourceType(String name) {
+            this.name = name;
+        }
 
+        public static ResourceType getValueOf(String levelString) {
+            for (ResourceType resType : ResourceType.values()) {
+                if (resType.name.equalsIgnoreCase(levelString)) {
+                    return resType;
+                }
+            }
+            return null;
+        }
 
-    /** where the resource will reside in the AFP output */
-    private int level = PRINT_FILE; // default is print-file level (images)
+        public String getName() {
+            return name;
+        }
+    }
 
     /** the external resource group file path */
-    private String extFilePath = null;
+    private URI extUri = null;
+    private ResourceType resourceType;
 
     /**
      * Sets the resource placement level within the AFP output
@@ -67,18 +77,8 @@ public class AFPResourceLevel {
      * @return true if the resource level was successfully set
      */
     public static AFPResourceLevel valueOf(String levelString) {
-        if (levelString != null) {
-            levelString = levelString.toLowerCase();
-            AFPResourceLevel resourceLevel = null;
-            for (int i = 0; i < NAMES.length; i++) {
-                if (NAMES[i].equals(levelString)) {
-                    resourceLevel = new AFPResourceLevel(i);
-                    break;
-                }
-            }
-            return resourceLevel;
-        }
-        return null;
+        ResourceType resType = ResourceType.getValueOf(levelString);
+        return resType != null ? new AFPResourceLevel(resType) : null;
     }
 
     /**
@@ -86,17 +86,8 @@ public class AFPResourceLevel {
      *
      * @param level the resource level
      */
-    public AFPResourceLevel(int level) {
-        setLevel(level);
-    }
-
-    /**
-     * Sets the resource level
-     *
-     * @param level the resource level
-     */
-    public void setLevel(int level) {
-        this.level = level;
+    public AFPResourceLevel(ResourceType resourceType) {
+        this.resourceType = resourceType;
     }
 
     /**
@@ -105,7 +96,7 @@ public class AFPResourceLevel {
      * @return true if this is at page level
      */
     public boolean isPage() {
-       return level == PAGE;
+        return resourceType == PAGE;
     }
 
     /**
@@ -114,7 +105,7 @@ public class AFPResourceLevel {
      * @return true if this is at page group level
      */
     public boolean isPageGroup() {
-        return level == PAGE_GROUP;
+        return resourceType == PAGE_GROUP;
     }
 
     /**
@@ -123,7 +114,7 @@ public class AFPResourceLevel {
      * @return true if this is at document level
      */
     public boolean isDocument() {
-        return level == DOCUMENT;
+        return resourceType == DOCUMENT;
     }
 
     /**
@@ -132,7 +123,7 @@ public class AFPResourceLevel {
      * @return true if this is at external level
      */
     public boolean isExternal() {
-        return level == EXTERNAL;
+        return resourceType == EXTERNAL;
     }
 
     /**
@@ -141,7 +132,7 @@ public class AFPResourceLevel {
      * @return true if this is at print-file level
      */
     public boolean isPrintFile() {
-        return level == PRINT_FILE;
+        return resourceType == PRINT_FILE;
     }
 
     /**
@@ -150,30 +141,30 @@ public class AFPResourceLevel {
      * @return true if this resource level is inline
      */
     public boolean isInline() {
-        return level == INLINE;
+        return resourceType == INLINE;
     }
 
     /**
-     * Returns the destination file path of the external resource group file
+     * Returns the URI of the external resource group.
      *
-     * @return the destination file path of the external resource group file
+     * @return the destination URI of the external resource group
      */
-    public String getExternalFilePath() {
-        return this.extFilePath;
+    public URI getExternalURI() {
+        return this.extUri;
     }
 
     /**
-     * Sets the external destination of the resource
+     * Sets the URI of the external resource group.
      *
-     * @param filePath the external resource group file
+     * @param filePath the URI of the external resource group
      */
-    public void setExternalFilePath(String filePath) {
-        this.extFilePath = filePath;
+    public void setExternalUri(URI uri) {
+        this.extUri = uri;
     }
 
     /** {@inheritDoc} */
     public String toString() {
-        return NAMES[level] +  (isExternal() ? ", file=" + extFilePath : "");
+        return resourceType + (isExternal() ? ", uri=" + extUri : "");
     }
 
     /** {@inheritDoc} */
@@ -186,16 +177,16 @@ public class AFPResourceLevel {
         }
 
         AFPResourceLevel rl = (AFPResourceLevel)obj;
-        return (level == rl.level)
-            && (extFilePath == rl.extFilePath
-                    || extFilePath != null && extFilePath.equals(rl.extFilePath));
+        return (resourceType == rl.resourceType)
+            && (extUri == rl.extUri
+                    || extUri != null && extUri.equals(rl.extUri));
     }
 
     /** {@inheritDoc} */
     public int hashCode() {
         int hash = 7;
-        hash = 31 * hash + level;
-        hash = 31 * hash + (null == extFilePath ? 0 : extFilePath.hashCode());
+        hash = 31 * hash + resourceType.hashCode();
+        hash = 31 * hash + (null == extUri ? 0 : extUri.hashCode());
         return hash;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java Tue Jul  3 16:01:48 2012
@@ -22,6 +22,7 @@ package org.apache.fop.afp;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.fop.afp.AFPResourceLevel.ResourceType;
 import org.apache.fop.afp.modca.ResourceObject;
 
 /**
@@ -58,7 +59,7 @@ public class AFPResourceLevelDefaults {
         // level not explicitly set/changed so default to inline for GOCA graphic objects
         // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07), hard copy works just fine)
         setDefaultResourceLevel(ResourceObject.TYPE_GRAPHIC,
-                new AFPResourceLevel(AFPResourceLevel.INLINE));
+                new AFPResourceLevel(ResourceType.INLINE));
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceManager.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPResourceManager.java Tue Jul  3 16:01:48 2012
@@ -31,6 +31,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.afp.AFPResourceLevel.ResourceType;
 import org.apache.fop.afp.fonts.AFPFont;
 import org.apache.fop.afp.fonts.CharacterSet;
 import org.apache.fop.afp.modca.AbstractNamedAFPObject;
@@ -41,8 +42,9 @@ import org.apache.fop.afp.modca.PageSegm
 import org.apache.fop.afp.modca.Registry;
 import org.apache.fop.afp.modca.ResourceGroup;
 import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.afp.util.AFPResourceAccessor;
 import org.apache.fop.afp.util.AFPResourceUtil;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.apps.io.InternalResourceResolver;
 
 /**
  * Manages the creation and storage of document resources
@@ -74,9 +76,9 @@ public class AFPResourceManager {
     /**
      * Main constructor
      */
-    public AFPResourceManager() {
+    public AFPResourceManager(InternalResourceResolver resourceResolver) {
         this.factory = new Factory();
-        this.streamer = new AFPStreamer(factory);
+        this.streamer = new AFPStreamer(factory, resourceResolver);
         this.dataObjectFactory = new AFPDataObjectFactory(factory);
     }
 
@@ -119,8 +121,8 @@ public class AFPResourceManager {
      * @param filePath the default resource group file path
      */
 
-    public void setDefaultResourceGroupFilePath(String filePath) {
-        streamer.setDefaultResourceGroupFilePath(filePath);
+    public void setDefaultResourceGroupUri(URI uri) {
+        streamer.setDefaultResourceGroupUri(uri);
     }
 
     /**
@@ -325,7 +327,7 @@ public class AFPResourceManager {
         if (afpFont.isEmbeddable()) {
             //Embed fonts (char sets and code pages)
             if (charSet.getResourceAccessor() != null) {
-                ResourceAccessor accessor = charSet.getResourceAccessor();
+                AFPResourceAccessor accessor = charSet.getResourceAccessor();
                 createIncludedResource(
                         charSet.getName(), accessor,
                         ResourceObject.TYPE_FONT_CHARACTER_SET);
@@ -352,7 +354,7 @@ public class AFPResourceManager {
      * @param resourceObjectType the resource object type ({@link ResourceObject}.*)
      * @throws IOException if an I/O error occurs while loading the resource
      */
-    public void createIncludedResource(String resourceName, ResourceAccessor accessor,
+    public void createIncludedResource(String resourceName, AFPResourceAccessor accessor,
                 byte resourceObjectType) throws IOException {
         URI uri;
         try {
@@ -373,9 +375,9 @@ public class AFPResourceManager {
      * @param resourceObjectType the resource object type ({@link ResourceObject}.*)
      * @throws IOException if an I/O error occurs while loading the resource
      */
-    public void createIncludedResource(String resourceName, URI uri, ResourceAccessor accessor,
+    public void createIncludedResource(String resourceName, URI uri, AFPResourceAccessor accessor,
                 byte resourceObjectType) throws IOException {
-        AFPResourceLevel resourceLevel = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
+        AFPResourceLevel resourceLevel = new AFPResourceLevel(ResourceType.PRINT_FILE);
 
         AFPResourceInfo resourceInfo = new AFPResourceInfo();
         resourceInfo.setLevel(resourceLevel);
@@ -416,9 +418,9 @@ public class AFPResourceManager {
      * @throws IOException if an I/O error occurs while loading the resource
      */
     public void createIncludedResourceFromExternal(final String resourceName,
-            final URI uri, final ResourceAccessor accessor) throws IOException {
+            final URI uri, final AFPResourceAccessor accessor) throws IOException {
 
-        AFPResourceLevel resourceLevel = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
+        AFPResourceLevel resourceLevel = new AFPResourceLevel(ResourceType.PRINT_FILE);
 
         AFPResourceInfo resourceInfo = new AFPResourceInfo();
         resourceInfo.setLevel(resourceLevel);

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPStreamer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPStreamer.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPStreamer.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/AFPStreamer.java Tue Jul  3 16:01:48 2012
@@ -20,20 +20,22 @@
 package org.apache.fop.afp;
 
 import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.RandomAccessFile;
+import java.net.URI;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.fop.afp.modca.ResourceGroup;
 import org.apache.fop.afp.modca.StreamedResourceGroup;
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.TempResourceURIGenerator;
 
 /**
  * Manages the streaming of the AFP output
@@ -42,43 +44,45 @@ public class AFPStreamer implements Stre
     /** Static logging instance */
     private static final Log LOG = LogFactory.getLog(AFPStreamer.class);
 
-    private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_";
-
-    private static final int BUFFER_SIZE = 4096; // 4k writing buffer
-
     private static final String DEFAULT_EXTERNAL_RESOURCE_FILENAME = "resources.afp";
 
+    private static final TempResourceURIGenerator TEMP_URI_GENERATOR
+            = new TempResourceURIGenerator("AFPDataStream_");
 
     private final Factory factory;
 
+    private final InternalResourceResolver resourceResolver;
+
     /** A mapping of external resource destinations to resource groups */
-    private final Map/*<String,AFPExternalResourceGroup>*/pathResourceGroupMap
-        = new java.util.HashMap/*<String,AFPExternalResourceGroup>*/();
+    private final Map<URI, ResourceGroup> pathResourceGroupMap = new HashMap<URI, ResourceGroup>();
 
     private StreamedResourceGroup printFileResourceGroup;
 
     /** Sets the default resource group file path */
-    private String defaultResourceGroupFilePath = DEFAULT_EXTERNAL_RESOURCE_FILENAME;
+    private URI defaultResourceGroupUri;
 
-    private File tempFile;
+    private final URI tempUri;
 
     /** temporary document outputstream */
-    private OutputStream documentOutputStream;
+    private OutputStream tempOutputStream;
 
     /** the final outputstream */
     private OutputStream outputStream;
 
-    private RandomAccessFile documentFile;
-
     private DataStream dataStream;
 
     /**
      * Main constructor
      *
      * @param factory a factory
+     * @param resourceResolver resource resolver
      */
-    public AFPStreamer(Factory factory) {
+    public AFPStreamer(Factory factory, InternalResourceResolver resourceResolver) {
         this.factory = factory;
+        this.resourceResolver = resourceResolver;
+        this.tempUri = TEMP_URI_GENERATOR.generate();
+        defaultResourceGroupUri = URI.create(DEFAULT_EXTERNAL_RESOURCE_FILENAME);
+
     }
 
     /**
@@ -89,11 +93,8 @@ public class AFPStreamer implements Stre
      * @throws IOException thrown if an I/O exception of some sort has occurred
      */
     public DataStream createDataStream(AFPPaintingState paintingState) throws IOException {
-        this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null);
-        this.documentFile = new RandomAccessFile(tempFile, "rw");
-        this.documentOutputStream = new BufferedOutputStream(
-                new FileOutputStream(documentFile.getFD()));
-        this.dataStream = factory.createDataStream(paintingState, documentOutputStream);
+        this.tempOutputStream = new BufferedOutputStream(resourceResolver.getOutputStream(tempUri));
+        this.dataStream = factory.createDataStream(paintingState, tempOutputStream);
         return dataStream;
     }
 
@@ -102,8 +103,8 @@ public class AFPStreamer implements Stre
      *
      * @param filePath the default resource group file path
      */
-    public void setDefaultResourceGroupFilePath(String filePath) {
-        this.defaultResourceGroupFilePath = filePath;
+    public void setDefaultResourceGroupUri(URI uri) {
+        this.defaultResourceGroupUri = uri;
     }
 
     /**
@@ -118,23 +119,23 @@ public class AFPStreamer implements Stre
             return null;
         }
         if (level.isExternal()) {
-            String filePath = level.getExternalFilePath();
-            if (filePath == null) {
+            URI uri = level.getExternalURI();
+            if (uri == null) {
                 LOG.warn("No file path provided for external resource, using default.");
-                filePath = defaultResourceGroupFilePath;
+                uri = defaultResourceGroupUri;
             }
-            resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath);
+            resourceGroup = pathResourceGroupMap.get(uri);
             if (resourceGroup == null) {
                 OutputStream os = null;
                 try {
-                    os = new BufferedOutputStream(new FileOutputStream(filePath));
-                } catch (FileNotFoundException fnfe) {
-                    LOG.error("Failed to create/open external resource group file '"
-                            + filePath + "'");
+                    os = new BufferedOutputStream(resourceResolver.getOutputStream(uri));
+                } catch (IOException ioe) {
+                    LOG.error("Failed to create/open external resource group for uri '"
+                            + uri + "'");
                 } finally {
                     if (os != null) {
                         resourceGroup = factory.createStreamedResourceGroup(os);
-                        pathResourceGroupMap.put(filePath, resourceGroup);
+                        pathResourceGroupMap.put(uri, resourceGroup);
                     }
                 }
             }
@@ -156,34 +157,20 @@ public class AFPStreamer implements Stre
      *
      * @throws IOException if an an I/O exception of some sort has occurred
      */
-        // write out any external resource groups
+    // write out any external resource groups
     public void close() throws IOException {
         Iterator it = pathResourceGroupMap.values().iterator();
         while (it.hasNext()) {
             StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next();
             resourceGroup.close();
         }
-
         // close any open print-file resource group
         if (printFileResourceGroup != null) {
             printFileResourceGroup.close();
         }
-
         // write out document
         writeToStream(outputStream);
-
         outputStream.close();
-
-
-        if (documentOutputStream != null) {
-            documentOutputStream.close();
-        }
-
-        if (documentFile != null) {
-            documentFile.close();
-        }
-        // delete temporary file
-        tempFile.delete();
     }
 
     /**
@@ -197,28 +184,11 @@ public class AFPStreamer implements Stre
 
     /** {@inheritDoc} */
     public void writeToStream(OutputStream os) throws IOException {
-//        long start = System.currentTimeMillis();
-        int len = (int)documentFile.length();
-        int numChunks = len / BUFFER_SIZE;
-        int remainingChunkSize = len % BUFFER_SIZE;
-        byte[] buffer;
-
-        documentFile.seek(0);
-        if (numChunks > 0) {
-            buffer = new byte[BUFFER_SIZE];
-            for (int i = 0; i < numChunks; i++) {
-                documentFile.read(buffer, 0, BUFFER_SIZE);
-                os.write(buffer, 0, BUFFER_SIZE);
-            }
-        } else {
-            buffer = new byte[remainingChunkSize];
-        }
-        if (remainingChunkSize > 0) {
-            documentFile.read(buffer, 0, remainingChunkSize);
-            os.write(buffer, 0, remainingChunkSize);
-        }
+        tempOutputStream.close();
+        InputStream tempInputStream = resourceResolver.getResource(tempUri);
+        IOUtils.copy(tempInputStream, os);
+        //TODO this should notify the stream provider that it is safe to delete the temp data
+        tempInputStream.close();
         os.flush();
-//        long end = System.currentTimeMillis();
-//        log.debug("writing time " + (end - start) + "ms");
     }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java Tue Jul  3 16:01:48 2012
@@ -165,9 +165,8 @@ public class AFPBase12FontCollection imp
     }
 
     private RasterFont createReferencedRasterFont(String fontFamily) {
-        RasterFont font = new RasterFont(fontFamily);
-        font.setEmbeddable(false); //Font is assumed to be available on the target platform
-        return font;
+        boolean embeddable = false; //Font is assumed to be available on the target platform
+        return new RasterFont(fontFamily, embeddable);
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPFont.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AFPFont.java Tue Jul  3 16:01:48 2012
@@ -35,16 +35,18 @@ import org.apache.fop.fonts.Typeface;
 public abstract class AFPFont extends Typeface {
 
     /** The font name */
-    protected String name;
+    protected final String name;
 
-    private boolean embeddable = true;
+    private final boolean embeddable;
 
     /**
      * Constructor for the base font requires the name.
      * @param name the name of the font
+     * @param embeddable whether this font is to be embedded
      */
-    public AFPFont(String name) {
+    public AFPFont(String name, boolean embeddable) {
         this.name = name;
+        this.embeddable = embeddable;
     }
 
     /** {@inheritDoc} */
@@ -89,7 +91,7 @@ public abstract class AFPFont extends Ty
      * Returns the kerning map for the font.
      * @return the kerning map
      */
-    public Map getKerningInfo() {
+    public Map<Integer, Map<Integer, Integer>> getKerningInfo() {
         return null;
     }
 
@@ -101,14 +103,6 @@ public abstract class AFPFont extends Ty
     public abstract CharacterSet getCharacterSet(int size);
 
     /**
-     * Controls whether this font is embeddable or not.
-     * @param value true to enable embedding, false otherwise.
-     */
-    public void setEmbeddable(boolean value) {
-        this.embeddable = value;
-    }
-
-    /**
      * Indicates if this font may be embedded.
      * @return True, if embedding is possible/permitted
      */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java Tue Jul  3 16:01:48 2012
@@ -32,13 +32,12 @@ public abstract class AbstractOutlineFon
     /**
      * Constructor for an outline font.
      *
-     * @param name
-     *            the name of the font
-     * @param charSet
-     *            the chracter set
+     * @param name the name of the font
+     * @param embeddable sets whether or not this font is to be embedded
+     * @param charSet the chracter set
      */
-    public AbstractOutlineFont(String name, CharacterSet charSet) {
-        super(name);
+    public AbstractOutlineFont(String name, boolean embeddable, CharacterSet charSet) {
+        super(name, embeddable);
         this.charSet = charSet;
     }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSet.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSet.java Tue Jul  3 16:01:48 2012
@@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.afp.AFPConstants;
 import org.apache.fop.afp.AFPEventProducer;
 import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
 import org.apache.fop.afp.util.StringUtils;
 
 /**
@@ -77,7 +77,7 @@ public class CharacterSet {
     protected final String name;
 
     /** The path to the installed fonts */
-    private final ResourceAccessor accessor;
+    private final AFPResourceAccessor accessor;
 
     /** The current orientation (currently only 0 is supported by FOP) */
     private final String currentOrientation = "0";
@@ -100,7 +100,7 @@ public class CharacterSet {
      * @param eventProducer for handling AFP related events
      */
     CharacterSet(String codePage, String encoding, CharacterSetType charsetType, String name,
-            ResourceAccessor accessor, AFPEventProducer eventProducer) {
+            AFPResourceAccessor accessor, AFPEventProducer eventProducer) {
         if (name.length() > MAX_NAME_LEN) {
             String msg = "Character set name '" + name + "' must be a maximum of "
                 + MAX_NAME_LEN + " characters";
@@ -115,7 +115,7 @@ public class CharacterSet {
         }
         this.codePage = codePage;
         this.encoding = encoding;
-        this.encoder = CharactersetEncoder.newInstance(encoding, charsetType);
+        this.encoder = charsetType.getEncoder(encoding);
         this.accessor = accessor;
 
         this.characterSetOrientations = new HashMap<String, CharacterSetOrientation>(4);
@@ -211,7 +211,7 @@ public class CharacterSet {
      * Returns the resource accessor to load the font resources with.
      * @return the resource accessor to load the font resources with
      */
-    public ResourceAccessor getResourceAccessor() {
+    public AFPResourceAccessor getResourceAccessor() {
         return this.accessor;
     }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java Tue Jul  3 16:01:48 2012
@@ -19,9 +19,9 @@
 
 package org.apache.fop.afp.fonts;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -38,8 +38,9 @@ import org.apache.xmlgraphics.image.load
 
 import org.apache.fop.afp.AFPConstants;
 import org.apache.fop.afp.AFPEventProducer;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
 import org.apache.fop.afp.util.StructuredFieldReader;
+import org.apache.fop.apps.io.InternalResourceResolver;
 import org.apache.fop.fonts.Typeface;
 
 /**
@@ -138,28 +139,24 @@ public abstract class CharacterSetBuilde
      * Returns an InputStream to a given file path and filename
      *
      * * @param accessor the resource accessor
-     * @param filename the file name
+     * @param uriStr the URI
      * @param eventProducer for handling AFP related events
      * @return an inputStream
-     *
      * @throws IOException in the event that an I/O exception of some sort has occurred
      */
-    protected InputStream openInputStream(ResourceAccessor accessor, String filename,
+    private InputStream openInputStream(AFPResourceAccessor accessor, String uriStr,
             AFPEventProducer eventProducer)
             throws IOException {
         URI uri;
         try {
-            uri = new URI(filename.trim());
+            uri = InternalResourceResolver.cleanURI(uriStr.trim());
         } catch (URISyntaxException e) {
-            throw new FileNotFoundException("Invalid filename: "
-                    + filename + " (" + e.getMessage() + ")");
+            throw new MalformedURLException("Invalid uri: " + uriStr + " (" + e.getMessage() + ")");
         }
-
         if (LOG.isDebugEnabled()) {
             LOG.debug("Opening " + uri);
         }
-        InputStream inputStream = accessor.createInputStream(uri);
-        return inputStream;
+        return accessor.createInputStream(uri);
     }
 
     /**
@@ -167,7 +164,7 @@ public abstract class CharacterSetBuilde
      *
      * @param inputStream the inputstream to close
      */
-    protected void closeInputStream(InputStream inputStream) {
+    private void closeInputStream(InputStream inputStream) {
         try {
             if (inputStream != null) {
                 inputStream.close();
@@ -191,7 +188,7 @@ public abstract class CharacterSetBuilde
      * @throws IOException if an I/O error occurs
      */
     public CharacterSet buildSBCS(String characterSetName, String codePageName, String encoding,
-            ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
+            AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
         return processFont(characterSetName, codePageName, encoding, CharacterSetType.SINGLE_BYTE,
                 accessor, eventProducer);
     }
@@ -211,7 +208,7 @@ public abstract class CharacterSetBuilde
      * @throws IOException if an I/O error occurs
      */
     public CharacterSet buildDBCS(String characterSetName, String codePageName, String encoding,
-            CharacterSetType charsetType, ResourceAccessor accessor, AFPEventProducer eventProducer)
+            CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer)
             throws IOException {
         return processFont(characterSetName, codePageName, encoding, charsetType, accessor,
                 eventProducer);
@@ -236,7 +233,7 @@ public abstract class CharacterSetBuilde
     }
 
     private CharacterSet processFont(String characterSetName, String codePageName, String encoding,
-            CharacterSetType charsetType, ResourceAccessor accessor, AFPEventProducer eventProducer)
+            CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer)
             throws IOException {
         // check for cached version of the characterset
         String descriptor = characterSetName + "_" + encoding + "_" + codePageName;
@@ -329,7 +326,7 @@ public abstract class CharacterSetBuilde
      * @throws IOException if an I/O exception of some sort has occurred.
      */
     protected Map<String, String> loadCodePage(String codePage, String encoding,
-            ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
+            AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
 
         // Create the HashMap to store code page information
         Map<String, String> codePages = new HashMap<String, String>();
@@ -337,7 +334,11 @@ public abstract class CharacterSetBuilde
         InputStream inputStream = null;
         try {
             inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
-
+        } catch (IOException e) {
+            eventProducer.codePageNotFound(this, e);
+            throw e;
+        }
+        try {
             StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
             byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF);
 
@@ -367,8 +368,6 @@ public abstract class CharacterSetBuilde
                     position++;
                 }
             }
-        } catch (FileNotFoundException e) {
-            eventProducer.codePageNotFound(this, e);
         } finally {
             closeInputStream(inputStream);
         }
@@ -383,9 +382,8 @@ public abstract class CharacterSetBuilde
      * @return a class representing the font descriptor
      * @throws IOException if an I/O exception of some sort has occurred.
      */
-    protected static FontDescriptor processFontDescriptor(
-                StructuredFieldReader structuredFieldReader)
-    throws IOException {
+    private static FontDescriptor processFontDescriptor(
+            StructuredFieldReader structuredFieldReader) throws IOException {
 
         byte[] fndData = structuredFieldReader.getNext(FONT_DESCRIPTOR_SF);
         return new FontDescriptor(fndData);
@@ -399,8 +397,8 @@ public abstract class CharacterSetBuilde
      * @return the FontControl
      * @throws IOException if an I/O exception of some sort has occurred.
      */
-    protected FontControl processFontControl(StructuredFieldReader structuredFieldReader)
-    throws IOException {
+    private FontControl processFontControl(StructuredFieldReader structuredFieldReader)
+            throws IOException {
 
         byte[] fncData = structuredFieldReader.getNext(FONT_CONTROL_SF);
 
@@ -431,7 +429,7 @@ public abstract class CharacterSetBuilde
      * @return CharacterSetOrientation array
      * @throws IOException if an I/O exception of some sort has occurred.
      */
-    protected CharacterSetOrientation[] processFontOrientation(
+    private CharacterSetOrientation[] processFontOrientation(
         StructuredFieldReader structuredFieldReader) throws IOException {
 
         byte[] data = structuredFieldReader.getNext(FONT_ORIENTATION_SF);
@@ -464,7 +462,6 @@ public abstract class CharacterSetBuilde
 
             }
         }
-
         return orientations.toArray(EMPTY_CSO_ARRAY);
     }
 
@@ -480,7 +477,7 @@ public abstract class CharacterSetBuilde
      *                  font metric values
      * @throws IOException if an I/O exception of some sort has occurred.
      */
-    protected void processFontPosition(StructuredFieldReader structuredFieldReader,
+    private void processFontPosition(StructuredFieldReader structuredFieldReader,
         CharacterSetOrientation[] characterSetOrientations, double metricNormalizationFactor)
             throws IOException {
 
@@ -537,7 +534,7 @@ public abstract class CharacterSetBuilde
      *                  font metric values
      * @throws IOException if an I/O exception of some sort has occurred.
      */
-    protected void processFontIndex(StructuredFieldReader structuredFieldReader,
+    private void processFontIndex(StructuredFieldReader structuredFieldReader,
             CharacterSetOrientation cso, Map<String, String> codepage,
             double metricNormalizationFactor)
         throws IOException {
@@ -709,22 +706,23 @@ public abstract class CharacterSetBuilde
             return INSTANCE;
         }
 
+        @Override
         protected Map<String, String> loadCodePage(String codePage, String encoding,
-                ResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
-
+                AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException {
             // Create the HashMap to store code page information
             Map<String, String> codePages = new HashMap<String, String>();
-
             InputStream inputStream = null;
             try {
-                inputStream = openInputStream(accessor, codePage.trim(), eventProducer);
-
-                StructuredFieldReader structuredFieldReader
-                    = new StructuredFieldReader(inputStream);
+                inputStream = super.openInputStream(accessor, codePage.trim(), eventProducer);
+            } catch (IOException e) {
+                eventProducer.codePageNotFound(this, e);
+                throw e;
+            }
+            try {
+                StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream);
                 byte[] data;
                 while ((data = structuredFieldReader.getNext(CHARACTER_TABLE_SF)) != null) {
                     int position = 0;
-
                     byte[] gcgiBytes = new byte[8];
                     byte[] charBytes = new byte[2];
                     // Read data, ignoring bytes 0 - 2
@@ -752,12 +750,9 @@ public abstract class CharacterSetBuilde
                         }
                     }
                 }
-            } catch (FileNotFoundException e) {
-                eventProducer.codePageNotFound(this, e);
             } finally {
-                closeInputStream(inputStream);
+                super.closeInputStream(inputStream);
             }
-
             return codePages;
         }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetType.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetType.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharacterSetType.java Tue Jul  3 16:01:48 2012
@@ -19,13 +19,39 @@
 
 package org.apache.fop.afp.fonts;
 
+import org.apache.fop.afp.fonts.CharactersetEncoder.DefaultEncoder;
+import org.apache.fop.afp.fonts.CharactersetEncoder.EbcdicDoubleByteLineDataEncoder;
+
 /**
  * An enumeration of AFP characterset types.
  */
 public enum CharacterSetType {
     /** Double byte character sets; these do NOT have the shift-in;shift-out operators */
-    DOUBLE_BYTE,
+    DOUBLE_BYTE {
+        @Override
+        CharactersetEncoder getEncoder(String encoding) {
+            return new DefaultEncoder(encoding, true);
+        }
+    },
     /** Double byte character sets; these can have the shift-in;shift-out operators */
-    DOUBLE_BYTE_LINE_DATA,
-    SINGLE_BYTE;
+    DOUBLE_BYTE_LINE_DATA {
+        @Override
+        CharactersetEncoder getEncoder(String encoding) {
+            return new EbcdicDoubleByteLineDataEncoder(encoding);
+        }
+    },
+    SINGLE_BYTE {
+        @Override
+        CharactersetEncoder getEncoder(String encoding) {
+            return new DefaultEncoder(encoding, false);
+        }
+    };
+
+    /**
+     * Returns the character-set encoder
+     *
+     * @param encoding
+     * @return
+     */
+    abstract CharactersetEncoder getEncoder(String encoding);
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharactersetEncoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharactersetEncoder.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharactersetEncoder.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/CharactersetEncoder.java Tue Jul  3 16:01:48 2012
@@ -87,7 +87,7 @@ public abstract class CharactersetEncode
      */
     public static EncodedChars encodeSBCS(CharSequence chars, String encoding)
             throws CharacterCodingException {
-        CharactersetEncoder encoder = newInstance(encoding, CharacterSetType.SINGLE_BYTE);
+        CharactersetEncoder encoder = CharacterSetType.SINGLE_BYTE.getEncoder(encoding);
         return encoder.encode(chars);
     }
 
@@ -97,8 +97,8 @@ public abstract class CharactersetEncode
      * sequence it will return its EBCDIC code-point, however, the "Shift In - Shift Out" operators
      * are removed from the sequence of bytes. These are only used in Line Data.
      */
-    private static final class EbcdicDoubleByteLineDataEncoder extends CharactersetEncoder {
-        private EbcdicDoubleByteLineDataEncoder(String encoding) {
+    static final class EbcdicDoubleByteLineDataEncoder extends CharactersetEncoder {
+        EbcdicDoubleByteLineDataEncoder(String encoding) {
             super(encoding);
         }
         @Override
@@ -115,10 +115,10 @@ public abstract class CharactersetEncode
      * the primary format for most Latin character sets. This can also be used for Unicode double-
      * byte character sets (DBCS).
      */
-    private static final class DefaultEncoder extends CharactersetEncoder {
+    static final class DefaultEncoder extends CharactersetEncoder {
         private final boolean isDBCS;
 
-        private DefaultEncoder(String encoding, boolean isDBCS) {
+        DefaultEncoder(String encoding, boolean isDBCS) {
             super(encoding);
             this.isDBCS = isDBCS;
         }
@@ -130,24 +130,6 @@ public abstract class CharactersetEncode
     }
 
     /**
-     * Returns an new instance of a {@link CharactersetEncoder}.
-     *
-     * @param encoding the encoding for the underlying character encoder
-     * @param isEbcdicDBCS whether or not this wraps a double-byte EBCDIC code page.
-     * @return the CharactersetEncoder
-     */
-    static CharactersetEncoder newInstance(String encoding, CharacterSetType charsetType) {
-        switch (charsetType) {
-        case DOUBLE_BYTE_LINE_DATA:
-            return new EbcdicDoubleByteLineDataEncoder(encoding);
-        case DOUBLE_BYTE:
-            return new DefaultEncoder(encoding, true);
-        default:
-            return new DefaultEncoder(encoding, false);
-        }
-    }
-
-    /**
      * A container for encoded character bytes
      */
     // CSOFF: FinalClass - disabling "final" modifier so that this class can be mocked

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java Tue Jul  3 16:01:48 2012
@@ -19,6 +19,8 @@
 
 package org.apache.fop.afp.fonts;
 
+import java.lang.Character.UnicodeBlock;
+import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -33,7 +35,7 @@ public class DoubleByteFont extends Abst
 
     //See also http://unicode.org/reports/tr11/ which we've not closely looked at, yet
     //TODO the Unicode block listed here is probably not complete (ex. Hiragana, Katakana etc.)
-    private static final Set IDEOGRAPHIC = new java.util.HashSet();
+    private static final Set<UnicodeBlock> IDEOGRAPHIC = new HashSet<UnicodeBlock>();
     static {
         IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS);
         //IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT);//Java 1.5
@@ -45,10 +47,11 @@ public class DoubleByteFont extends Abst
     /**
      * Constructor for an double-byte outline font.
      * @param name the name of the font
+     * @param embeddable whether or not this font is embeddable
      * @param charSet the character set
      */
-    public DoubleByteFont(String name, CharacterSet charSet) {
-        super(name, charSet);
+    public DoubleByteFont(String name, boolean embeddable, CharacterSet charSet) {
+        super(name, embeddable, charSet);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java Tue Jul  3 16:01:48 2012
@@ -20,7 +20,7 @@
 package org.apache.fop.afp.fonts;
 
 import org.apache.fop.afp.AFPEventProducer;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
 import org.apache.fop.fonts.Typeface;
 
 /**
@@ -42,7 +42,7 @@ public class FopCharacterSet extends Cha
      */
     public FopCharacterSet(String codePage, String encoding, String name, Typeface charSet,
             AFPEventProducer eventProducer) {
-        super(codePage, encoding, CharacterSetType.SINGLE_BYTE, name, (ResourceAccessor) null,
+        super(codePage, encoding, CharacterSetType.SINGLE_BYTE, name, (AFPResourceAccessor) null,
                 eventProducer);
         this.charSet = charSet;
     }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/OutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/OutlineFont.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/OutlineFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/OutlineFont.java Tue Jul  3 16:01:48 2012
@@ -27,10 +27,11 @@ public class OutlineFont extends Abstrac
     /**
      * Construct outline font with specified name and character set.
      * @param name font's name
+     * @param embeddable whether or not this font is embeddable
      * @param charSet font's character set
      */
-    public OutlineFont(String name, CharacterSet charSet) {
-        super(name, charSet);
+    public OutlineFont(String name, boolean embeddable, CharacterSet charSet) {
+        super(name, embeddable, charSet);
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/RasterFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/RasterFont.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/RasterFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/fonts/RasterFont.java Tue Jul  3 16:01:48 2012
@@ -52,8 +52,8 @@ public class RasterFont extends AFPFont 
      * @param name
      *            the name of the font
      */
-    public RasterFont(String name) {
-        super(name);
+    public RasterFont(String name, boolean embeddable) {
+        super(name, embeddable);
     }
 
     /**
@@ -76,7 +76,7 @@ public class RasterFont extends AFPFont 
     public CharacterSet getCharacterSet(int sizeInMpt) {
 
         Integer requestedSize = Integer.valueOf(sizeInMpt);
-        CharacterSet csm = (CharacterSet) charSets.get(requestedSize);
+        CharacterSet csm = charSets.get(requestedSize);
         double sizeInPt = sizeInMpt / 1000.0;
 
         if (csm != null) {
@@ -85,7 +85,7 @@ public class RasterFont extends AFPFont 
 
         if (substitutionCharSets != null) {
             //Check first if a substitution has already been added
-            csm = (CharacterSet) substitutionCharSets.get(requestedSize);
+            csm = substitutionCharSets.get(requestedSize);
         }
 
         if (csm == null && !charSets.isEmpty()) {
@@ -95,9 +95,9 @@ public class RasterFont extends AFPFont 
             SortedMap<Integer, CharacterSet> smallerSizes = charSets.headMap(requestedSize);
             SortedMap<Integer, CharacterSet> largerSizes = charSets.tailMap(requestedSize);
             int smallerSize = smallerSizes.isEmpty() ? 0
-                    : ((Integer)smallerSizes.lastKey()).intValue();
+                    : smallerSizes.lastKey().intValue();
             int largerSize = largerSizes.isEmpty() ? Integer.MAX_VALUE
-                    : ((Integer)largerSizes.firstKey()).intValue();
+                    : largerSizes.firstKey().intValue();
 
             Integer fontSize;
             if (!smallerSizes.isEmpty()
@@ -106,7 +106,7 @@ public class RasterFont extends AFPFont 
             } else {
                 fontSize = Integer.valueOf(largerSize);
             }
-            csm = (CharacterSet) charSets.get(fontSize);
+            csm = charSets.get(fontSize);
 
             if (csm != null) {
                 // Add the substitute mapping, so subsequent calls will

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java Tue Jul  3 16:01:48 2012
@@ -26,16 +26,15 @@ import java.net.URI;
 
 import org.apache.commons.io.IOUtils;
 
+import org.apache.fop.afp.util.AFPResourceAccessor;
 import org.apache.fop.afp.util.AFPResourceUtil;
-import org.apache.fop.afp.util.ResourceAccessor;
-
 
 /**
  * Encapsulates an included resource object that is loaded from an external file.
  */
 public class IncludedResourceObject extends AbstractNamedAFPObject {
 
-    private ResourceAccessor resourceAccessor;
+    private AFPResourceAccessor resourceAccessor;
     private URI uri;
 
     /**
@@ -45,7 +44,7 @@ public class IncludedResourceObject exte
      * @param uri the URI of the external file
      */
     public IncludedResourceObject(String name,
-            ResourceAccessor resourceAccessor, URI uri) {
+            AFPResourceAccessor resourceAccessor, URI uri) {
         super(name);
         this.resourceAccessor = resourceAccessor;
         this.uri = uri;

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java Tue Jul  3 16:01:48 2012
@@ -92,13 +92,10 @@ public final class AFPResourceUtil {
             throws UnsupportedEncodingException {
         //The first 8 bytes of the field data represent the resource name
         byte[] nameBytes = new byte[8];
-
-        byte[] fieldData = field.getData();
-        if (fieldData.length < 8) {
-            throw new IllegalArgumentException("Field data does not contain a resource name");
-        }
-        System.arraycopy(fieldData, 0, nameBytes, 0, 8);
-        return new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
+        System.arraycopy(field.getData(), 0, nameBytes, 0, 8);
+        String asciiName;
+        asciiName = new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
+        return asciiName;
     }
 
     /**
@@ -131,13 +128,12 @@ public final class AFPResourceUtil {
     public static void copyNamedResource(String name,
             final InputStream in, final OutputStream out) throws IOException {
         final MODCAParser parser = new MODCAParser(in);
-        Collection<String> resourceNames = new java.util.HashSet<String>();
+        Collection resourceNames = new java.util.HashSet();
 
         //Find matching "Begin" field
         final UnparsedStructuredField fieldBegin;
         while (true) {
-            final UnparsedStructuredField field = parser.readNextStructuredField();
-
+            UnparsedStructuredField field = parser.readNextStructuredField();
             if (field == null) {
                 throw new IOException("Requested resource '" + name
                         + "' not found. Encountered resource names: " + resourceNames);
@@ -146,10 +142,8 @@ public final class AFPResourceUtil {
             if (field.getSfTypeCode() != TYPE_CODE_BEGIN) { //0xA8=Begin
                 continue; //Not a "Begin" field
             }
-            final String resourceName = getResourceName(field);
-
+            String resourceName = getResourceName(field);
             resourceNames.add(resourceName);
-
             if (resourceName.equals(name)) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Start of requested structured field found:\n"
@@ -176,35 +170,45 @@ public final class AFPResourceUtil {
         if (wrapInResource) {
             ResourceObject resourceObject =  new ResourceObject(name) {
                 protected void writeContent(OutputStream os) throws IOException {
-                    copyNamedStructuredFields(name, fieldBegin, parser, out);
+                    copyStructuredFields(name, fieldBegin, parser, out);
                 }
             };
             resourceObject.setType(ResourceObject.TYPE_PAGE_SEGMENT);
             resourceObject.writeToStream(out);
         } else {
-            copyNamedStructuredFields(name, fieldBegin, parser, out);
+            copyStructuredFields(name, fieldBegin, parser, out);
         }
     }
 
-    private static void copyNamedStructuredFields(final String name,
-            UnparsedStructuredField fieldBegin, MODCAParser parser,
-            OutputStream out) throws IOException {
-
-        UnparsedStructuredField field = fieldBegin;
-
-        while (true) {
+    private static void copyStructuredFields(String name, UnparsedStructuredField fieldBegin,
+            MODCAParser parser, OutputStream out) throws IOException {
+        boolean inRequestedResource;
+
+        //The "Begin" field first
+        out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
+        fieldBegin.writeTo(out);
+        UnparsedStructuredField field;
+
+        //Then the rest of the fields until the corresponding "End" field
+        inRequestedResource = true;
+        do {
+            field = parser.readNextStructuredField();
             if (field == null) {
-                throw new IOException("Ending structured field not found for resource " + name);
+                break; //Unexpected EOF
             }
-            out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
-            field.writeTo(out);
 
-            if (field.getSfTypeCode() == TYPE_CODE_END
-                    && fieldBegin.getSfCategoryCode() == field.getSfCategoryCode()
-                    && name.equals(getResourceName(field))) {
-                break;
+            if (field.getSfTypeCode() == TYPE_CODE_END) {
+                String resourceName = getResourceName(field);
+                if (resourceName.equals(name)) {
+                    inRequestedResource = false; //Signal end of loop
+                }
             }
-            field = parser.readNextStructuredField();
+            out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
+            field.writeTo(out);
+        } while (inRequestedResource);
+        if (inRequestedResource) {
+            throw new IOException("Ending structured field not found for resource " + name);
         }
     }
+
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java Tue Jul  3 16:01:48 2012
@@ -21,18 +21,22 @@ package org.apache.fop.apps;
 
 // Java
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URISyntaxException;
 import java.util.Date;
 import java.util.Map;
 
 import javax.xml.transform.Source;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
 
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.loader.ImageContext;
+import org.apache.xmlgraphics.image.loader.ImageManager;
 import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
 import org.apache.xmlgraphics.util.UnitConv;
@@ -41,17 +45,27 @@ import org.apache.fop.Version;
 import org.apache.fop.accessibility.Accessibility;
 import org.apache.fop.accessibility.DummyStructureTreeEventHandler;
 import org.apache.fop.accessibility.StructureTreeEventHandler;
+import org.apache.fop.apps.io.InternalResourceResolver;
 import org.apache.fop.events.DefaultEventBroadcaster;
 import org.apache.fop.events.Event;
 import org.apache.fop.events.EventBroadcaster;
 import org.apache.fop.events.EventListener;
 import org.apache.fop.events.FOPEventListenerProxy;
 import org.apache.fop.events.LoggingEventListener;
+import org.apache.fop.fo.ElementMappingRegistry;
 import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fonts.FontManager;
+import org.apache.fop.layoutmgr.LayoutManagerMaker;
+import org.apache.fop.render.ImageHandlerRegistry;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfig;
+import org.apache.fop.render.RendererConfig.RendererConfigParser;
+import org.apache.fop.render.RendererConfigOption;
 import org.apache.fop.render.RendererFactory;
 import org.apache.fop.render.XMLHandlerRegistry;
 import org.apache.fop.render.intermediate.IFDocumentHandler;
+import org.apache.fop.util.ColorSpaceCache;
+import org.apache.fop.util.ContentHandlerFactoryRegistry;
 
 /**
  * This is the user agent for FOP.
@@ -75,24 +89,13 @@ import org.apache.fop.render.intermediat
  */
 public class FOUserAgent {
 
-    /** Defines the default target resolution (72dpi) for FOP */
-    public static final float DEFAULT_TARGET_RESOLUTION
-            = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
-
     private static Log log = LogFactory.getLog("FOP");
 
-    private FopFactory factory;
-
-    /**
-     *  The base URL for all URL resolutions, especially for
-     *  external-graphics.
-     */
-    private String base = null;
+    private final FopFactory factory;
 
-    /** A user settable URI Resolver */
-    private URIResolver uriResolver = null;
+    private final InternalResourceResolver resourceResolver;
 
-    private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
+    private float targetResolution = FopFactoryConfig.DEFAULT_TARGET_RESOLUTION;
     private Map rendererOptions = new java.util.HashMap();
     private File outputFile = null;
     private IFDocumentHandler documentHandlerOverride = null;
@@ -131,7 +134,7 @@ public class FOUserAgent {
     private ImageSessionContext imageSessionContext = new AbstractImageSessionContext() {
 
         public ImageContext getParentContext() {
-            return getFactory();
+            return factory;
         }
 
         public float getTargetResolution() {
@@ -148,21 +151,59 @@ public class FOUserAgent {
      * Main constructor. <b>This constructor should not be called directly. Please use the
      * methods from FopFactory to construct FOUserAgent instances!</b>
      * @param factory the factory that provides environment-level information
+     * @param resourceResolver the resolver used to acquire resources
      * @see org.apache.fop.apps.FopFactory
      */
-    public FOUserAgent(FopFactory factory) {
-        if (factory == null) {
-            throw new NullPointerException("The factory parameter must not be null");
-        }
+    FOUserAgent(FopFactory factory, InternalResourceResolver resourceResolver) {
         this.factory = factory;
-        setBaseURL(factory.getBaseURL());
+        this.resourceResolver = resourceResolver;
         setTargetResolution(factory.getTargetResolution());
         setAccessibility(factory.isAccessibilityEnabled());
     }
 
-    /** @return the associated FopFactory instance */
-    public FopFactory getFactory() {
-        return this.factory;
+    /**
+     * Returns a new {@link Fop} instance. Use this factory method if your output type
+     * requires an output stream and you want to configure this very rendering run,
+     * i.e. if you want to set some metadata like the title and author of the document
+     * you want to render. In that case, create a new {@link FOUserAgent} instance
+     * using {@link #newFOUserAgent()}.
+     * <p>
+     * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can
+     * use the constants defined in {@link MimeConstants}.
+     * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
+     * @param stream the output stream
+     * @return the new Fop instance
+     * @throws FOPException when the constructor fails
+     */
+    public Fop newFop(String outputFormat, OutputStream stream) throws FOPException {
+        return new Fop(outputFormat, this, stream);
+    }
+
+
+    /**
+     * Returns a new {@link Fop} instance. Use this factory method if you want to configure this
+     * very rendering run, i.e. if you want to set some metadata like the title and author of the
+     * document you want to render. In that case, create a new {@link FOUserAgent}
+     * instance using {@link #newFOUserAgent()}.
+     * <p>
+     * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can
+     * use the constants defined in {@link MimeConstants}.
+     * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
+     * @return the new Fop instance
+     * @throws FOPException  when the constructor fails
+     */
+    public Fop newFop(String outputFormat) throws FOPException {
+        return newFop(outputFormat, null);
+    }
+
+
+    /**
+     * Returns the resource resolver.
+     *
+     * @return the resource resolver
+     */
+    public InternalResourceResolver getResourceResolver() {
+        return resourceResolver;
     }
 
     // ---------------------------------------------- rendering-run dependent stuff
@@ -177,7 +218,6 @@ public class FOUserAgent {
             setStructureTreeEventHandler(documentHandler.getStructureTreeEventHandler());
         }
         this.documentHandlerOverride = documentHandler;
-
     }
 
     /**
@@ -345,48 +385,13 @@ public class FOUserAgent {
     }
 
     /**
-     * Sets the base URL.
-     * @param baseUrl base URL
-     */
-    public void setBaseURL(String baseUrl) {
-        this.base = baseUrl;
-    }
-
-    /**
-     * Sets font base URL.
-     * @param fontBaseUrl font base URL
-     * @deprecated Use {@link org.apache.fop.fonts.FontManager#setFontBaseURL(String)} instead.
-     */
-    public void setFontBaseURL(String fontBaseUrl) {
-        try {
-            getFactory().getFontManager().setFontBaseURL(fontBaseUrl);
-        } catch (MalformedURLException e) {
-            throw new IllegalArgumentException(e.getMessage());
-        }
-    }
-
-    /**
-     * Returns the base URL.
-     * @return the base URL
-     */
-    public String getBaseURL() {
-        return this.base;
-    }
-
-    /**
-     * Sets the URI Resolver.
-     * @param resolver the new URI resolver
-     */
-    public void setURIResolver(URIResolver resolver) {
-        this.uriResolver = resolver;
-    }
-
-    /**
-     * Returns the URI Resolver.
-     * @return the URI Resolver
-     */
-    public URIResolver getURIResolver() {
-        return this.uriResolver;
+     * Gets the renderer options given an interface representing renderer configuration options.
+     *
+     * @param option the renderer option
+     * @return the value
+    */
+    public Object getRendererOption(RendererConfigOption option) {
+        return rendererOptions.get(option.getName());
     }
 
     /**
@@ -396,39 +401,20 @@ public class FOUserAgent {
      * @param uri URI to access
      * @return A {@link javax.xml.transform.Source} object, or null if the URI
      * cannot be resolved.
-     * @see org.apache.fop.apps.FOURIResolver
-     */
-    public Source resolveURI(String uri) {
-        return resolveURI(uri, getBaseURL());
-    }
-
-    /**
-     * Attempts to resolve the given URI.
-     * Will use the configured resolver and if not successful fall back
-     * to the default resolver.
-     * @param href URI to access
-     * @param base the base URI to resolve against
-     * @return A {@link javax.xml.transform.Source} object, or null if the URI
-     * cannot be resolved.
-     * @see org.apache.fop.apps.FOURIResolver
      */
-    public Source resolveURI(String href, String base) {
-        Source source = null;
-        //RFC 2397 data URLs don't need to be resolved, just decode them through FOP's default
-        //URIResolver.
-        boolean bypassURIResolution = href.startsWith("data:");
-        if (!bypassURIResolution && uriResolver != null) {
-            try {
-                source = uriResolver.resolve(href, base);
-            } catch (TransformerException te) {
-                log.error("Attempt to resolve URI '" + href + "' failed: ", te);
-            }
-        }
-        if (source == null) {
-            // URI Resolver not configured or returned null, use default resolver from the factory
-            source = getFactory().resolveURI(href, base);
+    public StreamSource resolveURI(String uri) {
+        // TODO: What do we want to do when resources aren't found??? We also need to remove this
+        // method entirely
+        try {
+            // Have to do this so we can resolve data URIs
+            StreamSource src = new StreamSource(resourceResolver.getResource(uri));
+            src.setSystemId(uri);
+            return src;
+        } catch (URISyntaxException use) {
+            return null;
+        } catch (IOException ioe) {
+            return null;
         }
-        return source;
     }
 
     /**
@@ -498,29 +484,18 @@ public class FOUserAgent {
     //                                                (convenience access to FopFactory methods)
 
     /**
-     * Returns the font base URL.
-     * @return the font base URL
-     * @deprecated Use {@link org.apache.fop.fonts.FontManager#getFontBaseURL()} instead.
-     * This method is not used by FOP.
-     */
-    public String getFontBaseURL() {
-        String fontBase = getFactory().getFontManager().getFontBaseURL();
-        return fontBase != null ? fontBase : getBaseURL();
-    }
-
-    /**
      * Returns the conversion factor from pixel units to millimeters. This
      * depends on the desired source resolution.
      * @return float conversion factor
      * @see #getSourceResolution()
      */
     public float getSourcePixelUnitToMillimeter() {
-        return getFactory().getSourcePixelUnitToMillimeter();
+        return factory.getSourcePixelUnitToMillimeter();
     }
 
     /** @return the resolution for resolution-dependant input */
     public float getSourceResolution() {
-        return getFactory().getSourceResolution();
+        return factory.getSourceResolution();
     }
 
     /**
@@ -531,7 +506,7 @@ public class FOUserAgent {
      * @see FopFactory#getPageHeight()
      */
     public String getPageHeight() {
-        return getFactory().getPageHeight();
+        return factory.getPageHeight();
     }
 
     /**
@@ -542,7 +517,7 @@ public class FOUserAgent {
      * @see FopFactory#getPageWidth()
      */
     public String getPageWidth() {
-        return getFactory().getPageWidth();
+        return factory.getPageWidth();
     }
 
     /**
@@ -551,7 +526,7 @@ public class FOUserAgent {
      * @see FopFactory#validateStrictly()
      */
     public boolean validateStrictly() {
-        return getFactory().validateStrictly();
+        return factory.validateStrictly();
     }
 
     /**
@@ -560,21 +535,21 @@ public class FOUserAgent {
      * @see FopFactory#isBreakIndentInheritanceOnReferenceAreaBoundary()
      */
     public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
-        return getFactory().isBreakIndentInheritanceOnReferenceAreaBoundary();
+        return factory.isBreakIndentInheritanceOnReferenceAreaBoundary();
     }
 
     /**
      * @return the RendererFactory
      */
     public RendererFactory getRendererFactory() {
-        return getFactory().getRendererFactory();
+        return factory.getRendererFactory();
     }
 
     /**
      * @return the XML handler registry
      */
     public XMLHandlerRegistry getXMLHandlerRegistry() {
-        return getFactory().getXMLHandlerRegistry();
+        return factory.getXMLHandlerRegistry();
     }
 
     /**
@@ -663,12 +638,53 @@ public class FOUserAgent {
     }
 
     /**
-     * Control whether complex script features should be enabled
+     * Returns the renderer configuration object for a particular MIME type.
+     *
+     * @param mimeType the config MIME type
+     * @param configCreator the parser for creating the config for the first run of parsing.
+     * @return the renderer configuration object
+     * @throws FOPException if an error occurs when creating the config object
+     */
+    public RendererConfig getRendererConfig(String mimeType, RendererConfigParser configCreator)
+            throws FOPException {
+        return factory.getRendererConfig(this, getRendererConfiguration(mimeType), configCreator);
+    }
+
+    /**
+     * Returns a {@link Configuration} object for which contains renderer configuration for a given
+     * MIME type.
      *
-     * @param useComplexScriptFeatures true if FOP is to use complex script features
+     * @param mimeType the renderer configuration MIME type
+     * @return the configuration object
      */
-    public void setComplexScriptFeaturesEnabled(boolean useComplexScriptFeatures) {
-        factory.setComplexScriptFeaturesEnabled ( useComplexScriptFeatures );
+    public Configuration getRendererConfiguration(String mimeType) {
+        Configuration cfg = getUserConfig();
+        String type = "renderer";
+        String mime = "mime";
+        if (cfg == null) {
+            if (log.isDebugEnabled()) {
+                log.debug("userconfig is null");
+            }
+            return null;
+        }
+
+        Configuration userConfig = null;
+
+        Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type);
+        for (int i = 0; i < cfgs.length; ++i) {
+            Configuration child = cfgs[i];
+            try {
+                if (child.getAttribute(mime).equals(mimeType)) {
+                    userConfig = child;
+                    break;
+                }
+            } catch (ConfigurationException e) {
+                // silently pass over configurations without mime type
+            }
+        }
+        log.debug((userConfig == null ? "No u" : "U")
+                + "ser configuration found for MIME type " + mimeType);
+        return userConfig;
     }
 
     /**
@@ -714,5 +730,69 @@ public class FOUserAgent {
     public StructureTreeEventHandler getStructureTreeEventHandler() {
         return this.structureTreeEventHandler;
     }
+
+    /** @see FopFactory#getLayoutManagerMakerOverride() */
+    public LayoutManagerMaker getLayoutManagerMakerOverride() {
+        return factory.getLayoutManagerMakerOverride();
+    }
+
+    /** @see FopFactory#getContentHandlerFactoryRegistry() */
+    public ContentHandlerFactoryRegistry getContentHandlerFactoryRegistry() {
+        return factory.getContentHandlerFactoryRegistry();
+    }
+
+    /** @see FopFactory#getImageManager() */
+    public ImageManager getImageManager() {
+        return factory.getImageManager();
+    }
+
+    /** @see FopFactory#getElementMappingRegistry() */
+    public ElementMappingRegistry getElementMappingRegistry() {
+        return factory.getElementMappingRegistry();
+    }
+
+    /** @see FopFactory#getFontManager() */
+    public FontManager getFontManager() {
+        return factory.getFontManager();
+    }
+
+    /**
+     * Indicates whether a namespace URI is on the ignored list.
+     * @param namespaceURI the namespace URI
+     * @return true if the namespace is ignored by FOP
+     */
+    public boolean isNamespaceIgnored(String namespaceURI) {
+        return factory.isNamespaceIgnored(namespaceURI);
+    }
+
+    /**
+     * Is the user configuration to be validated?
+     * @return if the user configuration should be validated
+     */
+    public boolean validateUserConfigStrictly() {
+        return factory.validateUserConfigStrictly();
+    }
+
+    /**
+     * Get the user configuration.
+     * @return the user configuration
+     */
+    public Configuration getUserConfig() {
+        return factory.getUserConfig();
+    }
+
+    /** @return the image handler registry */
+    public ImageHandlerRegistry getImageHandlerRegistry() {
+        return factory.getImageHandlerRegistry();
+    }
+
+    /** TODO: javadoc*/
+    public ColorSpaceCache getColorSpaceCache() {
+        return factory.getColorSpaceCache();
+    }
+
+    public Map<String, String> getHyphPatNames() {
+        return factory.getHyphPatNames();
+    }
 }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/Fop.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/Fop.java?rev=1356804&r1=1356803&r2=1356804&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/Fop.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/Fop.java Tue Jul  3 16:01:48 2012
@@ -66,12 +66,12 @@ public class Fop {
      * @throws FOPException if setting up the DefaultHandler fails
      */
     Fop(String outputFormat, FOUserAgent ua, OutputStream stream) throws FOPException {
+        if (ua == null) {
+            throw new FOPException("Cannot create a new Fop instance without a User Agent.");
+        }
         this.outputFormat = outputFormat;
 
         foUserAgent = ua;
-        if (foUserAgent == null) {
-            foUserAgent = FopFactory.newInstance().newFOUserAgent();
-        }
 
         this.stream = stream;
 



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