|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.jgit.util.NB
public final class NB
Conversion utilities for network byte order handling.
| Method Summary | |
|---|---|
static int |
compareUInt32(int a,
int b)
Compare a 32 bit unsigned integer stored in a 32 bit signed integer. |
static int |
decodeInt32(byte[] intbuf,
int offset)
Convert sequence of 4 bytes (network byte order) into signed value. |
static int |
decodeUInt16(byte[] intbuf,
int offset)
Convert sequence of 2 bytes (network byte order) into unsigned value. |
static long |
decodeUInt32(byte[] intbuf,
int offset)
Convert sequence of 4 bytes (network byte order) into unsigned value. |
static long |
decodeUInt64(byte[] intbuf,
int offset)
Convert sequence of 8 bytes (network byte order) into unsigned value. |
static void |
encodeInt16(byte[] intbuf,
int offset,
int v)
Write a 16 bit integer as a sequence of 2 bytes (network byte order). |
static void |
encodeInt32(byte[] intbuf,
int offset,
int v)
Write a 32 bit integer as a sequence of 4 bytes (network byte order). |
static void |
encodeInt64(byte[] intbuf,
int offset,
long v)
Write a 64 bit integer as a sequence of 8 bytes (network byte order). |
static byte[] |
readFully(java.io.File path)
Read an entire local file into memory as a byte array. |
static void |
readFully(java.nio.channels.FileChannel fd,
long pos,
byte[] dst,
int off,
int len)
Read the entire byte array into memory, or throw an exception. |
static byte[] |
readFully(java.io.File path,
int max)
Read an entire local file into memory as a byte array. |
static void |
readFully(java.io.InputStream fd,
byte[] dst,
int off,
int len)
Read the entire byte array into memory, or throw an exception. |
static void |
skipFully(java.io.InputStream fd,
long toSkip)
Skip an entire region of an input stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final byte[] readFully(java.io.File path)
throws java.io.FileNotFoundException,
java.io.IOException
path - location of the file to read.
java.io.FileNotFoundException - the file does not exist.
java.io.IOException - the file exists, but its contents cannot be read.
public static final byte[] readFully(java.io.File path,
int max)
throws java.io.FileNotFoundException,
java.io.IOException
path - location of the file to read.max - maximum number of bytes to read, if the file is larger than
this limit an IOException is thrown.
java.io.FileNotFoundException - the file does not exist.
java.io.IOException - the file exists, but its contents cannot be read.
public static void readFully(java.io.InputStream fd,
byte[] dst,
int off,
int len)
throws java.io.IOException
fd - input stream to read the data from.dst - buffer that must be fully populated, [off, off+len).off - position within the buffer to start writing to.len - number of bytes that must be read.
java.io.EOFException - the stream ended before dst was fully populated.
java.io.IOException - there was an error reading from the stream.
public static void readFully(java.nio.channels.FileChannel fd,
long pos,
byte[] dst,
int off,
int len)
throws java.io.IOException
fd - file to read the data from.pos - position to read from the file at.dst - buffer that must be fully populated, [off, off+len).off - position within the buffer to start writing to.len - number of bytes that must be read.
java.io.EOFException - the stream ended before dst was fully populated.
java.io.IOException - there was an error reading from the stream.
public static void skipFully(java.io.InputStream fd,
long toSkip)
throws java.io.IOException
The input stream's position is moved forward by the number of requested bytes, discarding them from the input. This method does not return until the exact number of bytes requested has been skipped.
fd - the stream to skip bytes from.toSkip - total number of bytes to be discarded. Must be >= 0.
java.io.EOFException - the stream ended before the requested number of bytes were
skipped.
java.io.IOException - there was an error reading from the stream.
public static int compareUInt32(int a,
int b)
This function performs an unsigned compare operation, even though Java does not natively support unsigned integer values. Negative numbers are treated as larger than positive ones.
a - the first value to compare.b - the second value to compare.
public static int decodeUInt16(byte[] intbuf,
int offset)
intbuf - buffer to acquire the 2 bytes of data from.offset - position within the buffer to begin reading from. This
position and the next byte after it (for a total of 2 bytes)
will be read.
public static int decodeInt32(byte[] intbuf,
int offset)
intbuf - buffer to acquire the 4 bytes of data from.offset - position within the buffer to begin reading from. This
position and the next 3 bytes after it (for a total of 4
bytes) will be read.
public static long decodeUInt32(byte[] intbuf,
int offset)
intbuf - buffer to acquire the 4 bytes of data from.offset - position within the buffer to begin reading from. This
position and the next 3 bytes after it (for a total of 4
bytes) will be read.
public static long decodeUInt64(byte[] intbuf,
int offset)
intbuf - buffer to acquire the 8 bytes of data from.offset - position within the buffer to begin reading from. This
position and the next 7 bytes after it (for a total of 8
bytes) will be read.
public static void encodeInt16(byte[] intbuf,
int offset,
int v)
intbuf - buffer to write the 2 bytes of data into.offset - position within the buffer to begin writing to. This position
and the next byte after it (for a total of 2 bytes) will be
replaced.v - the value to write.
public static void encodeInt32(byte[] intbuf,
int offset,
int v)
intbuf - buffer to write the 4 bytes of data into.offset - position within the buffer to begin writing to. This position
and the next 3 bytes after it (for a total of 4 bytes) will be
replaced.v - the value to write.
public static void encodeInt64(byte[] intbuf,
int offset,
long v)
intbuf - buffer to write the 48bytes of data into.offset - position within the buffer to begin writing to. This position
and the next 7 bytes after it (for a total of 8 bytes) will be
replaced.v - the value to write.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||