java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress
org.newsclub.net.unix.AFSocketAddress
org.newsclub.net.unix.AFGenericSocketAddress
- All Implemented Interfaces:
Serializable
An
AFSocketAddress for unknown socket types.- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocketAddress
AFSocketAddress.AFSocketAddressConstructor<T extends AFSocketAddress> -
Method Summary
Modifier and TypeMethodDescriptionReturns the correspondingAFAddressFamily.getFile()Returns theFilecorresponding with this address, if possible.booleanChecks if the address can be resolved to aFile.static booleanChecks if anInetAddresscan be unwrapped to anAFGenericSocketAddress.static booleanChecks if aSocketAddresscan be unwrapped to anAFGenericSocketAddress.static AFGenericSocketAddressReturns anAFGenericSocketAddressfor the given URI, if possible.static AFGenericSocketAddressReturns anAFGenericSocketAddressfor the given URI, if possible.byte[]toBytes()Returns the native representation of this generic address, which is most likely not portable.toString()Tries to create a URI based on thisAFSocketAddress.static AFGenericSocketAddressReturns anAFGenericSocketAddressgiven a specialInetAddresshostname that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress().static AFGenericSocketAddressunwrap(InetAddress address, int port) Returns anAFGenericSocketAddressgiven a specialInetAddressthat encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress().static AFGenericSocketAddressunwrap(SocketAddress address) Returns anAFGenericSocketAddressgiven a genericSocketAddress.Methods inherited from class org.newsclub.net.unix.AFSocketAddress
canMap, canMap, covers, getAddressFamily, getBytes, getInetAddress, getInetAddress, getInetAddress, getSocketAddress, isSupportedAddress, isUseDeserializationForInit, mapOrFail, mapOrFail, newBoundServerSocket, newConnectedSocket, newDeserializedAFSocketAddress, newForceBoundServerSocket, parseUnsignedInt, resolveAddress, toSocatAddressString, unwrap, unwrap, wrapAddress, writeNativeAddressToMethods inherited from class java.net.InetSocketAddress
createUnresolved, equals, getAddress, getHostName, getHostString, getPort, hashCode, isUnresolved
-
Method Details
-
unwrap
Returns anAFGenericSocketAddressgiven a specialInetAddressthat encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress().- Parameters:
address- The "special"InetAddress.port- The port (use 0 for "none").- Returns:
- The
AFGenericSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFGenericSocketAddressgiven a specialInetAddresshostname that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress().- Parameters:
hostname- The "special" hostname, as provided byInetAddress.getHostName().port- The port (use 0 for "none").- Returns:
- The
AFGenericSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFGenericSocketAddressgiven a genericSocketAddress.- Parameters:
address- The address to unwrap.- Returns:
- The
AFGenericSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
toString
- Overrides:
toStringin classInetSocketAddress
-
toBytes
public byte[] toBytes()Returns the native representation of this generic address, which is most likely not portable.The address contains the sa_family identifier as the first byte, and, on some platforms only, the address length, as the second byte.
- Returns:
- A new byte array containing the system-specific representation of that address.
-
hasFilename
public boolean hasFilename()Description copied from class:AFSocketAddressChecks if the address can be resolved to aFile.- Specified by:
hasFilenamein classAFSocketAddress- Returns:
trueif the address has a filename.
-
getFile
Description copied from class:AFSocketAddressReturns theFilecorresponding with this address, if possible. AFileNotFoundExceptionis thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.- Specified by:
getFilein classAFSocketAddress- Returns:
- The filename.
- Throws:
FileNotFoundException- if the address is not associated with a filename.
-
isSupportedAddress
Checks if anInetAddresscan be unwrapped to anAFGenericSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
isSupportedAddress
Checks if aSocketAddresscan be unwrapped to anAFGenericSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily.- Returns:
- The address family instance.
-
of
Returns anAFGenericSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
of
Returns anAFGenericSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.overridePort- The port to forcibly use, or-1for "don't override".- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
toURI
Description copied from class:AFSocketAddressTries to create a URI based on thisAFSocketAddress.- Overrides:
toURIin classAFSocketAddress- Parameters:
scheme- The target scheme.template- An optional template to reuse certain parameters (e.g., the "path" component for anhttprequest), ornull.- Returns:
- The URI.
- Throws:
IOException- on error.
-