3 Mayıs 2019 Cuma

PropertiesConfiguration Sınıfı

Giri
Şu satırı dahil ederiz.
import org.apache.commons.configuration2.PropertiesConfiguration;
constructor
Şöyle yaparız.
Configuration config = null;
try {

  config = new PropertiesConfiguration("config.properties"); 
} catch (ConfigurationException e) {
  ...
}
addProperty metodu
Şöyle yaparız.
config.addProperty("VALUE_FACTORY", BVF_extendo4000.INSTANCE);
getLayout metodu
Açıklaması şöyle
Each PropertiesConfiguration object is associated with a Layout object, an instance of the class PropertiesConfigurationLayout. This layout object is responsible for preserving most of the structure of loaded configuration files. This means that things like comments or blank lines in a saved properties file will closely resemble the original properties file (the algorithm is not 100 percent perfect, but for most use cases it should be sufficient).
Şöyle yaparız.
PropertiesConfigurationLayout layout = config.getLayout();
save metodu
Şöyle yaparız.
config.save( new FileWriter( "c:/try/out.props"));
setProperty metodu
cleartProperty(...) + addProperty(...) gibi çalışır.
Örnek
Şöyle yaparız.
PropertiesConfiguration config =  new PropertiesConfiguration("in.properties");
config.setProperty("application.version", "myvar");

1 Mayıs 2019 Çarşamba

FTPSClient Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
constructor
Şöyle yaparız.
FTPSClient ftpClient = new FTPSClient();
connect metodu
Şöyle yaparız.
ftpClient.connect("foo.com", 21);
enterLocalPassiveMode metodu
Şöyle yaparız.
ftpClient.enterLocalPassiveMode();
login metodu
Şöyle yaparız.
ftpClient.login("login", "password");
setFileType metodu
Şöyle yaparız.
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
setTrustManager metodu
Server Verification with TLS1.2 için şöyle yaparız.
File storeFile = new File("pure-ftpd.jks");
KeyStore keystore = loadKeyStore("JKS", storeFile, "password");
X509TrustManager defaultTM = TrustManagerUtils.getDefaultTrustManager(keystore);
String[] TLSversions = new String[]{"TLSv1.2"};
FTPSClient ftpTLS = new FTPSClient("SSL", false);
ftpTLS.setEnabledProtocols(TLSversions);
ftpTLS.setTrustManager(defaultTM);
ftpTLS.addProtocolCommandListener(new PrintCommandListener(
  new PrintWriter(System.out), true));
ftpTLS.setRemoteVerificationEnabled(true);
ftpTLS.setDefaultPort(21);
ftpTLS.connect("127.0.0.1", 21);

24 Nisan 2019 Çarşamba

CatalogFactoryBase Sınıfı

getCatalog metodu
Şöyle yaparız.
Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();

16 Nisan 2019 Salı

Triple Sınıfı

of metodu
Şöyle yaparız
Triple.of("NOTIFICATION", EventType.EVENT_TYPE_COMMENT_VIDEO.getEventType() ,"GRP_USER")

15 Nisan 2019 Pazartesi

LRUMap Sınıfı

Giriş
Açıklaması şöyle.
A Map implementation with a fixed maximum size which removes the least recently used entry if an entry is added when full.
constructor
Şöyle yaparız.
int maxSize= 1024
LRUMap myCacheMap = new LRUMap(maxSize)

11 Nisan 2019 Perşembe

CircularFifoBuffer Sınıfı

constructor
commons-lang 4 ile şöyle yaparız.
Queue buf = new CircularFifoQueue(4);
add metodu
Kapasite dolunce en eski elemanı siler. Şöyle yaparız.
Buffer buf = new CircularFifoBuffer(4);
buf.add("A");
buf.add("B");
buf.add("C");
buf.add("D"); //ABCD
buf.add("E"); //BCDE
remove metodu
En eski elemanı döndürür.