1 package org.apache.lucene.util.encoding;
3 import java.io.IOException;
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * A simple {@link IntEncoder}, writing an integer as 4 raw bytes. *
25 * @lucene.experimental
27 public class SimpleIntEncoder extends IntEncoder {
30 * This method makes sure the value wasn't previously encoded by checking
31 * against the Set. If the value wasn't encoded, it's added to the Set, and
32 * encoded with {#link Vint8#encode}
35 * an integer to be encoded
37 * possibly thrown by the OutputStream
40 public void encode(int value) throws IOException {
41 out.write(value >>> 24);
42 out.write((value >> 16) & 0xFF);
43 out.write((value >> 8) & 0xFF);
44 out.write(value & 0xFF);
48 public IntDecoder createMatchingDecoder() {
49 return new SimpleIntDecoder();
53 public String toString() {