1 11 package org.eclipse.compare.internal; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.jface.text.IDocument; 16 17 20 public class DocumentManager { 21 22 private static final boolean DEBUG= false; 23 24 private static ArrayList fgKeys= new ArrayList (); 25 private static ArrayList fgValues= new ArrayList (); 26 27 public static IDocument get(Object o) { 28 29 for (int i= 0; i < fgKeys.size(); i++) { 30 if (fgKeys.get(i) == o) 31 return (IDocument) fgValues.get(i); 32 } 33 return null; 34 } 35 36 public static void put(Object o, IDocument document) { 37 if (DEBUG) System.out.println("DocumentManager.put: " + document); for (int i= 0; i < fgKeys.size(); i++) { 39 if (fgKeys.get(i) == o) { 40 fgValues.set(i, document); 41 return; 42 } 43 } 44 fgKeys.add(o); 45 fgValues.add(document); 46 } 47 48 public static void remove(IDocument document) { 49 if (document != null) { 50 if (DEBUG) System.out.println("DocumentManager.remove: " + document); for (int i= 0; i < fgValues.size(); i++) { 52 if (fgValues.get(i) == document) { 53 fgKeys.remove(i); 54 fgValues.remove(i); 55 return; 56 } 57 } 58 if (DEBUG) System.out.println("DocumentManager.remove: not found"); } 60 } 61 62 public static void dump() { 63 if (DEBUG) System.out.println("DocumentManager: managed docs:" + fgValues.size()); } 65 } 66 | Popular Tags |