View Javadoc
1   /*
2    * Copyright (C) 2012, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.internal.storage.file;
12  
13  import java.io.DataOutput;
14  import java.io.IOException;
15  import java.io.OutputStream;
16  
17  import org.eclipse.jgit.util.NB;
18  
19  /**
20   * An implementation of {@link DataOutput} that only handles
21   * {@link #writeInt(int)} and {@link #writeLong(long)} using the Git conversion
22   * utilities for network byte order handling. This is needed to write
23   * {@link com.googlecode.javaewah.EWAHCompressedBitmap}s.
24   */
25  class SimpleDataOutput implements DataOutput {
26  	private final OutputStream fd;
27  
28  	private final byte[] buf = new byte[8];
29  
30  	SimpleDataOutput(OutputStream fd) {
31  		this.fd = fd;
32  	}
33  
34  	/** {@inheritDoc} */
35  	@Override
36  	public void writeShort(int v) throws IOException {
37  		NB.encodeInt16(buf, 0, v);
38  		fd.write(buf, 0, 2);
39  	}
40  
41  	/** {@inheritDoc} */
42  	@Override
43  	public void writeInt(int v) throws IOException {
44  		NB.encodeInt32(buf, 0, v);
45  		fd.write(buf, 0, 4);
46  	}
47  
48  	/** {@inheritDoc} */
49  	@Override
50  	public void writeLong(long v) throws IOException {
51  		NB.encodeInt64(buf, 0, v);
52  		fd.write(buf, 0, 8);
53  	}
54  
55  	/** {@inheritDoc} */
56  	@Override
57  	public void write(int b) throws IOException {
58  		throw new UnsupportedOperationException();
59  	}
60  
61  	/** {@inheritDoc} */
62  	@Override
63  	public void write(byte[] b) throws IOException {
64  		throw new UnsupportedOperationException();
65  	}
66  
67  	/** {@inheritDoc} */
68  	@Override
69  	public void write(byte[] b, int off, int len) throws IOException {
70  		throw new UnsupportedOperationException();
71  	}
72  
73  	/** {@inheritDoc} */
74  	@Override
75  	public void writeBoolean(boolean v) throws IOException {
76  		throw new UnsupportedOperationException();
77  	}
78  
79  	/** {@inheritDoc} */
80  	@Override
81  	public void writeByte(int v) throws IOException {
82  		throw new UnsupportedOperationException();
83  	}
84  
85  	/** {@inheritDoc} */
86  	@Override
87  	public void writeChar(int v) throws IOException {
88  		throw new UnsupportedOperationException();
89  	}
90  
91  	/** {@inheritDoc} */
92  	@Override
93  	public void writeFloat(float v) throws IOException {
94  		throw new UnsupportedOperationException();
95  	}
96  
97  	/** {@inheritDoc} */
98  	@Override
99  	public void writeDouble(double v) throws IOException {
100 		throw new UnsupportedOperationException();
101 	}
102 
103 	/** {@inheritDoc} */
104 	@Override
105 	public void writeBytes(String s) throws IOException {
106 		throw new UnsupportedOperationException();
107 	}
108 
109 	/** {@inheritDoc} */
110 	@Override
111 	public void writeChars(String s) throws IOException {
112 		throw new UnsupportedOperationException();
113 	}
114 
115 	/** {@inheritDoc} */
116 	@Override
117 	public void writeUTF(String s) throws IOException {
118 		throw new UnsupportedOperationException();
119 	}
120 }