Commit 569ad96a authored by Riegel's avatar Riegel
Browse files

Style: Rename function and field

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 18 additions and 13 deletions
+18 -13
...@@ -30,7 +30,7 @@ public class ArchivePacker { ...@@ -30,7 +30,7 @@ public class ArchivePacker {
tmpDir = Files.createTempDirectory("zipTmp"); tmpDir = Files.createTempDirectory("zipTmp");
tmpDir.toFile().deleteOnExit(); tmpDir.toFile().deleteOnExit();
for (CityGmlZipEntry entry : archive.getEntries()) { for (CityGmlZipEntry entry : archive.getEntries()) {
if (entry.getErrorType() != null || !entry.isDecompressed()) { if (entry.getErrorType() != null || !entry.isLoaded()) {
continue; continue;
} }
CityDoctorModel model = entry.getModel(); CityDoctorModel model = entry.getModel();
......
...@@ -26,7 +26,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -26,7 +26,7 @@ public class CityGmlZipEntry implements Serializable {
private final String displayName; private final String displayName;
private transient CityDoctorModel model; private transient CityDoctorModel model;
private CityGmlZipArchive parentArchive; private CityGmlZipArchive parentArchive;
private boolean decompressed; private boolean inMemory;
private long fileSize = -1L; private long fileSize = -1L;
private static final long MB = 1024 * 1024L; private static final long MB = 1024 * 1024L;
private ZipEntryErrorType errorType = null; private ZipEntryErrorType errorType = null;
...@@ -42,7 +42,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -42,7 +42,7 @@ public class CityGmlZipEntry implements Serializable {
} }
public void loadEntry(ParserConfiguration config, ProgressListener l) { public void loadEntry(ParserConfiguration config, ProgressListener l) {
if (decompressed) { if (inMemory) {
return; return;
} }
if (errorType != null) { if (errorType != null) {
...@@ -51,7 +51,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -51,7 +51,7 @@ public class CityGmlZipEntry implements Serializable {
} }
try { try {
this.model = CityGmlParser.parseCityGmlZipEntry(this, config, l); this.model = CityGmlParser.parseCityGmlZipEntry(this, config, l);
this.decompressed = true; this.inMemory = true;
} catch (CityGmlParseException | InvalidGmlFileException e) { } catch (CityGmlParseException | InvalidGmlFileException e) {
logger.error(e); logger.error(e);
this.errorType = ZipEntryErrorType.INVALID_CITY_GML_FILE; this.errorType = ZipEntryErrorType.INVALID_CITY_GML_FILE;
...@@ -91,7 +91,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -91,7 +91,7 @@ public class CityGmlZipEntry implements Serializable {
return memoryLimit > (fileSize / MB); return memoryLimit > (fileSize / MB);
} }
protected CityGmlZipEntry(ZipEntry entry, CityGmlZipArchive parentArchive, boolean decompressed) { private CityGmlZipEntry(ZipEntry entry, CityGmlZipArchive parentArchive, boolean inMemory) {
this.fileName = entry.getName(); this.fileName = entry.getName();
this.filePath = Path.of(entry.getName()); this.filePath = Path.of(entry.getName());
this.displayName = filePath.getFileName().toString(); this.displayName = filePath.getFileName().toString();
...@@ -99,7 +99,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -99,7 +99,7 @@ public class CityGmlZipEntry implements Serializable {
this.fileSize = entry.getSize(); this.fileSize = entry.getSize();
} }
this.model = null; this.model = null;
this.decompressed = decompressed; this.inMemory = inMemory;
this.parentArchive = parentArchive; this.parentArchive = parentArchive;
} }
...@@ -140,8 +140,13 @@ public class CityGmlZipEntry implements Serializable { ...@@ -140,8 +140,13 @@ public class CityGmlZipEntry implements Serializable {
return filePath.getParent().resolve(libraryObjectPath); return filePath.getParent().resolve(libraryObjectPath);
} }
public boolean isDecompressed() { /**
return decompressed; * Returns whether this entry has been loaded into memory.
*
* @return true if
*/
public boolean isLoaded() {
return inMemory;
} }
/** /**
......
...@@ -200,7 +200,7 @@ public class CityDoctorController { ...@@ -200,7 +200,7 @@ public class CityDoctorController {
} }
public void loadZipEntry(CityGmlZipEntry entry) { public void loadZipEntry(CityGmlZipEntry entry) {
if (!entry.isDecompressed()) { if (!entry.isLoaded()) {
entry.loadEntry(currentConfig); entry.loadEntry(currentConfig);
} }
if (entry.getErrorType() != null) { if (entry.getErrorType() != null) {
......
...@@ -118,7 +118,7 @@ public class ZipEntryManager { ...@@ -118,7 +118,7 @@ public class ZipEntryManager {
private final String unknownValueText = Localization.getText("ZipEntryManager.unknownValue"); private final String unknownValueText = Localization.getText("ZipEntryManager.unknownValue");
private static final Predicate<ZipEntryNode> entryDecompressed = node -> private static final Predicate<ZipEntryNode> entryDecompressed = node ->
(node.getEntry().isDecompressed() || node.getEntry().getErrorType() != null); (node.getEntry().isLoaded() || node.getEntry().getErrorType() != null);
private static final Predicate<ZipEntryNode> entryValidated = entryDecompressed.and(node -> private static final Predicate<ZipEntryNode> entryValidated = entryDecompressed.and(node ->
(node.getEntry().getModel() != null && node.getEntry().getModel().isValidated())); (node.getEntry().getModel() != null && node.getEntry().getModel().isValidated()));
...@@ -383,8 +383,8 @@ public class ZipEntryManager { ...@@ -383,8 +383,8 @@ public class ZipEntryManager {
} else { } else {
erroneousValue.setText(Localization.getText("ZipEntryManager.no")); erroneousValue.setText(Localization.getText("ZipEntryManager.no"));
loadBtn.setDisable(!entry.isDecompressed()); loadBtn.setDisable(!entry.isLoaded());
decompressBtn.setDisable(entry.isDecompressed()); decompressBtn.setDisable(entry.isLoaded());
if (entry.getModel() == null) { if (entry.getModel() == null) {
validatedValue.setText(unknownValueText); validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText); objectCountValue.setText(unknownValueText);
......
...@@ -25,7 +25,7 @@ public class ZipEntryNode { ...@@ -25,7 +25,7 @@ public class ZipEntryNode {
return Color.RED; return Color.RED;
} }
return Color.BLUE; return Color.BLUE;
} else if (entry.isDecompressed()) { } else if (entry.isLoaded()) {
return Color.BLUE; return Color.BLUE;
} else { } else {
return Color.BLACK; return Color.BLACK;
......
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