Fragment 1. 缓存技术的脏数据问题 /** * A report printer is used to print a report. * * @version 1.0 9/9/2003 * @author Bill */ public class ReportPrinter { /** * Constructs a ReportPrinter instance. */ public ReportPrinter() { // do something... }
/** * Prints a printable. * * @param printable the specified printable object */ public void print(Printable printable) { Graphics g = getGraphics(). g.setFont(getReportFont(printable.getFont()).
printable.print(g). }
/** * Returns the corresponding report font of a java font. * * @param javaFont the specified java font * @return the corresponding report font */ private Font getReportFont(font javaFont) { Font reportFont = fontMap.get(javaFont).
/** * Loads the corresponding report font of a java font. * * @param javaFont the specified java font * @param the corresponding report font */ protected static Font loadFont(Font javaFont) { Font reportFont = null.
// do something...
return reportFont. }
/** * The font map(java font->report font). */ private static HashMap fontMap = new HashMap(). }