mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-24 22:07:33 +00:00
Merge pull request #665 from matthew16550/SourceFileReaderAbstract
Extract common code to SourceFileReaderAbstract constructor
This commit is contained in:
commit
061ce99bc5
@ -38,12 +38,10 @@ package net.sourceforge.plantuml;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
import net.sourceforge.plantuml.security.SFile;
|
||||
|
||||
public class SourceFileReader extends SourceFileReaderAbstract implements ISourceFileReader {
|
||||
@ -70,11 +68,7 @@ public class SourceFileReader extends SourceFileReaderAbstract implements ISourc
|
||||
|
||||
public SourceFileReader(Defines defines, final File file, File outputDirectory, List<String> config, String charset,
|
||||
FileFormatOption fileFormatOption) throws IOException {
|
||||
this.file = file;
|
||||
this.fileFormatOption = fileFormatOption;
|
||||
if (file.exists() == false) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
super(file, fileFormatOption, defines, config, charset);
|
||||
FileSystem.getInstance().setCurrentDir(SFile.fromFile(file.getAbsoluteFile().getParentFile()));
|
||||
if (outputDirectory == null) {
|
||||
outputDirectory = file.getAbsoluteFile().getParentFile();
|
||||
@ -86,9 +80,6 @@ public class SourceFileReader extends SourceFileReaderAbstract implements ISourc
|
||||
}
|
||||
this.outputDirectory = outputDirectory;
|
||||
|
||||
final Reader reader = getReader(charset);
|
||||
builder = new BlockUmlBuilder(config, charset, defines, reader,
|
||||
SFile.fromFile(file.getAbsoluteFile().getParentFile()), FileWithSuffix.getFileName(file));
|
||||
}
|
||||
|
||||
private File getDirIfDirectory(String newName) throws FileNotFoundException {
|
||||
|
@ -53,6 +53,7 @@ import java.util.Set;
|
||||
import net.sourceforge.plantuml.api.ImageDataSimple;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.error.PSystemError;
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
import net.sourceforge.plantuml.security.SFile;
|
||||
import net.sourceforge.plantuml.security.SecurityUtils;
|
||||
@ -68,6 +69,19 @@ public abstract class SourceFileReaderAbstract implements ISourceFileReader {
|
||||
private boolean checkMetadata;
|
||||
private boolean noerror;
|
||||
|
||||
public SourceFileReaderAbstract(File file, FileFormatOption fileFormatOption, Defines defines, List<String> config, String charset)
|
||||
throws IOException {
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
this.file = file;
|
||||
this.fileFormatOption = fileFormatOption;
|
||||
this.builder = new BlockUmlBuilder(config, charset, defines, getReader(charset),
|
||||
SFile.fromFile(file.getAbsoluteFile().getParentFile()), FileWithSuffix.getFileName(file));
|
||||
}
|
||||
|
||||
public void setCheckMetadata(boolean checkMetadata) {
|
||||
this.checkMetadata = checkMetadata;
|
||||
}
|
||||
|
@ -40,18 +40,12 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
import net.sourceforge.plantuml.security.SFile;
|
||||
|
||||
public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements ISourceFileReader {
|
||||
|
||||
public SourceFileReaderCopyCat(Defines defines, final File file, File outputDirectory, List<String> config,
|
||||
String charset, FileFormatOption fileFormatOption) throws IOException {
|
||||
this.file = file;
|
||||
this.fileFormatOption = fileFormatOption;
|
||||
if (file.exists() == false) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
super(file, fileFormatOption, defines, config, charset);
|
||||
final String path = file.getParentFile().getPath();
|
||||
// System.err.println("SourceFileReaderCopyCat::path=" + path);
|
||||
// System.err.println("SourceFileReaderCopyCat::outputDirectory=" +
|
||||
@ -63,8 +57,6 @@ public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements
|
||||
// System.err.println("SourceFileReaderCopyCat=" +
|
||||
// this.outputDirectory.getPath() + " "
|
||||
// + this.outputDirectory.getAbsolutePath());
|
||||
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset),
|
||||
SFile.fromFile(file.getAbsoluteFile().getParentFile()), FileWithSuffix.getFileName(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,12 +5,12 @@
|
||||
* (C) Copyright 2009-2020, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
*
|
||||
* http://plantuml.com/patreon (only 1$ per month!)
|
||||
* http://plantuml.com/paypal
|
||||
*
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
@ -40,24 +40,15 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
import net.sourceforge.plantuml.security.SFile;
|
||||
|
||||
public class SourceFileReaderHardFile extends SourceFileReaderAbstract implements ISourceFileReader {
|
||||
|
||||
public SourceFileReaderHardFile(Defines defines, final File file, File outputFile, List<String> config,
|
||||
String charset, FileFormatOption fileFormatOption) throws IOException {
|
||||
this.file = file;
|
||||
this.fileFormatOption = fileFormatOption;
|
||||
super(file, fileFormatOption, defines, config, charset);
|
||||
this.outputFile = outputFile;
|
||||
if (file.exists() == false) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
FileSystem.getInstance().setCurrentDir(SFile.fromFile(file.getAbsoluteFile().getParentFile()));
|
||||
|
||||
final SFile parentFile = SFile.fromFile(file.getAbsoluteFile().getParentFile());
|
||||
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), parentFile,
|
||||
FileWithSuffix.getFileName(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user