pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / java / org / apache / lucene / util / encoding / IntDecoder.java
1 package org.apache.lucene.util.encoding;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5
6 /**
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements.  See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License.  You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22
23 /**
24  * Decodes integers from a set {@link InputStream}. For re-usability, the
25  * decoder's input stream can be set by ({@link #reInit(InputStream)}).
26  * By design, Decoders are NOT thread-safe.
27  * 
28  * @lucene.experimental
29  */
30 public abstract class IntDecoder {
31   
32   /** A special long value which is used to indicate end-of-stream has reached. */
33   public static final long EOS = 0x100000000L;
34
35   /** Input stream from which the encoded bytes are read */
36   protected InputStream in;
37
38   /** Sets the input stream from which the encoded data is read. */
39   public void reInit(InputStream in) {
40     this.in = in;
41   }
42   
43   /**
44    * Decodes data received from the input stream, and returns one decoded
45    * integer. If end of stream is reached, {@link #EOS} is returned.
46    * 
47    * @return one decoded integer as long or {@link #EOS} if end-of-stream
48    *         reached.
49    * @throws IOException if an I/O error occurs
50    */
51   public abstract long decode() throws IOException;
52
53 }