AutoDetector.java revision 41cdf40d933f4029c37cf844f8cf3314114e4e0a
1// This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2// 3// TagSoup is licensed under the Apache License, 4// Version 2.0. You may obtain a copy of this license at 5// http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6// additional legal rights not granted by this license. 7// 8// TagSoup is distributed in the hope that it will be useful, but 9// unless required by applicable law or agreed to in writing, TagSoup 10// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11// OF ANY KIND, either express or implied; not even the implied warranty 12// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13// 14// 15// Interface to objects that translate InputStreams to Readers by auto-detection 16 17package org.ccil.cowan.tagsoup; 18import java.io.Reader; 19import java.io.InputStream; 20 21/** 22Classes which accept an InputStream and provide a Reader which figures 23out the encoding of the InputStream and reads characters from it should 24conform to this interface. 25@see java.io.InputStream 26@see java.io.Reader 27*/ 28 29public interface AutoDetector { 30 31 /** 32 Given an InputStream, return a suitable Reader that understands 33 the presumed character encoding of that InputStream. 34 If bytes are consumed from the InputStream in the process, they 35 <i>must</i> be pushed back onto the InputStream so that they can be 36 reinterpreted as characters. 37 @param i The InputStream 38 @return A Reader that reads from the InputStream 39 */ 40 41 public Reader autoDetectingReader(InputStream i); 42 43 } 44