Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r532 committed - Formatting changes for all files

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r532 committed - Formatting changes for all files


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r532 committed - Formatting changes for all files
  • Date: Wed, 24 Aug 2011 20:50:11 +0000

Revision: 532
Author:

Date: Wed Aug 24 13:48:59 2011
Log: Formatting changes for all files
http://code.google.com/p/ndt/source/detail?r=532

Modified:
/branches/kkumar_code_organize/Applet/Message.java
/branches/kkumar_code_organize/Applet/MessageType.java
/branches/kkumar_code_organize/Applet/NDTConstants.java
/branches/kkumar_code_organize/Applet/NewFrame.java
/branches/kkumar_code_organize/Applet/OsfwWorker.java
/branches/kkumar_code_organize/Applet/Protocol.java
/branches/kkumar_code_organize/Applet/ResultsTextPane.java
/branches/kkumar_code_organize/Applet/StatusPanel.java
/branches/kkumar_code_organize/Applet/Tcpbw100.java
/branches/kkumar_code_organize/Applet/UserAgentTools.java

=======================================
--- /branches/kkumar_code_organize/Applet/Message.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/Message.java Wed Aug 24 13:48:59 2011
@@ -5,11 +5,11 @@
* bytes of the message "body" byte array are often used to store length (For
* example, second/third array positions)
*
- * <p>
- * TODO for a later release: It may be worthwhile exploring whether
- * MessageTypes could be merged here instead of being located in
- * NDTConstants. Message/Type could also be made into an enumeration and
- * checks for the current MessageType being assigned could be incorporated.
+ * <p>
+ * TODO for a later release: It may be worthwhile exploring whether MessageTypes
+ * could be merged here instead of being located in NDTConstants. Message/Type
+ * could also be made into an enumeration and checks for the current MessageType
+ * being assigned could be incorporated.
*
* @see MessageType for more Message Types.
*
@@ -66,10 +66,9 @@
}

/**
- * Set Message body, given a byte array and a size parameter.
- * This may be useful if user wants to initialize the message,
- * and then continue to populate it later.
- * This method is unused currently.
+ * Set Message body, given a byte array and a size parameter. This
may be
+ * useful if user wants to initialize the message, and then continue
to
+ * populate it later. This method is unused currently.
*
* @param iParamSize
* byte array size
=======================================
--- /branches/kkumar_code_organize/Applet/MessageType.java Sat Aug 20 10:12:56 2011
+++ /branches/kkumar_code_organize/Applet/MessageType.java Wed Aug 24 13:48:59 2011
@@ -2,17 +2,17 @@
* */

public class MessageType {
-
- public static final byte COMM_FAILURE = 0;
- public static final byte SRV_QUEUE = 1;
- public static final byte MSG_LOGIN = 2;
- public static final byte TEST_PREPARE = 3;
- public static final byte TEST_START = 4;
- public static final byte TEST_MSG = 5;
- public static final byte TEST_FINALIZE = 6;
- public static final byte MSG_ERROR = 7;
- public static final byte MSG_RESULTS = 8;
- public static final byte MSG_LOGOUT = 9;
- public static final byte MSG_WAITING = 10;
+
+ public static final byte COMM_FAILURE = 0;
+ public static final byte SRV_QUEUE = 1;
+ public static final byte MSG_LOGIN = 2;
+ public static final byte TEST_PREPARE = 3;
+ public static final byte TEST_START = 4;
+ public static final byte TEST_MSG = 5;
+ public static final byte TEST_FINALIZE = 6;
+ public static final byte MSG_ERROR = 7;
+ public static final byte MSG_RESULTS = 8;
+ public static final byte MSG_LOGOUT = 9;
+ public static final byte MSG_WAITING = 10;

}
=======================================
--- /branches/kkumar_code_organize/Applet/NDTConstants.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/NDTConstants.java Wed Aug 24 13:48:59 2011
@@ -4,27 +4,28 @@
import javax.swing.JOptionPane;

/**
- *
- * Class to hold constants. These constants include both Protocol related
- * constants and non-protocol related ones which are used by the software.
- * The different sections of constants are listed under appropriate
- * "sections".
+ *
+ * Class to hold constants. These constants include both Protocol related
+ * constants and non-protocol related ones which are used by the software. The
+ * different sections of constants are listed under appropriate "sections".
*
*/
public class NDTConstants {

- // Section: System variables
+ // Section: System variables
// used by the META tests
public static final String META_CLIENT_OS = "client.os.name";
public static final String META_BROWSER_OS = "client.browser.name";
public static final String META_CLIENT_KERNEL_VERSION = "client.kernel.version";
public static final String META_CLIENT_VERSION = "client.version";

- /* TODO for a later release: Version could be moved to some
"configurable"
- * or "property" area instead of being in code that needs compilation. */
+ /*
+ * TODO for a later release: Version could be moved to some
"configurable"
+ * or "property" area instead of being in code that needs compilation.
+ */
public static final String VERSION = "3.6.4";
-
- public static final String NDT_TITLE_STR = "TCP/Web100 Network Diagnostic Tool v";
+
+ public static final String NDT_TITLE_STR = "TCP/Web100 Network Diagnostic Tool v";

// Section: Test type
public static final byte TEST_MID = (1 << 0);
@@ -35,10 +36,10 @@
public static final byte TEST_META = (1 << 5);

// Section: Firewall test status
- public static final int SFW_NOTTESTED = 0;
+ public static final int SFW_NOTTESTED = 0;
public static final int SFW_NOFIREWALL = 1;
- public static final int SFW_UNKNOWN = 2;
- public static final int SFW_POSSIBLE = 3;
+ public static final int SFW_UNKNOWN = 2;
+ public static final int SFW_POSSIBLE = 3;

public static final double VIEW_DIFF = 0.1;

@@ -52,101 +53,119 @@
public static final int SRV_QUEUE_TEST_STARTS_NOW = 0;
public static final int SRV_QUEUE_SERVER_FAULT = 9977;
public static final int SRV_QUEUE_SERVER_BUSY = 9988;
- public static final int SRV_QUEUE_HEARTBEAT = 9990 ;
+ public static final int SRV_QUEUE_HEARTBEAT = 9990;
public static final int SRV_QUEUE_SERVER_BUSY_60s = 9999;

// Section: Middlebox test related constants
- public static final int MIDDLEBOX_PREDEFINED_MSS = 8192;//8k buffer
size
+ public static final int MIDDLEBOX_PREDEFINED_MSS = 8192;// 8k buffer
size
public static final int ETHERNET_MTU_SIZE = 1456;

// Section: SFW test related constants
public static final String SFW_PREDEFINED_TEST_MESSAGE = "Simple firewall test";

-
private static ResourceBundle _rscBundleMessages;
public static final String TCPBW100_MSGS = "Tcpbw100_msgs";
- public static final int PREDEFINED_BUFFER_SIZE = 8192; //8k buffer
size
-
- //Section: Data rate indicator integers
+ public static final int PREDEFINED_BUFFER_SIZE = 8192; // 8k buffer
size
+
+ // Section: Data rate indicator integers
public static final int DATA_RATE_INSUFFICIENT_DATA = -2;
public static final int DATA_RATE_SYSTEM_FAULT = -1;
public static final int DATA_RATE_RTT = 0;
public static final int DATA_RATE_DIAL_UP = 1;
public static final int DATA_RATE_T1 = 2;
public static final int DATA_RATE_ETHERNET = 3;
- public static final int DATA_RATE_T3 = 4;
+ public static final int DATA_RATE_T3 = 4;
public static final int DATA_RATE_FAST_ETHERNET = 5;
public static final int DATA_RATE_OC_12 = 6;
public static final int DATA_RATE_GIGABIT_ETHERNET = 7;
public static final int DATA_RATE_OC_48 = 8;
public static final int DATA_RATE_10G_ETHERNET = 9;
- //public static final int DATA_RATE_RETRANSMISSIONS = 10;
+ // public static final int DATA_RATE_RETRANSMISSIONS = 10;

// Section: Data rate indicator strings
- public static final String T1_STR = "T1";
- public static final String T3_STR = "T3";
- public static final String ETHERNET_STR = "Ethernet";
+ public static final String T1_STR = "T1";
+ public static final String T3_STR = "T3";
+ public static final String ETHERNET_STR = "Ethernet";
public static final String FAST_ETHERNET = "FastE";
public static final String OC_12_STR = "OC-12";
- public static final String GIGABIT_ETHERNET_STR = "GigE";
+ public static final String GIGABIT_ETHERNET_STR = "GigE";
public static final String OC_48_STR = "OC-48";
public static final String TENGIGABIT_ETHERNET_STR = "10 Gig";
public static final String SYSTEM_FAULT_STR = "systemFault";
- public static final String DIALUP_STR = "dialup2"; //unused, commenting out for now
- public static final String RTT_STR = "rtt"; //round trip time
+ public static final String DIALUP_STR = "dialup2"; // unused, commenting out
+
// for now
+ public static final String RTT_STR = "rtt"; // round trip time

// Section: Data units
- public static final int KILO = 1000; // Used in conversions from seconds->mS,
- public static final int KILO_BYTES = 1024;// Used in kilobits->bits conversions
- public static final int EIGHT = 8; // Used in octal number, conversions from Bytes-> bits etc
-
- //Section: Duplex mismatch conditions
- public static final int DUPLEX_OK_INDICATOR = 0;
+ public static final int KILO = 1000; // Used in conversions from
+
// seconds->mS,
+ public static final int KILO_BYTES = 1024;// Used in kilobits->bits
+
// conversions
+ public static final int EIGHT = 8; // Used in octal number, conversions from
+
// Bytes-> bits etc
+
+ // Section: Duplex mismatch conditions
+ public static final int DUPLEX_OK_INDICATOR = 0;
public static final int DUPLEX_NOK_INDICATOR = 1;
public static final int DUPLEX_SWITCH_FULL_HOST_HALF = 2;
public static final int DUPLEX_SWITCH_HALF_HOST_FULL = 3;
-
+
// Section: miscellaneous
- public static final int SOCKET_FREE_PORT_INDICATOR = 0 ;
+ public static final int SOCKET_FREE_PORT_INDICATOR = 0;
public static final String LOOPBACK_ADDRS_STRING = "127.0.0.1";
-
- // constant to indicate protocol read success
+
+ // constant to indicate protocol read success
public static final int PROTOCOL_MSG_READ_SUCCESS = 0;
+
// system variables could be declared as strings too
// half_duplex:, country , etc.

- /** Initializes a few constants
- * @param paramLocale local Locale object
- * */
- public static void initConstants(Locale paramLocale) {
- try {
- _rscBundleMessages = ResourceBundle.getBundle( TCPBW100_MSGS, paramLocale);
+ /**
+ * Initializes a few constants
+ *
+ * @param paramLocale
+ * local Locale object
+ * */
+ public static void initConstants(Locale paramLocale) {
+ try {
+ _rscBundleMessages =
ResourceBundle.getBundle(TCPBW100_MSGS,
+ paramLocale);
System.out.println("Obtained messages ");
} catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
+ JOptionPane.showMessageDialog(null,
+ "Error while loading language
files:\n" + e.getMessage());
e.printStackTrace();
}

- } //end method
-
- /** Initializes a few constants
- * @param paramStrLang local Language String
- * @param paramStrCountry local country String
+ } // end method
+
+ /**
+ * Initializes a few constants
+ *
+ * @param paramStrLang
+ * local Language String
+ * @param paramStrCountry
+ * local country String
* */
- public static void initConstants(String paramStrLang, String paramStrCountry) {
- try {
+ public static void initConstants(String paramStrLang, String paramStrCountry) {
+ try {
Locale locale = new Locale(paramStrLang,
paramStrCountry);
- _rscBundleMessages =
ResourceBundle.getBundle("Tcpbw100_msgs", locale);
+ _rscBundleMessages =
ResourceBundle.getBundle("Tcpbw100_msgs",
+ locale);
} catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
+ JOptionPane.showMessageDialog(null,
+ "Error while loading language
files:\n" + e.getMessage());
e.printStackTrace();
}
- }//end method initconstants
-
-
- /** Getter method for to fetch from resourceBundle
- * @param paramStrName name of parameter to be fetched
- * @return Value of parameter input */
+ }// end method initconstants
+
+ /**
+ * Getter method for to fetch from resourceBundle
+ *
+ * @param paramStrName
+ * name of parameter to be fetched
+ * @return Value of parameter input
+ */
public static String getMessageString(String paramStrName) {
return _rscBundleMessages.getString(paramStrName);
}
=======================================
--- /branches/kkumar_code_organize/Applet/NewFrame.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/NewFrame.java Wed Aug 24 13:48:59 2011
@@ -3,24 +3,24 @@

import javax.swing.JFrame;

-
/**
* Utility class that creates a new "Frame" with a window closing functionality.
- * This Class is used to provide a base "frame" for the Statistics, Details and
+ * This Class is used to provide a base "frame" for the Statistics, Details and
* Options windows
*
- * This class is declared separately so that it can be easily extended
- * by users to customize based on individual needs
+ * This class is declared separately so that it can be easily extended by users
+ * to customize based on individual needs
*
*/
public class NewFrame extends JFrame {
/**
- * Auto-generated compiler constant that does not contribute to
- * classes' functionality
+ * Auto-generated compiler constant that does not contribute to
classes'
+ * functionality
*/
private static final long serialVersionUID = 8990839319520684317L;
-
- /** Constructor
+
+ /**
+ * Constructor
**/
public NewFrame() {
addWindowListener(new WindowAdapter() {
@@ -31,5 +31,5 @@
});
// System.err.println("Extended Frame class - RAC9/15/03");
}
-
+
} // class: NewFrame
=======================================
--- /branches/kkumar_code_organize/Applet/OsfwWorker.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/OsfwWorker.java Wed Aug 24 13:48:59 2011
@@ -3,18 +3,18 @@
import java.net.Socket;

/**
- * OsfwWorker creates a thread that listens for a message from the server. It functions
- * to check if the server has sent a message that is valid and sufficient to determine
- * if the server->client direction has a fire-wall.
+ * OsfwWorker creates a thread that listens for a message from the server. It
+ * functions to check if the server has sent a message that is valid and
+ * sufficient to determine if the server->client direction has a fire-wall.
*
* <p>
- * As part of the simple firewall test, the Server must try
- * to connect to the Client's ephemeral port and send a TEST_MSG message containing
- * a pre-defined string "Simple firewall test" of 20 chars using this newly created
+ * As part of the simple firewall test, the Server must try to connect to the
+ * Client's ephemeral port and send a TEST_MSG message containing a pre-defined
+ * string "Simple firewall test" of 20 chars using this newly created
* connection. This class implements this functionality.
*
- * The result of the test is set back into the Tcpbw100._iS2cSFWResult variable
- * (using setter methods) for the test results to be interpreted later
+ * The result of the test is set back into the Tcpbw100._iS2cSFWResult variable
+ * (using setter methods) for the test results to be interpreted later
* */

public class OsfwWorker implements Runnable {
@@ -30,7 +30,7 @@
*
* @param Socket
* srvSocketParam Socket used to transmit protocol messages
- *
+ *
* @param iParamTestTime
* Test time duration to wait for message from server
*/
@@ -58,7 +58,7 @@

/**
* Make current thread sleep for 1000 ms
- *
+ *
* */
public void finalize() {
// If test is not already complete/terminated, then sleep
@@ -86,13 +86,13 @@
// set timeout to given value in ms
_srvSocket.setSoTimeout(_iTestTime * 1000);
try {
-
+
// Blocking call trying to create connection
to socket and
// accept it
socketObj = _srvSocket.accept();
} catch (Exception e) {
e.printStackTrace();
-
+
// The "accept" call has failed, and
indicates a firewall
// possibility
this._localTcpAppObj
@@ -105,7 +105,7 @@

// commented out sections indicate move to outer class
if (sfwCtl.recv_msg(msg) != 0) {
-
+
// error, msg read/received incorrectly.
Hence set status as
// unknown
System.out
@@ -147,13 +147,13 @@
_iFinalized = true;
return;
}
-
- // If none of the above conditions were met, then,
the server
- // message has been received correctly, and there
seems to be no
- // firewall
+
+ // If none of the above conditions were met, then,
the server
+ // message has been received correctly, and there
seems to be no
+ // firewall
this._localTcpAppObj

.setS2cSFWTestResults(NDTConstants.SFW_NOFIREWALL);
-
+
} catch (IOException ex) {
// Status of firewall could not be determined before
concluding

this._localTcpAppObj.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
@@ -164,7 +164,8 @@
socketObj.close();
_srvSocket.close();
} catch (IOException e) {
- System.err.println("OsfwWorker: Exception trying to close
sockets" + e);
+ System.err.println("OsfwWorker: Exception trying to close
sockets"
+ + e);
// log exception occurence
}
_iFinalized = true;
=======================================
--- /branches/kkumar_code_organize/Applet/Protocol.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/Protocol.java Wed Aug 24 13:48:59 2011
@@ -3,79 +3,92 @@
import java.io.OutputStream;
import java.net.Socket;

-/** Class aggregating operations that can be performed for sending/receiving/reading
- * Protocol messages
+/**
+ * Class aggregating operations that can be performed for
+ * sending/receiving/reading Protocol messages
*
* */

-
public class Protocol {
private InputStream _ctlInStream;
private OutputStream _ctlOutStream;

- /** Constructor that accepts socket over which to communicate as
parameter
- * @param ctlSocketParam socket used to send the protocol messages
over
- * @throws IOException if Input/Output streams cannot be
- * read from/written into correctly
+ /**
+ * Constructor that accepts socket over which to communicate as
parameter
+ *
+ * @param ctlSocketParam
+ * socket used to send the protocol messages over
+ * @throws IOException
+ * if Input/Output streams cannot be read from/written
into
+ * correctly
*/
- public Protocol(Socket ctlSocketParam) throws IOException
- {
+ public Protocol(Socket ctlSocketParam) throws IOException {
_ctlInStream = ctlSocketParam.getInputStream();
_ctlOutStream = ctlSocketParam.getOutputStream();
}

- /** Send message given its Type and data byte
- * @param bParamType Control Message Type
- * @param bParamToSend Data value to send
- * @throws IOException If data cannot be successfully written to
- * the Output Stream
+ /**
+ * Send message given its Type and data byte
+ *
+ * @param bParamType
+ * Control Message Type
+ * @param bParamToSend
+ * Data value to send
+ * @throws IOException
+ * If data cannot be successfully written to the Output
Stream
*
* */
- public void send_msg(byte bParamType, byte bParamToSend) throws IOException
- {
+ public void send_msg(byte bParamType, byte bParamToSend) throws IOException {
byte[] tab = new byte[] { bParamToSend };
send_msg(bParamType, tab);
}

-
- /** Send protocol messages given their type and data byte array
- * @param bParamType Control Message Type
- * @param bParamToSend Data value array to send
- * @throws IOException If data cannot be successfully written to
- * the Output Stream
+ /**
+ * Send protocol messages given their type and data byte array
+ *
+ * @param bParamType
+ * Control Message Type
+ * @param bParamToSend
+ * Data value array to send
+ * @throws IOException
+ * If data cannot be successfully written to the Output
Stream
*
* */
- public void send_msg(byte bParamType, byte[] bParamToSend) throws IOException
- {
+ public void send_msg(byte bParamType, byte[] bParamToSend)
+ throws IOException {
byte[] header = new byte[3];
header[0] = bParamType;

- //2 bytes are used to hold data length. Thus, max(data
length) = 65535
- header[1] = (byte) (bParamToSend.length >> 8);
+ // 2 bytes are used to hold data length. Thus, max(data
length) = 65535
+ header[1] = (byte) (bParamToSend.length >> 8);
header[2] = (byte) bParamToSend.length;

- //Write data to outputStream
+ // Write data to outputStream
_ctlOutStream.write(header);
_ctlOutStream.write(bParamToSend);
}

- /** Populate Message byte array with specific number of bytes of data
- * from socket input stream
- * @param msgParam Message object to be populated
- * @param iParamAmount specified number of bytes to be read
+ /**
+ * Populate Message byte array with specific number of bytes of data
from
+ * socket input stream
+ *
+ * @param msgParam
+ * Message object to be populated
+ * @param iParamAmount
+ * specified number of bytes to be read
* @return integer number of bytes populated
- * @throws IOException If data cannot be successfully read from
- * the Input Stream
+ * @throws IOException
+ * If data cannot be successfully read from the Input
Stream
*/
- public int readn(Message msgParam, int iParamAmount) throws
IOException
- {
- int read = 0;
+ public int readn(Message msgParam, int iParamAmount) throws
IOException {
+ int read = 0;
int tmp;
- //msg.body = new byte[amount];
+ // msg.body = new byte[amount];
msgParam.initBodySize(iParamAmount);
while (read != iParamAmount) {
- //tmp = _ctlin.read(msg.body, read, amount - read);
- tmp = _ctlInStream.read(msgParam._yaBody, read,
iParamAmount - read);
+ // tmp = _ctlin.read(msg.body, read, amount - read);
+ tmp = _ctlInStream
+ .read(msgParam._yaBody, read,
iParamAmount - read);
if (tmp <= 0) {
return read;
}
@@ -84,42 +97,43 @@
return read;
}

- /** Receive message at end-point of socket
- * @param msgParam Message object
+ /**
+ * Receive message at end-point of socket
+ *
+ * @param msgParam
+ * Message object
* @return integer with values:
- * <p>
- * a) Success:
- * <ul>
- * <li>
- * value=0 : successfully read expected number of bytes.
- * </li> </ul>
- * <p>
- * b) Error:
- * <ul>
- * <li>value= 1 : Error reading ctrl-message length and data type itself, since
- * NDTP-control packet has to be at
- * the least 3 octets long </li>
- * <li>value= 3 : Error, mismatch between "length" field of ctrl-message and
- * actual data read </li>
- * </ul>
+ * <p>
+ * a) Success:
+ * <ul>
+ * <li>
+ * value=0 : successfully read expected number of bytes.</li>
+ * </ul>
+ * <p>
+ * b) Error:
+ * <ul>
+ * <li>value= 1 : Error reading ctrl-message length and data
type
+ * itself, since NDTP-control packet has to be at the least 3 octets
+ * long</li>
+ * <li>value= 3 : Error, mismatch between "length" field of
+ * ctrl-message and actual data read</li>
+ * </ul>
* */
- public int recv_msg(Message msgParam) throws IOException
- {
+ public int recv_msg(Message msgParam) throws IOException {
int length;
if (readn(msgParam, 3) != 3) {
return 1;
}
/*
- * msg.type = msg.body[0];
- length = ((int) msg.body[1] & 0xFF) << 8;
- length += (int) msg.body[2] & 0xFF;
+ * msg.type = msg.body[0]; length = ((int) msg.body[1] & 0xFF)
<< 8;
+ * length += (int) msg.body[2] & 0xFF;
*/
- byte [] yaMsgBody = msgParam.getBody();
+ byte[] yaMsgBody = msgParam.getBody();
msgParam.setType(yaMsgBody[0]);

- //Get data length
+ // Get data length
length = ((int) yaMsgBody[1] & 0xFF) << 8;
- length += (int) yaMsgBody[2] & 0xFF;
+ length += (int) yaMsgBody[2] & 0xFF;

if (readn(msgParam, length) != length) {
return 3;
@@ -127,18 +141,16 @@
return 0;
}

- /** Method to close open Streams
+ /**
+ * Method to close open Streams
*/
- public void close()
- {
+ public void close() {
try {
_ctlInStream.close();
_ctlOutStream.close();
- }
- catch (IOException e) {
+ } catch (IOException e) {
e.printStackTrace();
}
}

-
-} //end class Protocol
+} // end class Protocol
=======================================
--- /branches/kkumar_code_organize/Applet/ResultsTextPane.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/ResultsTextPane.java Wed Aug 24 13:48:59 2011
@@ -12,40 +12,42 @@
* by users to customize based on individual needs
*
*/
-public class ResultsTextPane extends JTextPane
-{
-
+public class ResultsTextPane extends JTextPane {

/**
* Compiler auto-generate value not directly related to class functionality
*/
private static final long serialVersionUID = -2224271202004876654L;

- /** Method to append String into the current document
- * @param paramTextStr String to be inserted into the document
+ /**
+ * Method to append String into the current document
+ *
+ * @param paramTextStr
+ * String to be inserted into the document
**/
- public void append(String paramTextStr)
- {
+ public void append(String paramTextStr) {
try {
- getStyledDocument().insertString(getStyledDocument().getLength(), paramTextStr, null);
- }
- catch (BadLocationException e) {
- System.out.println("WARNING: failed to append text to the text pane! [" + paramTextStr + "]");
+
getStyledDocument().insertString(getStyledDocument().getLength(),
+ paramTextStr, null);
+ } catch (BadLocationException e) {
+ System.out
+ .println("WARNING: failed to append text
to the text pane! ["
+ + paramTextStr + "]");
}
}

/**
* JTextPane method to insert a component into the document as a replacement
- * for currently selected content. If no selection is made, the
- * the component is inserted at the current position of the caret.
- * @param paramCompObj the component to insert
+ * for currently selected content. If no selection is made, the the
+ * component is inserted at the current position of the caret.
+ *
+ * @param paramCompObj
+ * the component to insert
* */
- public void insertComponent(Component paramCompObj)
- {
+ public void insertComponent(Component paramCompObj) {
setSelectionStart(this.getStyledDocument().getLength());
- setSelectionEnd(this.getStyledDocument().getLength());
+ setSelectionEnd(this.getStyledDocument().getLength());
super.insertComponent(paramCompObj);
}
-
-}
-
+
+}
=======================================
--- /branches/kkumar_code_organize/Applet/StatusPanel.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/StatusPanel.java Wed Aug 24 13:48:59 2011
@@ -6,45 +6,49 @@
import javax.swing.JPanel;
import javax.swing.JProgressBar;

-/** Class that displays status of tests being run.
- * It also provides methods to set status message,
- * record intention to stop tests, and to fetch the status of whether
- * the test is to be stopped.
+/**
+ * Class that displays status of tests being run. It also provides methods to
+ * set status message, record intention to stop tests, and to fetch the status
+ * of whether the test is to be stopped.
* */

-public class StatusPanel extends JPanel
-{
+public class StatusPanel extends JPanel {
/**
* Compiler generated constant that is not related to current classes'
* specific functionality
*/
private static final long serialVersionUID = 2609233901130079136L;
-
-
- private int _iTestsCompleted; // variable used to record the count of "finished" tests
- private int _iTestsNum; //total test count
+
+ private int _iTestsCompleted; // variable used to record the count of
+ //
"finished" tests
+ private int _iTestsNum; // total test count
private boolean _bStop = false;

private JLabel _labelTestNum = new JLabel();
private JButton _buttonStop;
private JProgressBar _progressBarObj = new JProgressBar();

- /* Constructor
+ /*
+ * Constructor
+ *
* @param testsNum Total number of tests scheduled to be run
- * @param sParamaEnableMultiple String indicating whether multiple
tests
- * have been scheduled */
+ *
+ * @param sParamaEnableMultiple String indicating whether multiple
tests
+ * have been scheduled
+ */
public StatusPanel(int iParamTestsNum, String sParamEnableMultiple) {
this._iTestsCompleted = 1;
this._iTestsNum = iParamTestsNum;

setTestNoLabelText();
-
- // If multiple tests are enabled to be run, then add information about the
+
+ // If multiple tests are enabled to be run, then add
information about
+ // the
// test number being run
- if ( sParamEnableMultiple != null) {
+ if (sParamEnableMultiple != null) {
add(_labelTestNum);
}
-
+
_progressBarObj.setMinimum(0);
_progressBarObj.setMaximum(_iTestsNum);
_progressBarObj.setValue(0);
@@ -52,45 +56,51 @@
if (_iTestsNum == 0) {
_progressBarObj.setString("");
_progressBarObj.setIndeterminate(true);
- }
- else {
- _progressBarObj.setString(NDTConstants.getMessageString("initialization"));
+ } else {
+ _progressBarObj.setString(NDTConstants
+ .getMessageString("initialization"));
}
add(_progressBarObj);
- _buttonStop= new
JButton(NDTConstants.getMessageString("stop"));
+ _buttonStop = new
JButton(NDTConstants.getMessageString("stop"));
_buttonStop.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
_bStop = true;
_buttonStop.setEnabled(false);
-
StatusPanel.this.setText(NDTConstants.getMessageString("stopping"));
+ StatusPanel.this.setText(NDTConstants
+
.getMessageString("stopping"));
}

});
-
- // If multiple tests are enabled to be run, provide user
option to
+
+ // If multiple tests are enabled to be run, provide user
option to
// stop the one currently running
if (sParamEnableMultiple != null) {
add(_buttonStop);
}
}

- /** Set Test number being run
+ /**
+ * Set Test number being run
* */
private void setTestNoLabelText() {
- _labelTestNum.setText(NDTConstants.getMessageString("test") + " " + _iTestsCompleted + " " +
- NDTConstants.getMessageString("of") + " "
+_iTestsNum);
-
+ _labelTestNum.setText(NDTConstants.getMessageString("test") + "
"
+ + _iTestsCompleted + " " +
NDTConstants.getMessageString("of")
+ + " " + _iTestsNum);
+
}

- /** Get intention to stop tests
+ /**
+ * Get intention to stop tests
+ *
* @return boolean indicating intention to stop or not
* */
public boolean wantToStop() {
return _bStop;
}

- /** End the currently running test
+ /**
+ * End the currently running test
* */
public void endTest() {
_progressBarObj.setValue(_iTestsCompleted);
@@ -98,12 +108,15 @@
setTestNoLabelText();
}

- /** Sets a string explaining progress of tests
- * @param sParamText String status of test-run
+ /**
+ * Sets a string explaining progress of tests
+ *
+ * @param sParamText
+ * String status of test-run
* */
public void setText(String sParamText) {
if (!_progressBarObj.isIndeterminate()) {
_progressBarObj.setString(sParamText);
}
}
-} //end class StatusPanel
+} // end class StatusPanel
=======================================
--- /branches/kkumar_code_organize/Applet/Tcpbw100.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/Tcpbw100.java Wed Aug 24 13:48:59 2011
@@ -46,72 +46,69 @@
import javax.swing.SpinnerNumberModel;

/*
-Copyright 2003 University of Chicago. All rights reserved.
-The Web100 Network Diagnostic Tool (NDT) is distributed subject to
-the following license conditions:
-SOFTWARE LICENSE AGREEMENT
-Software: Web100 Network Diagnostic Tool (NDT)
-
-1. The "Software", below, refers to the Web100 Network Diagnostic Tool (NDT)
-(in either source code, or binary form and accompanying documentation). Each
-licensee is addressed as "you" or "Licensee."
-
-2. The copyright holder shown above hereby grants Licensee a royalty-free
-nonexclusive license, subject to the limitations stated herein and U.S. Government
-license rights.
-
-3. You may modify and make a copy or copies of the Software for use within your
-organization, if you meet the following conditions:
- a. Copies in source code must include the copyright notice and this Software
- License Agreement.
- b. Copies in binary form must include the copyright notice and this Software
- License Agreement in the documentation and/or other materials provided with the copy.
-
-4. You may make a copy, or modify a copy or copies of the Software or any
-portion of it, thus forming a work based on the Software, and distribute copies
-outside your organization, if you meet all of the following conditions:
- a. Copies in source code must include the copyright notice and this
- Software License Agreement;
- b. Copies in binary form must include the copyright notice and this
- Software License Agreement in the documentation and/or other materials
- provided with the copy;
- c. Modified copies and works based on the Software must carry prominent
- notices stating that you changed specified portions of the Software.
-
-5. Portions of the Software resulted from work developed under a U.S. Government
-contract and are subject to the following license: the Government is granted
-for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable
-worldwide license in this computer software to reproduce, prepare derivative
-works, and perform publicly and display publicly.
-
-6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY
-OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES
-DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT,
-(2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
-COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE
-OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT
-THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT
-ANY ERRORS WILL BE CORRECTED.
-
-7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE
-UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES:
-BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE
-DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS
-OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED
-ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR
-OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF
-SUCH LOSS OR DAMAGES.
-The Software was developed at least in part by the University of Chicago,
-as Operator of Argonne National Laboratory (http://miranda.ctd.anl.gov:7123/).
+ Copyright 2003 University of Chicago. All rights reserved.
+ The Web100 Network Diagnostic Tool (NDT) is distributed subject to
+ the following license conditions:
+ SOFTWARE LICENSE AGREEMENT
+ Software: Web100 Network Diagnostic Tool (NDT)
+
+ 1. The "Software", below, refers to the Web100 Network Diagnostic Tool (NDT)
+ (in either source code, or binary form and accompanying documentation). Each
+ licensee is addressed as "you" or "Licensee."
+
+ 2. The copyright holder shown above hereby grants Licensee a royalty-free
+ nonexclusive license, subject to the limitations stated herein and U.S. Government
+ license rights.
+
+ 3. You may modify and make a copy or copies of the Software for use within your
+ organization, if you meet the following conditions:
+ a. Copies in source code must include the copyright notice and this Software
+ License Agreement.
+ b. Copies in binary form must include the copyright notice and this Software
+ License Agreement in the documentation and/or other materials provided with the copy.
+
+ 4. You may make a copy, or modify a copy or copies of the Software or any
+ portion of it, thus forming a work based on the Software, and distribute copies
+ outside your organization, if you meet all of the following conditions:
+ a. Copies in source code must include the copyright notice and this
+ Software License Agreement;
+ b. Copies in binary form must include the copyright notice and this
+ Software License Agreement in the documentation and/or other materials
+ provided with the copy;
+ c. Modified copies and works based on the Software must carry prominent
+ notices stating that you changed specified portions of the Software.
+
+ 5. Portions of the Software resulted from work developed under a U.S. Government
+ contract and are subject to the following license: the Government is granted
+ for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable
+ worldwide license in this computer software to reproduce, prepare derivative
+ works, and perform publicly and display publicly.
+
+ 6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY
+ OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES
+ DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT,
+ (2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
+ COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE
+ OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT
+ THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT
+ ANY ERRORS WILL BE CORRECTED.
+
+ 7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE
+ UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES:
+ BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE
+ DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS
+ OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED
+ ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR
+ OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF
+ SUCH LOSS OR DAMAGES.
+ The Software was developed at least in part by the University of Chicago,
+ as Operator of Argonne National Laboratory (http://miranda.ctd.anl.gov:7123/).
*/

-
-
-
- /*
- * Naming convention used: Hungarian, with the following details
+/*
+ * Naming convention used: Hungarian, with the following details
* _VarName: Instance variables
* __Varname: Static variables (instead of c_VarName to reduce length)
* iVarName: Integer variable
@@ -129,28 +126,27 @@
* indicate their types
*
*/
-
- /**
- * Main Applet class that creates UI, defines tests and interprets results
- * from the tests.
- *
- * */
-public class Tcpbw100 extends JApplet implements ActionListener {
-
+
+/**
+ * Main Applet class that creates UI, defines tests and interprets results from
+ * the tests.
+ *
+ * */
+public class Tcpbw100 extends JApplet implements ActionListener {

/**
- * Compiler generated UID that does not follow naming convention,
- * and is not related to functionality itself
+ * Compiler generated UID that does not follow naming convention, and is not
+ * related to functionality itself
*/
private static final long serialVersionUID = -2030725073538492542L;
-
+
JTextArea _txtDiagnosis, _txtStatistics;
ResultsTextPane _resultsTxtPane;
- //String inresult, outresult; //comment out unused variables
+ // String inresult, outresult; //comment out unused variables
String _sErrMsg;
JButton _buttonStartTest;
- //TODO: Could use just one button for dismiss and copy. For later
release
- JButton _buttonDismiss, _buttonStatsDismiss;
+ // TODO: Could use just one button for dismiss and copy. For later
release
+ JButton _buttonDismiss, _buttonStatsDismiss;
JButton _buttonCopy, _buttonStatsCopy;
JButton _buttonDetails;
JButton _buttonStatistics;
@@ -158,26 +154,28 @@
JButton _buttonOptions;
JCheckBox _chkboxDefaultTest, _chkboxPreferIPv6;
JSpinner _spinnerTestCount = new JSpinner();
- String[] _saDelays = { "immediate", "1min","5mins","10mins","30mins","2hours","12hours","1day" };
+ String[] _saDelays = { "immediate", "1min", "5mins", "10mins",
"30mins",
+ "2hours", "12hours", "1day" };
JComboBox _cmboboxDelay;

boolean _bRandomize;
boolean _bFailed, _bCanCopy;
- //URL location; //unused, hence commenting out
+ // URL location; //unused, hence commenting out
NewFrame _frameWeb100Vars, _frameDetailedStats, _frameOptions;
- //String s; Unused, commenting out
+ // String s; Unused, commenting out
double _dTime;
int _iECNEnabled, _iNagleEnabled, MSSSent, MSSRcvd;
int _iSACKEnabled, _iTimestampsEnabled, _iWinScaleRcvd,
_iWinScaleSent;
int _iFastRetran, _iAckPktsOut, _iSmoothedRTT, _iCurrentCwnd,
_iMaxCwnd;
int _iSndLimTimeRwin, _iSndLimTimeCwnd, _iSndLimTimeSender;
- int _iSndLimTransRwin, _iSndLimTransCwnd, _iSndLimTransSender, _iMaxSsthresh;
+ int _iSndLimTransRwin, _iSndLimTransCwnd, _iSndLimTransSender,
+ _iMaxSsthresh;
int _iSumRTT, _iCountRTT, _iCurrentMSS, _iTimeouts, _iPktsRetrans;
int _iSACKsRcvd, _iDupAcksIn, _iMaxRwinRcvd, _iMaxRwinSent;
int _iDataPktsOut, _iRcvbuf, _iSndbuf, _iAckPktsIn, _iDataBytesOut;
int _iPktsOut, _iCongestionSignals, _iRcvWinScale;
- //int _iPkts, _iLength=8192, _iCurrentRTO;
- int _iPkts, _iLength = NDTConstants.PREDEFINED_BUFFER_SIZE,
_iCurrentRTO;
+ // int _iPkts, _iLength=8192, _iCurrentRTO;
+ int _iPkts, _iLength = NDTConstants.PREDEFINED_BUFFER_SIZE,
_iCurrentRTO;
int _iC2sData, _iC2sAck, _iS2cData, _iS2cAck;
// added for mailto url
protected URL _targetURL;
@@ -188,65 +186,66 @@
double _dSbytes;

/**
- * Added by Martin Sandsmark, UNINETT AS
- * Internationalization
+ * Added by Martin Sandsmark, UNINETT AS Internationalization
*/
private Locale _localeObj;
private ResourceBundle _resBundDisplayMsgs;
- private String _sLang="en";
- private String _sCountry="US";
- //private static String lang="nb";
- //private static String country="NO";
+ private String _sLang = "en";
+ private String _sCountry = "US";
+ // private static String lang="nb";
+ // private static String country="NO";
/***/

- //these variables are self-explanatory. Do not follow naming convention, but left that way
+ // these variables are self-explanatory. Do not follow naming
convention,
+ // but left that way
int half_duplex, congestion, bad_cable, mismatch;
double mylink;
double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
double aspd;
- //end naming convention-not-followed variables
+ // end naming convention-not-followed variables

boolean _bIsApplication = false;
boolean _bTestInProgress = false;
String sHostName = null;
String _sTestResults, _sMidBoxTestResult;
- byte _yTests = NDTConstants.TEST_MID | NDTConstants.TEST_C2S | NDTConstants.TEST_S2C |
- NDTConstants.TEST_SFW | NDTConstants.TEST_STATUS | NDTConstants.TEST_META;
+ byte _yTests = NDTConstants.TEST_MID | NDTConstants.TEST_C2S
+ | NDTConstants.TEST_S2C | NDTConstants.TEST_SFW
+ | NDTConstants.TEST_STATUS | NDTConstants.TEST_META;
int _iC2sSFWResult = NDTConstants.SFW_NOTTESTED;
int _iS2cSFWResult = NDTConstants.SFW_NOTTESTED;
-
+

/*************************************************************************
- * JavaScript access API extension
- * Added by Seth Peery and Gregory Wilson, Virginia Tech
- * October 28, 2009
- * This section adds classwide variables, written to at runtime,
- * which are then exposed by public accessor methods that can be
called
- * from web applications using NDT as a back-end.
+ * JavaScript access API extension Added by Seth Peery and Gregory
Wilson,
+ * Virginia Tech October 28, 2009 This section adds classwide
variables,
+ * written to at runtime, which are then exposed by public accessor methods
+ * that can be called from web applications using NDT as a back-end.
*/

- //These variables are accessed by the setter/getter methods. While they do not follow naming convention,
- // are left this way
- // pub_c2sspd is assigned the value of _dC2sspd (declared above). the pub_xxx version seems to be used
- //for making public to javascript. No other details known
+ // These variables are accessed by the setter/getter methods. While they do
+ // not follow naming convention,
+ // are left this way
+ // pub_c2sspd is assigned the value of _dC2sspd (declared above). the
+ // pub_xxx version seems to be used
+ // for making public to javascript. No other details known
private double pub_c2sspd = 0.0;
private double pub_s2cspd = 0.0;
private int pub_CurRwinRcvd = 0; // source variable does not exist
private int pub_MaxRwinRcvd = 0;
- private int pub_MinRTT = 0; // source variable does not exist
- private int pub_MaxRTT = 0; // source variable does not exist
+ private int pub_MinRTT = 0; // source variable does not exist
+ private int pub_MaxRTT = 0; // source variable does not exist
private double pub_loss = 0.0;
private double pub_avgrtt = 0.0;
- //TODO:Getter/setter commented out for both below. Why?
- private int pub_MinRTO = 0; // source variable does not exist
+ // TODO:Getter/setter commented out for both below. Why?
+ private int pub_MinRTO = 0; // source variable does not exist
private int pub_MaxRTO = 0; // source variable does not exist
private int pub_CurRTO = 0;
// private String pub_CWNDpeaks = ""; // source variable does not
exist
private int pub_SACKsRcvd = 0;
- private String pub_osVer = "unknown";
+ private String pub_osVer = "unknown";
private String pub_javaVer = "unknown";
private String pub_host = "unknown";
- private String pub_osName = "unknown";
+ private String pub_osName = "unknown";
private String pub_osArch = "unknown";
private int pub_mismatch = 0;
private int pub_Bad_cable = 0;
@@ -259,7 +258,7 @@
private Date pub_TimeStamp;
private String pub_isReady = new String("no");
private String pub_clientIP = "unknown";
- private int pub_jitter = 0; //unused. TODO: find out use
+ private int pub_jitter = 0; // unused. TODO: find out use
private int pub_Timeouts = 0;
private String pub_errmsg = "Test not run.";
private String pub_diagnosis = "Test not run.";
@@ -270,10 +269,10 @@
private String _sIsAutoRun;
private String _sUserAgent = null;

- /** public static void main for invoking as an Application
+ /**
+ * public static void main for invoking as an Application
* */
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
JFrame frame = new JFrame("ANL/Internet2 NDT (applet)");
if (args.length != 1) {
System.out.println("Usage: java -jar Tcpbw100.jar " +
"HOST");
@@ -295,108 +294,87 @@
frame.setVisible(true);
}

-
/*
* Accessor methods for public variables
- **/
-
- public String get_c2sspd()
- {
+ */
+
+ public String get_c2sspd() {
// Expressed as MiB using base 10
- return Double.toString((pub_c2sspd));
+ return Double.toString((pub_c2sspd));
}

- public String get_s2cspd()
- {
+ public String get_s2cspd() {
// Expressed as MiB using base 10
return Double.toString(pub_s2cspd);
}

- public String get_CurRwinRcvd()
- {
+ public String get_CurRwinRcvd() {
return Integer.toString(pub_CurRwinRcvd);
}

- public String get_MaxRwinRcvd()
- {
+ public String get_MaxRwinRcvd() {
return Integer.toString(pub_MaxRwinRcvd);
}

- public String get_Ping()
- {
+ public String get_Ping() {
return Integer.toString(pub_MinRTT);
- }
-
- public String get_MaxRTT()
- {
+ }
+
+ public String get_MaxRTT() {
return Integer.toString(pub_MaxRTT);
- }
-
- public String get_loss()
- {
+ }
+
+ public String get_loss() {
return Double.toString(pub_loss);
}

- public String get_avgrtt()
- {
- return Double.toString(pub_avgrtt);
+ public String get_avgrtt() {
+ return Double.toString(pub_avgrtt);
}

- /* public String get_MinRTO()
- {
- return pub_MinRTO;
- }*/
-
- /* public String get_MaxRTO()
- {
- return pub_MaxRTO;
- }*/
-
- public String get_CurRTO()
- {
+ /*
+ * public String get_MinRTO() { return pub_MinRTO; }
+ */
+
+ /*
+ * public String get_MaxRTO() { return pub_MaxRTO; }
+ */
+
+ public String get_CurRTO() {
return Integer.toString(pub_CurRTO);
}

/*
- public String get_CWNDpeaks()
- {
- return pub_CWNDpeaks;
- } */
-
- public String get_SACKsRcvd()
- {
+ * public String get_CWNDpeaks() { return pub_CWNDpeaks; }
+ */
+
+ public String get_SACKsRcvd() {
return Integer.toString(pub_SACKsRcvd);
- }
-
- public String get_osVer()
- {
+ }
+
+ public String get_osVer() {
return pub_osVer;
}

- public String get_javaVer()
- {
+ public String get_javaVer() {
return pub_javaVer;
}

- public String get_host()
- {
+ public String get_host() {
return pub_host;
}

- public String get_osName()
- {
+ public String get_osName() {
return pub_osName;
}

- public String get_osArch()
- {
+ public String get_osArch() {
return pub_osArch;
}

- public String get_mismatch()
- {
+ public String get_mismatch() {
String result;
- if (pub_mismatch==0) {
+ if (pub_mismatch == 0) {
result = "no";
} else {
result = "yes";
@@ -404,10 +382,9 @@
return result;
}

- public String get_Bad_cable()
- {
+ public String get_Bad_cable() {
String result;
- if (pub_Bad_cable ==1) {
+ if (pub_Bad_cable == 1) {
result = "yes";
} else {
result = "no";
@@ -415,8 +392,7 @@
return result;
}

- public String get_congestion()
- {
+ public String get_congestion() {
String result;
if (pub_congestion == 1) {
result = "yes";
@@ -426,171 +402,161 @@
return result;
}

- public String get_cwndtime()
- {
+ public String get_cwndtime() {
return Double.toString(pub_cwndtime);
}

- public String get_AccessTech()
- {
+ public String get_AccessTech() {
return pub_AccessTech;
}

- public String get_rcvrLimiting()
- {
- return Double.toString(pub_pctRcvrLimited);
+ public String get_rcvrLimiting() {
+ return Double.toString(pub_pctRcvrLimited);
}

- public String get_optimalRcvrBuffer()
- {
- return Integer.toString(pub_MaxRwinRcvd*1024);
+ public String get_optimalRcvrBuffer() {
+ return Integer.toString(pub_MaxRwinRcvd * 1024);
}

- public String get_clientIP()
- {
+ public String get_clientIP() {
return pub_clientIP;
}

- public String get_natStatus()
- {
+ public String get_natStatus() {
return pub_natBox;
}

- public String get_DupAcksOut()
- {
+ public String get_DupAcksOut() {
return Integer.toString(pub_DupAcksOut);
}

- public String get_TimeStamp()
- {
+ public String get_TimeStamp() {
String result = "unknown";
if (pub_TimeStamp != null) {
- result = pub_TimeStamp.toString();
+ result = pub_TimeStamp.toString();
}
return result;
}

- //commenting out unused method, but not removing in case of future use
- /*
- public String isReady()
- {
-
- // if ((pub_isReady == null) || (pub_isReady.equals(""))) {
- // pub_isReady = "no";
- // }
- // String result = "foo";
-
- //if (failed) {
- // pub_isReady = "failed1";
- //}
- //result = pub_isReady;
- // return result;
- return pub_isReady;
- }
- */
-
- public String get_jitter()
- {
+ // commenting out unused method, but not removing in case of future
use
+ /*
+ * public String isReady() {
+ *
+ * // if ((pub_isReady == null) || (pub_isReady.equals(""))) { //
+ * pub_isReady = "no"; // } // String result = "foo";
+ *
+ * //if (failed) { // pub_isReady = "failed1"; //} //result =
pub_isReady;
+ * // return result; return pub_isReady; }
+ */
+
+ public String get_jitter() {
return Integer.toString((pub_MaxRTT - pub_MinRTT));
}

- public String get_WaitSec()
- {
- return Integer.toString((pub_CurRTO * pub_Timeouts)/1000);
+ public String get_WaitSec() {
+ return Integer.toString((pub_CurRTO * pub_Timeouts) / 1000);
}

- public String get_errmsg()
- {
- //String result = "Test not run";
- //result = pub_errmsg;
- //return result;
+ public String get_errmsg() {
+ // String result = "Test not run";
+ // result = pub_errmsg;
+ // return result;
return pub_errmsg;
}

- public String get_diagnosis()
- {
+ public String get_diagnosis() {
return pub_diagnosis;
- }
-
- public String get_statistics()
- {
+ }
+
+ public String get_statistics() {
return pub_statistics;
- }
-
- public String get_status()
- {
+ }
+
+ public String get_status() {
return pub_status;
- }
-
- public String get_instSpeed()
- {
- return Double.toString((8.0 * pub_bytes) / (System.currentTimeMillis() - pub_time));
+ }
+
+ public String get_instSpeed() {
+ return Double.toString((8.0 * pub_bytes)
+ / (System.currentTimeMillis() - pub_time));
}

- /** Set UserAgent String containing browser details.
+ /**
+ * Set UserAgent String containing browser details.
+ *
* @return String UserAgent details set locally
- * @see UserAgentTools
+ * @see UserAgentTools
* */
public String getUserAgent() {
return _sUserAgent;
}

- /** Set UserAgent String.
- * @param paramStrUserAgent UserAgent String to be set locally
- * @see UserAgentTools
+ /**
+ * Set UserAgent String.
+ *
+ * @param paramStrUserAgent
+ * UserAgent String to be set locally
+ * @see UserAgentTools
* */
public void setUserAgent(String paramStrUserAgent) {
this._sUserAgent = paramStrUserAgent;
}

- /**
- * Get Client->Server fire-wall test results.
- * @return integer indicating C->S test results
- * */
+ /**
+ * Get Client->Server fire-wall test results.
+ *
+ * @return integer indicating C->S test results
+ * */
public int getC2sSFWTestResults() {
return this._iC2sSFWResult;
}

- /**
- * Set Client->Server fire-wall test results.
- * @param iParamC2SRes integer indicating C->S test results
- * */
+ /**
+ * Set Client->Server fire-wall test results.
+ *
+ * @param iParamC2SRes
+ * integer indicating C->S test results
+ * */
public void setC2sSFWTestResults(int iParamC2SRes) {
this._iC2sSFWResult = iParamC2SRes;
}

- /**
- * Get Server->Client fire-wall test results.
- * @return integer indicating C->S test results
- * */
+ /**
+ * Get Server->Client fire-wall test results.
+ *
+ * @return integer indicating C->S test results
+ * */
public int getS2cSFWTestResults() {
return this._iS2cSFWResult;
}

/**
- * Set server->Client fire-wall test results.
- * @param iParamS2CRes integer indicating C->S test results
- * */
+ * Set server->Client fire-wall test results.
+ *
+ * @param iParamS2CRes
+ * integer indicating C->S test results
+ * */
public void setS2cSFWTestResults(int iParamS2CRes) {
this._iS2cSFWResult = iParamS2CRes;
}
-
+
/*
- End of accessor methods
- **/
-
- /** Class to start tests in a thread.
- * Starts by disabling all buttons, and invokes the dottcp() method.
- * This thread is stopped when the number of tests that was configured to be
- * run have all completed, or if the user stops it by interrupting from the GUI.
- * Once the tests have been run, the buttons are enabled so that results can be
- * viewed in detail.
- * */
+ * End of accessor methods
+ */
+
+ /**
+ * Class to start tests in a thread. Starts by disabling all buttons,
and
+ * invokes the dottcp() method. This thread is stopped when the
number of
+ * tests that was configured to be run have all completed, or if the
user
+ * stops it by interrupting from the GUI. Once the tests have been run, the
+ * buttons are enabled so that results can be viewed in detail.
+ * */
class TestWorker implements Runnable {
public void run() {
if (!_bTestInProgress) {
int testNo = 1;
- int testsNum =
((Integer)_spinnerTestCount.getValue()).intValue();
+ int testsNum = ((Integer)
_spinnerTestCount.getValue())
+ .intValue();
_bTestInProgress = true;
createDiagnoseWindow();
createStatsWindow();
@@ -601,14 +567,17 @@
_buttonOptions.setEnabled(false);
_spinnerTestCount.setEnabled(false);

- //StatusPanel sPanel = new
StatusPanel(testsNum);
+ // StatusPanel sPanel = new
StatusPanel(testsNum);
// re-arch. Replaced above by the line below
String sTempEnable =
getParameter("enableMultipleTests");

- // create status panel based on whether
multiple tests are enabled
- // If not, then the progress bar displays just the specific test (middlebox, C2S, firewall etc)
- // If yes, then the progress bar also shows the progress on the number of tests
-
+ // create status panel based on whether
multiple tests are
+ // enabled
+ // If not, then the progress bar displays
just the specific test
+ // (middlebox, C2S, firewall etc)
+ // If yes, then the progress bar also shows
the progress on the
+ // number of tests
+
StatusPanel sPanel = new
StatusPanel(testsNum, sTempEnable);
getContentPane().add(BorderLayout.NORTH,
sPanel);
getContentPane().validate();
@@ -620,10 +589,17 @@
break;
}
if (testsNum == 0) {
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("startingTest") + " " + testNo + " **\n");
- }
- else {
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("startingTest") + " " + testNo + " " + _resBundDisplayMsgs.getString("of") + " " + testsNum + " **\n");
+
_resultsTxtPane.append("\n** "
+ +
_resBundDisplayMsgs
+
.getString("startingTest") + " "
+ + testNo +
" **\n");
+ } else {
+
_resultsTxtPane.append("\n** "
+ +
_resBundDisplayMsgs
+
.getString("startingTest") + " "
+ + testNo +
" "
+ +
_resBundDisplayMsgs.getString("of") + " "
+ + testsNum +
" **\n");
}
dottcp(sPanel);
// If test count scheduled is
complete, quit
@@ -639,57 +615,88 @@
// increment test count
testNo += 1;

- // This iteration of tests is now complete. Enable all buttons and output
+ // This iteration of tests is
now complete. Enable all
+ // buttons and output
// so that user can view
details of results

_buttonDetails.setEnabled(true);

_buttonStatistics.setEnabled(true);

_buttonMailTo.setEnabled(true);

_buttonOptions.setEnabled(true);
- _txtStatistics.append("\n** " + _resBundDisplayMsgs.getString("test") + " " + testNo + " **\n");
- _txtDiagnosis.append("\n** " + _resBundDisplayMsgs.getString("test") + " " + testNo + " **\n");
-
- // Now, sleep for some time based on user's choice before running the next
+ _txtStatistics.append("\n** "
+ +
_resBundDisplayMsgs.getString("test") + " "
+ + testNo + "
**\n");
+ _txtDiagnosis.append("\n** "
+ +
_resBundDisplayMsgs.getString("test") + " "
+ + testNo + "
**\n");
+
+ // Now, sleep for some time
based on user's choice
+ // before running the next
// iteration of the test suite
try {
switch
(_cmboboxDelay.getSelectedIndex()) {
case 1:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep1m") + " **\n");
+
_resultsTxtPane
+
.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep1m")
+
+ " **\n");

Thread.sleep(1000 * 60);
break;
case 2:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep5m") + " **\n");
+
_resultsTxtPane
+
.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep5m")
+
+ " **\n");

Thread.sleep(1000 * 60 * 5);
break;
case 3:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep10m") + " **\n");
+
_resultsTxtPane.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep10m")
+ +
" **\n");

Thread.sleep(1000 * 60 * 10);
break;
case 4:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep30m") + " **\n");
+
_resultsTxtPane.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep30m")
+ +
" **\n");

Thread.sleep(1000 * 60 * 30);
break;
case 5:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep2h") + " **\n");
+
_resultsTxtPane
+
.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep2h")
+
+ " **\n");

Thread.sleep(1000 * 60 * 120);
break;
case 6:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep12h") + " **\n");
+
_resultsTxtPane.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep12h")
+ +
" **\n");

Thread.sleep(1000 * 60 * 720);
break;
case 7:
- _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep1d") + " **\n");
+
_resultsTxtPane
+
.append("\n** "
+
+ _resBundDisplayMsgs
+
.getString("sleep1d")
+
+ " **\n");

Thread.sleep(1000 * 60 * 1440);
break;
}
- }
- catch (InterruptedException
e) {
+ } catch (InterruptedException
e) {
// do nothing.
}
}
- } catch(IOException e) {
+ } catch (IOException e) {
e.printStackTrace();
- _bFailed=true;
- _sErrMsg =
_resBundDisplayMsgs.getString("serverBusy30s") + "\n";
+ _bFailed = true;
+ _sErrMsg =
_resBundDisplayMsgs.getString("serverBusy30s")
+ + "\n";
}

// If test failed due to any reason, mark
failure reason too
@@ -700,14 +707,16 @@
pub_errmsg = _sErrMsg;
}

- // Enable all buttons. Continue activities to
mark status as complete
+ // Enable all buttons. Continue activities to
mark status as
+ // complete
_buttonDetails.setEnabled(true);
_buttonStatistics.setEnabled(true);
_buttonMailTo.setEnabled(true);
_buttonOptions.setEnabled(true);
_spinnerTestCount.setEnabled(true);

showStatus(_resBundDisplayMsgs.getString("done2"));
- _resultsTxtPane.append("\n" + _resBundDisplayMsgs.getString("clickStart2") + "\n");
+ _resultsTxtPane.append("\n"
+ +
_resBundDisplayMsgs.getString("clickStart2") + "\n");
_buttonStartTest.setEnabled(true);
_bTestInProgress = false;
getContentPane().remove(sPanel);
@@ -715,17 +724,16 @@
getContentPane().repaint();
}
}
- } //end inner class
-
-
- /**
+ } // end inner class
+
+ /**
* "Remote Control" function - invoke NDT' runtest() method from the
API
*/
- public void run_test()
- {
- // The Java security model considers calling a method that
opens a socket
- // from JavaScript to be a privileged action. By using
- // java.security.privilegedAction here, we can grant
JavaScript the
+ public void run_test() {
+ // The Java security model considers calling a method that
opens a
+ // socket
+ // from JavaScript to be a privileged action. By using
+ // java.security.privilegedAction here, we can grant
JavaScript the
// same expanded privileges as the signed applet to open a
socket.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -735,13 +743,12 @@
}
});
}
-

/**
* Initialize the base NDT window Applet init() method
*/
public void init() {
- if (getParameter("country") != null) {
+ if (getParameter("country") != null) {
_sCountry = getParameter("country");
}
if (getParameter("language") != null) {
@@ -776,32 +783,34 @@

}

- /** Initialize the "main" window.
- * The main window is composed of
- * 1. The results pane, which describes the process and displays their results
- * 2. The buttons pane, which houses all the buttons for various
options
- * //TODO :Can we move this to SwingUtilies? Plan for later release - it does'nt help
- //with understanding the functionality itself
- *
- * */
- private void createMainWindow () {
- // set content manager
+ /**
+ * Initialize the "main" window. The main window is composed of 1. The
+ * results pane, which describes the process and displays their
results 2.
+ * The buttons pane, which houses all the buttons for various options //TODO
+ * :Can we move this to SwingUtilies? Plan for later release - it
does'nt
+ * help //with understanding the functionality itself
+ *
+ * */
+ private void createMainWindow() {
+ // set content manager
getContentPane().setLayout(new BorderLayout());

// start with status set to "Ready" to perform tests
showStatus(_resBundDisplayMsgs.getString("ready"));

- // initialize
- _bFailed = false ;
- _bRandomize = false; //Seems unused after this. Retaining
either way
+ // initialize
***The diff for this file has been truncated for email.***
=======================================
--- /branches/kkumar_code_organize/Applet/UserAgentTools.java Wed Aug 24 13:30:34 2011
+++ /branches/kkumar_code_organize/Applet/UserAgentTools.java Wed Aug 24 13:48:59 2011
@@ -12,41 +12,50 @@

public class UserAgentTools {

- public static String getFirstVersionNumber(String a_userAgent, int a_position, int numDigits) {
+ public static String getFirstVersionNumber(String a_userAgent,
+ int a_position, int numDigits) {
String ver = getVersionNumber(a_userAgent, a_position);
- if (ver==null) return "";
+ if (ver == null)
+ return "";
int i = 0;
- String res="";
- while (i<ver.length() && i<numDigits) {
- res+=String.valueOf(ver.charAt(i));
+ String res = "";
+ while (i < ver.length() && i < numDigits) {
+ res += String.valueOf(ver.charAt(i));
i++;
}
return res;
}

public static String getVersionNumber(String a_userAgent, int a_position) {
- if (a_position<0) return "";
+ if (a_position < 0)
+ return "";
StringBuffer res = new StringBuffer();
int status = 0;

while (a_position < a_userAgent.length()) {
char c = a_userAgent.charAt(a_position);
switch (status) {
- case 0: //<SPAN class="codecomment"> No valid digits encountered yet</span>
- if (c == ' ' || c=='/') break;
- if (c == ';' || c==')') return "";
+ case 0: // <SPAN class="codecomment"> No valid digits
encountered
+ // yet</span>
+ if (c == ' ' || c == '/')
+ break;
+ if (c == ';' || c == ')')
+ return "";
status = 1;
- case 1: //<SPAN class="codecomment"> Version number in
progress</span>
- if (c == ';' || c=='/' || c==')' || c=='(' || c=='[') return res.toString().trim();
- if (c == ' ') status = 2;
+ case 1: // <SPAN class="codecomment"> Version number
in
+ // progress</span>
+ if (c == ';' || c == '/' || c == ')' || c ==
'(' || c == '[')
+ return res.toString().trim();
+ if (c == ' ')
+ status = 2;
res.append(c);
break;
- case 2: //<SPAN class="codecomment"> Space encountered - Might need to end the parsing</span>
- if ((Character.isLetter(c) &&
- Character.isLowerCase(c)) ||
- Character.isDigit(c)) {
+ case 2: // <SPAN class="codecomment"> Space
encountered - Might need
+ // to end the parsing</span>
+ if ((Character.isLetter(c) &&
Character.isLowerCase(c))
+ || Character.isDigit(c)) {
res.append(c);
- status=1;
+ status = 1;
} else
return res.toString().trim();
break;
@@ -56,364 +65,385 @@
return res.toString().trim();
}

- public static String[]getArray(String a, String b, String c) {
- String[]res = new String[3];
- res[0]=a;
- res[1]=b;
- res[2]=c;
+ public static String[] getArray(String a, String b, String c) {
+ String[] res = new String[3];
+ res[0] = a;
+ res[1] = b;
+ res[2] = c;
return res;
}

public static String[] getBotName(String userAgent) {
userAgent = userAgent.toLowerCase();
- int pos=0;
- String res=null;
- if ((pos=userAgent.indexOf("help.yahoo.com/"))>-1) {
- res= "Yahoo";
- pos+=7;
- } else if ((pos=userAgent.indexOf("google/"))>-1) {
- res= "Google";
- pos+=7;
- }
- else if ((pos=userAgent.indexOf("msnbot/"))>-1) {
- res= "MSNBot";
- pos+=7;
- }
- else if ((pos=userAgent.indexOf("googlebot/"))>-1) {
- res= "Google";
- pos+=10;
- }
- else if ((pos=userAgent.indexOf("webcrawler/"))>-1) {
- res= "WebCrawler";
- pos+=11;
- }
- else if ((pos=userAgent.indexOf("inktomi"))>-1) {
- //<SPAN class="codecomment"> The following two bots don't have any version number in their User-Agent strings.</span>
- res= "Inktomi";
- pos=-1;
- } else if ((pos=userAgent.indexOf("teoma"))>-1) {
- res= "Teoma";
- pos=-1;
- }
- if (res==null) return null;
- return getArray(res,res,res +
getVersionNumber(userAgent,pos));
- }
-
+ int pos = 0;
+ String res = null;
+ if ((pos = userAgent.indexOf("help.yahoo.com/")) > -1) {
+ res = "Yahoo";
+ pos += 7;
+ } else if ((pos = userAgent.indexOf("google/")) > -1) {
+ res = "Google";
+ pos += 7;
+ } else if ((pos = userAgent.indexOf("msnbot/")) > -1) {
+ res = "MSNBot";
+ pos += 7;
+ } else if ((pos = userAgent.indexOf("googlebot/")) > -1) {
+ res = "Google";
+ pos += 10;
+ } else if ((pos = userAgent.indexOf("webcrawler/")) > -1) {
+ res = "WebCrawler";
+ pos += 11;
+ } else if ((pos = userAgent.indexOf("inktomi")) > -1) {
+ // <SPAN class="codecomment"> The following two bots
don't have any
+ // version number in their User-Agent strings.</span>
+ res = "Inktomi";
+ pos = -1;
+ } else if ((pos = userAgent.indexOf("teoma")) > -1) {
+ res = "Teoma";
+ pos = -1;
+ }
+ if (res == null)
+ return null;
+ return getArray(res, res, res + getVersionNumber(userAgent,
pos));
+ }

public static String[] getOS(String userAgent) {
- if (getBotName(userAgent)!=null) return
getArray("Bot","Bot","Bot");
- String[]res = null;
+ if (getBotName(userAgent) != null)
+ return getArray("Bot", "Bot", "Bot");
+ String[] res = null;
int pos;
- if ((pos=userAgent.indexOf("Windows-NT"))>-1) {
- res =
getArray("Win","WinNT","Win"+getVersionNumber(userAgent,pos+8));
- }
- else if (userAgent.indexOf("Windows NT")>-1) {
- //<SPAN class="codecomment"> The different versions of Windows NT are decoded in the verbosity level 2</span>
- //<SPAN class="codecomment"> ie: Windows NT 5.1 = Windows
XP</span>
- if ((pos=userAgent.indexOf("Windows NT 5.1"))>-1) {
- res =
getArray("Win","WinXP","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows NT
6.0"))>-1) {
- res = getArray("Win","Vista","Vista"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows NT
6.1"))>-1) {
- res = getArray("Win","Seven","Seven "+getVersionNumber(userAgent,pos+7));
- } else if ((pos=userAgent.indexOf("Windows NT
5.0"))>-1) {
- res = getArray("Win","Win2000","Win"+getVersionNumber(userAgent,pos+7));
- } else if ((pos=userAgent.indexOf("Windows NT
5.2"))>-1) {
- res = getArray("Win","Win2003","Win"+getVersionNumber(userAgent,pos+7));
- } else if ((pos=userAgent.indexOf("Windows NT
4.0"))>-1) {
- res =
getArray("Win","WinNT4","Win"+getVersionNumber(userAgent,pos+7));
- } else if ((pos=userAgent.indexOf("Windows NT)"))>-1)
{
- res = getArray("Win","WinNT","WinNT");
- } else if ((pos=userAgent.indexOf("Windows NT;"))>-1)
{
- res = getArray("Win","WinNT","WinNT");
- }
- else {
- res = getArray("Win","WinNT?","WinNT?");
- }
- }
- else if (userAgent.indexOf("Win")>-1) {
- if (userAgent.indexOf("Windows")>-1) {
- if ((pos=userAgent.indexOf("Windows 98"))>-1)
{
- res =
getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if
((pos=userAgent.indexOf("Windows_98"))>-1) {
- res =
getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+8));
- }
- else if ((pos=userAgent.indexOf("Windows
2000"))>-1) {
- res = getArray("Win","Win2000","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows
95"))>-1) {
- res =
getArray("Win","Win95","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows
9x"))>-1) {
- res =
getArray("Win","Win9x","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows
ME"))>-1) {
- res =
getArray("Win","WinME","Win"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Windows
CE;"))>-1) {
- res = getArray("Win","WinCE","WinCE");
- }
- else if ((pos=userAgent.indexOf("Windows
3.1"))>-1) {
- res =
getArray("Win","Win31","Win"+getVersionNumber(userAgent,pos+7));
- }
- //<SPAN class="codecomment"> If no version was found, rely on the following code to detect "WinXX"</span>
- //<SPAN class="codecomment"> As some User-Agents include two references to Windows</span>
- //<SPAN class="codecomment"> Ex: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5)</span>
+ if ((pos = userAgent.indexOf("Windows-NT")) > -1) {
+ res = getArray("Win", "WinNT",
+ "Win" + getVersionNumber(userAgent,
pos + 8));
+ } else if (userAgent.indexOf("Windows NT") > -1) {
+ // <SPAN class="codecomment"> The different versions
of Windows NT
+ // are decoded in the verbosity level 2</span>
+ // <SPAN class="codecomment"> ie: Windows NT 5.1 = Windows
XP</span>
+ if ((pos = userAgent.indexOf("Windows NT 5.1")) > -1)
{
+ res = getArray("Win", "WinXP",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT 6.0"))
> -1) {
+ res = getArray("Win", "Vista",
+ "Vista" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT 6.1"))
> -1) {
+ res = getArray("Win", "Seven",
+ "Seven " +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT 5.0"))
> -1) {
+ res = getArray("Win", "Win2000",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT 5.2"))
> -1) {
+ res = getArray("Win", "Win2003",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT 4.0"))
> -1) {
+ res = getArray("Win", "WinNT4",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows NT)")) >
-1) {
+ res = getArray("Win", "WinNT", "WinNT");
+ } else if ((pos = userAgent.indexOf("Windows NT;")) >
-1) {
+ res = getArray("Win", "WinNT", "WinNT");
+ } else {
+ res = getArray("Win", "WinNT?", "WinNT?");
+ }
+ } else if (userAgent.indexOf("Win") > -1) {
+ if (userAgent.indexOf("Windows") > -1) {
+ if ((pos = userAgent.indexOf("Windows 98")) >
-1) {
+ res = getArray("Win", "Win98",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos =
userAgent.indexOf("Windows_98")) > -1) {
+ res = getArray("Win", "Win98",
+ "Win" +
getVersionNumber(userAgent, pos + 8));
+ } else if ((pos = userAgent.indexOf("Windows
2000")) > -1) {
+ res = getArray("Win", "Win2000",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows
95")) > -1) {
+ res = getArray("Win", "Win95",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows
9x")) > -1) {
+ res = getArray("Win", "Win9x",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows
ME")) > -1) {
+ res = getArray("Win", "WinME",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Windows
CE;")) > -1) {
+ res = getArray("Win", "WinCE",
"WinCE");
+ } else if ((pos = userAgent.indexOf("Windows
3.1")) > -1) {
+ res = getArray("Win", "Win31",
+ "Win" +
getVersionNumber(userAgent, pos + 7));
+ }
+ // <SPAN class="codecomment"> If no version
was found, rely on
+ // the following code to detect "WinXX"</span>
+ // <SPAN class="codecomment"> As some
User-Agents include two
+ // references to Windows</span>
+ // <SPAN class="codecomment"> Ex: Mozilla/5.0
(Windows; U;
+ // Win98; en-US; rv:1.5)</span>
}
if (res == null) {
- if ((pos=userAgent.indexOf("Win98"))>-1) {
- res =
getArray("Win","Win98","Win"+getVersionNumber(userAgent,pos+3));
- }
- else if ((pos=userAgent.indexOf("Win31"))>-1)
{
- res =
getArray("Win","Win31","Win"+getVersionNumber(userAgent,pos+3));
- }
- else if ((pos=userAgent.indexOf("Win95"))>-1)
{
- res =
getArray("Win","Win95","Win"+getVersionNumber(userAgent,pos+3));
- }
- else if ((pos=userAgent.indexOf("Win
9x"))>-1) {
- res =
getArray("Win","Win9x","Win"+getVersionNumber(userAgent,pos+3));
- } else if
((pos=userAgent.indexOf("WinNT4.0"))>-1) {
- res = getArray("Win","WinNT4","Win"+getVersionNumber(userAgent,pos+3));
- }
- else if ((pos=userAgent.indexOf("WinNT"))>-1)
{
- res =
getArray("Win","WinNT","Win"+getVersionNumber(userAgent,pos+3));
+ if ((pos = userAgent.indexOf("Win98")) > -1) {
+ res = getArray("Win", "Win98",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("Win31"))
> -1) {
+ res = getArray("Win", "Win31",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("Win95"))
> -1) {
+ res = getArray("Win", "Win95",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("Win 9x"))
> -1) {
+ res = getArray("Win", "Win9x",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("WinNT4.0"))
> -1) {
+ res = getArray("Win", "WinNT4",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("WinNT"))
> -1) {
+ res = getArray("Win", "WinNT",
+ "Win" +
getVersionNumber(userAgent, pos + 3));
}
}
if (res == null) {
- if ((pos=userAgent.indexOf("Windows"))>-1) {
- res =
getArray("Win","Win?","Win?"+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Win"))>-1) {
- res =
getArray("Win","Win?","Win?"+getVersionNumber(userAgent,pos+3));
- }
- else
- //<SPAN class="codecomment"> Should not
happen at this point</span>
- res = getArray("Win","Win?","Win?");
- }
- } else
- if ((pos=userAgent.indexOf("Mac OS X"))>-1) {
- if ((userAgent.indexOf("iPhone"))>-1) {
- pos = userAgent.indexOf("iPhone OS");
- if ((userAgent.indexOf("iPod"))>-1) {
- res = getArray("iOS","iOS-iPod","iOS-iPod "+((pos<0)?"":getVersionNumber(userAgent,pos+9)));
- }
- else {
- res = getArray("iOS","iOS-iPhone","iOS-iPhone "+((pos<0)?"":getVersionNumber(userAgent,pos+9)));
- }
- }
- else if ((userAgent.indexOf("iPad"))>-1) {
- pos = userAgent.indexOf("CPU OS");
- res = getArray("iOS","iOS-iPad","iOS-iPad "+((pos<0)?"":getVersionNumber(userAgent,pos+6)));
- }
- else
- res = getArray("Mac","MacOSX","MacOS "+getVersionNumber(userAgent,pos+8));
- }
- else if ((pos=userAgent.indexOf("Android"))>-1) {
- res = getArray("Linux","Android","Android "+getVersionNumber(userAgent,pos+8));
- }
- else if ((pos=userAgent.indexOf("Mac_PowerPC"))>-1) {
- res = getArray("Mac","MacPPC","MacOS "+getVersionNumber(userAgent,pos+3));
- }
- else if ((pos=userAgent.indexOf("Macintosh"))>-1) {
- if (userAgent.indexOf("PPC")>-1)
- res = getArray("Mac","MacPPC","Mac
PPC");
- else
- res =
getArray("Mac?","Mac?","MacOS?");
- }
- else if ((pos=userAgent.indexOf("FreeBSD"))>-1) {
- res = getArray("*BSD","*BSD FreeBSD","FreeBSD "+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("OpenBSD"))>-1) {
- res = getArray("*BSD","*BSD OpenBSD","OpenBSD "+getVersionNumber(userAgent,pos+7));
- }
- else if ((pos=userAgent.indexOf("Linux"))>-1) {
- String detail = "Linux
"+getVersionNumber(userAgent,pos+5);
- String med = "Linux";
- if ((pos=userAgent.indexOf("Ubuntu/"))>-1) {
- detail = "Ubuntu
"+getVersionNumber(userAgent,pos+7);
- med+=" Ubuntu";
- }
- res = getArray("Linux",med,detail);
- }
- else if ((pos=userAgent.indexOf("CentOS"))>-1) {
- res = getArray("Linux","Linux
CentOS","CentOS");
- }
- else if ((pos=userAgent.indexOf("NetBSD"))>-1) {
- res = getArray("*BSD","*BSD NetBSD","NetBSD "+getVersionNumber(userAgent,pos+6));
- }
- else if ((pos=userAgent.indexOf("Unix"))>-1) {
- res = getArray("Linux","Linux","Linux "+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("SunOS"))>-1) {
- res = getArray("Unix","SunOS","SunOS"+getVersionNumber(userAgent,pos+5));
- }
- else if ((pos=userAgent.indexOf("IRIX"))>-1) {
- res =
getArray("Unix","IRIX","IRIX"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("SonyEricsson"))>-1) {
- res = getArray("SonyEricsson","SonyEricsson","SonyEricsson"+getVersionNumber(userAgent,pos+12));
- }
- else if ((pos=userAgent.indexOf("Nokia"))>-1) {
- res = getArray("Nokia","Nokia","Nokia"+getVersionNumber(userAgent,pos+5));
- }
- else if ((pos=userAgent.indexOf("BlackBerry"))>-1) {
- res = getArray("BlackBerry","BlackBerry","BlackBerry"+getVersionNumber(userAgent,pos+10));
- }
- else if ((pos=userAgent.indexOf("SymbianOS"))>-1) {
- res = getArray("SymbianOS","SymbianOS","SymbianOS"+getVersionNumber(userAgent,pos+10));
- }
- else if ((pos=userAgent.indexOf("BeOS"))>-1) {
- res = getArray("BeOS","BeOS","BeOS");
- }
- else if ((pos=userAgent.indexOf("Nintendo Wii"))>-1) {
- res = getArray("Nintendo Wii","Nintendo Wii","Nintendo Wii"+getVersionNumber(userAgent,pos+10));
- }
- else if ((pos=userAgent.indexOf("J2ME/MIDP"))>-1) {
- res = getArray("Java","J2ME","J2ME/MIDP");
- }
+ if ((pos = userAgent.indexOf("Windows")) >
-1) {
+ res = getArray("Win", "Win?",
+ "Win?" +
getVersionNumber(userAgent, pos + 7));
+ } else if ((pos = userAgent.indexOf("Win")) >
-1) {
+ res = getArray("Win", "Win?",
+ "Win?" +
getVersionNumber(userAgent, pos + 3));
+ } else
+ // <SPAN class="codecomment"> Should
not happen at this
+ // point</span>
+ res = getArray("Win", "Win?", "Win?");
+ }
+ } else if ((pos = userAgent.indexOf("Mac OS X")) > -1) {
+ if ((userAgent.indexOf("iPhone")) > -1) {
+ pos = userAgent.indexOf("iPhone OS");
+ if ((userAgent.indexOf("iPod")) > -1) {
+ res = getArray(
+ "iOS",
+ "iOS-iPod",
+ "iOS-iPod "
+ + ((pos < 0) ?
"" : getVersionNumber(
+
userAgent, pos + 9)));
+ } else {
+ res = getArray(
+ "iOS",
+ "iOS-iPhone",
+ "iOS-iPhone "
+ + ((pos < 0) ?
"" : getVersionNumber(
+
userAgent, pos + 9)));
+ }
+ } else if ((userAgent.indexOf("iPad")) > -1) {
+ pos = userAgent.indexOf("CPU OS");
+ res = getArray("iOS", "iOS-iPad", "iOS-iPad "
+ + ((pos < 0) ? ""
+ :
getVersionNumber(userAgent, pos + 6)));
+ } else
+ res = getArray("Mac", "MacOSX",
+ "MacOS " +
getVersionNumber(userAgent, pos + 8));
+ } else if ((pos = userAgent.indexOf("Android")) > -1) {
+ res = getArray("Linux", "Android",
+ "Android " +
getVersionNumber(userAgent, pos + 8));
+ } else if ((pos = userAgent.indexOf("Mac_PowerPC")) > -1) {
+ res = getArray("Mac", "MacPPC",
+ "MacOS " +
getVersionNumber(userAgent, pos + 3));
+ } else if ((pos = userAgent.indexOf("Macintosh")) > -1) {
+ if (userAgent.indexOf("PPC") > -1)
+ res = getArray("Mac", "MacPPC", "Mac PPC");
else
- res = getArray("?","?","?");
+ res = getArray("Mac?", "Mac?", "MacOS?");
+ } else if ((pos = userAgent.indexOf("FreeBSD")) > -1) {
+ res = getArray("*BSD", "*BSD FreeBSD", "FreeBSD "
+ + getVersionNumber(userAgent, pos +
7));
+ } else if ((pos = userAgent.indexOf("OpenBSD")) > -1) {
+ res = getArray("*BSD", "*BSD OpenBSD", "OpenBSD "
+ + getVersionNumber(userAgent, pos +
7));
+ } else if ((pos = userAgent.indexOf("Linux")) > -1) {
+ String detail = "Linux " +
getVersionNumber(userAgent, pos + 5);
+ String med = "Linux";
+ if ((pos = userAgent.indexOf("Ubuntu/")) > -1) {
+ detail = "Ubuntu " +
getVersionNumber(userAgent, pos + 7);
+ med += " Ubuntu";
+ }
+ res = getArray("Linux", med, detail);
+ } else if ((pos = userAgent.indexOf("CentOS")) > -1) {
+ res = getArray("Linux", "Linux CentOS", "CentOS");
+ } else if ((pos = userAgent.indexOf("NetBSD")) > -1) {
+ res = getArray("*BSD", "*BSD NetBSD",
+ "NetBSD " +
getVersionNumber(userAgent, pos + 6));
+ } else if ((pos = userAgent.indexOf("Unix")) > -1) {
+ res = getArray("Linux", "Linux",
+ "Linux " +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("SunOS")) > -1) {
+ res = getArray("Unix", "SunOS",
+ "SunOS" + getVersionNumber(userAgent,
pos + 5));
+ } else if ((pos = userAgent.indexOf("IRIX")) > -1) {
+ res = getArray("Unix", "IRIX",
+ "IRIX" + getVersionNumber(userAgent,
pos + 4));
+ } else if ((pos = userAgent.indexOf("SonyEricsson")) > -1) {
+ res = getArray("SonyEricsson", "SonyEricsson",
"SonyEricsson"
+ + getVersionNumber(userAgent, pos +
12));
+ } else if ((pos = userAgent.indexOf("Nokia")) > -1) {
+ res = getArray("Nokia", "Nokia",
+ "Nokia" + getVersionNumber(userAgent,
pos + 5));
+ } else if ((pos = userAgent.indexOf("BlackBerry")) > -1) {
+ res = getArray("BlackBerry", "BlackBerry",
"BlackBerry"
+ + getVersionNumber(userAgent, pos +
10));
+ } else if ((pos = userAgent.indexOf("SymbianOS")) > -1) {
+ res = getArray("SymbianOS", "SymbianOS", "SymbianOS"
+ + getVersionNumber(userAgent, pos +
10));
+ } else if ((pos = userAgent.indexOf("BeOS")) > -1) {
+ res = getArray("BeOS", "BeOS", "BeOS");
+ } else if ((pos = userAgent.indexOf("Nintendo Wii")) > -1) {
+ res = getArray("Nintendo Wii", "Nintendo Wii", "Nintendo
Wii"
+ + getVersionNumber(userAgent, pos +
10));
+ } else if ((pos = userAgent.indexOf("J2ME/MIDP")) > -1) {
+ res = getArray("Java", "J2ME", "J2ME/MIDP");
+ } else
+ res = getArray("?", "?", "?");
return res;
}

-
- public static String []getBrowser(String userAgent) {
+ public static String[] getBrowser(String userAgent) {
if (userAgent == null) {
- return getArray("?","?","?");
- }
- String []botName;
- if ((botName=getBotName(userAgent))!=null) return botName;
- String[]res = null;
+ return getArray("?", "?", "?");
+ }
+ String[] botName;
+ if ((botName = getBotName(userAgent)) != null)
+ return botName;
+ String[] res = null;
int pos;
- if ((pos=userAgent.indexOf("Lotus-Notes/"))>-1) {
- res = getArray("LotusNotes","LotusNotes","LotusNotes"+getVersionNumber(userAgent,pos+12));
- } else
- if ((pos=userAgent.indexOf("Opera"))>-1) {
- String ver =
getVersionNumber(userAgent,pos+5);
- res = getArray("Opera","Opera"+getFirstVersionNumber(userAgent,pos+5,1),"Opera"+ver);
- if ((pos=userAgent.indexOf("Opera
Mini/"))>-1) {
- String ver2 =
getVersionNumber(userAgent,pos+11);
- res = getArray("Opera","Opera Mini","Opera
Mini "+ver2);
- }
- else if ((pos=userAgent.indexOf("Opera
Mobi/"))>-1) {
- String ver2 =
getVersionNumber(userAgent,pos+11);
- res = getArray("Opera","Opera Mobi","Opera
Mobi "+ver2);
- }
- }
- else if (userAgent.indexOf("MSIE")>-1) {
- if ((pos=userAgent.indexOf("MSIE 6.0"))>-1) {
- res = getArray("MSIE","MSIE6","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE
5.0"))>-1) {
- res = getArray("MSIE","MSIE5","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE
5.5"))>-1) {
- res = getArray("MSIE","MSIE5.5","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE
5."))>-1) {
- res = getArray("MSIE","MSIE5.x","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE
4"))>-1) {
- res = getArray("MSIE","MSIE4","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE 7"))>-1 && userAgent.indexOf("Trident/4.0")<0) {
- res = getArray("MSIE","MSIE7","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE 8"))>-1 || userAgent.indexOf("Trident/4.0")>-1) {
- res = getArray("MSIE","MSIE8","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else if ((pos=userAgent.indexOf("MSIE 9"))>-1 || userAgent.indexOf("Trident/4.0")>-1) {
- res = getArray("MSIE","MSIE9","MSIE"+getVersionNumber(userAgent,pos+4));
- }
- else
- res = getArray("MSIE","MSIE?","MSIE?"+getVersionNumber(userAgent,userAgent.indexOf("MSIE")+4));
- }
- else if ((pos=userAgent.indexOf("Gecko/"))>-1) {
- res = getArray("Gecko","Gecko","Gecko"+getFirstVersionNumber(userAgent,pos+5,4));
- if ((pos=userAgent.indexOf("Camino/"))>-1) {
- res[1]+="(Camino)";
-
res[2]+="(Camino"+getVersionNumber(userAgent,pos+7)+")";
- }
- else if
((pos=userAgent.indexOf("Chimera/"))>-1) {
- res[1]+="(Chimera)";
-
res[2]+="(Chimera"+getVersionNumber(userAgent,pos+8)+")";
- }
- else if
((pos=userAgent.indexOf("Firebird/"))>-1) {
- res[1]+="(Firebird)";
-
res[2]+="(Firebird"+getVersionNumber(userAgent,pos+9)+")";
- }
- else if
((pos=userAgent.indexOf("Phoenix/"))>-1) {
- res[1]+="(Phoenix)";
-
res[2]+="(Phoenix"+getVersionNumber(userAgent,pos+8)+")";
- }
- else if
((pos=userAgent.indexOf("Galeon/"))>-1) {
- res[1]+="(Galeon)";
-
res[2]+="(Galeon"+getVersionNumber(userAgent,pos+7)+")";
- }
- else if
((pos=userAgent.indexOf("Firefox/"))>-1) {
- res[1]+="(Firefox)";
-
res[2]+="(Firefox"+getVersionNumber(userAgent,pos+8)+")";
- }
- else if
((pos=userAgent.indexOf("Netscape/"))>-1) {
- if
((pos=userAgent.indexOf("Netscape/6"))>-1) {
- res[1]+="(NS6)";
-
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
- }
- else if
((pos=userAgent.indexOf("Netscape/7"))>-1) {
- res[1]+="(NS7)";
-
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
- }
- else if
((pos=userAgent.indexOf("Netscape/8"))>-1) {
- res[1]+="(NS8)";
-
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
- }
- else if
((pos=userAgent.indexOf("Netscape/9"))>-1) {
- res[1]+="(NS9)";
-
res[2]+="(NS"+getVersionNumber(userAgent,pos+9)+")";
- }
- else {
- res[1]+="(NS?)";
- res[2]+="(NS?"+getVersionNumber(userAgent,userAgent.indexOf("Netscape/")+9)+")";
- }
- }
+ if ((pos = userAgent.indexOf("Lotus-Notes/")) > -1) {
+ res = getArray("LotusNotes", "LotusNotes",
"LotusNotes"
+ + getVersionNumber(userAgent, pos +
12));
+ } else if ((pos = userAgent.indexOf("Opera")) > -1) {
+ String ver = getVersionNumber(userAgent, pos + 5);
+ res = getArray("Opera",
+ "Opera" +
getFirstVersionNumber(userAgent, pos + 5, 1),
+ "Opera" + ver);
+ if ((pos = userAgent.indexOf("Opera Mini/")) > -1) {
+ String ver2 = getVersionNumber(userAgent, pos
+ 11);
+ res = getArray("Opera", "Opera Mini", "Opera Mini
" + ver2);
+ } else if ((pos = userAgent.indexOf("Opera Mobi/")) >
-1) {
+ String ver2 = getVersionNumber(userAgent, pos
+ 11);
+ res = getArray("Opera", "Opera Mobi", "Opera Mobi
" + ver2);
+ }
+ } else if (userAgent.indexOf("MSIE") > -1) {
+ if ((pos = userAgent.indexOf("MSIE 6.0")) > -1) {
+ res = getArray("MSIE", "MSIE6",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 5.0")) >
-1) {
+ res = getArray("MSIE", "MSIE5",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 5.5")) >
-1) {
+ res = getArray("MSIE", "MSIE5.5",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 5.")) > -1)
{
+ res = getArray("MSIE", "MSIE5.x",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 4")) > -1) {
+ res = getArray("MSIE", "MSIE4",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 7")) > -1
+ && userAgent.indexOf("Trident/4.0") <
0) {
+ res = getArray("MSIE", "MSIE7",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 8")) > -1
+ || userAgent.indexOf("Trident/4.0") >
-1) {
+ res = getArray("MSIE", "MSIE8",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else if ((pos = userAgent.indexOf("MSIE 9")) > -1
+ || userAgent.indexOf("Trident/4.0") >
-1) {
+ res = getArray("MSIE", "MSIE9",
+ "MSIE" +
getVersionNumber(userAgent, pos + 4));
+ } else
+ res = getArray(
+ "MSIE",
+ "MSIE?",
+ "MSIE?"
+ +
getVersionNumber(userAgent,
+
userAgent.indexOf("MSIE") + 4));
+ } else if ((pos = userAgent.indexOf("Gecko/")) > -1) {
+ res = getArray("Gecko", "Gecko",
+ "Gecko" +
getFirstVersionNumber(userAgent, pos + 5, 4));
+ if ((pos = userAgent.indexOf("Camino/")) > -1) {
+ res[1] += "(Camino)";
+ res[2] += "(Camino" +
getVersionNumber(userAgent, pos + 7)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Chimera/")) >
-1) {
+ res[1] += "(Chimera)";
+ res[2] += "(Chimera" +
getVersionNumber(userAgent, pos + 8)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Firebird/")) >
-1) {
+ res[1] += "(Firebird)";
+ res[2] += "(Firebird" +
getVersionNumber(userAgent, pos + 9)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Phoenix/")) >
-1) {
+ res[1] += "(Phoenix)";
+ res[2] += "(Phoenix" +
getVersionNumber(userAgent, pos + 8)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Galeon/")) > -1)
{
+ res[1] += "(Galeon)";
+ res[2] += "(Galeon" +
getVersionNumber(userAgent, pos + 7)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Firefox/")) >
-1) {
+ res[1] += "(Firefox)";
+ res[2] += "(Firefox" +
getVersionNumber(userAgent, pos + 8)
+ + ")";
+ } else if ((pos = userAgent.indexOf("Netscape/")) >
-1) {
+ if ((pos = userAgent.indexOf("Netscape/6")) >
-1) {
+ res[1] += "(NS6)";
+ res[2] += "(NS" +
getVersionNumber(userAgent, pos + 9)
+ + ")";
+ } else if ((pos =
userAgent.indexOf("Netscape/7")) > -1) {
+ res[1] += "(NS7)";
+ res[2] += "(NS" +
getVersionNumber(userAgent, pos + 9)
+ + ")";
+ } else if ((pos =
userAgent.indexOf("Netscape/8")) > -1) {
+ res[1] += "(NS8)";
+ res[2] += "(NS" +
getVersionNumber(userAgent, pos + 9)
+ + ")";
+ } else if ((pos =
userAgent.indexOf("Netscape/9")) > -1) {
+ res[1] += "(NS9)";
+ res[2] += "(NS" +
getVersionNumber(userAgent, pos + 9)
+ + ")";
+ } else {
+ res[1] += "(NS?)";
+ res[2] += "(NS?"
+ +
getVersionNumber(userAgent,
+
userAgent.indexOf("Netscape/") + 9) + ")";
+ }
+ }
+ } else if ((pos = userAgent.indexOf("Netscape/")) > -1) {
+ if ((pos = userAgent.indexOf("Netscape/4")) > -1) {
+ res = getArray("NS", "NS4",
+ "NS" +
getVersionNumber(userAgent, pos + 9));
} else
- if ((pos=userAgent.indexOf("Netscape/"))>-1) {
- if
((pos=userAgent.indexOf("Netscape/4"))>-1) {
- res =
getArray("NS","NS4","NS"+getVersionNumber(userAgent,pos+9));
- }
- else
- res =
getArray("NS","NS?","NS?"+getVersionNumber(userAgent,pos+9));
- }
- else if
((pos=userAgent.indexOf("Chrome/"))>-1) {
- res = getArray("KHTML","KHTML(Chrome)","KHTML(Chrome"+getVersionNumber(userAgent,pos+6)+")");
- }
- else if
((pos=userAgent.indexOf("Safari/"))>-1) {
- res = getArray("KHTML","KHTML(Safari)","KHTML(Safari"+getVersionNumber(userAgent,pos+6)+")");
- }
- else if
((pos=userAgent.indexOf("Konqueror/"))>-1) {
- res = getArray("KHTML","KHTML(Konqueror)","KHTML(Konqueror"+getVersionNumber(userAgent,pos+9)+")");
- }
- else if ((pos=userAgent.indexOf("KHTML"))>-1)
{
- res = getArray("KHTML","KHTML?","KHTML?("+getVersionNumber(userAgent,pos+5)+")");
- }
- else if
((pos=userAgent.indexOf("NetFront"))>-1) {
- res = getArray("NetFront","NetFront","NetFront "+getVersionNumber(userAgent,pos+8));
- }
- else if
((pos=userAgent.indexOf("BlackBerry"))>-1) {
- pos=userAgent.indexOf("/",pos+2);
- res = getArray("BlackBerry","BlackBerry","BlackBerry"+getVersionNumber(userAgent,pos+1));
- }
- else if (userAgent.indexOf("Mozilla/4.")==0 &&
- userAgent.indexOf("Mozilla/4.0")<0
&&
- userAgent.indexOf("Mozilla/4.5
")<0) {
- //<SPAN class="codecomment"> We will interpret Mozilla/4.x as Netscape Communicator is and only if x</span>
- //<SPAN class="codecomment"> is not 0 or
5</span>
- res = getArray("Communicator","Communicator","Communicator"+getVersionNumber(userAgent,pos+8));
- }
- else return getArray("?","?","?");
+ res = getArray("NS", "NS?",
+ "NS?" +
getVersionNumber(userAgent, pos + 9));
+ } else if ((pos = userAgent.indexOf("Chrome/")) > -1) {
+ res = getArray("KHTML", "KHTML(Chrome)",
"KHTML(Chrome"
+ + getVersionNumber(userAgent, pos + 6) +
")");
+ } else if ((pos = userAgent.indexOf("Safari/")) > -1) {
+ res = getArray("KHTML", "KHTML(Safari)",
"KHTML(Safari"
+ + getVersionNumber(userAgent, pos + 6) +
")");
+ } else if ((pos = userAgent.indexOf("Konqueror/")) > -1) {
+ res = getArray("KHTML", "KHTML(Konqueror)",
"KHTML(Konqueror"
+ + getVersionNumber(userAgent, pos + 9) +
")");
+ } else if ((pos = userAgent.indexOf("KHTML")) > -1) {
+ res = getArray("KHTML", "KHTML?",
+ "KHTML?(" + getVersionNumber(userAgent, pos +
5) + ")");
+ } else if ((pos = userAgent.indexOf("NetFront")) > -1) {
+ res = getArray("NetFront", "NetFront", "NetFront "
+ + getVersionNumber(userAgent, pos +
8));
+ } else if ((pos = userAgent.indexOf("BlackBerry")) > -1) {
+ pos = userAgent.indexOf("/", pos + 2);
+ res = getArray("BlackBerry", "BlackBerry",
"BlackBerry"
+ + getVersionNumber(userAgent, pos +
1));
+ } else if (userAgent.indexOf("Mozilla/4.") == 0
+ && userAgent.indexOf("Mozilla/4.0") < 0
+ && userAgent.indexOf("Mozilla/4.5 ") < 0) {
+ // <SPAN class="codecomment"> We will interpret
Mozilla/4.x as
+ // Netscape Communicator is and only if x</span>
+ // <SPAN class="codecomment"> is not 0 or 5</span>
+ res = getArray("Communicator", "Communicator",
"Communicator"
+ + getVersionNumber(userAgent, pos +
8));
+ } else
+ return getArray("?", "?", "?");
return res;
}
}


  • [ndt-dev] [ndt] r532 committed - Formatting changes for all files, ndt, 08/24/2011

Archive powered by MHonArc 2.6.16.

Top of Page