Package com.itstherules.stream.model

Source Code of com.itstherules.stream.model.ItemsModel

package com.itstherules.stream.model;

import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;

import com.itstherules.stream.filefilter.ItemsFilter;


public class ItemsModel extends AbstractModel {
 
  private String extensions;
  private final String baseDirectory;
  private final String currentDirectory;
 
  public ItemsModel(String baseDirectory,String currentDirectory, String extensions) {
    this.baseDirectory = baseDirectory;
    this.currentDirectory = currentDirectory;
    this.extensions = extensions;
  }

  public String getDirectoryPath() {
    return getFullPath(this.baseDirectory) + "/" + nullGuard(currentDirectory);
  }

  public File get(String fileName) throws FileNotFoundException{
    for (File file : asList()) {
      if(fileName.equalsIgnoreCase(file.getName())){
        return file;
      }
    }
    throw new FileNotFoundException();
  }
 
  public FileFilter getFilter() {
    return new ItemsFilter(extensions);
  }
 
  public String getCurrentDirectory() {
    return currentDirectory;
  }
 
  public String getBaseDirectory() {
    return baseDirectory;
  }
 
}
TOP

Related Classes of com.itstherules.stream.model.ItemsModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.