Package org.eclipse.core.runtime.content
Interface IContentType
-
- All Superinterfaces:
IContentTypeSettings
public interface IContentType extends IContentTypeSettings
Content types represent and provide information on file types, such as associated file names/extensions, default charset, etc.- Since:
- 3.0
- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FILE_EXTENSION_SPEC
File spec type constant, indicating a file extension specification.static int
FILE_NAME_SPEC
File spec type constant, indicating a file name specification.static int
FILE_PATTERN_SPEC
File spec type constant, indicating a file name pattern specification.static int
IGNORE_PRE_DEFINED
File spec type flag constant, indicating that predefined file specifications should not be taken into account.static int
IGNORE_USER_DEFINED
File spec type flag constant, indicating that user-defined file specifications should not be taken into account.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IContentType
getBaseType()
Returns a reference to this content type's base type.String
getDefaultCharset()
Returns the default charset for this content type if one has been defined,null
otherwise.IContentDescription
getDefaultDescription()
Returns the default content description for this content type.IContentDescription
getDescriptionFor(InputStream contents, QualifiedName[] options)
Tries to obtain a description for the given contents.IContentDescription
getDescriptionFor(Reader contents, QualifiedName[] options)
Tries to obtain a description for the given contents.String[]
getFileSpecs(int type)
Returns file specifications from this content type.String
getId()
Returns this content type's unique identifier.String
getName()
Returns a user-friendly name for this content type.IContentTypeSettings
getSettings(IScopeContext context)
Returns the settings for this content type in the given preference context.boolean
isAssociatedWith(String fileName)
Returns whether this content type is associated with the given file name.boolean
isAssociatedWith(String fileName, IScopeContext context)
Returns whether this content type is associated with the given file name in the given preference scope.boolean
isKindOf(IContentType another)
Returns whether this content type is a kind of the given content type.-
Methods inherited from interface org.eclipse.core.runtime.content.IContentTypeSettings
addFileSpec, isUserDefined, removeFileSpec, setDefaultCharset
-
-
-
-
Field Detail
-
IGNORE_PRE_DEFINED
static final int IGNORE_PRE_DEFINED
File spec type flag constant, indicating that predefined file specifications should not be taken into account.- See Also:
- Constant Field Values
-
IGNORE_USER_DEFINED
static final int IGNORE_USER_DEFINED
File spec type flag constant, indicating that user-defined file specifications should not be taken into account.- See Also:
- Constant Field Values
-
FILE_NAME_SPEC
static final int FILE_NAME_SPEC
File spec type constant, indicating a file name specification.- See Also:
- Constant Field Values
-
FILE_EXTENSION_SPEC
static final int FILE_EXTENSION_SPEC
File spec type constant, indicating a file extension specification.- See Also:
- Constant Field Values
-
FILE_PATTERN_SPEC
static final int FILE_PATTERN_SPEC
File spec type constant, indicating a file name pattern specification.?
represents any single character,*
represent any string.- Since:
- 3.7
- See Also:
- Constant Field Values
-
-
Method Detail
-
getBaseType
IContentType getBaseType()
Returns a reference to this content type's base type. If this content type does not have a base type (it is a root type), returnsnull
.- Returns:
- this content type's base type, or
null
-
getDefaultDescription
IContentDescription getDefaultDescription()
Returns the default content description for this content type. A default content description is returned by the content type API whenever content analysis could not find any particular information to be described about the contents being processed, so all default attributes for the content type in question apply.Clients doing caching of content descriptions may choose to treat default descriptions in a special manner, since they are easily recoverable through this API.
- Returns:
- a content description
- Since:
- 3.1
-
getDescriptionFor
IContentDescription getDescriptionFor(InputStream contents, QualifiedName[] options) throws IOException
Tries to obtain a description for the given contents.Any IOExceptions that may occur while reading the given input stream will flow to the caller. The input stream will not be closed by this operation.
- Parameters:
contents
- the contents to be interpretedoptions
- an array of keys for all properties that should be described- Returns:
- a content description if one could be obtained, or
null
- Throws:
IOException
- if an error occurs while reading the contents- See Also:
IContentDescription
-
getDescriptionFor
IContentDescription getDescriptionFor(Reader contents, QualifiedName[] options) throws IOException
Tries to obtain a description for the given contents.Any IOExceptions that may occur while reading the given reader will flow to the caller. The reader will not be closed by this operation.
- Parameters:
contents
- the contents to be interpretedoptions
- an array of keys for all properties that should be described- Returns:
- a content description if one could be obtained, or
null
- Throws:
UnsupportedOperationException
- if this content type has a describer that does not implementITextContentDescriber
IOException
- if an error occurs while reading the contents- See Also:
IContentDescription
-
getDefaultCharset
String getDefaultCharset()
Returns the default charset for this content type if one has been defined,null
otherwise. This refinement of the correspondingIContentTypeSettings
method also takes into account the charset defined by the content type provider (or its base content type).- Specified by:
getDefaultCharset
in interfaceIContentTypeSettings
- Returns:
- the default charset, or
null
-
getFileSpecs
String[] getFileSpecs(int type)
Returns file specifications from this content type. The type mask is a bit-wise or of file specification type constants indicating the file specification types of interest. This refinement of the correspondingIContentTypeSettings
method supports additional flags because it also takes into account the file specifications defined by the content type provider (or its base content type).- Specified by:
getFileSpecs
in interfaceIContentTypeSettings
- Parameters:
type
- a bit-wise or of file specification type constants. Valid flags are:- one of
FILE_EXTENSION_SPEC
orFILE_NAME_SPEC
- and optionally, one of
IGNORE_PRE_DEFINED
orIGNORE_USER_DEFINED
- one of
- Returns:
- the file specification
- See Also:
FILE_NAME_SPEC
,FILE_EXTENSION_SPEC
,IGNORE_PRE_DEFINED
,IGNORE_USER_DEFINED
-
getId
String getId()
Returns this content type's unique identifier. Each content type has an identifier by which they can be retrieved from the content type catalog.- Specified by:
getId
in interfaceIContentTypeSettings
- Returns:
- this content type's unique identifier
-
getName
String getName()
Returns a user-friendly name for this content type.- Returns:
- this content type's name
-
isAssociatedWith
boolean isAssociatedWith(String fileName)
Returns whether this content type is associated with the given file name.- Parameters:
fileName
- the file name- Returns:
true
if this content type is associated with the given file name,false
otherwise- See Also:
isAssociatedWith(String, IScopeContext)
-
isAssociatedWith
boolean isAssociatedWith(String fileName, IScopeContext context)
Returns whether this content type is associated with the given file name in the given preference scope.- Parameters:
fileName
- the file namecontext
- a preference scope context- Returns:
true
if this content type is associated with the given file name,false
otherwise- Since:
- 3.1
-
isKindOf
boolean isKindOf(IContentType another)
Returns whether this content type is a kind of the given content type. A content type A is a kind of a content type B if:- A and B are the same content type, or
- A's base type is B, or
- A's base type is a kind of B.
- Parameters:
another
- a content type- Returns:
true
if this content type is a kind of the given content type,false
otherwise
-
getSettings
IContentTypeSettings getSettings(IScopeContext context) throws CoreException
Returns the settings for this content type in the given preference context.- Parameters:
context
- a preference scope context- Returns:
- setting in the given context
- Throws:
CoreException
- if this method fails. Reasons include:- An error occurred obtaining the settings.
- Since:
- 3.1
-
-