public final class ContentTypeRegistry
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
addConverter(DataConverter converter) |
void |
addFilter(org.java.plugin.registry.Extension extension)
Registers the filter represented by the given
Extension |
void |
addListener(java.lang.String eventName,
EventListener listener) |
void |
addType(java.lang.Class<?> clazz) |
void |
addType(ContentType type) |
int |
availableConverterCount() |
java.util.List<DataConverter> |
availableConverters() |
java.util.List<ContentType> |
availableTypes() |
int |
availableTypesCount() |
java.lang.Object |
convert(java.lang.Object data,
java.lang.Object targetType,
Options options) |
java.util.Collection<ContentType> |
getAssignableTypes(ContentType target)
Returns a collection of
ContentType objects with declared
content classes assignable to the content class of the target
parameter. |
java.util.Collection<ContentType> |
getCompatibleTypes(ContentType target)
Returns a collection of
ContentType s that are compatible as
per the isCompatible(ContentType, ContentType) method. |
static java.lang.String |
getContentTypeId(org.java.plugin.registry.Extension extension) |
java.util.Collection<ContentType> |
getConversionTargets(ContentType type,
boolean includeCompatible) |
DataConverter |
getConverter(ContentType inputType,
ContentType resultType) |
DataConverter[] |
getConvertersForInputType(ContentType inputType) |
DataConverter[] |
getConvertersForResultType(ContentType resultType) |
java.awt.datatransfer.DataFlavor |
getDataFlavor(ContentType contentType) |
ContentType |
getEnclosingType(java.lang.Object data) |
ContentTypeCollection |
getEnclosingTypes(java.lang.Object data) |
static ContentType |
getEntryType(java.lang.Object container)
Tries to fetch the
ContentType describing entries
in the given container. |
java.util.Collection<org.java.plugin.registry.Extension> |
getFilters(ContentType contentType)
Returns only those filters that are explicitly declared
to handle the given
ContentType . |
java.util.Collection<org.java.plugin.registry.Extension> |
getFilters(ContentType contentType,
boolean includeCompatible) |
static ContentTypeRegistry |
getInstance() |
ContentType |
getType(org.java.plugin.registry.Extension extension) |
ContentType |
getType(java.lang.String id) |
ContentType |
getTypeForClass(java.lang.Object data) |
static boolean |
isCompatible(ContentTypeCollection collection,
java.lang.String typeId) |
static boolean |
isCompatible(ContentType type,
ContentType target)
Checks whether
ContentType target is compatible
towards the type argument. |
static boolean |
isCompatible(ContentType type,
java.lang.Object content)
Checks whether the given
ContentType accepts the content
argument. |
static boolean |
isCompatible(java.lang.String typeId,
ContentType target)
Fetches the
ContentType identified by typeId and runs
a call to isCompatible(ContentType, ContentType) with the result. |
static boolean |
isCompatible(java.lang.String typeId,
java.lang.Object content) |
boolean |
isConvertible(ContentType source,
ContentType target) |
static boolean |
isStrictType(ContentType type) |
void |
removeListener(EventListener listener) |
void |
removeListener(EventListener listener,
java.lang.String eventName) |
public static ContentTypeRegistry getInstance()
public ContentType getType(java.lang.String id)
public ContentType getType(org.java.plugin.registry.Extension extension)
public ContentType getTypeForClass(java.lang.Object data)
public ContentType getEnclosingType(java.lang.Object data)
public ContentTypeCollection getEnclosingTypes(java.lang.Object data)
public java.util.Collection<ContentType> getAssignableTypes(ContentType target)
ContentType
objects with declared
content classes assignable to the content class of the target
parameter. The returned collection does not contain the target
parameter itself!
Note that this method does not use the ContentType.accepts(Object)
filter method to determine assignability but relies on Class.isAssignableFrom(Class)
with the content classes of the two content types being checked.
public java.util.Collection<ContentType> getCompatibleTypes(ContentType target)
ContentType
s that are compatible as
per the isCompatible(ContentType, ContentType)
method.public static boolean isCompatible(ContentType type, java.lang.Object content)
ContentType
accepts the content
argument. This is done by using the ContentType.accepts(Object)
method. If content
is of type Class
it is passed as-is
otherwise the result of its Object#getClass()
method is used as
argument.public static boolean isCompatible(ContentType type, ContentType target)
ContentType
target
is compatible
towards the type
argument. This check is delegated to type
's
ContentType.accepts(Object)
method with the result of target
's
ContentType.getContentClass()
.
Note that the default ContentType
implementations for common
java data types do a pure Object#equals(Object)
check on the
two Class
objects in question. Implementations of type
LazyExtensionContentType
honor the ContentType.STRICT_INHERITANCE
property and either check for class equality or assignability via
Class.isAssignableFrom(Class)
. Custom implementations are free
to use whatever mechanics they seem fit.
public static boolean isCompatible(java.lang.String typeId, ContentType target)
ContentType
identified by typeId
and runs
a call to isCompatible(ContentType, ContentType)
with the result.public static boolean isCompatible(java.lang.String typeId, java.lang.Object content)
public static boolean isCompatible(ContentTypeCollection collection, java.lang.String typeId)
public static boolean isStrictType(ContentType type)
public static java.lang.String getContentTypeId(org.java.plugin.registry.Extension extension)
public static ContentType getEntryType(java.lang.Object container)
ContentType
describing entries
in the given container. If no type could be fetched a result
value of null
will be returned.public boolean isConvertible(ContentType source, ContentType target)
public java.util.Collection<ContentType> getConversionTargets(ContentType type, boolean includeCompatible)
public java.lang.Object convert(java.lang.Object data, java.lang.Object targetType, Options options) throws DataConversionException
DataConversionException
public void addListener(java.lang.String eventName, EventListener listener)
public void removeListener(EventListener listener, java.lang.String eventName)
public void removeListener(EventListener listener)
public void addType(ContentType type)
public void addType(java.lang.Class<?> clazz)
public java.util.List<ContentType> availableTypes()
public int availableTypesCount()
public java.util.Collection<org.java.plugin.registry.Extension> getFilters(ContentType contentType)
ContentType
.public java.util.Collection<org.java.plugin.registry.Extension> getFilters(ContentType contentType, boolean includeCompatible)
public void addFilter(org.java.plugin.registry.Extension extension)
Extension
public void addConverter(DataConverter converter)
public java.util.List<DataConverter> availableConverters()
public int availableConverterCount()
public DataConverter[] getConvertersForInputType(ContentType inputType)
public DataConverter[] getConvertersForResultType(ContentType resultType)
public DataConverter getConverter(ContentType inputType, ContentType resultType)
public java.awt.datatransfer.DataFlavor getDataFlavor(ContentType contentType)