Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ru.deltasolutions.utils.file.transfer; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; /** * * @author Ivan */ public class SFTPFileTransferConfig { public int port; private int ioretries = 3; private int retries = 2; private int timeout; private int ioretrypause = 4000; private int retrypause = 10000; public String user = null; public String host = null; public String password = null; private String protocol = "sftp"; private String downloadRequest = "get"; private String uploadRequest = "put"; private String idfile = null; private String checkHostKey = "no"; private String hostKeyFile = null; private String ifExists = "backup"; public SFTPFileTransferConfig() { } public int getPort() { return port; } public int getIoretries() { return ioretries; } public int getRetries() { return retries; } public int getTimeout() { return timeout; } public int getIoretrypause() { return ioretrypause; } public int getRetrypause() { return retrypause; } public String getUser() { return user; } public String getHost() { return host; } public String getPassword() { return password; } public String getProtocol() { return protocol; } public String getDownloadRequest() { return downloadRequest; } public String getIdfile() { return idfile; } public String getCheckHostKey() { return checkHostKey; } public String getHostKeyFile() { return hostKeyFile; } public String getIfExists() { return ifExists; } public String getUploadRequest() { return uploadRequest; } public void setUploadRequest(String uploadRequest) { this.uploadRequest = uploadRequest; } public void setPort(int port) { this.port = port; } public void setIoretries(int ioretries) { this.ioretries = ioretries; } public void setRetries(int retries) { this.retries = retries; } public void setTimeout(int timeout) { this.timeout = timeout; } public void setIoretrypause(int ioretrypause) { this.ioretrypause = ioretrypause; } public void setRetrypause(int retrypause) { this.retrypause = retrypause; } public void setUser(String user) { this.user = user; } public void setHost(String host) { this.host = host; } public void setPassword(String password) { this.password = password; } public void setProtocol(String protocol) { this.protocol = protocol; } public void setDownloadRequest(String downloadRequest) { this.downloadRequest = downloadRequest; } public void setIdfile(String idfile) { this.idfile = idfile; } public void setCheckHostKey(String checkHostKey) { this.checkHostKey = checkHostKey; } public void setHostKeyFile(String hostKeyFile) { this.hostKeyFile = hostKeyFile; } public void setIfExists(String ifExists) { this.ifExists = ifExists; } public boolean isValid() { return !(this.port == 0 | this.user == null | this.host == null | (this.password == null && this.idfile == null) | (this.checkHostKey.equals("yes") && this.hostKeyFile == null) | (!this.protocol.equalsIgnoreCase("sftp"))); } @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { String str = mapper.writeValueAsString(this); return str; } catch (JsonProcessingException e) { return null; } } }