fop 0.95

org.apache.fop.fonts
Class FontCache

java.lang.Object
  extended by org.apache.fop.fonts.FontCache
All Implemented Interfaces:
java.io.Serializable

public final class FontCache
extends java.lang.Object
implements java.io.Serializable

Fop cache (currently only used for font info caching)

See Also:
Serialized Form

Constructor Summary
FontCache()
          Default constructor
 
Method Summary
 void addFont(EmbedFontInfo fontInfo)
          adds a font info to cache
 void clear()
          Clears font cache
 boolean containsFont(EmbedFontInfo fontInfo)
          is this font info in the cache?
 boolean containsFont(java.lang.String embedUrl)
          is this font in the cache?
protected static java.lang.String getCacheKey(EmbedFontInfo fontInfo)
          creates a key given a font info for the font mapping
static java.io.File getDefaultCacheFile(boolean forWriting)
          Returns the default font cache file.
 CachedFontInfo getFont(java.lang.String embedUrl)
          returns a font from the cache
 boolean hasChanged()
          cache has been updated since it was read
 boolean isFailedFont(java.lang.String embedUrl, long lastModified)
          has this font previously failed to load?
static FontCache load()
          Reads the default font cache file and returns its contents.
static FontCache loadFrom(java.io.File cacheFile)
          Reads a font cache file and returns its contents.
 void registerFailedFont(java.lang.String embedUrl, long lastModified)
          registers a failed font with the cache
 void removeFont(java.lang.String embedUrl)
          removes font from cache
 void save()
          Writes the font cache to disk.
 void saveTo(java.io.File cacheFile)
          Writes the font cache to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontCache

public FontCache()
Default constructor

Method Detail

getDefaultCacheFile

public static java.io.File getDefaultCacheFile(boolean forWriting)
Returns the default font cache file.

Parameters:
forWriting - true if the user directory should be created
Returns:
the default font cache file

load

public static FontCache load()
Reads the default font cache file and returns its contents.

Returns:
the font cache deserialized from the file (or null if no cache file exists or if it could not be read)

loadFrom

public static FontCache loadFrom(java.io.File cacheFile)
Reads a font cache file and returns its contents.

Parameters:
cacheFile - the cache file
Returns:
the font cache deserialized from the file (or null if no cache file exists or if it could not be read)

save

public void save()
          throws FOPException
Writes the font cache to disk.

Throws:
FOPException - fop exception

saveTo

public void saveTo(java.io.File cacheFile)
            throws FOPException
Writes the font cache to disk.

Parameters:
cacheFile - the file to write to
Throws:
FOPException - fop exception

getCacheKey

protected static java.lang.String getCacheKey(EmbedFontInfo fontInfo)
creates a key given a font info for the font mapping

Parameters:
fontInfo - font info
Returns:
font cache key

hasChanged

public boolean hasChanged()
cache has been updated since it was read

Returns:
if this cache has changed

containsFont

public boolean containsFont(java.lang.String embedUrl)
is this font in the cache?

Parameters:
embedUrl - font info
Returns:
boolean

containsFont

public boolean containsFont(EmbedFontInfo fontInfo)
is this font info in the cache?

Parameters:
fontInfo - font info
Returns:
font

addFont

public void addFont(EmbedFontInfo fontInfo)
adds a font info to cache

Parameters:
fontInfo - font info

getFont

public CachedFontInfo getFont(java.lang.String embedUrl)
returns a font from the cache

Parameters:
embedUrl - font info
Returns:
boolean

removeFont

public void removeFont(java.lang.String embedUrl)
removes font from cache

Parameters:
embedUrl - embed url

isFailedFont

public boolean isFailedFont(java.lang.String embedUrl,
                            long lastModified)
has this font previously failed to load?

Parameters:
embedUrl - embed url
lastModified - last modified
Returns:
whether this is a failed font

registerFailedFont

public void registerFailedFont(java.lang.String embedUrl,
                               long lastModified)
registers a failed font with the cache

Parameters:
embedUrl - embed url
lastModified - time last modified

clear

public void clear()
Clears font cache


fop 0.95

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.