Top Description Fields Constructors Methods
io.netty.channel.unix

public Class FileDescriptor

extends Object
Class Inheritance
Known Direct Subclasses
io.netty.channel.unix.Socket
Imports
java.io.File, .IOException, java.nio.ByteBuffer, java.util.concurrent.atomic.AtomicIntegerFieldUpdater

Native FileDescriptor implementation which allows to wrap an int and provide a FileDescriptor for it.

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv volatile int
state

Bit map = [Output Shutdown | Input Shutdown | Closed]

private static final int
private static final int
private static final int
private static final int
private static final AtomicIntegerFieldUpdater<FileDescriptor>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
casState(int expected, int update)

public void
close()

Close the file descriptor.

private static native int
close(int fd)

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public static FileDescriptor
from(String path)

Open a new FileDescriptor for the given path.

public static FileDescriptor
from(File file)

Open a new FileDescriptor for the given File.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
pack-priv static int
inputShutdown(int state)

public final int
intValue()

Return the int value of the filedescriptor.

pack-priv static boolean
isClosed(int state)

pack-priv static boolean
isInputShutdown(int state)

public boolean
isOpen()

Returns true if the file descriptor is open.

pack-priv static boolean
isOutputShutdown(int state)

protected boolean
private static native long
private static native int
open(String path)

pack-priv static int
outputShutdown(int state)

public static FileDescriptor[]

Returns:

[0] = read end, [1] = write end
pipe
()

public final int
read(ByteBuffer buf, int pos, int limit)

private static native int
read(int fd, ByteBuffer buf, int pos, int limit)

public final int
readAddress(long address, int pos, int limit)

private static native int
readAddress(int fd, long address, int pos, int limit)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final int
write(ByteBuffer buf, int pos, int limit)

private static native int
write(int fd, ByteBuffer buf, int pos, int limit)

public final int
writeAddress(long address, int pos, int limit)

private static native int
writeAddress(int fd, long address, int pos, int limit)

public final long
writev(ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)

private static native long
writev(int fd, ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)

public final long
writevAddresses(long memoryAddress, int length)

private static native long
writevAddresses(int fd, long memoryAddress, int length)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

fdback to summary
pack-priv final int fd
stateback to summary
pack-priv volatile int state

Bit map = [Output Shutdown | Input Shutdown | Closed]

STATE_ALL_MASKback to summary
private static final int STATE_ALL_MASK
STATE_CLOSED_MASKback to summary
private static final int STATE_CLOSED_MASK
STATE_INPUT_SHUTDOWN_MASKback to summary
private static final int STATE_INPUT_SHUTDOWN_MASK
STATE_OUTPUT_SHUTDOWN_MASKback to summary
private static final int STATE_OUTPUT_SHUTDOWN_MASK
stateUpdaterback to summary
private static final AtomicIntegerFieldUpdater<FileDescriptor> stateUpdater

Constructor Detail

FileDescriptorback to summary
public FileDescriptor(int fd)

Method Detail

casStateback to summary
pack-priv final boolean casState(int expected, int update)
closeback to summary
public void close() throws IOException

Close the file descriptor.

closeback to summary
private static native int close(int fd)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fromback to summary
public static FileDescriptor from(String path) throws IOException

Open a new FileDescriptor for the given path.

fromback to summary
public static FileDescriptor from(File file) throws IOException

Open a new FileDescriptor for the given File.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
inputShutdownback to summary
pack-priv static int inputShutdown(int state)
intValueback to summary
public final int intValue()

Return the int value of the filedescriptor.

isClosedback to summary
pack-priv static boolean isClosed(int state)
isInputShutdownback to summary
pack-priv static boolean isInputShutdown(int state)
isOpenback to summary
public boolean isOpen()

Returns true if the file descriptor is open.

isOutputShutdownback to summary
pack-priv static boolean isOutputShutdown(int state)
markClosedback to summary
protected boolean markClosed()
newPipeback to summary
private static native long newPipe()
openback to summary
private static native int open(String path)
outputShutdownback to summary
pack-priv static int outputShutdown(int state)
pipeback to summary
public static FileDescriptor[] pipe() throws IOException
Returns:FileDescriptor[]

[0] = read end, [1] = write end

readback to summary
public final int read(ByteBuffer buf, int pos, int limit) throws IOException
readback to summary
private static native int read(int fd, ByteBuffer buf, int pos, int limit)
readAddressback to summary
public final int readAddress(long address, int pos, int limit) throws IOException
readAddressback to summary
private static native int readAddress(int fd, long address, int pos, int limit)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
public final int write(ByteBuffer buf, int pos, int limit) throws IOException
writeback to summary
private static native int write(int fd, ByteBuffer buf, int pos, int limit)
writeAddressback to summary
public final int writeAddress(long address, int pos, int limit) throws IOException
writeAddressback to summary
private static native int writeAddress(int fd, long address, int pos, int limit)
writevback to summary
public final long writev(ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite) throws IOException
writevback to summary
private static native long writev(int fd, ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)
writevAddressesback to summary
public final long writevAddresses(long memoryAddress, int length) throws IOException
writevAddressesback to summary
private static native long writevAddresses(int fd, long memoryAddress, int length)