11 Eylül 2019 Çarşamba

OLSMultipleLinearRegression

Giriş
Şu satırı dahil ederiz
import org.apache.commons.math4.linear.Array2DRowRealMatrix;
import org.apache.commons.math4.linear.RealMatrix;
import org.apache.commons.math4.linear.RealVector;
import org.apache.commons.math4.stat.regression.OLSMultipleLinearRegression;
estimateRegressionParameters metodu
Şöyle yaparız.
OLSMultipleLinearRegression regression = ...;
double []beta= regression.estimateRegressionParameters();
estimateRegressionParametersStandardErrors metodu
Şöyle yaparız.
OLSMultipleLinearRegression regression = ...;
double []sigmas= regression.estimateRegressionParametersStandardErrors();

10 Eylül 2019 Salı

VFS FileSystemOptions Sınıfı

constructor
Şöyle yaparız.
FileSystemOptions opts = new FileSystemOptions();

VFS SftpFileSystemConfigBuilder Sınıfı

setUserDirIsRoot metodu
Root dizini atar
Örnek
Şöyle yaparız.
public static FileSystemOptions createDefaultOptions() throws FileSystemException {
  FileSystemOptions opts = new FileSystemOptions();

  SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(
        opts, "no");

  SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);

  return opts;
}

VFS StandardFileSystemManager Sınıfı

Giriş
Virtual File System projesine aittir. Şu satırı dahil ederiz
import org.apache.commons.vfs2.impl.StandartFileSytemManager;
costructor
Normalde bu sınıfı elle yaratmaya gerek yok. Şöyle yaparız. Bu kod zaten StandardFileSystemManager nesnesi dönüyor.


FileSystemManager fsManager = VFS.getManager();
Örnek
Şöyle yaparız.
StandardFileSystemManager fsManager = new StandardFileSystemManager();
init metodu
Şöyle yaparız.
StandardFileSystemManager fsManager = new StandardFileSystemManager();
fsManager.init();
resolveFile metodu
Örnek
Şöyle yaparız.
File file = ...
FileObject localFile = fsManager.resolveFile(file.getAbsolutePath());
Örnek
Şöyle yaparız.
FileObject remote = fsManager.resolveFile(
        "sftp://<USERNAME>:<PASSWORD>@<DOMAINNAME>.com/tmp1.zip");

9 Eylül 2019 Pazartesi

Lang3 BooleanUtils Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.commons.lang3.BooleanUtils;
and metodu
Primitive veya Object kullanılabilir.
Örnek
Şöyle yaparız.
BooleanUtils.and(new boolean[]{true, true}) 
BooleanUtils.and(new Boolean[]{Boolean.TRUE, Boolean.TRUE})
isTrue metodu
Boolean nesnenin null kontrolünü de yapar.
Örnek
Şöyle yaparız
Boolean isReady = ...;

if (BooleanUtils.isTrue(isReady)) {
   // ...
}
toBoolean metodu
Unboxing işlemini yaparken Boolean nesnenin null kontrolünü de yapar.

toStringOnOff metodu
İmzası şöyle. Sonuç olarak "on","off" veya "null" döner
toStringOnOff(boolean bool)
toStringOnOff(Boolean bool)
toStringTrueFalse metodu
İmzası şöyle. Sonuç olarak "true","false" veya "null" döner
toStringTrueFalse(boolean bool)
toStringTrueFalse(Boolean bool)

toStringYesNo metodu
İmzası şöyle. Sonuç olarak "yes","no" veya "null" döner
toStringYesNo(boolean bool)
toStringYesNo(Boolean bool)
Şöyle yaparız. Çıktı olarak "no" alırız
boolean myBoolean = false;
String result = BooleanUtils.toStringYesNo(myBoolean);
System.out.println(result);

3 Eylül 2019 Salı

Imaging Sınıfı

getBufferedImage metodu
Şöyle yaparız
BufferedImage image = Imaging.getBufferedImage(new File(image));
getMetaData metodu
Şöyle yaparız
File f = ...;
ImageMetadata meta = Imaging.getMetadata(f);
writeImageToBytes metodu
Şöyle yaparız
BufferedImage image = ...;
ImageFormat format = ImageFormats.JPEG;
Map<String, Object> params = new HashMap<>();
return Imaging.writeImageToBytes(image, format, params);