com.poiji.bind.mapping.XSSFUnmarshallerStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of poiji2 Show documentation
Show all versions of poiji2 Show documentation
Perfect annotation based library to read and write excel files
package com.poiji.bind.mapping;
import com.poiji.bind.PoijiInputStream;
import com.poiji.exception.PoijiException;
import com.poiji.option.PoijiOptions;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.function.Consumer;
/**
* Created by hakan on 22/10/2017
*/
final class XSSFUnmarshallerStream extends XSSFUnmarshaller {
private final PoijiInputStream> poijiInputStream;
XSSFUnmarshallerStream(PoijiInputStream> poijiInputStream, PoijiOptions options) {
super(options);
this.poijiInputStream = poijiInputStream;
}
@Override
public void unmarshal(Class type, Consumer super T> consumer) {
if (options.getPassword() != null) {
returnFromEncryptedFile(type, consumer);
return;
}
returnFromExcelFile(type, consumer);
}
@Override
public void returnFromExcelFile(Class type, Consumer super T> consumer) {
try (OPCPackage open = OPCPackage.open(poijiInputStream.stream())) {
unmarshal0(type, consumer, open);
} catch (ParserConfigurationException | SAXException | IOException | OpenXML4JException e) {
throw new PoijiException("Problem occurred while reading data", e);
}
}
@Override
public void returnFromEncryptedFile(Class type, Consumer super T> consumer) {
try (POIFSFileSystem fs = new POIFSFileSystem(poijiInputStream.stream())) {
listOfEncryptedItems(type, consumer, fs);
} catch (IOException e) {
throw new PoijiException("Problem occurred while reading data", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy