com.levigo.jadice.document
Class FormatRegistry

java.lang.Object
  extended by com.levigo.jadice.document.FormatRegistry

public class FormatRegistry
extends Object


Constructor Summary
FormatRegistry()
           
 
Method Summary
static Format detectFileFormat(SeekableInputStream stream)
          Detect and return the format of the file by looking at the first bytes of a file.
static ClassLoader getAdditionalFormatClassLoader()
          Returns an additional context class loader used to load format providers.
static Format getFormat(MimeType type)
           
static Format getFormatForExtension(String extension)
          Retrieve the first FormatInfo which has a default extension which matches the given extension.
static List<Format> getFormatInformation()
          Retrieve the format information for the currently registered document types.
static Integer getPriority(Format format)
          Return the overridden priority for the given format or null if the default priority applies.
static void setAdditionalFormatClassLoader(ClassLoader formatClassLoader)
          Sets an additional context classloader used to load format providers.
static void setPriority(Format format, int priority)
          Override the default detection priority of the given format, replacing it with the given priority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatRegistry

public FormatRegistry()
Method Detail

getAdditionalFormatClassLoader

public static ClassLoader getAdditionalFormatClassLoader()
Returns an additional context class loader used to load format providers. If this class loader is null, the system class loader will be used.

Returns:
ClassLoader

setPriority

public static void setPriority(Format format,
                               int priority)
Override the default detection priority of the given format, replacing it with the given priority. Formats are give a chance to check whether they can handle a given stream in order of descending priority.

Parameters:
format -
priority -

getPriority

public static Integer getPriority(Format format)
Return the overridden priority for the given format or null if the default priority applies. The default priority of a Format can be retrieved by a call of Format.getPriority().

Parameters:
format - the format the priority is asked for
Returns:
the overridden priority, if defined. Otherwise null which indicates that the default priority of the format applies.

getFormatForExtension

public static Format getFormatForExtension(String extension)
Retrieve the first FormatInfo which has a default extension which matches the given extension.

Parameters:
extension -
Returns:
FormatInfo

getFormatInformation

public static final List<Format> getFormatInformation()
Retrieve the format information for the currently registered document types.

Returns:
Iterator of FormatInfo

getFormat

public static Format getFormat(MimeType type)

setAdditionalFormatClassLoader

public static void setAdditionalFormatClassLoader(ClassLoader formatClassLoader)
Sets an additional context classloader used to load format providers. If the given class loader is null, the system class loader will be used. Changing this loader must happen before any format is loaded, because the format provider access lazily takes place while the first loading process. Afterwards no further access is done.

Parameters:
formatClassLoader - the new class loader to use

detectFileFormat

public static Format detectFileFormat(SeekableInputStream stream)
                               throws IOException
Detect and return the format of the file by looking at the first bytes of a file. Each format decides for its own how many bytes it needs for detection.

Parameters:
stream - the raw data stream
Returns:
the file format.
Throws:
IOException - if an io error or an unsupported encoding occurred


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.