Code example for WeakReference

Methods: get

0
 
    /** 
     * @return the hog reports 
     */ 
    public SimpleHogBug[] getHogReport() { 
        if (hogData == null || hogData.get() == null) {
            readHogReport(); 
        } 
        if (hogData == null || hogData.get() == null)
            return null; 
        return hogData.get();
    } 
 
    public void writeBugReport(HogBugReport r) {
        if (r != null) {
            SimpleHogBug[] list = convert(r.getHbList(), true);
            if (list != null){
                bugData = new WeakReference<SimpleHogBug[]>(list);
                writeObject(list, BUGFILE);
            } 
        }