All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.common.file.StoringFileContext Maven / Gradle / Ivy

There is a newer version: 4.7.2
Show newest version
package org.onetwo.common.file;

import java.io.InputStream;
import java.util.Map;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

public class StoringFileContext {
	
	public static StoringFileContext create(InputStream inputStream, String fileName){
		return new StoringFileContext(null, inputStream, fileName);
	}
	
	public static StoringFileContext create(String module, InputStream inputStream, String fileName){
		return new StoringFileContext(module, inputStream, fileName);
	}
	
	private InputStream inputStream;
	private String fileName;
	private Map context;
	private String module;
	private StoreFilePathStrategy storeFilePathStrategy = SimpleFileStorer.SIMPLE_STORE_STRATEGY;
	
	
	public StoringFileContext(String module, InputStream inputStream, String fileName) {
		super();
		this.inputStream = inputStream;
		this.fileName = fileName;
		this.module = module;
	}

	public StoringFileContext put(String name, Object value){
		if(context==null){
			context = Maps.newHashMap();
		}
		context.put(name, value);
		return this;
	}

	public Map getContext() {
		return context==null?ImmutableMap.of():ImmutableMap.copyOf(context);
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public String getFileName() {
		return fileName;
	}

	public String getModule() {
		return module;
	}

	public void setModule(String module) {
		this.module = module;
	}

	public StoreFilePathStrategy getStoreFilePathStrategy() {
		return storeFilePathStrategy;
	}

	public void setStoreFilePathStrategy(StoreFilePathStrategy storeFilePathStrategy) {
		this.storeFilePathStrategy = storeFilePathStrategy;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy