本文整理汇总了Java中java.lang.ref.Reference.get方法的典型用法代码示例。如果您正苦于以下问题:Java Reference.get方法的具体用法?Java Reference.get怎么用?Java Reference.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.ref.Reference
的用法示例。
在下文中一共展示了Reference.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findInstance
import java.lang.ref.Reference; //导入方法依赖的package包/类
public synchronized Object findInstance(Class<?> c) {
int size = knownInstances.size();
int index = hashForClass(c, size);
for (int i = 0; i < size; i++) {
Reference<Object> ref = knownInstances.get(index);
if (ref == null) {
break;
}
Object obj = ref.get();
if (obj != null) {
if (c == obj.getClass()) {
return obj;
}
}
if (++index == size) {
index = 0;
}
}
return null;
}
示例2: attach
import java.lang.ref.Reference; //导入方法依赖的package包/类
public void attach(Action action) {
Reference<Action> d = delegate;
if ((d == null) || (d.get() == action)) {
return;
}
Action prev = d.get();
// reattaches to different action
if (prev != null) {
prev.removePropertyChangeListener(this);
}
this.delegate = new WeakReference<Action>(action);
action.addPropertyChangeListener(this);
}
示例3: removeProjectOpenListener
import java.lang.ref.Reference; //导入方法依赖的package包/类
@Override
public synchronized void removeProjectOpenListener(IDEProject.OpenListener listener) {
if (ideProjectOpenListeners != null) {
Iterator<Reference<IDEProject.OpenListener>> it = ideProjectOpenListeners.iterator();
while (it.hasNext()) {
Reference<IDEProject.OpenListener> r = it.next();
IDEProject.OpenListener l = r.get();
if (l == null || l == listener) {
it.remove(); // also doing cleanup of GC'ed references
}
}
if (ideProjectOpenListeners.isEmpty()) {
ideProjectOpenListeners = null;
if (projectOpenListener != null) {
OpenProjects.getDefault().removePropertyChangeListener(projectOpenListener);
projectOpenListener = null;
}
}
}
}
示例4: toString
import java.lang.ref.Reference; //导入方法依赖的package包/类
@Override
public String toString() {
StringBuilder sb = new StringBuilder(200);
sb.append("DocumentOpenClose: ").append(getSimpleName(ces)). // NOI18N
append(", documentStatus=").append(documentStatus);
Reference<StyledDocument> ref = docRef;
sb.append(", docRef=");
if (ref != null) {
StyledDocument doc = ref.get();
sb.append("(").append(getSimpleName(doc)).append(")");
} else {
sb.append("null");
}
if (activeOpen != null) {
sb.append("\n activeOpen: ").append(activeOpen);
}
if (activeReload != null) {
sb.append("\n activeReload: ").append(activeReload);
}
if (activeClose != null) {
sb.append("\n activeClose: ").append(activeClose);
}
return sb.toString();
}
示例5: areBreakpointsEnabled
import java.lang.ref.Reference; //导入方法依赖的package包/类
private boolean areBreakpointsEnabled() {
boolean isEnabled = true;
for (Reference<Breakpoint> br : bRefs) {
Breakpoint b = br.get();
if (b != null && !b.isEnabled()) {
isEnabled = false;
}
}
return isEnabled;
}
示例6: propertyChange
import java.lang.ref.Reference; //导入方法依赖的package包/类
public void propertyChange(java.beans.PropertyChangeEvent evt) {
synchronized (LISTENER) {
Reference<Action> d = delegate;
if ((d == null) || (d.get() == null)) {
return;
}
}
CallbackSystemAction c = get();
if (c != null) {
c.updateEnabled();
}
}
示例7: flush
import java.lang.ref.Reference; //导入方法依赖的package包/类
private void flush(Map<Project, Reference<AuxiliaryConfigBasedPreferencesProvider>> m) {
for (Reference<AuxiliaryConfigBasedPreferencesProvider> rp : m.values()) {
AuxiliaryConfigBasedPreferencesProvider p = rp.get();
if(p != null) {
p.flush();
}
}
}
示例8: getManagers
import java.lang.ref.Reference; //导入方法依赖的package包/类
synchronized List<FoldManager> getManagers() {
List<FoldManager> live = new ArrayList<>(managers.size());
for (Iterator<Reference<FoldManager>> it = managers.iterator(); it.hasNext(); ) {
Reference<FoldManager> ref = it.next();
FoldManager x = ref.get();
if (x == null) {
it.remove();
} else {
live.add(x);
}
}
return live;
}
示例9: getChild
import java.lang.ref.Reference; //导入方法依赖的package包/类
private final AbstractFolder getChild(String name, boolean onlyValid) {
Reference<AbstractFolder> r = map.get(name);
if (r == null) {
//On OpenVMS, see if the name is stored in a different case
//to work around a JVM bug.
//
if (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_VMS) {
if (Character.isLowerCase(name.charAt(0))) {
r = map.get(name.toUpperCase());
} else {
r = map.get(name.toLowerCase());
}
if (r == null) {
return null;
}
} else {
return null;
}
}
AbstractFolder fo = r.get();
if (fo == null) {
// object does not exist => have to recreate it
fo = createFile(name);
if ((fo != null) && fo.isValid()) {
map.put(name, (fo != null) ? createReference(fo) : null);
} else {
if (onlyValid) {
fo = null;
}
}
}
return fo;
}
示例10: getMacrosPanel
import java.lang.ref.Reference; //导入方法依赖的package包/类
private MacrosPanel getMacrosPanel(Lookup masterLookup) {
Reference<MacrosPanel> ref = PANELS.get(masterLookup);
MacrosPanel panel = ref == null ? null : ref.get();
if (panel == null) {
panel = new MacrosPanel(masterLookup);
PANELS.put(masterLookup, new WeakReference<MacrosPanel>(panel));
}
this.lastPanel = panel;
return panel;
}
示例11: isCollectible
import java.lang.ref.Reference; //导入方法依赖的package包/类
private static boolean isCollectible(Reference reference) {
int[] array = new int[10];
while (true) {
try {
array = new int[array.length + array.length / 3];
}
catch (OutOfMemoryError error) {
return null == reference.get();
}
}
}
示例12: isMavenProjectLoaded
import java.lang.ref.Reference; //导入方法依赖的package包/类
/**
* a marginally unreliable, non blocking method for figuring if the model is loaded or not.
* @return
*/
public boolean isMavenProjectLoaded() {
Reference<MavenProject> prj = project;
if (prj != null) {
return prj.get() != null;
}
return false;
}
示例13: addBeanInfo
import java.lang.ref.Reference; //导入方法依赖的package包/类
public void addBeanInfo(ClasspathInfo cp, FxBean instance, Set<String> parents) {
ClasspathCache cc = null;
synchronized (cache) {
String key = createKey(cp);
Reference<ClasspathCache> c = cache.get(key);
if (c != null) {
cc = c.get();
}
if (cc == null) {
cache.put(key, new CacheRef(cc = new ClasspathCache(cp), key));
}
}
cc.addBeanInfo(instance, parents);
}
示例14: get
import java.lang.ref.Reference; //导入方法依赖的package包/类
public Bitmap get(String key) {
Reference<Bitmap> reference = (Reference) this.softMap.get(key);
if (reference != null) {
return (Bitmap) reference.get();
}
return null;
}
示例15: forRoot
import java.lang.ref.Reference; //导入方法依赖的package包/类
@Override
public CompileOnSaveAction forRoot(@NonNull final URL root) {
synchronized (normCache) {
final Reference<DefaultCompileOnSaveAction> ref = normCache.get(root);
DefaultCompileOnSaveAction res;
if (ref == null || (res = ref.get()) == null) {
res = new DefaultCompileOnSaveAction(root);
normCache.put(root, new WeakReference<>(res));
}
return res;
}
}