|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.semanticdesktop.aperture.runtime.ApertureRuntime
public class ApertureRuntime
A facade to the Aperture functionality. This class provides simple methods that allow you to accomplish the basic Aperture use cases in as little as two lines of code.
Constructor Summary | |
---|---|
ApertureRuntime()
|
Method Summary | |
---|---|
RDFContainer |
extractFrom(File file)
Tries to extract as much information from the given file as possible. |
RDFContainer |
extractFrom(InputStream stream,
String nameOrPathOrUrl)
Tries to extract as much information from the given input stream as possible. |
RDFContainer |
extractFrom(String uriString)
Tries to extract as much information from the given URI as possible. |
ExtractorRegistry |
getExtractorRegistry()
Returns the extractor registry. |
MimeTypeIdentifier |
getMimeTypeIdentifier()
Returns the mime type identifier. |
String |
identifyMimeType(InputStream stream,
String nameOrPathOrUrl)
Tries to identify the MIME type of the given input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ApertureRuntime()
Method Detail |
---|
public RDFContainer extractFrom(String uriString) throws IOException
uri
- the uri from which information is to be extracted. Only the URU with schemes supported by
the DefaultDataAccessorRegistry
registry and DefaultSubCrawlerRegistry
can be accessed and extracted. In most cases
the resulting InputStream will be read in its entirety, and the method may try download the
content into a temporary file (created with File.createTempFile(String, String)
. The
file will be deleted before this method returns, yet there must be enough room on the partition
that houses the temporary folder.
RDFContainer
instance containing the data extracted from the URL. It must be disposed
properly by the caller of this method, with a call to RDFContainer.dispose()
. This method
may return null if an object with this URI has not been found.
IllegalArgumentException
- if the uriString is invalid
IOException
- if an I/O error occurs during processingpublic RDFContainer extractFrom(InputStream stream, String nameOrPathOrUrl) throws IOException
stream
- the stream from which information is to be extracted. In most cases the stream will be
read in its entirety, so it will probably be unusable after this method returns. THIS METHOD
may try to download the entire file to a temporary filenameOrPathOrUrl
- (obligatory) this argument has two purposes: firstly, the file name and
extension will be extracted from it which in turn will be used to aid the MIME type
detection. Secondly it will serve as the basis for the creation of the URI for the returned
RDFContainer. If this argument is already a valid URI it will be used unchanged. Otherwise a
new uri will be created, with a 'file:' prefix, and the name or path appended to that prefix,
correctly URL-encoded. The process is heuristic, so in a general case the user should make
no assumptions what will the URI exactly look like. It should always be checked by calling
RDFContainer.getDescribedUri()
on the returned RDFContainer
instance.
RDFContainer
instance containing the data extracted from the InputStream.
IOException
- if an I/O error occurs in the process.public RDFContainer extractFrom(File file) throws IOException
file
- the file from which information is to be extracted
RDFContainer
instance containing the data extracted from the file.
IOException
- if an I/O error occurs in the process.public String identifyMimeType(InputStream stream, String nameOrPathOrUrl) throws IOException
stream
- the input stream you'd like to identify. If the stream supports mark() and reset(), it's
InputStream.markSupported()
method returns true, the stream is marked and then reset
at the end. If not, then it's not. If you would like to use that stream afterwards, make
sure it does support InputStream.mark(int)
or wrap it in a
BufferedInputStream
if it doesn't. Closing the stream is YOUR responsiblity so make
so remember about this. You can also leave this argument as NULL in which case the
identifier will try to guess the MIME type from the file name or url.nameOrPathOrUrl
- an optional argument, that may help with checking. Many MIME types can be
detected by looking at the extension of that file. It can be the name of the file, its path
or an URL.
IOException
- if an I/O error occurs while reading from the streampublic ExtractorRegistry getExtractorRegistry()
public MimeTypeIdentifier getMimeTypeIdentifier()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |