1 19 package org.netbeans.modules.languages.features; 20 21 import java.lang.ref.WeakReference ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 import org.netbeans.api.editor.fold.FoldType; 25 26 27 public class Folds { 28 29 private static Map <String ,WeakReference <FoldType>> nameToFoldType = new HashMap <String ,WeakReference <FoldType>>(); 30 31 public static synchronized FoldType getFoldType (String name) { 32 if (name == null) return null; 33 WeakReference <FoldType> wr = nameToFoldType.get (name); 34 FoldType ft = wr == null ? null : wr.get (); 35 if (ft == null) { 36 ft = new FoldType (name); 37 nameToFoldType.put (name, new WeakReference <FoldType> (ft)); 38 } 39 return ft; 40 } 41 } 42 43 | Popular Tags |