Commit b7569651 authored by Riegel's avatar Riegel
Browse files

Refactor: Rename CityGmlZipInputStream

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 16 additions and 16 deletions
+16 -16
......@@ -39,7 +39,7 @@ import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipInputStream;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -199,8 +199,8 @@ public class CityGmlParser {
CityGMLContext context = getContext();
if (config.getValidate()) {
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(entry)){
List<String> messages = validateStream(cgis.getInputStream(),context);
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)){
List<String> messages = validateStream(entryFile.getInputStream(),context);
if (!messages.isEmpty()) {
throw new InvalidGmlFileException("Invalid GML File. First error: \n" + messages.get(0));
}
......@@ -220,8 +220,8 @@ public class CityGmlParser {
public static CityDoctorModel decompressAndParseCityGmlEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l, CityGMLContext context)
throws CityGmlParseException {
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(entry)){
BufferedInputStream bis = new BufferedInputStream(cgis.getInputStream());
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)){
BufferedInputStream bis = new BufferedInputStream(entryFile.getInputStream());
readEpsgCodeFromInputStream(bis,config);
CityGMLInputFactory in = context.createCityGMLInputFactory()
.withChunking(ChunkOptions.chunkByProperties(chunkProperties).skipCityModel(false));
......@@ -294,8 +294,8 @@ public class CityGmlParser {
public static void streamCityGml(CityGmlZipEntry entry, ParserConfiguration config, CityGmlConsumer cityObjectConsumer,
String outputFile) throws CityGmlParseException, IOException {
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(entry)) {
parseEpsgCodeFromStream(cgis.getInputStream(), config);
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) {
parseEpsgCodeFromStream(entryFile.getInputStream(), config);
startReadingCityGmlZipEntry(entry, config, null,cityObjectConsumer, outputFile);
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new CityGmlParseException("Failed to read CityGML stream", e);
......@@ -360,8 +360,8 @@ public class CityGmlParser {
private static void startReadingCityGmlZipEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l,
CityGmlConsumer cityObjectConsumer, String outputFile) {
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(entry);
ObservedInputStream ois = new ObservedInputStream(cgis.getInputStream(), entry.getFileSize())){
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry);
ObservedInputStream ois = new ObservedInputStream(entryFile.getInputStream(), entry.getFileSize())){
if (l != null) {
ois.addListener(l::updateProgress);
}
......
......@@ -71,8 +71,8 @@ public class CityGmlZipEntry implements Serializable {
if (fileSize != -1L) {
return memoryLimit > fileSize;
}
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(this)){
long filesize = cgis.getFileSize();
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(this)){
long filesize = entryFile.getFileSize();
if (filesize != -1){
this.fileSize = filesize;
return memoryLimit > fileSize;
......
......@@ -6,14 +6,14 @@ import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class CityGmlZipInputStream implements AutoCloseable {
public class CityGmlZipEntryFile implements AutoCloseable {
private final ZipFile zip;
private final ZipEntry zipEntry;
private boolean closed = false;
private static final long MB = 1024 * 1024L;
public CityGmlZipInputStream(CityGmlZipEntry entry) throws IOException {
public CityGmlZipEntryFile(CityGmlZipEntry entry) throws IOException {
CityGmlZipArchive archive = entry.getArchive();
zip = new ZipFile(archive.getArchivePath().toFile());
zipEntry = zip.getEntry(entry.getFileName());
......
......@@ -49,7 +49,7 @@ import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipInputStream;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -754,8 +754,8 @@ public class Checker {
PdfStreamReporter pdfReporter = getPdfReporter(config, pdfBos, fileName);
// execute schematron first
try (CityGmlZipInputStream cgis = new CityGmlZipInputStream(entry)) {
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, cgis.getInputStream());
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) {
SvrlContentHandler handler = executeSchematronValidationIfAvailable(config, entryFile.getInputStream());
CityGmlConsumer con = new StreamCityGmlConsumer(c, xmlReporter, pdfReporter, handler, config, null);
// parse and validate
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment