All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.core.runtime.content.IContentType Maven / Gradle / Ivy

Go to download

AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based @AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step. This library is a superset of AspectJ weaver and hence also of AspectJ runtime.

There is a newer version: 1.9.22.1
Show newest version
/*******************************************************************************
 * Copyright (c) 2004, 2009 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.runtime.content;

import java.io.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.IScopeContext;

/**
 * Content types represent and provide information on file types, such as
 * associated file names/extensions, default charset, etc.
 *
 * @noimplement This interface is not intended to be implemented by clients.
 * @since 3.0
 */
public interface IContentType extends IContentTypeSettings {
	/**
	 * File spec type flag constant, indicating that predefined file
	 * specifications should not be taken into account.
	 */
	int IGNORE_PRE_DEFINED = 0b1;
	/**
	 * File spec type flag constant, indicating that user-defined file
	 * specifications should not be taken into account.
	 */
	int IGNORE_USER_DEFINED = 0b10;
	/**
	 * File spec type constant, indicating a file name specification.
	 */
	int FILE_NAME_SPEC = 0b100;
	/**
	 * File spec type constant, indicating a file extension specification.
	 */
	int FILE_EXTENSION_SPEC = 0b1000;
	/**
	 * File spec type constant, indicating a file name pattern specification.
	 * ? represents any single character, * represent any
	 * string.
	 *
	 * @since 3.7
	 */
	int FILE_PATTERN_SPEC = 0b10000;

	/**
	 * 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), returns null.
	 *
	 * @return this content type's base type, or null
	 */
	IContentType getBaseType();

	/**
	 * 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. *

* * @return a content description * @since 3.1 */ IContentDescription getDefaultDescription(); /** * 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. *

* * @param contents the contents to be interpreted * @param options an array of keys for all properties that should be described * @return a content description if one could be obtained, or * null * @throws IOException if an error occurs while reading the contents * @see IContentDescription */ 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 reader * will flow to the caller. The reader will not be closed by this * operation. *

* * @param contents the contents to be interpreted * @param options an array of keys for all properties that should be described * @return a content description if one could be obtained, or * null * @throws UnsupportedOperationException if this content type * has a describer that does not implement * ITextContentDescriber * @throws IOException if an error occurs while reading the contents * @see IContentDescription */ IContentDescription getDescriptionFor(Reader contents, QualifiedName[] options) throws IOException; /** * Returns the default charset for this content type if one has been defined, * null otherwise. * This refinement of the corresponding IContentTypeSettings * method also takes into account the charset defined by the content type * provider (or its base content type). * * @return the default charset, or null */ @Override String getDefaultCharset(); /** * 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 corresponding IContentTypeSettings * method supports additional flags because it also takes into account the * file specifications defined by the content type provider (or its base * content type). * * @param type a bit-wise or of file specification type constants. Valid * flags are: *
    *
  • one of FILE_EXTENSION_SPEC or *FILE_NAME_SPEC
  • *
  • and optionally, one of IGNORE_PRE_DEFINED *or IGNORE_USER_DEFINED
  • *
* @return the file specification * @see #FILE_NAME_SPEC * @see #FILE_EXTENSION_SPEC * @see #IGNORE_PRE_DEFINED * @see #IGNORE_USER_DEFINED */ @Override String[] getFileSpecs(int type); /** * Returns this content type's unique identifier. Each content type has an * identifier by which they can be retrieved from the content type catalog. * * @return this content type's unique identifier */ @Override String getId(); /** * Returns a user-friendly name for this content type. * * @return this content type's name */ String getName(); /** * Returns whether this content type is associated with the * given file name. * * @param fileName the file name * @return true if this content type is associated with * the given file name, false otherwise * @see #isAssociatedWith(String, IScopeContext) */ boolean isAssociatedWith(String fileName); /** * Returns whether this content type is associated with the * given file name in the given preference scope. * * @param fileName the file name * @param context a preference scope context * @return true if this content type is associated with * the given file name, false otherwise * @since 3.1 */ boolean isAssociatedWith(String fileName, IScopeContext context); /** * 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: *
    *
  1. A and B are the same content type, or
  2. *
  3. A's base type is B, or
  4. *
  5. A's base type is a kind of B.
  6. *
* * @param another a content type * @return true if this content type is a kind of the * given content type, false otherwise */ boolean isKindOf(IContentType another); /** * Returns the settings for this content type in the given * preference context. * * @param context a preference scope context * @return setting in the given context * @throws CoreException if this method fails. Reasons include: *
    *
  • An error occurred obtaining the settings.
  • *
* @since 3.1 */ IContentTypeSettings getSettings(IScopeContext context) throws CoreException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy