ca.odell.glazedlists.impl.pmap.LoadValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* 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);
}
}
}