All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.odell.glazedlists.impl.pmap.LoadValue Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
/* Glazed Lists                                                 (c) 2003-2006 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.impl.pmap;

// NIO is used for CTP
import ca.odell.glazedlists.impl.nio.*;
import ca.odell.glazedlists.impl.io.*;
import java.util.*;
import java.nio.*;
import java.nio.channels.*;
import java.text.ParseException;
import java.io.*;
// logging
import java.util.logging.*;

/**
 * Loads the value for a chunk from disk.
 *
 * @author Jesse Wilson
 */
class LoadValue implements Runnable {
     
    /** logging */
    private static Logger logger = Logger.getLogger(LoadValue.class.toString());
    
    /** the chunk with the data of interest */
    private final Chunk chunk;
    
    /** the interested party */
    private final ValueCallback valueCallback;
    
    /**
     * Create a new LoadValue.
     */
    public LoadValue(Chunk chunk, ValueCallback valueCallback) {
        this.chunk = chunk;
        this.valueCallback = valueCallback;
    }
    
    /**
     * Read a chunk's value from disk.
     */
    public void run() {
        try {
            if(!chunk.isOn()) throw new IOException("Chunk has been destroyed");
            valueCallback.valueLoaded(chunk, chunk.readValue());

        } catch(IOException e) {
            chunk.getPersistentMap().fail(e, "Failed to read value from file " + chunk.getPersistentMap().getFile().getPath());
            valueCallback.valueLoaded(chunk, null);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy