Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.core.io
Class HaleIO

java.lang.Object
  extended by eu.esdihumboldt.hale.common.core.io.HaleIO

public abstract class HaleIO
extends Object

Hale I/O utilities

Since:
2.5
Author:
Simon Templer
Partner:
01 / Fraunhofer Institute for Computer Graphics Research

Constructor Summary
HaleIO()
           
 
Method Summary
static
<P extends IOProvider>
P
createIOProvider(Class<P> providerType, org.eclipse.core.runtime.content.IContentType contentType, String providerId)
          Creates an I/O provider instance
static List<IOProviderDescriptor> filterFactories(Collection<IOProviderDescriptor> factories, org.eclipse.core.runtime.content.IContentType contentType)
          Filter I/O provider factories by content type
static
<P extends IOProvider>
org.eclipse.core.runtime.content.IContentType
findContentType(Class<P> providerType, com.google.common.io.InputSupplier<? extends InputStream> in, String filename)
          Find the content type for the given input
static List<org.eclipse.core.runtime.content.IContentType> findContentTypesFor(Collection<org.eclipse.core.runtime.content.IContentType> types, com.google.common.io.InputSupplier<? extends InputStream> in, String filename)
          Find the content types that match the given file name and/or input.
static
<T extends ImportProvider>
T
findImportProvider(Class<T> type, InputStream in)
          Automatically find an import provider to load a resource that is available through an input stream that can only be read once.
static
<P extends IOProvider>
P
findIOProvider(Class<P> providerType, com.google.common.io.InputSupplier<? extends InputStream> in, String filename)
          Find an I/O provider instance for the given input
static
<P extends IOProvider>
IOProviderDescriptor
findIOProviderFactory(Class<P> providerType, org.eclipse.core.runtime.content.IContentType contentType, String providerId)
          Find an I/O provider factory
static
<P extends IOProvider>
Collection<IOProviderDescriptor>
getProviderFactories(Class<P> providerType)
          Get the I/O provider factories of a certain type
static boolean isCompatibleContentType(org.eclipse.core.runtime.content.IContentType parentType, org.eclipse.core.runtime.content.IContentType valueType)
          Test if the given value content type is compatible with the given parent content type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HaleIO

public HaleIO()
Method Detail

filterFactories

public static List<IOProviderDescriptor> filterFactories(Collection<IOProviderDescriptor> factories,
                                                         org.eclipse.core.runtime.content.IContentType contentType)
Filter I/O provider factories by content type

Parameters:
factories - the I/O provider factories
contentType - the content type factories must support
Returns:
provider factories that support the given content type

findContentTypesFor

public static List<org.eclipse.core.runtime.content.IContentType> findContentTypesFor(Collection<org.eclipse.core.runtime.content.IContentType> types,
                                                                                      com.google.common.io.InputSupplier<? extends InputStream> in,
                                                                                      String filename)
Find the content types that match the given file name and/or input. NOTE: The implementation should try to restrict the result to one content type and only use the input supplier if absolutely needed.

Parameters:
types - the types to match
in - the input supplier to use for testing, may be null if the file name is not null
filename - the file name, may be null if the input supplier is not null
Returns:
the matched content types

getProviderFactories

public static <P extends IOProvider> Collection<IOProviderDescriptor> getProviderFactories(Class<P> providerType)
Get the I/O provider factories of a certain type

Parameters:
providerType - the provider type, usually an interface
Returns:
the factories currently registered in the system

findIOProviderFactory

public static <P extends IOProvider> IOProviderDescriptor findIOProviderFactory(Class<P> providerType,
                                                                                org.eclipse.core.runtime.content.IContentType contentType,
                                                                                String providerId)
Find an I/O provider factory

Type Parameters:
P - the provider interface type
Parameters:
providerType - the provider type, usually an interface
contentType - the content type the provider must match, may be null if providerId is set
providerId - the id of the provider to use, may be null if contentType is set
Returns:
the I/O provider factory or null if no matching I/O provider factory is found

createIOProvider

public static <P extends IOProvider> P createIOProvider(Class<P> providerType,
                                                        org.eclipse.core.runtime.content.IContentType contentType,
                                                        String providerId)
Creates an I/O provider instance

Type Parameters:
P - the provider interface type
Parameters:
providerType - the provider type, usually an interface
contentType - the content type the provider must match, may be null if providerId is set
providerId - the id of the provider to use, may be null if contentType is set
Returns:
the I/O provider preconfigured with the content type if it was given or null if no matching I/O provider is found

findContentType

public static <P extends IOProvider> org.eclipse.core.runtime.content.IContentType findContentType(Class<P> providerType,
                                                                                                   com.google.common.io.InputSupplier<? extends InputStream> in,
                                                                                                   String filename)
Find the content type for the given input

Type Parameters:
P - the provider interface type
Parameters:
providerType - the provider type, usually an interface
in - the input supplier to use for testing, may be null if the file name is not null
filename - the file name, may be null if the input supplier is not null
Returns:
the content type or null if no matching content type is found

findIOProvider

public static <P extends IOProvider> P findIOProvider(Class<P> providerType,
                                                      com.google.common.io.InputSupplier<? extends InputStream> in,
                                                      String filename)
Find an I/O provider instance for the given input

Type Parameters:
P - the provider interface type
Parameters:
providerType - the provider type, usually an interface
in - the input supplier to use for testing, may be null if the file name is not null
filename - the file name, may be null if the input supplier is not null
Returns:
the I/O provider or null if no matching I/O provider is found

findImportProvider

public static <T extends ImportProvider> T findImportProvider(Class<T> type,
                                                              InputStream in)
Automatically find an import provider to load a resource that is available through an input stream that can only be read once.

Parameters:
type - the import provider type
in - the input stream
Returns:
the import provider or null if none was found

isCompatibleContentType

public static boolean isCompatibleContentType(org.eclipse.core.runtime.content.IContentType parentType,
                                              org.eclipse.core.runtime.content.IContentType valueType)
Test if the given value content type is compatible with the given parent content type

Parameters:
parentType - the parent content type
valueType - the value content type
Returns:
if the value content type is compatible with the parent content type

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d