1 /******************************************************************************* 2 * Copyright (c) 2004, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.core.runtime.content; 12 13 import java.io.IOException; 14 import java.io.Reader; 15 16 /** 17 * Text content describers extend basic content describers to provide 18 * the ability of scanning character streams (readers). Describers for 19 * text-based content types must implement this interface 20 * instead of <code>IContentDescription</code>. 21 * <p> 22 * Note: It is expected that content describer implementations be declared in a package 23 * that is exempt from plug-in activation (using the Eclipse-AutoStart bundle 24 * manifest header). Since all describers are instantiated when the content type 25 * framework is initialized, failure in complying with this requirement causes 26 * premature activation, which must be avoided. Future implementations of the 27 * framework might refuse to instantiate describers if doing so would trigger 28 * activation of the corresponding plug-in. 29 * </p> 30 * <p> 31 * Clients may implement this interface. 32 * </p> 33 * 34 * @see IContentDescription 35 * @since 3.0 36 */ 37 public interface ITextContentDescriber extends IContentDescriber { 38 /** 39 * Tries to fill a description for the given contents. Returns 40 * an <code>int</code> indicating whether the given stream of 41 * characters represents a valid sample for this describer's corresponding 42 * content type. If no content description is provided, this method should 43 * only perform content type validation. 44 * <p> 45 * The stream provided must be kept open, and any IOExceptions while 46 * reading it should flow to the caller. 47 * </p> 48 * 49 * @param contents the contents to be examined 50 * @param description a description to be filled in, or <code>null</code> if 51 * only content type validation is to be performed 52 * @return one of the following:<ul> 53 * <li><code>VALID</code></li> 54 * <li><code>INVALID</code></li> 55 * <li><code>INDETERMINATE</code></li> 56 * </ul> 57 * @throws IOException if an I/O error occurs 58 * @see IContentDescription 59 * @see #VALID 60 * @see #INVALID 61 * @see #INDETERMINATE 62 */ 63 public int describe(Reader contents, IContentDescription description) throws IOException; 64 } 65