16 Eylül 2019 Pazartesi

POI Excel Cell Arayüzü

Giriş
Şu satırı dahil ederiz.
import org.apache.poi.ss.usermodel.Cell;
Row sınıfı tarafından yaratılır.

getCellTypeEnum metodu
1 NUMERIC
getNumericCellValue() ile hücre değerine erişiriz.
Örnek
Şöyle yaparız
switch (cell.getCellType()) {
  case Cell.CELL_TYPE_NUMERIC:
    System.out.println((int)cell.getNumericCellValue());
    break;
  ...
}
2. STRING
getStringCellValue() ile hücre değerine erişiriz.
Örnek
Şöyle yaparız
switch (cell.getCellType()) {
  case Cell.CELL_TYPE_STRING:
    System.out.println(cell.getStringCellValue());
    break;
   ...
}
Örnek
Şöyle yaparız.
Cell currentCell = ...;

if(currentCell.getCellTypeEnum() == CellType.STRING) {
  String phoneNumber = currentCell.toString().trim();
}
setCellValue metodu
Date, Boolean, String, Double gibi nesneler alabilir.

Örnek
Şöyle yaparız
String cellValue = ... ;
cell.setCellValue(cellValue);

12 Eylül 2019 Perşembe

POI Excel XSSFSheet Sınıfı

createDrawingPatriarch metodu
Şöyle yaparız.
XSSFDrawing drawing = worksheet.createDrawingPatriarch();
createRow metodu
XSSFRow nesnesi döner.

Örnek
Şöyle yaparız.
int i = 0;
XSSFRow row = spreadsheet.createRow(i);
createTable metodu
XSSFTable nesnesi döner.

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");