You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SimpleDataOutput.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. package org.eclipse.jgit.internal.storage.file;
  11. import java.io.DataOutput;
  12. import java.io.IOException;
  13. import java.io.OutputStream;
  14. import org.eclipse.jgit.util.NB;
  15. /**
  16. * An implementation of {@link DataOutput} that only handles
  17. * {@link #writeInt(int)} and {@link #writeLong(long)} using the Git conversion
  18. * utilities for network byte order handling. This is needed to write
  19. * {@link com.googlecode.javaewah.EWAHCompressedBitmap}s.
  20. */
  21. class SimpleDataOutput implements DataOutput {
  22. private final OutputStream fd;
  23. private final byte[] buf = new byte[8];
  24. SimpleDataOutput(OutputStream fd) {
  25. this.fd = fd;
  26. }
  27. /** {@inheritDoc} */
  28. @Override
  29. public void writeShort(int v) throws IOException {
  30. NB.encodeInt16(buf, 0, v);
  31. fd.write(buf, 0, 2);
  32. }
  33. /** {@inheritDoc} */
  34. @Override
  35. public void writeInt(int v) throws IOException {
  36. NB.encodeInt32(buf, 0, v);
  37. fd.write(buf, 0, 4);
  38. }
  39. /** {@inheritDoc} */
  40. @Override
  41. public void writeLong(long v) throws IOException {
  42. NB.encodeInt64(buf, 0, v);
  43. fd.write(buf, 0, 8);
  44. }
  45. /** {@inheritDoc} */
  46. @Override
  47. public void write(int b) throws IOException {
  48. throw new UnsupportedOperationException();
  49. }
  50. /** {@inheritDoc} */
  51. @Override
  52. public void write(byte[] b) throws IOException {
  53. throw new UnsupportedOperationException();
  54. }
  55. /** {@inheritDoc} */
  56. @Override
  57. public void write(byte[] b, int off, int len) throws IOException {
  58. throw new UnsupportedOperationException();
  59. }
  60. /** {@inheritDoc} */
  61. @Override
  62. public void writeBoolean(boolean v) throws IOException {
  63. throw new UnsupportedOperationException();
  64. }
  65. /** {@inheritDoc} */
  66. @Override
  67. public void writeByte(int v) throws IOException {
  68. throw new UnsupportedOperationException();
  69. }
  70. /** {@inheritDoc} */
  71. @Override
  72. public void writeChar(int v) throws IOException {
  73. throw new UnsupportedOperationException();
  74. }
  75. /** {@inheritDoc} */
  76. @Override
  77. public void writeFloat(float v) throws IOException {
  78. throw new UnsupportedOperationException();
  79. }
  80. /** {@inheritDoc} */
  81. @Override
  82. public void writeDouble(double v) throws IOException {
  83. throw new UnsupportedOperationException();
  84. }
  85. /** {@inheritDoc} */
  86. @Override
  87. public void writeBytes(String s) throws IOException {
  88. throw new UnsupportedOperationException();
  89. }
  90. /** {@inheritDoc} */
  91. @Override
  92. public void writeChars(String s) throws IOException {
  93. throw new UnsupportedOperationException();
  94. }
  95. /** {@inheritDoc} */
  96. @Override
  97. public void writeUTF(String s) throws IOException {
  98. throw new UnsupportedOperationException();
  99. }
  100. }