1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 package org.modeshape.graph.mimetype; 25 26 import java.io.IOException; 27 import java.io.InputStream; 28 import net.jcip.annotations.ThreadSafe; 29 30 /** 31 * MIME-type detection libraries must provide thread-safe implementations of this interface to enable ModeShape to use the libraries to 32 * return MIME-types for data sources. 33 */ 34 @ThreadSafe 35 public interface MimeTypeDetector { 36 37 /** 38 * Returns the MIME-type of a data source, using its supplied content and/or its supplied name, depending upon the 39 * implementation. If the MIME-type cannot be determined, either a "default" MIME-type or <code>null</code> may be returned, 40 * where the former will prevent earlier registered MIME-type detectors from being consulted. 41 * <p> 42 * Note that detector implementations should <i>not</i> {@link InputStream#close() close} the supplied input stream. 43 * </p> 44 * 45 * @param name The name of the data source; may be <code>null</code>. 46 * @param content The content of the data source; may be <code>null</code>. 47 * @return The MIME-type of the data source, or optionally <code>null</code> if the MIME-type could not be determined. 48 * @throws IOException If an error occurs reading the supplied content. 49 */ 50 String mimeTypeOf( String name, 51 InputStream content ) throws IOException; 52 }