Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.core.runtime.content
Interface IContentTypeManager

public interface IContentTypeManager

The content type manager provides facilities file name and content-based type lookup, and content description.

This interface is not intended to be implemented by clients.

Since:
  3.0
See Also:
  `Platform.getContentTypeManager()`

Nested Class Summary
`static class` | `IContentTypeManager.ContentTypeChangeEvent` An event object which describes the details of a change to a content type.
`static interface` | `IContentTypeManager.IContentTypeChangeListener` A listener to be used to receive content type change events.

Field Summary
`static String` | `CT_TEXT` Content type identifier constant for platform's primary text-based content type: `org.eclipse.core.runtime.text`.

Method Summary
`void` | `addContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener listener)` Register the given listener for notification of content type changes.
`IContentType` | `findContentTypeFor(InputStream contents, String fileName)` Returns the preferred content type for the given contents and file name.
`IContentType` | `findContentTypeFor(String fileName)` Returns the preferred content type for the given file name.
`IContentType[]` | `findContentTypesFor(InputStream contents, String fileName)` Returns the content types associated to the given contents and file name.
`IContentType[]` | `findContentTypesFor(String fileName)` Returns all content types known by the platform that are associated to the given file name.
`IContentType[]` | `getAllContentTypes()` Returns all content types known by the platform.
`IContentType` | `getContentType(String contentTypeIdentifier)` Returns the content type with the given identifier, or `null` if no such content type is known by the platform.
`IContentDescription` | `getDescriptionFor(InputStream contents, String fileName, QualifiedName[] options)` Tries to obtain a description for the given contents and file name.
`IContentDescription` | `getDescriptionFor(Reader contents, String fileName, QualifiedName[] options)` Tries to obtain a description for the given contents and file name.
`void` | `removeContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener listener)` De-register the given listener from receiving notification of content type changes.

Field Detail

### CT_TEXT

    public static final String CT_TEXT

  Content type identifier constant for platform's primary text-based content type: `org.eclipse.core.runtime.text`.

  All text-based content types ought to be sub types of the content type identified by this string. This provides a simple way for detecting whether a content type is text-based:

       IContentType text = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
       IContentType someType = ...;
       boolean isTextBased = someType.isKindOf(text);

  See Also:
    Constant Field Values

Method Detail

### addContentTypeChangeListener

    public void addContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener listener)

  Register the given listener for notification of content type changes. Calling this method multiple times with the same listener has no effect. The given listener argument must not be `null`.

  Parameters:
    `listener` - the content type change listener to register
  See Also:
    `removeContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener)`, `IContentTypeManager.IContentTypeChangeListener`

### findContentTypeFor

    public IContentType findContentTypeFor(InputStream contents,
                                           String fileName)
                                    throws IOException

  Returns the preferred content type for the given contents and file name.

  Returns `null` if no associated content types are found.

  If a file name is not provided, the entire content type registry will be queried. For performance reasons, it is highly recomended to provide a file name if available.

  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` - an input stream
    `fileName` - the file name associated to the contents, or `null`
  Returns:
    the preferred content type associated to the given file name, or `null`
  Throws:
    `IOException` - if an error occurs while reading the contents

### findContentTypeFor

    public IContentType findContentTypeFor(String fileName)

  Returns the preferred content type for the given file name. If multiple content types are associated with the given file name, the one considered the most appropriated will be returned. If there are no content types associated, `null` is returned.

  Parameters:
    `fileName` - the name of the file
  Returns:
    the preferred content type associated to the given file name, or `null`

### findContentTypesFor

    public IContentType[] findContentTypesFor(InputStream contents,
                                              String fileName)
                                       throws IOException

  Returns the content types associated to the given contents and file name.

  Returns an empty array if no associated content types are found.

  If a file name is not provided, the entire content type registry will be queried. For performance reasons, it is highly recomended to provide a file name if available.

  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` - an input stream
    `fileName` - the file name associated to the contents, or `null`
  Returns:
    all content types associated to the given contents and file name
  Throws:
    `IOException` - if an error occurs while reading the contents

### findContentTypesFor

    public IContentType[] findContentTypesFor(String fileName)

  Returns all content types known by the platform that are associated to the given file name.

  Returns an empty array if there are no content types associated.

  Parameters:
    `fileName` - the name of the file
  Returns:
    all content types associated to the given file spec

### getAllContentTypes

    public IContentType[] getAllContentTypes()

  Returns all content types known by the platform.

  Returns an empty array if there are no content types available.

  Returns:
    all content types known by the platform.

### getContentType

    public IContentType getContentType(String contentTypeIdentifier)

  Returns the content type with the given identifier, or `null` if no such content type is known by the platform.

  Parameters:
    `contentTypeIdentifier` - the identifier for the content type
  Returns:
    the content type, or `null`

### getDescriptionFor

    public IContentDescription getDescriptionFor(InputStream contents,
                                                 String fileName,
                                                 QualifiedName[] options)
                                          throws IOException

  Tries to obtain a description for the given contents and file name.

  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.

  If a file name is not provided, the entire content type registry will be queried. For performance reasons, it is highly recomended to provide a file name if available.

  Parameters:
    `contents` - the contents to be interpreted
    `fileName` - the file name associated to the contents, or `null`
    `options` - an array of keys for all properties that should be described, or `IContentDescription.ALL`, for all of them
  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

    public IContentDescription getDescriptionFor(Reader contents,
                                                 String fileName,
                                                 QualifiedName[] options)
                                          throws IOException

  Tries to obtain a description for the given contents and file name.

  Any IOExceptions that may occur while reading the given input stream will flow to the caller. The reader will not be closed by this operation.

  If a file name is not provided, the entire content type registry will be queried. For performance reasons, it is highly recomended to provide a file name if available.

  Parameters:
    `contents` - the contents to be interpreted
    `fileName` - the file name associated to the contents, or `null`
    `options` - an array of keys for all properties that should be described, or `IContentDescription.ALL`, for all of them
  Returns:
    a content description if one could be obtained, or `null`
  Throws:
    `IOException` - if an error occurs while reading the contents
  See Also:
    `IContentDescription`

### removeContentTypeChangeListener

    public void removeContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener listener)

  De-register the given listener from receiving notification of content type changes. Calling this method multiple times with the same listener has no effect. The given listener argument must not be `null`.

  Parameters:
    `listener` - the content type change listener to remove
  See Also:
    `addContentTypeChangeListener(IContentTypeManager.IContentTypeChangeListener)`, `IContentTypeManager.IContentTypeChangeListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.