66public class JschConnectionInfo {
77 private String serverName ;
88 private String host ;
9- private String port ;
9+ private int port ;
1010 private String userName ;
1111 private String password ;
1212 private AlertLogCommand alc ;
13-
13+
1414 public JschConnectionInfo () {
1515 this .alc = new AlertLogCommand ();
1616 }
1717
18- public JschConnectionInfo (String serverName , String host , String port , String userName , String password ) {
18+ public JschConnectionInfo (String serverName , String host , int port , String userName , String password ) {
1919 this .serverName = serverName ;
2020 this .host = host ;
2121 this .port = port ;
@@ -24,13 +24,32 @@ public JschConnectionInfo(String serverName, String host, String port, String us
2424 this .alc = new AlertLogCommand ();
2525 }
2626
27- public JschConnectionInfo (String serverName , String host , String port , String userName , String password ,
27+ public JschConnectionInfo (String serverName , String host , String port , String userName , String password ) {
28+ this (serverName , host , 22 , userName , password );
29+ this .setPort (port );
30+ }
31+
32+ public JschConnectionInfo (String serverName , String host , int port , String userName , String password ,
2833 AlertLogCommand alc ) {
29- this .serverName = serverName ;
30- this .host = host ;
31- this .port = port ;
32- this .userName = userName ;
33- this .password = password ;
34+ this (serverName , host , port , userName , password );
3435 this .alc = alc ;
3536 }
37+
38+ public JschConnectionInfo (String serverName , String host , String port , String userName , String password ,
39+ AlertLogCommand alc ) {
40+ this (serverName , host , 22 , userName , password , alc );
41+ this .setPort (port );
42+ }
43+
44+ public int getPort () {
45+ return this .port == 0 ? 22 : this .port ;
46+ }
47+
48+ public void setPort (String portString ) {
49+ try {
50+ this .port = Integer .parseInt (portString );
51+ } catch (NumberFormatException e ) {
52+ this .port = 22 ; // ±âº»°ª
53+ }
54+ }
3655}
0 commit comments