From 2154eeb5a8966041afd346f31d6267fc2331374f Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 30 Jul 2017 19:46:11 +0200 Subject: [PATCH] Formatting --- src/com/barchart/udt/OptionUDT.java | 175 +++++++++++++--------------- src/com/barchart/udt/SocketUDT.java | 12 +- 2 files changed, 84 insertions(+), 103 deletions(-) diff --git a/src/com/barchart/udt/OptionUDT.java b/src/com/barchart/udt/OptionUDT.java index 1abde578..79200beb 100644 --- a/src/com/barchart/udt/OptionUDT.java +++ b/src/com/barchart/udt/OptionUDT.java @@ -7,7 +7,10 @@ */ package com.barchart.udt; -import static com.barchart.udt.OptionUDT.Format.*; +import static com.barchart.udt.OptionUDT.Format.BINARY; +import static com.barchart.udt.OptionUDT.Format.BOOLEAN; +import static com.barchart.udt.OptionUDT.Format.DECIMAL; +import static com.barchart.udt.OptionUDT.Format.DEFAULT; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -57,76 +60,76 @@ public class OptionUDT { } /** the Maximum Transfer Unit. */ - public static final OptionUDT UDT_MSS = // - NEW(0, Integer.class, DECIMAL); + public static final OptionUDT UDT_MSS = NEW(0, Integer.class, DECIMAL); + /** the Maximum Transfer Unit., bytes */ - public static final OptionUDT Maximum_Transfer_Unit = // - NEW(0, Integer.class, DECIMAL); + public static final OptionUDT Maximum_Transfer_Unit = NEW(0, Integer.class, DECIMAL); + /** if sending is blocking. */ - public static final OptionUDT UDT_SNDSYN = // - NEW(1, Boolean.class, BOOLEAN); + public static final OptionUDT UDT_SNDSYN = NEW(1, Boolean.class, BOOLEAN); + /** if sending is blocking., true/false */ - public static final OptionUDT Is_Send_Synchronous = // - NEW(1, Boolean.class, BOOLEAN); + public static final OptionUDT Is_Send_Synchronous = NEW(1, Boolean.class, BOOLEAN); + /** if receiving is blocking. */ - public static final OptionUDT UDT_RCVSYN = // - NEW(2, Boolean.class, BOOLEAN); + public static final OptionUDT UDT_RCVSYN = NEW(2, Boolean.class, BOOLEAN); + /** if receiving is blocking, true/false */ - public static final OptionUDT Is_Receive_Synchronous = // - NEW(2, Boolean.class, BOOLEAN); + public static final OptionUDT Is_Receive_Synchronous = NEW(2, Boolean.class, BOOLEAN); + /** custom congestion control algorithm */ @SuppressWarnings("rawtypes") - public static final OptionUDT UDT_CC = // - NEW(3, FactoryUDT.class, DEFAULT); + + public static final OptionUDT UDT_CC = NEW(3, FactoryUDT.class, DEFAULT); /** custom congestion control algorithm, class factory */ @SuppressWarnings("rawtypes") - public static final OptionUDT Custom_Congestion_Control = // - NEW(3, FactoryUDT.class, DEFAULT); + public static final OptionUDT Custom_Congestion_Control = NEW(3, FactoryUDT.class, DEFAULT); + /** Flight flag size (window size). */ - public static final OptionUDT UDT_FC = // - NEW(4, Integer.class, BINARY); + public static final OptionUDT UDT_FC = NEW(4, Integer.class, BINARY); + /** Flight flag size (window size), bytes */ - public static final OptionUDT Flight_Window_Size = // - NEW(4, Integer.class, BINARY); + public static final OptionUDT Flight_Window_Size = NEW(4, Integer.class, BINARY); + /** maximum buffer in sending queue. */ - public static final OptionUDT UDT_SNDBUF = // - NEW(5, Integer.class, DECIMAL); + public static final OptionUDT UDT_SNDBUF = NEW(5, Integer.class, DECIMAL); + /** maximum buffer in sending queue. */ - public static final OptionUDT Protocol_Send_Buffer_Size = // - NEW(5, Integer.class, DECIMAL); + public static final OptionUDT Protocol_Send_Buffer_Size = NEW(5, Integer.class, DECIMAL); + /** UDT receiving buffer size. */ - public static final OptionUDT UDT_RCVBUF = // - NEW(6, Integer.class, DECIMAL); + public static final OptionUDT UDT_RCVBUF = NEW(6, Integer.class, DECIMAL); + /** UDT receiving buffer size limit, bytes */ - public static final OptionUDT Protocol_Receive_Buffer_Size = // - NEW(6, Integer.class, DECIMAL); + public static final OptionUDT Protocol_Receive_Buffer_Size = NEW(6, Integer.class, DECIMAL); + /** waiting for unsent data when closing. */ - public static final OptionUDT UDT_LINGER = // - NEW(7, LingerUDT.class, DECIMAL); + public static final OptionUDT UDT_LINGER = NEW(7, LingerUDT.class, DECIMAL); + /** waiting for unsent data when closing. true/false and timeout, seconds */ - public static final OptionUDT Time_To_Linger_On_Close = // - NEW(7, LingerUDT.class, DECIMAL); + public static final OptionUDT Time_To_Linger_On_Close = NEW(7, LingerUDT.class, DECIMAL); + /** UDP sending buffer size. */ - public static final OptionUDT UDP_SNDBUF = // - NEW(8, Integer.class, DECIMAL); + public static final OptionUDT UDP_SNDBUF = NEW(8, Integer.class, DECIMAL); + /** UDP sending buffer size limit, bytes */ - public static final OptionUDT System_Send_Buffer_Size = // - NEW(8, Integer.class, DECIMAL); + public static final OptionUDT System_Send_Buffer_Size = NEW(8, Integer.class, DECIMAL); + /** UDP receiving buffer size. */ - public static final OptionUDT UDP_RCVBUF = // - NEW(9, Integer.class, DECIMAL); + public static final OptionUDT UDP_RCVBUF = NEW(9, Integer.class, DECIMAL); + /** UDP receiving buffer size limit, bytes */ - public static final OptionUDT System_Receive_Buffer_Size = // - NEW(9, Integer.class, DECIMAL); + public static final OptionUDT System_Receive_Buffer_Size = NEW(9, Integer.class, DECIMAL); + /* maximum datagram message size */ // UDT_MAXMSG(10, Integer.class, DECIMAL); no support in udt core @@ -135,90 +138,81 @@ public class OptionUDT { // UDT_MSGTTL(11, Integer.class, DECIMAL); no support in udt core /** rendezvous connection mode. */ - public static final OptionUDT UDT_RENDEZVOUS = // - NEW(12, Boolean.class, BOOLEAN); + public static final OptionUDT UDT_RENDEZVOUS = NEW(12, Boolean.class, BOOLEAN); + /** rendezvous connection mode, enabled/disabled */ - public static final OptionUDT Is_Randezvous_Connect_Enabled = // - NEW(12, Boolean.class, BOOLEAN); + public static final OptionUDT Is_Randezvous_Connect_Enabled = NEW(12, Boolean.class, BOOLEAN); + /** send() timeout. */ - public static final OptionUDT UDT_SNDTIMEO = // - NEW(13, Integer.class, DECIMAL); + public static final OptionUDT UDT_SNDTIMEO = NEW(13, Integer.class, DECIMAL); + /** send() timeout. milliseconds */ - public static final OptionUDT Send_Timeout = // - NEW(13, Integer.class, DECIMAL); + public static final OptionUDT Send_Timeout = NEW(13, Integer.class, DECIMAL); + /** recv() timeout. */ - public static final OptionUDT UDT_RCVTIMEO = // - NEW(14, Integer.class, DECIMAL); + public static final OptionUDT UDT_RCVTIMEO = NEW(14, Integer.class, DECIMAL); + /** recv() timeout. milliseconds */ - public static final OptionUDT Receive_Timeout = // - NEW(14, Integer.class, DECIMAL); + public static final OptionUDT Receive_Timeout = NEW(14, Integer.class, DECIMAL); + /** reuse an existing port or create a one. */ - public static final OptionUDT UDT_REUSEADDR = // - NEW(15, Boolean.class, BOOLEAN); + public static final OptionUDT UDT_REUSEADDR = NEW(15, Boolean.class, BOOLEAN); + /** reuse an existing port or create a one. true/false */ - public static final OptionUDT Is_Address_Reuse_Enabled = // - NEW(15, Boolean.class, BOOLEAN); + public static final OptionUDT Is_Address_Reuse_Enabled = NEW(15, Boolean.class, BOOLEAN); + /** maximum bandwidth (bytes per second) that the connection can use. */ - public static final OptionUDT UDT_MAXBW = // - NEW(16, Long.class, DECIMAL); + public static final OptionUDT UDT_MAXBW = NEW(16, Long.class, DECIMAL); + /** maximum bandwidth (bytes per second) that the connection can use. */ - public static final OptionUDT Maximum_Bandwidth = // - NEW(16, Long.class, DECIMAL); + public static final OptionUDT Maximum_Bandwidth = NEW(16, Long.class, DECIMAL); + /** current socket state, see UDTSTATUS, read only */ - public static final OptionUDT UDT_STATE = // - NEW(17, Integer.class, DECIMAL); + public static final OptionUDT UDT_STATE = NEW(17, Integer.class, DECIMAL); + /** current socket status code, see {@link StatusUDT#getCode()}, read only */ - public static final OptionUDT Status_Code = // - NEW(17, Integer.class, DECIMAL); + public static final OptionUDT Status_Code = NEW(17, Integer.class, DECIMAL); + /** current available events associated with the socket */ - public static final OptionUDT UDT_EVENT = // - NEW(18, Integer.class, DECIMAL); + public static final OptionUDT UDT_EVENT = NEW(18, Integer.class, DECIMAL); + /** current available epoll events, see {@link EpollUDT.Opt#code} */ - public static final OptionUDT Epoll_Event_Mask = // - NEW(18, Integer.class, DECIMAL); + public static final OptionUDT Epoll_Event_Mask = NEW(18, Integer.class, DECIMAL); + /** size of data in the sending buffer */ - public static final OptionUDT UDT_SNDDATA = // - NEW(19, Integer.class, DECIMAL); + public static final OptionUDT UDT_SNDDATA = NEW(19, Integer.class, DECIMAL); + /** current consumed sending buffer utilization, read only, bytes */ - public static final OptionUDT Send_Buffer_Consumed = // - NEW(19, Integer.class, DECIMAL); + public static final OptionUDT Send_Buffer_Consumed = NEW(19, Integer.class, DECIMAL); + /** size of data available for recv */ - public static final OptionUDT UDT_RCVDATA = // - NEW(20, Integer.class, DECIMAL); - /** current available receiving buffer capacity, read only, bytes */ - public static final OptionUDT Receive_Buffer_Available = // - NEW(20, Integer.class, DECIMAL); + public static final OptionUDT UDT_RCVDATA = NEW(20, Integer.class, DECIMAL); + + /** current available receiving buffer capacity, read only, bytes */ + public static final OptionUDT Receive_Buffer_Available = NEW(20, Integer.class, DECIMAL); - // protected OptionUDT(final int code, final Class klaz, final Format format) { - this.code = code; this.type = klaz; this.format = format; values.add(this); - } - protected static OptionUDT NEW(final int code, final Class klaz, - final Format format) { + protected static OptionUDT NEW(final int code, final Class klaz, final Format format) { return new OptionUDT(code, klaz, format); } - public static void appendSnapshot( // - final SocketUDT socketUDT, // - final StringBuilder text // - ) { - + public static void appendSnapshot(final SocketUDT socketUDT, final StringBuilder text) { text.append("\n\t"); text.append(String.format("[id: 0x%08x]", socketUDT.id())); @@ -248,9 +242,7 @@ public class OptionUDT { } catch (final Exception e) { log.error("unexpected; " + optionName, e); } - } - } protected static final Logger log; @@ -284,7 +276,6 @@ public class OptionUDT { * render options in human format */ public enum Format { - DECIMAL() { @Override public String convert(final Object value) { @@ -328,7 +319,5 @@ public class OptionUDT { ; public abstract String convert(Object value); - } - } diff --git a/src/com/barchart/udt/SocketUDT.java b/src/com/barchart/udt/SocketUDT.java index 82f525dd..68989ce8 100644 --- a/src/com/barchart/udt/SocketUDT.java +++ b/src/com/barchart/udt/SocketUDT.java @@ -1619,17 +1619,13 @@ class SocketUDT { * @see #setOption0(int, Class, Object) */ public - void setOption( // - final OptionUDT option, // - final T value // - ) throws ExceptionUDT { + void setOption(final OptionUDT option, final T value) throws ExceptionUDT { if (option == null || value == null) { throw new IllegalArgumentException("option == null || value == null"); } setOption0(option.code(), option.type(), value); - } /** @@ -1637,11 +1633,7 @@ class SocketUDT { * href="http://udt.sourceforge.net/udt4/doc/opt.htm">UDT::setsockopt() */ protected native - void setOption0( // - final int code, // - final Class klaz, // - final Object value // - ) throws ExceptionUDT; + void setOption0(final int code, final Class klaz, final Object value) throws ExceptionUDT; /** * Set maximum receive buffer size. Affects both protocol-level (UDT) and