From: Adrian Cumiskey Date: Fri, 18 Jul 2008 15:13:34 +0000 (+0000) Subject: Some minor optimizations and javadoc corrections. X-Git-Tag: fop-1_0~376^2~132 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1c8e854d814a64633af4c09b8a97017bda8ea4c5;p=xmlgraphics-fop.git Some minor optimizations and javadoc corrections. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@677930 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/afp/DataObjectCache.java b/src/java/org/apache/fop/render/afp/DataObjectCache.java index aeec9cd78..a247f3383 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectCache.java +++ b/src/java/org/apache/fop/render/afp/DataObjectCache.java @@ -48,9 +48,9 @@ public final class DataObjectCache { = new java.util.HashMap/**/(); - /** Mapping of data object uri --> cache entry */ - private Map/**/ cacheRecordMap - = new java.util.HashMap/**/(); + /** Mapping of data object uri --> cache record */ + private Map/**/ recordMap + = new java.util.HashMap/**/(); /** Used for create data objects */ private DataObjectFactory factory = new DataObjectFactory(); @@ -64,9 +64,6 @@ public final class DataObjectCache { /** The temporary cache file */ private File tempFile; - /** The cache id */ - private int id; - /** The next file pointer position in the cache file */ private long nextPos; @@ -82,7 +79,7 @@ public final class DataObjectCache { DataObjectCache cache = (DataObjectCache)cacheMap.get(cacheKey); if (cache == null) { try { - cache = new DataObjectCache(); + cache = new DataObjectCache(id); cacheMap.put(cacheKey, cache); } catch (IOException e) { log.error("Failed to create cache"); @@ -94,9 +91,10 @@ public final class DataObjectCache { /** * Default constructor + * + * @param id the cache id */ - private DataObjectCache() throws IOException { - this.id = System.identityHashCode(Thread.currentThread()); + private DataObjectCache(int id) throws IOException { this.tempFile = File.createTempFile(CACHE_FILENAME_PREFIX + id, null); this.raFile = new RandomAccessFile(tempFile, "rw"); this.channel = raFile.getChannel(); @@ -123,7 +121,7 @@ public final class DataObjectCache { */ public String put(DataObjectInfo dataObjectInfo) { ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - Record record = (Record)cacheRecordMap.get(resourceInfo); + Record record = (Record)recordMap.get(resourceInfo); if (record == null) { record = new Record(); AbstractNamedAFPObject dataObj = factory.createObject(dataObjectInfo); @@ -145,7 +143,7 @@ public final class DataObjectCache { log.error("Failed to write cache record for '" + resourceInfo + "', " + e.getMessage()); } - cacheRecordMap.put(resourceInfo, record); + recordMap.put(resourceInfo, record); } return record.objectName; } @@ -157,7 +155,7 @@ public final class DataObjectCache { * @return the binary data of the AbstractDataObject or null if failed. */ public byte[] get(ResourceInfo resourceInfo) { - Record record = (Record)cacheRecordMap.get(resourceInfo); + Record record = (Record)recordMap.get(resourceInfo); if (record == null) { throw new IllegalArgumentException("Unknown data object " + resourceInfo); }