1 package org.apache.lucene.util.encoding;
3 import java.io.IOException;
4 import java.io.InputStream;
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
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.
28 * @lucene.experimental
30 public abstract class IntDecoder {
32 /** A special long value which is used to indicate end-of-stream has reached. */
33 public static final long EOS = 0x100000000L;
35 /** Input stream from which the encoded bytes are read */
36 protected InputStream in;
38 /** Sets the input stream from which the encoded data is read. */
39 public void reInit(InputStream in) {
44 * Decodes data received from the input stream, and returns one decoded
45 * integer. If end of stream is reached, {@link #EOS} is returned.
47 * @return one decoded integer as long or {@link #EOS} if end-of-stream
49 * @throws IOException if an I/O error occurs
51 public abstract long decode() throws IOException;