当前位置: 首页>>代码示例>>Java>>正文


Java Reference.get方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MetaInfCache.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CallbackSystemAction.java

示例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;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectServicesImpl.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DocumentOpenClose.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:BreakpointEnableAction.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CallbackSystemAction.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:AuxiliaryConfigBasedPreferencesProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ParsingFoldSupport.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:AbstractFolder.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MacrosPanelController.java

示例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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Test5102804.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:NbMavenProjectImpl.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:FxBeanCache.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:BaseMemoryCache.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:BuildArtifactMapperImpl.java


注:本文中的java.lang.ref.Reference.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。