private static int expectInteger(Object value) throws SocketException { try { return (Integer) value; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
public AFUNIXSocketException(String reason, final Throwable cause) { this(reason, (String) null); initCause(cause); }
private static int expectBoolean(Object value) throws SocketException { try { return ((Boolean) value).booleanValue() ? 1 : 0; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
@Override public Object getOption(int optID) throws SocketException { try { switch (optID) { case SocketOptions.SO_KEEPALIVE: case SocketOptions.TCP_NODELAY: return NativeUnixSocket.getSocketOptionInt(fd, optID) != 0 ? true : false; case SocketOptions.SO_LINGER: case SocketOptions.SO_TIMEOUT: case SocketOptions.SO_RCVBUF: case SocketOptions.SO_SNDBUF: return NativeUnixSocket.getSocketOptionInt(fd, optID); default: throw new AFUNIXSocketException("Unsupported option: " + optID); } } catch (final AFUNIXSocketException e) { throw e; } catch (final Exception e) { throw new AFUNIXSocketException("Error while getting option", e); } }
@Override public void write(byte[] buf, int off, int len) throws IOException { if (streamClosed) { throw new AFUNIXSocketException("This OutputStream has already been closed."); } if (len > buf.length - off) { throw new IndexOutOfBoundsException(); } try { while (len > 0 && !Thread.interrupted()) { final int written = NativeUnixSocket.write(fd, buf, off, len); if (written == -1) { throw new IOException("Unspecific error while writing"); } len -= written; off += written; } } catch (final IOException e) { throw (IOException) new IOException(e.getMessage() + " at " + AFUNIXSocketImpl.this.toString()).initCause(e); } }
return; default: throw new AFUNIXSocketException("Unsupported option: " + optID); throw new AFUNIXSocketException("Error while setting option", e);
private static int expectInteger(Object value) throws SocketException { try { return (Integer) value; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
private static int expectInteger(Object value) throws SocketException { try { return (Integer) value; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
private static int expectBoolean(Object value) throws SocketException { try { return ((Boolean) value).booleanValue() ? 1 : 0; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
private static int expectBoolean(Object value) throws SocketException { try { return ((Boolean) value).booleanValue() ? 1 : 0; } catch (final ClassCastException e) { throw new AFUNIXSocketException("Unsupported value: " + value, e); } catch (final NullPointerException e) { throw new AFUNIXSocketException("Value must not be null", e); } }
@Override public Object getOption(int optID) throws SocketException { try { switch (optID) { case SocketOptions.SO_KEEPALIVE: case SocketOptions.TCP_NODELAY: return NativeUnixSocket.getSocketOptionInt(fd, optID) != 0 ? true : false; case SocketOptions.SO_LINGER: case SocketOptions.SO_TIMEOUT: case SocketOptions.SO_RCVBUF: case SocketOptions.SO_SNDBUF: return NativeUnixSocket.getSocketOptionInt(fd, optID); default: throw new AFUNIXSocketException("Unsupported option: " + optID); } } catch (final AFUNIXSocketException e) { throw e; } catch (final Exception e) { throw new AFUNIXSocketException("Error while getting option", e); } }
@Override public Object getOption(int optID) throws SocketException { try { switch (optID) { case SocketOptions.SO_KEEPALIVE: case SocketOptions.TCP_NODELAY: return NativeUnixSocket.getSocketOptionInt(fd, optID) != 0 ? true : false; case SocketOptions.SO_LINGER: case SocketOptions.SO_TIMEOUT: case SocketOptions.SO_RCVBUF: case SocketOptions.SO_SNDBUF: return NativeUnixSocket.getSocketOptionInt(fd, optID); default: throw new AFUNIXSocketException("Unsupported option: " + optID); } } catch (final AFUNIXSocketException e) { throw e; } catch (final Exception e) { throw new AFUNIXSocketException("Error while getting option", e); } }
@Override public void write(byte[] buf, int off, int len) throws IOException { if (streamClosed) { throw new AFUNIXSocketException("This OutputStream has already been closed."); } if (len > buf.length - off) { throw new IndexOutOfBoundsException(); } try { while (len > 0 && !Thread.interrupted()) { final int written = NativeUnixSocket.write(fd, buf, off, len); if (written == -1) { throw new IOException("Unspecific error while writing"); } len -= written; off += written; } } catch (final IOException e) { throw (IOException) new IOException(e.getMessage() + " at " + AFUNIXSocketImpl.this.toString()).initCause(e); } }
throw (AFUNIXSocketException) e; throw new AFUNIXSocketException("Could not set port", e); throw new AFUNIXSocketException("Could not set port");
@Override public void write(byte[] buf, int off, int len) throws IOException { if (streamClosed) { throw new AFUNIXSocketException("This OutputStream has already been closed."); } if (len > buf.length - off) { throw new IndexOutOfBoundsException(); } try { while (len > 0 && !Thread.interrupted()) { final int written = NativeUnixSocket.write(fd, buf, off, len); if (written == -1) { throw new IOException("Unspecific error while writing"); } len -= written; off += written; } } catch (final IOException e) { throw (IOException) new IOException(e.getMessage() + " at " + AFUNIXSocketImpl.this.toString()).initCause(e); } }
return; default: throw new AFUNIXSocketException("Unsupported option: " + optID); throw new AFUNIXSocketException("Error while setting option", e);
return; default: throw new AFUNIXSocketException("Unsupported option: " + optID); throw new AFUNIXSocketException("Error while setting option", e);