1 package net.sf.saxon.om; 2 import java.util.HashMap ; 3 import java.util.Iterator ; 4 5 15 16 public final class DocumentPool { 17 18 23 private HashMap documentNameMap = new HashMap (10); 24 25 30 31 public void add(DocumentInfo doc, String name) { 32 if (name!=null) { 33 documentNameMap.put(name, doc); 34 } 35 } 36 37 42 43 public DocumentInfo find(String name) { 44 return (DocumentInfo)documentNameMap.get(name); 45 } 46 47 51 52 public DocumentInfo discard(DocumentInfo doc) { 53 Iterator iter = documentNameMap.keySet().iterator(); 54 while (iter.hasNext()) { 55 Object name = iter.next(); 56 DocumentInfo entry = (DocumentInfo) documentNameMap.get(name); 57 if (entry == doc) { 58 documentNameMap.remove(name); 59 return doc; 60 } 61 } 62 return doc; 63 } 64 65 } 66 67 | Popular Tags |