Package net.sf.basedb.core
Class File.CharsetTesterThread
java.lang.Object
net.sf.basedb.core.File.CharsetTesterThread
- All Implemented Interfaces:
Runnable
- Enclosing class:
- File
class File.CharsetTesterThread extends Object implements Runnable
-
Field Summary
Fields Modifier and Type Field Description private boolean
couldParse
private CharsetDetector
detector
private boolean
isRunning
private PipedInputStream
pip
private PipedOutputStream
pop
private Thread
thread
-
Constructor Summary
Constructors Constructor Description CharsetTesterThread(Charset charset)
-
Method Summary
Modifier and Type Method Description void
close()
The file has been uploaded.boolean
couldParse()
Returns TRUE if the file seems like valid (UTF-8).Charset
getCharset()
void
run()
Runs in a separate thread.void
write(byte[] b, int off, int len)
Runs in the main thread.void
write(int b)
Runs in the main thread.
-
Field Details
-
pop
-
pip
-
detector
-
thread
-
couldParse
private volatile boolean couldParse -
isRunning
private volatile boolean isRunning
-
-
Constructor Details
-
CharsetTesterThread
- Throws:
IOException
-
-
Method Details
-
run
public void run()Runs in a separate thread. -
getCharset
-
couldParse
public boolean couldParse()Returns TRUE if the file seems like valid (UTF-8). Note that this may not be correct until the close() method has been called. -
write
public void write(byte[] b, int off, int len)Runs in the main thread. Copy bytes to charset detector via the piped streams. -
write
public void write(int b)Runs in the main thread. Copy bytes to charset detector via the piped streams. -
close
public void close()The file has been uploaded. Wait for the charset detector threas to finish and the close everything.
-