01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.util;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20: import java.io.Reader;
21:
22: import org.apache.commons.io.IOUtils;
23:
24: /**
25: * @author ryan
26: * @version $Id$
27: * @since solr 1.2
28: */
29: public interface ContentStream {
30: String getName();
31:
32: String getSourceInfo();
33:
34: String getContentType();
35:
36: /**
37: * @return the stream size or <code>null</code> if not known
38: */
39: Long getSize(); // size if we know it, otherwise null
40:
41: /**
42: * Get an open stream. You are responsible for closing it. Consider using
43: * something like:
44: * <pre>
45: * InputStream stream = stream.getStream();
46: * try {
47: * // use the stream...
48: * }
49: * finally {
50: * IOUtils.closeQuietly(reader);
51: * }
52: * </pre>
53: *
54: * Only the first call to <code>getStream()</code> or <code>getReader()</code>
55: * is gaurenteed to work. The runtime behavior for aditional calls is undefined.
56: */
57: InputStream getStream() throws IOException;
58:
59: /**
60: * Get an open stream. You are responsible for closing it. Consider using
61: * something like:
62: * <pre>
63: * Reader reader = stream.getReader();
64: * try {
65: * // use the reader...
66: * }
67: * finally {
68: * IOUtils.closeQuietly(reader);
69: * }
70: * </pre>
71: *
72: * Only the first call to <code>getStream()</code> or <code>getReader()</code>
73: * is gaurenteed to work. The runtime behavior for aditional calls is undefined.
74: */
75: Reader getReader() throws IOException;
76: }
|