|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object eu.medsea.mimeutil.detector.MimeDetector
public abstract class MimeDetector
ALL MimeDetector(s) must extend this class.
Constructor Summary | |
---|---|
MimeDetector()
|
Method Summary | |
---|---|
protected static InputStream |
closeStream(InputStream in)
|
void |
delete()
You can override this method if for instance you allocated any resources in the init() method that need to be closed or deallocated specially. |
abstract String |
getDescription()
Abstract method to be implement by concrete MimeDetector(s). |
Collection |
getMimeTypes(byte[] data)
Called by MimeUtil.MimeDetectorRegistry.getMimeTypes(byte [] data) {} |
Collection |
getMimeTypes(File file)
Called by MimeUtil.MimeDetectorRegistry.getMimeTypes(File file) {} |
Collection |
getMimeTypes(InputStream in)
Called by MimeUtil.MimeDetectorRegistry.getMimeTypes(InputStream in) {} The InputStream must support the mark() and reset() methods. |
Collection |
getMimeTypes(String fileName)
Called by MimeUtil.MimeDetectorRegistry.getMimeTypes(String fileName) {} |
Collection |
getMimeTypes(URL url)
Called by MimeUtil.MimeDetectorRegistry.getMimeTypes(URL url) {} |
protected abstract Collection |
getMimeTypesByteArray(byte[] data)
Abstract method that must be implemented by concrete MimeDetector(s). |
protected abstract Collection |
getMimeTypesFile(File file)
Abstract method that must be implemented by concrete MimeDetector(s). |
protected abstract Collection |
getMimeTypesFileName(String fileName)
Abstract method that must be implemented by concrete MimeDetector(s). |
protected abstract Collection |
getMimeTypesInputStream(InputStream in)
Abstract method that must be implemented by concrete MimeDetector(s). |
protected abstract Collection |
getMimeTypesURL(URL url)
Abstract method that must be implemented by concrete MimeDetector(s). |
String |
getName()
Gets the name of this MimeDetector |
void |
init()
You can override this method if you have any special one off initialisation to perform such as allocating resources etc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MimeDetector()
Method Detail |
---|
public final String getName()
public final Collection getMimeTypes(String fileName) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
public final Collection getMimeTypes(File file) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
public final Collection getMimeTypes(URL url) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
public final Collection getMimeTypes(byte[] data) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
public final Collection getMimeTypes(InputStream in) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
public void init()
public void delete()
public abstract String getDescription()
protected abstract Collection getMimeTypesFileName(String fileName) throws UnsupportedOperationException
fileName
-
UnsupportedOperationException
protected abstract Collection getMimeTypesFile(File file) throws UnsupportedOperationException
file
-
UnsupportedOperationException
protected abstract Collection getMimeTypesURL(URL url) throws UnsupportedOperationException
file
-
UnsupportedOperationException
protected abstract Collection getMimeTypesInputStream(InputStream in) throws UnsupportedOperationException
If the InputStream passed in does not support the mark() and reset() methods a MimeException will be thrown before reaching this point. The implementation is responsible for the actual use of the mark() and reset() methods as the amount of data to retrieve from the stream is implementation and even call by call dependent. If you do not use the mark() and reset() methods on the Stream then the position in the Stream will have moved on when this method returns and the next MimeDetector that handles the stream will either fail or be incorrect.
To allow the reuse of the Stream in other parts of your code and by further MimeDetector(s) in a way that it is unaware of any data read via this method i.e. the Stream position will be returned to where it was when this method was called, it is IMPORTANT to utilise the mark() and reset() methods within your implementing method.
in
- InputStream.
UnsupportedOperationException
protected abstract Collection getMimeTypesByteArray(byte[] data) throws UnsupportedOperationException
data
- byte []. Is a byte array that you want to parse for matching mime types.
UnsupportedOperationException
protected static InputStream closeStream(InputStream in)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |