Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r531 committed - NDTConstants.java: Deleted comment about data member access, which is ...

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r531 committed - NDTConstants.java: Deleted comment about data member access, which is ...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r531 committed - NDTConstants.java: Deleted comment about data member access, which is ...
  • Date: Wed, 24 Aug 2011 20:30:53 +0000

Revision: 531
Author:

Date: Wed Aug 24 13:30:34 2011
Log: NDTConstants.java: Deleted comment about data member access, which is better as a commit log. More constants introduced in this class to define Data rates etc. All constants have been classified under section headers.

UserAgentTools.java : Deleted comment "Has been moved out and made into a non-static outer class that can be replaced more quickly, if need be", which is better as a commit log.

All other files: Implemented suggestions from Thomas

http://code.google.com/p/ndt/source/detail?r=531

Modified:
/branches/kkumar_code_organize/Applet/Message.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 Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/Message.java Wed Aug 24 13:30:34 2011
@@ -1,62 +1,96 @@
-/* Class to define Message.
- * Messages are composed of a "type" and a body
- * Some examples of message types are : COMM_FAILURE, SRV_QUEUE, MSG_LOGIN, TEST_PREPARE etc
- * @see MessageType.java for more examples
- * Messages are defined to have a "length" field too. Currently, 2 bytes of the the message
- * "body" byte array are often used to store length (second/third array positions , for example)
- *
- * TODO: It may be worthwhile exploring whether MessageTypes could be merged into here instead of NDTConstants.
- * . For a later release
+/**
+ * Class to define Message. Messages are composed of a "type" and a body. Some
+ * examples of message types are : COMM_FAILURE, SRV_QUEUE, MSG_LOGIN,
+ * TEST_PREPARE. Messages are defined to have a "length" field too. Currently, 2
+ * 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.
+ *
+ * @see MessageType for more Message Types.
*
*/
public class Message {

- //TODO: Could make these private and test changes in Protocol class. For later release
+ // TODO: Could make these private and test changes in Protocol class.
For
+ // later release
byte _yType;
byte[] _yaBody;

- /* Getter method to get Message Type
- * @param: none
- * @return byte indicating Message Type
- * */
+ /**
+ * Get Message Type
+ *
+ * @return byte indicating Message Type
+ * */
public byte getType() {
return _yType;
}

- /* Setter method to set Message Type
- * @return: none
- * @param byte indicating Message Type
- * */
+ /**
+ * Set Message Type
+ *
+ * @param bParamType
+ * byte indicating Message Type
+ * */
public void setType(byte bParamType) {
this._yType = bParamType;
}

- /* Getter method to get Message body
- * @return: byte array message body
- * @param none
- * */
+ /**
+ * Get Message body as array
+ *
+ * @return byte array message body
+ * */
public byte[] getBody() {
return _yaBody;
}

- /* Setter method to get Message body
- * @param iParamSize : byte array size
- * @param byte array message body
- * @return: none
- * */
+ /**
+ * Set Message body, given a byte array input
+ *
+ * @param baParamBody
+ * message body byte array
+ *
+ * */
+ public void setBody(byte[] baParamBody) {
+ int iParamSize = 0;
+ if (baParamBody != null) {
+ iParamSize = baParamBody.length;
+ }
+ _yaBody = new byte[iParamSize];
+ System.arraycopy(baParamBody, 0, _yaBody, 0, iParamSize);
+ }
+
+ /**
+ * 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
+ * @param baParamBody
+ * message body byte array
+ *
+ * */
public void setBody(byte[] baParamBody, int iParamSize) {
_yaBody = new byte[iParamSize];
System.arraycopy(baParamBody, 0, _yaBody, 0, iParamSize);
}

-
- /* Utility method to initialize Message body
- * @param iParamSize : byte array size
- * @return: none
- * */
+ /**
+ * Utility method to initialize Message body
+ *
+ * @param iParamSize
+ * byte array size
+ *
+ * */
public void initBodySize(int iParamSize) {
- this._yaBody = new byte[iParamSize];
- }
-
+ this._yaBody = new byte[iParamSize];
+ }

}
=======================================
--- /branches/kkumar_code_organize/Applet/NDTConstants.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/NDTConstants.java Wed Aug 24 13:30:34 2011
@@ -3,35 +3,30 @@

import javax.swing.JOptionPane;

-/**
- *
- */
-
/**
*
- * Class to hold constants, mostly those that are "non-protocol" related
- * The different sections of constants are enlisted under appropriate "sections"
- * If necessary, these sections can be broken off later into different files for
- * better readability
+ * 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".
*
- * Changed access specifier of constants to public from private. These are static message
- * types and not data members, and having public access privilege will not affect
- * encapsulation
*/
public class NDTConstants {

- //Section: System variables
- //used by the META tests
+ // 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 Check if version could be moved to some "configurable" or "property" area
+ /* 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";
-
- //Section: Test type
- //TODO: TestType class?
+
+ public static final String NDT_TITLE_STR = "TCP/Web100 Network Diagnostic Tool v";
+
+ // Section: Test type
public static final byte TEST_MID = (1 << 0);
public static final byte TEST_C2S = (1 << 1);
public static final byte TEST_S2C = (1 << 2);
@@ -39,7 +34,7 @@
public static final byte TEST_STATUS = (1 << 4);
public static final byte TEST_META = (1 << 5);

- //Section: Firewall test status
+ // Section: Firewall test status
public static final int SFW_NOTTESTED = 0;
public static final int SFW_NOFIREWALL = 1;
public static final int SFW_UNKNOWN = 2;
@@ -47,53 +42,83 @@

public static final double VIEW_DIFF = 0.1;

- //
- public static String TARGET1 = "U";
- public static String TARGET2 = "H";
-
- //NDT pre-fixed port ID
+ public static final String TARGET1 = "U";
+ public static final String TARGET2 = "H";
+
+ // NDT pre-fixed port ID
public static final int CONTROL_PORT_DEFAULT = 3001;

- //SRV-QUEUE message status constants
+ // Section: SRV-QUEUE message status constants
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_SERVER_BUSY_60s = 9999;

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

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


private static ResourceBundle _rscBundleMessages;
- public static String TCPBW100_MSGS = "Tcpbw100_msgs";
- public static int PREDEFINED_BUFFER_SIZE = 8192; //8k buffer size
-
- //Data rate indicator strings
- public static String T1_STR = "T1";
- public static String T3_STR = "T3";
- public static String ETHERNET_STR = "Ethernet";
- public static String FAST_ETHERNET = "FastE";
- public static String OC_12_STR = "OC-12";
- public static String GIGABIT_ETHERNET_STR = "GigE";
- public static String OC_48_STR = "OC-48";
- public static String TENGIGABIT_ETHERNET_STR = "10 Gig";
- public static String SYSTEM_FAULT_STR = "systemFault";
- public static String DIALUP_STR = "dialup2";
- public static String RTT_STR = "systemFault"; //round trip time
-
-
- //system variables could be declared as strings too
- //half_duplex:, country , etc. F
-
- /* Method to initialize a few constants
- * @param Locale: local Locale object
- * @return none */
- public static void initConstants(Locale paramLocale) {
+ 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 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_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;
+
+ // 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 FAST_ETHERNET = "FastE";
+ public static final String OC_12_STR = "OC-12";
+ 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
+
+ // 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 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 String LOOPBACK_ADDRS_STRING = "127.0.0.1";
+
+ // 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);
System.out.println("Obtained messages ");
@@ -104,13 +129,13 @@

} //end method

- /* Overloaded Method to initialize a few constants
- * @param lang: local Language String
- * @param country: local country object
- * @return none */
- public static void initConstants(String lang, String country) {
+ /** Initializes a few constants
+ * @param paramStrLang local Language String
+ * @param paramStrCountry local country String
+ * */
+ public static void initConstants(String paramStrLang, String paramStrCountry) {
try {
- Locale locale = new Locale(lang, country);
+ Locale locale = new Locale(paramStrLang,
paramStrCountry);
_rscBundleMessages =
ResourceBundle.getBundle("Tcpbw100_msgs", locale);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
@@ -119,9 +144,9 @@
}//end method initconstants


- /* Getter method for to fetch from resourceBundle
- * @param: String name of parameter to be fetched
- * @return: Value of parameter input*/
+ /** 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 Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/NewFrame.java Wed Aug 24 13:30:34 2011
@@ -4,19 +4,24 @@
import javax.swing.JFrame;


-/*
- * Class that defines a new Frame with a window closing functionality
+/**
+ * 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
+ * Options windows
+ *
+ * This class is declared separately so that it can be easily extended
+ * by users to customize based on individual needs
*
*/
-class NewFrame extends JFrame {
+public class NewFrame extends JFrame {
/**
- *
+ * Auto-generated compiler constant that does not contribute to
+ * classes' functionality
*/
private static final long serialVersionUID = 8990839319520684317L;

- /*Constructor
- * @param none*/
-
+ /** Constructor
+ **/
public NewFrame() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
=======================================
--- /branches/kkumar_code_organize/Applet/OsfwWorker.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/OsfwWorker.java Wed Aug 24 13:30:34 2011
@@ -1,147 +1,172 @@
-/*
- * OsfwWorker creates a thread that listens for a message from the server
+import java.io.IOException;
+import java.net.ServerSocket;
+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.
*
- * As part of the simple firewall test, The Server MUST try to connect to the Client's
- * ephemeral port and MUST send a TEST_MSG message containing a pre-defined string
- * "Simple firewall test" of 20 chars using the newly created connection.
- * This class implements this functionality
+ * <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
+ * connection. This class implements this functionality.
*
* The result of the test is set back into the Tcpbw100._iS2cSFWResult variable
- * via its setter methods for the test results to be interpreted later
+ * (using setter methods) for the test results to be interpreted later
* */

-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-
public class OsfwWorker implements Runnable {
-
+
private ServerSocket _srvSocket;
private int _iTestTime;
private boolean _iFinalized = false;
- //local TApplet reference
+ // local Tcpbw100 Applet reference
Tcpbw100 _localTcpAppObj;

- OsfwWorker(ServerSocket srvSocketParam, int iParamTestTime)
- {
+ /**
+ * Constructor
+ *
+ * @param Socket
+ * srvSocketParam Socket used to transmit protocol messages
+ *
+ * @param iParamTestTime
+ * Test time duration to wait for message from server
+ */
+ OsfwWorker(ServerSocket srvSocketParam, int iParamTestTime) {
this._srvSocket = srvSocketParam;
this._iTestTime = iParamTestTime;
}
-
- /*Constructor
- * @param ServerSocket: Socket on which to accept connections
- * @param int: Test time duration to wait for message from server
- * @param Tcpbw100: Applet object used to set the result of the S->C firewall test
+
+ /**
+ * Constructor accepting Tcpbw100 parameter
+ *
+ * @param ServerSocket
+ * Socket on which to accept connections
+ * @param iParamTestTime
+ * Test time duration to wait for message from server
+ * @param _localParam
+ * Applet object used to set the result of the S->C firewall test
*/
- OsfwWorker(ServerSocket srvSocketParam, int iParamTestTime, Tcpbw100 _localParam)
- {
+ OsfwWorker(ServerSocket srvSocketParam, int iParamTestTime,
+ Tcpbw100 _localParam) {
this._srvSocket = srvSocketParam;
this._iTestTime = iParamTestTime;
this._localTcpAppObj = _localParam;
}

- /* Method to make current thread sleep for 1000 ms
- * @param none
- * @return none
+ /**
+ * Make current thread sleep for 1000 ms
+ *
* */
- public void finalize()
- {
- //If test is not already complete/terminated, then sleep
+ public void finalize() {
+ // If test is not already complete/terminated, then sleep
while (!_iFinalized) {
try {
Thread.currentThread().sleep(1000);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
// do nothing.
}
}
}

- /* Run method of this SFW Worker thread.
- * This thread listens on the socket from the server for a given time period,
- * and checks to see
- * if the server has sent a message that is valid and sufficient to determine
- * if the S->C direction has a fire-wall
- * @return none*/
- public void run() {
-
+ /**
+ * run() method of this SFW Worker thread. This thread listens on the socket
+ * from the server for a given time period, and checks to see if the server
+ * has sent a message that is valid and sufficient to determine if the S->C
+ * direction has a fire-wall.
+ * */
+ public void run() {
+
Message msg = new Message();
Socket socketObj = null;

try {
- //set timeout to given value in ms
+ // set timeout to given value in ms
_srvSocket.setSoTimeout(_iTestTime * 1000);
try {
- //Blocking call trying to create connection
to socket and accept it
+
+ // Blocking call trying to create connection
to socket and
+ // accept it
socketObj = _srvSocket.accept();
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
- //The "accept" call has failed, and indicates
a firewall possibility
-
this._localTcpAppObj.setS2cSFWTestResults(NDTConstants.SFW_POSSIBLE);
+
+ // The "accept" call has failed, and
indicates a firewall
+ // possibility
+ this._localTcpAppObj
+
.setS2cSFWTestResults(NDTConstants.SFW_POSSIBLE);
_srvSocket.close();
_iFinalized = true;
return;
}
Protocol sfwCtl = new Protocol(socketObj);
-
- //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.println("Simple firewall test:
unrecognized message");
- //s2cResult = NDTConstants.SFW_UNKNOWN;
-
this._localTcpAppObj.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
- //close socket objects and wrap up
+
+ // 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
+ .println("Simple firewall test:
unrecognized message");
+ this._localTcpAppObj
+
.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
+ // close socket objects and wrap up
socketObj.close();
_srvSocket.close();
_iFinalized = true;
return;
}
- /* The server sends a TEST_MSG type packet. Any other message-type is not expected
- at this point, and hence an error */
+
+ // The server sends a TEST_MSG type packet. Any other
message-type
+ // is not expected at this point, and hence an error
if (msg.getType() != MessageType.TEST_MSG) {
- //s2cResult = NDTConstants.SFW_UNKNOWN;
-
this._localTcpAppObj.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
- //close socket objects and wrap up
+ this._localTcpAppObj
+
.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
+ // close socket objects and wrap up
socketObj.close();
_srvSocket.close();
_iFinalized = true;
return;
}
- /* The server protocol is expected to send a 20 char message that says "Simple firewall test" .
- * Every other message string indicates an unknown
firewall status
+
+ /**
+ * The server protocol is expected to send a 20 char
message that
+ * says "Simple firewall test" . Every other message
string
+ * indicates an unknown firewall status
*/
- if (! new String(msg.getBody()).equals(NDTConstants.SFW_PREDEFINED_TEST_MESSAGE)) {
+ if (!new String(msg.getBody())
+
.equals(NDTConstants.SFW_PREDEFINED_TEST_MESSAGE)) {
System.out.println("Simple firewall test: Improper
message");
- //s2cResult = NDTConstants.SFW_UNKNOWN;
-
this._localTcpAppObj.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
- //close socket objects and wrap up
+ this._localTcpAppObj
+
.setS2cSFWTestResults(NDTConstants.SFW_UNKNOWN);
+ // close socket objects and wrap up
socketObj.close();
_srvSocket.close();
_iFinalized = true;
return;
}
- //s2cResult = NDTConstants.SFW_NOFIREWALL;
- /* 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
- //s2cResult = NDTConstants.SFW_UNKNOWN;
+
+ // 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);
}
-
- //finalize an close open connections
+
+ // finalize and close connections
try {
socketObj.close();
_srvSocket.close();
- }
- catch (IOException e) {
- // do nothing
+ } catch (IOException e) {
+ System.err.println("OsfwWorker: Exception trying to close
sockets" + e);
+ // log exception occurence
}
_iFinalized = true;
}
}
-
=======================================
--- /branches/kkumar_code_organize/Applet/Protocol.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/Protocol.java Wed Aug 24 13:30:34 2011
@@ -3,7 +3,7 @@
import java.io.OutputStream;
import java.net.Socket;

-/* Class aggregating operations that can be performed for sending/receiving/reading
+/** Class aggregating operations that can be performed for sending/receiving/reading
* Protocol messages
*
* */
@@ -13,8 +13,10 @@
private InputStream _ctlInStream;
private OutputStream _ctlOutStream;

- /* Class Constructor
- * @param Socket: socket used to send the protocol messages over
+ /** 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
{
@@ -22,10 +24,11 @@
_ctlOutStream = ctlSocketParam.getOutputStream();
}

- /* Method to send message. Overloaded
- * @param bParamType: Ctrl Message Type
- * @param bParamToSend: Data value to send
- * @return none
+ /** 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
@@ -35,31 +38,34 @@
}


- /* Method to send msg. Overloaded
- * @param bParamType: Ctrl Message Type
- * @param bParamToSend[]: Data value to send
- * @return none
+ /** 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[] baParamTab) 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) (baParamTab.length >> 8);
- header[2] = (byte) baParamTab.length;
+ header[1] = (byte) (bParamToSend.length >> 8);
+ header[2] = (byte) bParamToSend.length;

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

- /* Populate Message byte array with specific number of bytes of data
+ /** 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 int: Actual number of bytes populated
+ * @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
*/
public int readn(Message msgParam, int iParamAmount) throws
IOException
{
@@ -78,18 +84,24 @@
return read;
}

- /* Receive message at end point of socket
- * @param Message object
- * @return : integer with values:
+ /** Receive message at end-point of socket
+ * @param msgParam Message object
+ * @return integer with values:
+ * <p>
* a) Success:
- * value=0 : successfully read expected number of bytes
+ * <ul>
+ * <li>
+ * value=0 : successfully read expected number of bytes.
+ * </li> </ul>
+ * <p>
* b) Error:
- * value= 1 : Error reading ctrl-message length and data type itself, since
+ * <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
- * value= 3 : Error, mismatch between "length" field of
ctrl-message and
- * actual data read
- *
+ * 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
{
@@ -115,9 +127,8 @@
return 0;
}

- /* Method to close open Streams
- * @param none
- * @return none*/
+ /** Method to close open Streams
+ */
public void close()
{
try {
@@ -129,5 +140,5 @@
}
}

-
-}
+
+} //end class Protocol
=======================================
--- /branches/kkumar_code_organize/Applet/ResultsTextPane.java Sat Aug 20 10:12:56 2011
+++ /branches/kkumar_code_organize/Applet/ResultsTextPane.java Wed Aug 24 13:30:34 2011
@@ -3,44 +3,48 @@
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;

-/* Class used to extend textPane to be used to display results
- * of tests
+/*
+ * Class that extends TextPane. This Text-pane is used as the chief
+ * Results window that summarizes the results of all tests
+ * that have been run.
+ *
+ * This class is declared separately so that it can be easily extended
+ * by users to customize based on individual needs
+ *
*/
public class ResultsTextPane extends JTextPane
{
+
+
/**
- *
+ * Compiler auto-generate value not directly related to class functionality
*/
- private static final long serialVersionUID = 1L;
-
- /*Method to append String into the current document
- * @param String : Text to be inserted into the document
- * @return none*/
- public void append(String text)
+ private static final long serialVersionUID = -2224271202004876654L;
+
+ /** Method to append String into the current document
+ * @param paramTextStr String to be inserted into the document
+ **/
+ public void append(String paramTextStr)
{
try {
- getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
+ getStyledDocument().insertString(getStyledDocument().getLength(), paramTextStr, null);
}
catch (BadLocationException e) {
- System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
+ 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 the component is inserted at the current position of the caret.
- * @param Component : the component to insert
- * @return none
- */
- public void insertComponent(Component c)
- {
- /*
- setSelectionStart(results.getStyledDocument().getLength());
- setSelectionEnd(results.getStyledDocument().getLength());
- */
- //change "results" to "this". re-arch
+ /**
+ * 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
+ * */
+ public void insertComponent(Component paramCompObj)
+ {
setSelectionStart(this.getStyledDocument().getLength());
setSelectionEnd(this.getStyledDocument().getLength());
- super.insertComponent(c);
+ super.insertComponent(paramCompObj);
}

}
=======================================
--- /branches/kkumar_code_organize/Applet/StatusPanel.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/StatusPanel.java Wed Aug 24 13:30:34 2011
@@ -6,19 +6,23 @@
import javax.swing.JPanel;
import javax.swing.JProgressBar;

-/* Class that displays status of tests being run Status
- * Also provides "utility" methods like displaying test number
- * being currently run, and stopping tests
+/** 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
{
/**
- *
+ * Compiler generated constant that is not related to current classes'
+ * specific functionality
*/
- private static final long serialVersionUID = 2609233901130079136L; //generated value
- private int _iTestsCompleted; //variable used to record the count of "finished" tests
- private int _iTestsNum;
+ 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 boolean _bStop = false;

private JLabel _labelTestNum = new JLabel();
@@ -27,22 +31,20 @@

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

setTestNoLabelText();
- //re-arch
- //If multiple tests are enabled to be run, then add
information about the
- //test number being run
+
+ // If multiple tests are enabled to be run, then add information about the
+ // test number being run
if ( sParamEnableMultiple != null) {
add(_labelTestNum);
}
- /*
- if ( getParameter("enableMultipleTests") != null ) {
- add(testNoLabel);
- }*/
+
_progressBarObj.setMinimum(0);
_progressBarObj.setMaximum(_iTestsNum);
_progressBarObj.setValue(0);
@@ -65,41 +67,40 @@
}

});
- /*
- if ( getParameter("enableMultipleTests") != null ) {
- add(stopButton);
- }*/
- //If multiple tests are enabled to be run, provide user
option to
- // stop the one currently running
+
+ // 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);
+
}

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

- /*end the currently running test
- * @param none
- * @return none*/
+ /** End the currently running test
+ * */
public void endTest() {
_progressBarObj.setValue(_iTestsCompleted);
_iTestsCompleted++;
setTestNoLabelText();
}

- /* Set progress text
- * @param sParamText: String status
- * @return none */
+ /** 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);
=======================================
--- /branches/kkumar_code_organize/Applet/Tcpbw100.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/Tcpbw100.java Wed Aug 24 13:30:34 2011
@@ -1,3 +1,50 @@
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Panel;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Date;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JApplet;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSpinner;
+import javax.swing.JTextArea;
+import javax.swing.SpinnerNumberModel;
+
/*
Copyright 2003 University of Chicago. All rights reserved.
The Web100 Network Diagnostic Tool (NDT) is distributed subject to
@@ -59,83 +106,44 @@
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
- * _VarName: Class variable (instead of c_VarName for class variables to reduce length)
+
+
+
+
+ /*
+ * Naming convention used: Hungarian, with the following details
+ * _VarName: Instance variables
+ * __Varname: Static variables (instead of c_VarName to reduce length)
* iVarName: Integer variable
* sVarName: String variable
* bVarName: boolean variable
- * dVarName: double varibale
+ * dVarName: double variable
* _iaVarName: Integer "Array" variable
* ...and some other self descriptive examples are..
* _rscBundleMessages : class scoped ResourceBundle Variable called "Messages"
* _cmboboxIpV6 : Class scoped combo-box variable to indicate IpV6 choice..
*
* Some variables which were called "pub_xxx" are declared to have "accessor" methods for use by
- * other clients. I have left this untouched. These are class scope variables. Though the type is
+ * other clients. I have left this untouched. These are private variables. Though the type is
* not evident from the declaration immediately, the "getter/setter" methods for them will immediately
* indicate their types
*
*/
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Panel;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Date;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-
-import javax.swing.BorderFactory;
-import javax.swing.BoxLayout;
-import javax.swing.JApplet;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSpinner;
-import javax.swing.JTextArea;
-import javax.swing.SpinnerNumberModel;
-
-
-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
*/
- private static final long serialVersionUID = -7736502859444730371L;
- /**
- *
- */
-
+ private static final long serialVersionUID = -2030725073538492542L;
+
JTextArea _txtDiagnosis, _txtStatistics;
ResultsTextPane _resultsTxtPane;
//String inresult, outresult; //comment out unused variables
@@ -153,7 +161,8 @@
String[] _saDelays = { "immediate", "1min","5mins","10mins","30mins","2hours","12hours","1day" };
JComboBox _cmboboxDelay;

- boolean _bRandomize, _bFailed, _bCanCopy;
+ boolean _bRandomize;
+ boolean _bFailed, _bCanCopy;
//URL location; //unused, hence commenting out
NewFrame _frameWeb100Vars, _frameDetailedStats, _frameOptions;
//String s; Unused, commenting out
@@ -178,6 +187,35 @@
int _iSsndqueue;
double _dSbytes;

+ /**
+ * 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";
+ /***/
+
+ //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
+
+ 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;
+ int _iC2sSFWResult = NDTConstants.SFW_NOTTESTED;
+ int _iS2cSFWResult = NDTConstants.SFW_NOTTESTED;
+

/*************************************************************************
* JavaScript access API extension
* Added by Seth Peery and Gregory Wilson, Virginia Tech
@@ -232,7 +270,33 @@
private String _sIsAutoRun;
private String _sUserAgent = null;

- /**
+ /** public static void main for invoking as an Application
+ * */
+ 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");
+ System.exit(0);
+ }
+ final Tcpbw100 applet = new Tcpbw100();
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ applet.destroy();
+ System.exit(0);
+ }
+ });
+ applet._bIsApplication = true;
+ applet.sHostName = args[0];
+ frame.getContentPane().add(applet);
+ frame.setSize(700, 320);
+ applet.init();
+ applet.start();
+ frame.setVisible(true);
+ }
+
+
+ /*
* Accessor methods for public variables
**/

@@ -406,6 +470,8 @@
return result;
}

+ //commenting out unused method, but not removing in case of future use
+ /*
public String isReady()
{

@@ -421,7 +487,8 @@
// return result;
return pub_isReady;
}
-
+ */
+
public String get_jitter()
{
return Integer.toString((pub_MaxRTT - pub_MinRTT));
@@ -460,9 +527,199 @@
return Double.toString((8.0 * pub_bytes) / (System.currentTimeMillis() - pub_time));
}

- /* "Remote Control" function - invoke NDT' runtest() method from the
API
- * @param none
- * @return none
+ /** Set UserAgent String containing browser details.
+ * @return String UserAgent details set locally
+ * @see UserAgentTools
+ * */
+ public String getUserAgent() {
+ return _sUserAgent;
+ }
+
+ /** 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
+ * */
+ public int getC2sSFWTestResults() {
+ return this._iC2sSFWResult;
+ }
+
+ /**
+ * 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
+ * */
+ public int getS2cSFWTestResults() {
+ return this._iS2cSFWResult;
+ }
+
+ /**
+ * 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.
+ * */
+ class TestWorker implements Runnable {
+ public void run() {
+ if (!_bTestInProgress) {
+ int testNo = 1;
+ int testsNum =
((Integer)_spinnerTestCount.getValue()).intValue();
+ _bTestInProgress = true;
+ createDiagnoseWindow();
+ createStatsWindow();
+ _buttonStartTest.setEnabled(false);
+ _buttonDetails.setEnabled(false);
+ _buttonStatistics.setEnabled(false);
+ _buttonMailTo.setEnabled(false);
+ _buttonOptions.setEnabled(false);
+ _spinnerTestCount.setEnabled(false);
+
+ //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
+
+ StatusPanel sPanel = new
StatusPanel(testsNum, sTempEnable);
+ getContentPane().add(BorderLayout.NORTH,
sPanel);
+ getContentPane().validate();
+ getContentPane().repaint();
+
+ try {
+ while (true) {
+ if (sPanel.wantToStop()) {
+ 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");
+ }
+ dottcp(sPanel);
+ // If test count scheduled is
complete, quit
+ if (testNo == testsNum) {
+ break;
+ }
+ // If user stops the test,
quit
+ if (sPanel.wantToStop()) {
+ break;
+ }
+ sPanel.setText("");
+ sPanel.endTest();
+ // increment test count
+ testNo += 1;
+
+ // 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
+ // iteration of the test suite
+ try {
+ switch
(_cmboboxDelay.getSelectedIndex()) {
+ case 1:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep1m") + " **\n");
+
Thread.sleep(1000 * 60);
+ break;
+ case 2:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep5m") + " **\n");
+
Thread.sleep(1000 * 60 * 5);
+ break;
+ case 3:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep10m") + " **\n");
+
Thread.sleep(1000 * 60 * 10);
+ break;
+ case 4:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep30m") + " **\n");
+
Thread.sleep(1000 * 60 * 30);
+ break;
+ case 5:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep2h") + " **\n");
+
Thread.sleep(1000 * 60 * 120);
+ break;
+ case 6:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep12h") + " **\n");
+
Thread.sleep(1000 * 60 * 720);
+ break;
+ case 7:
+ _resultsTxtPane.append("\n** " + _resBundDisplayMsgs.getString("sleep1d") + " **\n");
+
Thread.sleep(1000 * 60 * 1440);
+ break;
+ }
+ }
+ catch (InterruptedException
e) {
+ // do nothing.
+ }
+ }
+ } catch(IOException e) {
+ e.printStackTrace();
+ _bFailed=true;
+ _sErrMsg =
_resBundDisplayMsgs.getString("serverBusy30s") + "\n";
+ }
+
+ // If test failed due to any reason, mark
failure reason too
+ if (_bFailed) {
+ _resultsTxtPane.append(_sErrMsg);
+
+ pub_isReady = "failed";
+ pub_errmsg = _sErrMsg;
+ }
+
+ // 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");
+ _buttonStartTest.setEnabled(true);
+ _bTestInProgress = false;
+ getContentPane().remove(sPanel);
+ getContentPane().validate();
+ getContentPane().repaint();
+ }
+ }
+ } //end inner class
+
+
+ /**
+ * "Remote Control" function - invoke NDT' runtest() method from the
API
*/
public void run_test()
{
@@ -479,180 +736,132 @@
});
}

- /*Getter method for UserAgent String
- * @param none
- * @return String UserAgent
- * @see UserAgentTools.java */
- public String getUserAgent() {
- return _sUserAgent;
- }
-
- /*Setter method for UserAgent String
- * @param String UserAgent
- * @return none
- * @see UserAgentTools.java
- * */
- public void setUserAgent(String userAgent) {
- this._sUserAgent = userAgent;
- }

/**
- End of accessor methods
- **/
-
/************************************************************************/
-
- /**
- * Added by Martin Sandsmark, UNINETT AS
- * Internationalization
- */
- private Locale _localeObj;
- private ResourceBundle _resBundleMessages;
- private String lang="en";
- private String country="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
- 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 nameing 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;
- int _iC2sSFWResult = NDTConstants.SFW_NOTTESTED;
- int _iS2cSFWResult = NDTConstants.SFW_NOTTESTED;
-
-
- /* Method to initialize the base NDT window
- * Applet init() method
- * @param none
- * @return none
+ * Initialize the base NDT window Applet init() method
*/
public void init() {
- if (getParameter("country") != null) country =
getParameter("country");
- if (getParameter("language") != null) lang =
getParameter("language");
+ if (getParameter("country") != null) {
+ _sCountry = getParameter("country");
+ }
+ if (getParameter("language") != null) {
+ _sLang = getParameter("language");
+ }

try {
- _localeObj = new Locale(lang, country);
- _resBundleMessages = ResourceBundle.getBundle("Tcpbw100_msgs", _localeObj);
-
- //Replaced method call to initialize _resBundleMessages for access by class
- //NDTConstants.initConstants(locale);
- NDTConstants.initConstants(lang, country);
+ _localeObj = new Locale(_sLang, _sCountry);
+ _resBundDisplayMsgs =
ResourceBundle.getBundle("Tcpbw100_msgs",
+ _localeObj);
+
+ // Replaced method call to initialize
_resBundDisplayMsgs for access
+ // by class
+ // NDTConstants.initConstants(locale);
+ NDTConstants.initConstants(_sLang, _sCountry);

} 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();
}

- //call method to create a window
+ // call method to create a window
createMainWindow();
-
- //Autorun functionality
+
+ // Autorun functionality
_sIsAutoRun = getParameter("autoRun");
if ((_sIsAutoRun != null) && _sIsAutoRun.equals("true")) {
pub_errmsg = "Test in progress.";
- runtest();
+ runtest();
}

}

- /* Method that initializes the "main" window
+ /** 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
- * @param none
- * @return none
* //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
+ // set content manager
getContentPane().setLayout(new BorderLayout());

- //start with status set to "Ready" to perform tests
- showStatus(_resBundleMessages.getString("ready"));
-
- //initialize
+ // start with status set to "Ready" to perform tests
+ showStatus(_resBundDisplayMsgs.getString("ready"));
+
+ // initialize
_bFailed = false ;
- _bRandomize = false; //what is this used for? Seems unused in
code
+ _bRandomize = false; //Seems unused after this. Retaining
either way
_bCanCopy = false;

- //Results panel
+ // Results panel
_resultsTxtPane = new ResultsTextPane();
- _resultsTxtPane.append("TCP/Web100 Network Diagnostic Tool v" + NDTConstants.VERSION + "\n");
+ _resultsTxtPane.append( NDTConstants.NDT_TITLE_STR + NDTConstants.VERSION + "\n");
_resultsTxtPane.setEditable(false);
getContentPane().add(new JScrollPane(_resultsTxtPane));
- _resultsTxtPane.append(_resBundleMessages.getString("clickStart") + "\n");
-
- //Panel too add all buttons
+ _resultsTxtPane.append(_resBundDisplayMsgs.getString("clickStart") + "\n");
+
+ // Panel too add all buttons
Panel buttonsPanel = new Panel();

- //Add "start" button
- _buttonStartTest = new
JButton(_resBundleMessages.getString("start"));
+ // Add "start" button
+ _buttonStartTest = new
JButton(_resBundDisplayMsgs.getString("start"));
_buttonStartTest.addActionListener(this);
buttonsPanel.add(_buttonStartTest);

- //Add "statistics" button
- _buttonStatistics = new JButton(_resBundleMessages.getString("statistics"));
+ // Add "statistics" button
+ _buttonStatistics = new JButton(_resBundDisplayMsgs.getString("statistics"));
_buttonStatistics.addActionListener(this);
if (getParameter("disableStatistics") == null) {
buttonsPanel.add(_buttonStatistics);
}
_buttonStatistics.setEnabled(false);

- //Add "Details" button
- _buttonDetails = new JButton(_resBundleMessages.getString("moreDetails"));
+ // Add "Details" button
+ _buttonDetails = new JButton(_resBundDisplayMsgs.getString("moreDetails"));
_buttonDetails.addActionListener(this);
if (getParameter("disableDetails") == null) {
buttonsPanel.add(_buttonDetails);
}
_buttonDetails.setEnabled(false);

- //Add "Report problem" button
- _buttonMailTo = new JButton(_resBundleMessages.getString("reportProblem"));
+ // Add "Report problem" button
+ _buttonMailTo = new JButton(_resBundDisplayMsgs.getString("reportProblem"));
_buttonMailTo.addActionListener(this);
if (getParameter("disableMailto") == null) {
buttonsPanel.add(_buttonMailTo);
}
_buttonMailTo.setEnabled(false);

- //Add "Options" button
- _buttonOptions = new JButton(_resBundleMessages.getString("options") + "...");
+ // Add "Options" button
+ _buttonOptions = new JButton(_resBundDisplayMsgs.getString("options") + "...");
_buttonOptions.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
_buttonOptions.setEnabled(false);
- //call the Options-window create code
+ // call the Options-window create code
createOptionsWindow();
_buttonOptions.setEnabled(true);
}
});
- //If disableOptions is not set, then add button
+ // If disableOptions is not set, then add button
if (getParameter("disableOptions") == null) {
buttonsPanel.add(_buttonOptions);
}

- //add buttons panel to the main window
+ // add buttons panel to the main window
getContentPane().add(BorderLayout.SOUTH, buttonsPanel);

- //"Options" panel components
- //1. Is IPv6 preferred?
- _chkboxPreferIPv6 = new JCheckBox(_resBundleMessages.getString("preferIPv6"));
+ // "Options" panel components
+ // 1. Is IPv6 preferred?
+ _chkboxPreferIPv6 = new JCheckBox(_resBundDisplayMsgs.getString("preferIPv6"));
_chkboxPreferIPv6.setSelected(true);
- //2. Conduct default tests?
- _chkboxDefaultTest = new JCheckBox(_resBundleMessages.getString("defaultTests"));
+ // 2. Conduct default tests?
+ _chkboxDefaultTest = new JCheckBox(_resBundDisplayMsgs.getString("defaultTests"));
_chkboxDefaultTest.setSelected(true);
_chkboxDefaultTest.setEnabled(false);
- //3. configure number of tests
+ // 3. configure number of tests
SpinnerNumberModel model = new SpinnerNumberModel();
model.setMinimum(new Integer(0));
model.setValue(new Integer(1));
@@ -660,132 +869,146 @@
_spinnerTestCount.setPreferredSize(new Dimension(60, 20));
_cmboboxDelay = new JComboBox();
for (int i = 0; i < _saDelays.length; i++) {
-
_cmboboxDelay.addItem(_resBundleMessages.getString(_saDelays[i]));
+
_cmboboxDelay.addItem(_resBundDisplayMsgs.getString(_saDelays[i]));
}
_cmboboxDelay.setSelectedIndex(0);

- }
-
- /* Method that creates the "More details" window
- * @param none
- * @return none */
+ } // createDiagnoseWindow() ends
+
+
+ /** Create the "More details" window.
+ */
public void createDiagnoseWindow() {
- showStatus(_resBundleMessages.getString("getWeb100Var"));
-
+ showStatus(_resBundDisplayMsgs.getString("getWeb100Var"));
+
+ // create new frame
if (_frameWeb100Vars == null) {
_frameWeb100Vars = new NewFrame();
}
-
_frameWeb100Vars.setTitle(_resBundleMessages.getString("web100Var"));
+
+ // Get title for this window
+
_frameWeb100Vars.setTitle(_resBundDisplayMsgs.getString("web100Var"));
Panel buttons = new Panel();
_frameWeb100Vars.getContentPane().add("South", buttons);

- _buttonDismiss = new
JButton(_resBundleMessages.getString("close"));
+ // Add "close" button
+ _buttonDismiss = new
JButton(_resBundDisplayMsgs.getString("close"));
_buttonDismiss.addActionListener(this);

- _buttonCopy = new
JButton(_resBundleMessages.getString("copy"));
+ // Add "copy" button
+ _buttonCopy = new
JButton(_resBundDisplayMsgs.getString("copy"));
_buttonCopy.addActionListener(this);

- _txtDiagnosis = new JTextArea(_resBundleMessages.getString("web100KernelVar") + ":\n", 15,30);
+ // Create Text area for displaying results, add "Heading"
+ _txtDiagnosis = new JTextArea(_resBundDisplayMsgs.getString("web100KernelVar") + ":\n", 15,30);
_txtDiagnosis.setEditable(true);
_buttonDismiss.setEnabled(true);
_buttonCopy.setEnabled(_bCanCopy);

+ // Now place all the buttons
buttons.add("West", _buttonDismiss);
buttons.add("East", _buttonCopy);
_frameWeb100Vars.getContentPane().add(new
JScrollPane(_txtDiagnosis));
_frameWeb100Vars.pack();
- } // diagnose()
+ } // createDiagnoseWindow() ends


- /* Method that creates the "Statistics" window
- * @param none
- * @return none */
+ /** Create the "Statistics" window.
+ */
public void createStatsWindow() {
-
showStatus(_resBundleMessages.getString("printDetailedStats"));
-
+
showStatus(_resBundDisplayMsgs.getString("printDetailedStats"));
+
+ // create new frame
if (_frameDetailedStats == null) {
_frameDetailedStats = new NewFrame();
}
- _frameDetailedStats.setTitle(_resBundleMessages.getString("detailedStats"));
+ _frameDetailedStats.setTitle(_resBundDisplayMsgs.getString("detailedStats"));
+
+ // create panel for buttons
Panel buttons = new Panel();
_frameDetailedStats.getContentPane().add("South", buttons);

- _buttonStatsDismiss = new
JButton(_resBundleMessages.getString("close"));
+ // Button for "close"
+ _buttonStatsDismiss = new JButton(_resBundDisplayMsgs.getString("close"));
_buttonStatsDismiss.addActionListener(this);

- _buttonStatsCopy = new
JButton(_resBundleMessages.getString("copy"));
+ // Button for "copy"
+ _buttonStatsCopy = new
JButton(_resBundDisplayMsgs.getString("copy"));
_buttonStatsCopy.addActionListener(this);

- _txtStatistics = new JTextArea(_resBundleMessages.getString("web100Stats") + ":\n", 25,70);
+ // Text area for Statistics, add "heading"
+ _txtStatistics = new JTextArea(_resBundDisplayMsgs.getString("web100Stats") + ":\n", 25,70);
_txtStatistics.setEditable(true);
_buttonStatsDismiss.setEnabled(true);
_buttonStatsCopy.setEnabled(_bCanCopy);
-
+
+ // Place all components
buttons.add("West", _buttonStatsDismiss);
buttons.add("East", _buttonStatsCopy);
_frameDetailedStats.getContentPane().add(new JScrollPane(_txtStatistics));
_frameDetailedStats.pack();
- } // statistics()
+ } // createStatsWindow()


- /* Method that creates the "Options" window
+ /** Create the "Options" window.
* The options displayed to the user are:
- * 1. Perform default tests?
- * 2. Prefer IPV6?
- * 3. Select the number of times the test-suite is to be run
- * @param none
- * @return none */
+ * <ul>
+ *<li> Would you like to Perform default tests? </li>
+ *<li> Would you prefer IPV6? </li>
+ * <li> Select number of times the test-suite is to be run </li>
+ * </ul>
+ */
public void createOptionsWindow() {
- showStatus(_resBundleMessages.getString("showOptions"));
+ showStatus(_resBundDisplayMsgs.getString("showOptions"));

if (_frameOptions == null) {
_frameOptions = new NewFrame();
-
_frameOptions.setTitle(_resBundleMessages.getString("options"));
-
- //main panel
+
_frameOptions.setTitle(_resBundDisplayMsgs.getString("options"));
+
+ // main panel
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new BoxLayout(optionsPanel,
BoxLayout.Y_AXIS));

- //Panel for displaying the "default tests" option
+ // Panel for displaying the "default tests" option
JPanel testsPanel = new JPanel();
- testsPanel.setBorder(BorderFactory.createTitledBorder(_resBundleMessages.getString("performedTests")));
+ testsPanel.setBorder(BorderFactory.createTitledBorder(_resBundDisplayMsgs.getString("performedTests")));
testsPanel.add(_chkboxDefaultTest);
optionsPanel.add(testsPanel);

- //Panel for displaying the IPV6 option
+ // Panel for displaying the IPV6 option
JPanel protocolPanel = new JPanel();
- protocolPanel.setBorder(BorderFactory.createTitledBorder(_resBundleMessages.getString("ipProtocol")));
+ protocolPanel.setBorder(BorderFactory.createTitledBorder(_resBundDisplayMsgs.getString("ipProtocol")));
protocolPanel.add(_chkboxPreferIPv6);
optionsPanel.add(protocolPanel);

- /*
- * If user has enabled multiple tests, then build the
panel, and add it
- * to the parent( options ) panel
- */
+
+ // If user has enabled multiple tests, then build the
panel, and add it
+ // to the parent( options ) panel
+
if (getParameter("enableMultipleTests") != null) {
JPanel generalPanel = new JPanel();
generalPanel.setLayout(new
BoxLayout(generalPanel, BoxLayout.Y_AXIS));
- generalPanel.setBorder(BorderFactory.createTitledBorder(_resBundleMessages.getString("general")));
+ generalPanel.setBorder(BorderFactory.createTitledBorder(_resBundDisplayMsgs.getString("general")));
JPanel tmpPanel = new JPanel();
- tmpPanel.add(new JLabel(_resBundleMessages.getString("numberOfTests") + ":"));
+ tmpPanel.add(new JLabel(_resBundDisplayMsgs.getString("numberOfTests") + ":"));
tmpPanel.add(_spinnerTestCount);
generalPanel.add(tmpPanel);
tmpPanel = new JPanel();
- tmpPanel.add(new JLabel(_resBundleMessages.getString("delayBetweenTests") + ":"));
+ tmpPanel.add(new JLabel(_resBundDisplayMsgs.getString("delayBetweenTests") + ":"));
tmpPanel.add(_cmboboxDelay);
generalPanel.add(tmpPanel);

optionsPanel.add(generalPanel);
}

- //Add options to the parent frame
+ // Add options to the parent frame
_frameOptions.getContentPane().add(optionsPanel);

- //create and add panel containing buttons
+ // create and add panel containing buttons
Panel buttonsPanel = new Panel();
_frameOptions.getContentPane().add("South",
buttonsPanel);

- JButton okButton= new
JButton(_resBundleMessages.getString("ok"));
+ JButton okButton= new
JButton(_resBundDisplayMsgs.getString("ok"));
okButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
@@ -795,6 +1018,7 @@

});

+ // place buttons
buttonsPanel.add("West", okButton);

_frameOptions.pack();
@@ -804,163 +1028,28 @@
}


- /*Method to run the Thread that calls the "dottcp" method to run tests
+ /**
+ * Run the Thread that calls the "dottcp" method to run tests.
* This method is called by the Applet's init method if user selected
an
* "autorun" option, is run individually if user presses the "start button",
- * and is internally run by API call
- * @param none
- * @return none*/
+ * or, is internally invoked by the API call.
+ */
synchronized public void runtest() {
pub_status = "notStarted";
new Thread(new TestWorker()).start();
}

- /* Class that starts the tests in a thread
- * Starts by disabling all buttons
- * Calls 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 */
- class TestWorker implements Runnable {
- public void run() {
- if (!_bTestInProgress) {
- int testNo = 1;
- int testsNum =
((Integer)_spinnerTestCount.getValue()).intValue();
- _bTestInProgress = true;
- createDiagnoseWindow();
- createStatsWindow();
- _buttonStartTest.setEnabled(false);
- _buttonDetails.setEnabled(false);
- _buttonStatistics.setEnabled(false);
- _buttonMailTo.setEnabled(false);
- _buttonOptions.setEnabled(false);
- _spinnerTestCount.setEnabled(false);
-
- //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 specifi 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();
- getContentPane().repaint();
-
- try {
- while (true) {
- if (sPanel.wantToStop()) {
- break;
- }
- if (testsNum == 0) {
- _resultsTxtPane.append("\n** " + _resBundleMessages.getString("startingTest") + " " + testNo + " **\n");
- }
- else {
- _resultsTxtPane.append("\n** " + _resBundleMessages.getString("startingTest") + " " + testNo + " " + _resBundleMessages.getString("of") + " " + testsNum + " **\n");
- }
- dottcp(sPanel);
- //If test count scheduled is
complete, quit
- if (testNo == testsNum) {
- break;
- }
- //If user stops the test, quit
- if (sPanel.wantToStop()) {
- break;
- }
- sPanel.setText("");
- sPanel.endTest();
- //increment test count
- testNo += 1;
-
- /* 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** " + _resBundleMessages.getString("test") + " " + testNo + " **\n");
- _txtDiagnosis.append("\n** " + _resBundleMessages.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** " + _resBundleMessages.getString("sleep1m") + " **\n");
-
Thread.sleep(1000 * 60);
- break;
- case 2:
- _resultsTxtPane.append("\n** " + _resBundleMessages.getString("sleep5m") + " **\n");
-
Thread.sleep(1000 * 60 * 5);
- break;
- case 3:
- _resultsTxtPane.append("\n** " + _resBundleMessages.getString("sleep10m") + " **\n");
-
Thread.sleep(1000 * 60 * 10);
- break;
***The diff for this file has been truncated for email.***
=======================================
--- /branches/kkumar_code_organize/Applet/UserAgentTools.java Fri Aug 19 11:46:28 2011
+++ /branches/kkumar_code_organize/Applet/UserAgentTools.java Wed Aug 24 13:30:34 2011
@@ -8,10 +8,8 @@
* the underlying Operating System. Though the information inside a user-agent string is not restricted to
* these alone, currently, NDT uses this to get Browser OS only.
*
- * It has been moved out and made into a non-static outer class that can be replaced more quickly, if need be
- *
*/
-//private static class UserAgentTools {
+
public class UserAgentTools {

public static String getFirstVersionNumber(String a_userAgent, int a_position, int numDigits) {
@@ -25,7 +23,7 @@
}
return res;
}
-
+
public static String getVersionNumber(String a_userAgent, int a_position) {
if (a_position<0) return "";
StringBuffer res = new StringBuffer();
@@ -73,32 +71,30 @@
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
- //<SPAN class="codecomment"> The following two bots don't have any version number in their User-Agent strings.</span>
- if
((pos=userAgent.indexOf("inktomi"))>-1) {
- res=
"Inktomi";
- pos=-1;
- } else
- if
((pos=userAgent.indexOf("teoma"))>-1) {
- res=
"Teoma";
-
pos=-1;
- }
+ } 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));
}
@@ -110,176 +106,176 @@
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 (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 (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 (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 (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");
-

} else
-
res =
getArray("?","?","?");
+ 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");
+ }
+ else
+ res = getArray("?","?","?");
return res;
}

@@ -301,120 +297,123 @@
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 ((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 (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
- 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
- //<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>
-
if (userAgent.indexOf("Mozilla/4.")==0 &&
-
userAgent.indexOf("Mozilla/4.0")<0 &&
-
userAgent.indexOf("Mozilla/4.5 ")<0) {
- res = getArray("Communicator","Communicator","Communicator"+getVersionNumber(userAgent,pos+8));
-
} else
-
return getArray("?","?","?");
+ 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("?","?","?");
return res;
}
}


  • [ndt-dev] [ndt] r531 committed - NDTConstants.java: Deleted comment about data member access, which is ..., ndt, 08/24/2011

Archive powered by MHonArc 2.6.16.

Top of Page