|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.alfresco.encoding.AbstractCharactersetFinder
public abstract class AbstractCharactersetFinder
| Constructor Summary | |
|---|---|
AbstractCharactersetFinder()
|
|
| Method Summary | |
|---|---|
java.nio.charset.Charset |
detectCharset(byte[] buffer)
Attempt to detect the character set encoding for the given buffer. |
java.nio.charset.Charset |
detectCharset(java.io.InputStream is)
Attempt to detect the character set encoding for the give input stream. |
protected abstract java.nio.charset.Charset |
detectCharsetImpl(byte[] buffer)
Worker method for implementations to override. |
protected int |
getBufferSize()
Some implementations may only require a few bytes to do detect the stream type, whilst others may be more efficient with larger buffers. |
void |
setBufferSize(int bufferSize)
Set the maximum number of bytes to read ahead when attempting to determine the characterset. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractCharactersetFinder()
| Method Detail |
|---|
public void setBufferSize(int bufferSize)
bufferSize - the number of bytes - default 8K.public final java.nio.charset.Charset detectCharset(java.io.InputStream is)
BufferedInputStream.
The current state of the stream will be restored before the method returns.
The input stream is checked to ensure that it supports marks, after which a buffer is extracted, leaving the stream in its original state.
detectCharset in interface CharactersetFinderis - an input stream that must support marking
public final java.nio.charset.Charset detectCharset(byte[] buffer)
CharactersetFinder
detectCharset in interface CharactersetFinderbuffer - the first n bytes of the character stream
protected int getBufferSize()
Only override this method if there is a very compelling reason to adjust the buffer
size, and then consider handling the AbstractCharactersetFinder.setBufferSize(int) method by issuing a
warning. This will prevent users from setting the buffer size when it has no effect.
CharactersetFinder.detectCharset(byte[]) method.AbstractCharactersetFinder.setBufferSize(int)
protected abstract java.nio.charset.Charset detectCharsetImpl(byte[] buffer)
throws java.lang.Exception
The interface contract is that the data buffer must not be altered in any way.
buffer - the buffer of data no bigger than the requested
best buffer size. This can,
very efficiently, be turned into an InputStream using a
ByteArrayInputStream.
java.lang.Exception - Any exception, checked or not
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||