Skip to content

Commit 8528714

Browse files
committed
Refactoring: Change field data type of 'port' in 'JschConnectionInfo' Model from String to int
1 parent ef4f74d commit 8528714

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/main/java/root/core/domain/JschConnectionInfo.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
public 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
}

src/main/java/root/javafx/CustomView/ServerConnectionInfoAnchorPane.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void init() {
7575
public void setInitialValue(JschConnectionInfo jsch) {
7676
serverNameTF.setText(jsch.getServerName());
7777
hostTF.setText(jsch.getHost());
78-
portTF.setText(jsch.getPort());
78+
portTF.setText(String.valueOf(jsch.getPort()));
7979
userTF.setText(jsch.getUserName());
8080
passwordPF.setText(jsch.getPassword());
8181
alertLogFilePathTF.setText(jsch.getAlc().getReadFilePath());

0 commit comments

Comments
 (0)