add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / facet / src / java / org / apache / lucene / util / encoding / IntEncoderFilter.java
1 package org.apache.lucene.util.encoding;
2
3 import java.io.IOException;
4 import java.io.OutputStream;
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  * An abstract implementation of {@link IntEncoder} which is served as a filter
25  * on the values to encode. An encoder filter wraps another {@link IntEncoder}
26  * which does the actual encoding. This allows for chaining filters and
27  * encoders, such as: <code><pre>
28  * new UniqueValuesIntEncoder(new DGapIntEncoder(new VInt8IntEnoder()));
29  * {@link UniqueValuesIntEncoder} followed by {@link DGapIntEncoder}
30   </pre></code>
31  * <p>
32  * The default implementation implements {@link #close()} by closing the wrapped
33  * encoder and {@link #reInit(OutputStream)} by re-initializing the wrapped
34  * encoder.
35  * 
36  * @lucene.experimental
37  */
38 public abstract class IntEncoderFilter extends IntEncoder {
39
40   protected final IntEncoder encoder;
41
42   protected IntEncoderFilter(IntEncoder encoder) {
43     this.encoder = encoder;
44   }
45
46   @Override
47   public void close() throws IOException {
48     // There is no need to call super.close(), since we don't pass the output
49     // stream to super.
50     encoder.close();
51   }
52
53   @Override
54   public void reInit(OutputStream out) {
55     encoder.reInit(out);
56   }
57
58 }