1 19 package org.netbeans.modules.turbo; 20 21 import java.util.List ; 22 23 43 public interface TurboProvider { 44 45 48 boolean recognizesAttribute(String name); 49 50 53 boolean recognizesEntity(Object key); 54 55 64 Object readEntry(Object key, String name, MemoryCache memoryCache); 65 66 76 boolean writeEntry(Object key, String name, Object value); 77 78 82 public static final class MemoryCache { 83 84 private final boolean enabled; 85 86 private final List speculative; 87 88 private final Memory memory; 89 90 private MemoryCache(boolean enabled) { 91 this.enabled = enabled; 92 speculative = null; 93 memory = null; 94 } 95 96 private MemoryCache(Memory memory, List speculative) { 97 enabled = true; 98 this.memory = memory; 99 this.speculative = speculative; 100 } 101 102 107 static MemoryCache createDefault(Memory memory, List speculative) { 108 return new MemoryCache(memory, speculative); 109 } 110 111 112 static MemoryCache getTest() { 113 return new MemoryCache(false); 114 } 115 116 119 public void cacheEntry(Object key, String name, Object value) { 120 if (enabled == false) return; 121 memory.put(key, name, value); 122 if (speculative != null) speculative.add(new Object [] {key, name, value}); 123 } 124 125 126 List getSpeculative() { 127 return speculative; 128 } 129 } 130 } 131 | Popular Tags |