當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。