Package net.sf.basedb.core
Class File.CharsetTesterThread
- java.lang.Object
-
- net.sf.basedb.core.File.CharsetTesterThread
-
-
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
All Methods Instance Methods Concrete Methods 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 Detail
-
pop
private final PipedOutputStream pop
-
pip
private final PipedInputStream pip
-
detector
private final CharsetDetector detector
-
thread
private Thread thread
-
couldParse
private volatile boolean couldParse
-
isRunning
private volatile boolean isRunning
-
-
Constructor Detail
-
CharsetTesterThread
CharsetTesterThread(Charset charset) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getCharset
public Charset 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.
-
-