diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-18 15:13:34 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-18 15:13:34 +0000 |
commit | 1c8e854d814a64633af4c09b8a97017bda8ea4c5 (patch) | |
tree | 6dfd04f0354e140baf0318c332de4529a5872750 /src/java/org/apache/fop | |
parent | 91fbf6ec462003a68f0470f511d98fcabfdaba3d (diff) | |
download | xmlgraphics-fop-1c8e854d814a64633af4c09b8a97017bda8ea4c5.tar.gz xmlgraphics-fop-1c8e854d814a64633af4c09b8a97017bda8ea4c5.zip |
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
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r-- | src/java/org/apache/fop/render/afp/DataObjectCache.java | 22 |
1 files changed, 10 insertions, 12 deletions
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/*<Integer,DataObjectCache>*/(); - /** Mapping of data object uri --> cache entry */ - private Map/*<String,DataObjectCache.Entry>*/ cacheRecordMap - = new java.util.HashMap/*<String,DataObjectCache.Entry>*/(); + /** Mapping of data object uri --> cache record */ + private Map/*<ResourceInfo,DataObjectCache.Record>*/ recordMap + = new java.util.HashMap/*<ResourceInfo,DataObjectCache.Record>*/(); /** 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); } |