mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
This commit is contained in:
parent
8ff88645d4
commit
5deec17711
@ -44,6 +44,7 @@ import java.nio.charset.Charset;
|
|||||||
import net.sourceforge.plantuml.Log;
|
import net.sourceforge.plantuml.Log;
|
||||||
import net.sourceforge.plantuml.StringLocated;
|
import net.sourceforge.plantuml.StringLocated;
|
||||||
import net.sourceforge.plantuml.log.Logme;
|
import net.sourceforge.plantuml.log.Logme;
|
||||||
|
import net.sourceforge.plantuml.preproc2.ReadFilterMergeLines;
|
||||||
import net.sourceforge.plantuml.security.SURL;
|
import net.sourceforge.plantuml.security.SURL;
|
||||||
import net.sourceforge.plantuml.utils.StartUtils;
|
import net.sourceforge.plantuml.utils.StartUtils;
|
||||||
|
|
||||||
@ -67,22 +68,21 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
private StartDiagramExtractReader(ReadLine raw, String suf) {
|
private StartDiagramExtractReader(ReadLine raw, String suf) {
|
||||||
int bloc = 0;
|
int bloc = 0;
|
||||||
String uid = null;
|
String uid = null;
|
||||||
if (suf != null && suf.matches("\\d+")) {
|
if (suf != null && suf.matches("\\d+"))
|
||||||
bloc = Integer.parseInt(suf);
|
bloc = Integer.parseInt(suf);
|
||||||
} else {
|
else
|
||||||
uid = suf;
|
uid = suf;
|
||||||
}
|
|
||||||
if (bloc < 0) {
|
if (bloc < 0)
|
||||||
bloc = 0;
|
bloc = 0;
|
||||||
}
|
|
||||||
this.raw = raw;
|
this.raw = raw;
|
||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
try {
|
try {
|
||||||
while ((s = raw.readLine()) != null) {
|
while ((s = raw.readLine()) != null) {
|
||||||
if (StartUtils.isArobaseStartDiagram(s.getString()) && checkUid(uid, s)) {
|
if (StartUtils.isArobaseStartDiagram(s.getString()) && checkUid(uid, s)) {
|
||||||
if (bloc == 0) {
|
if (bloc == 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
bloc--;
|
bloc--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,37 +94,41 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkUid(String uid, StringLocated s) {
|
private boolean checkUid(String uid, StringLocated s) {
|
||||||
if (uid == null) {
|
if (uid == null)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
if (s.toString().matches(".*id=" + uid + "\\W.*")) {
|
if (s.toString().matches(".*id=" + uid + "\\W.*"))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadLine getReadLine(FileWithSuffix f2, StringLocated s, Charset charset) {
|
private static ReadLine getReadLine(FileWithSuffix f2, StringLocated s, Charset charset) {
|
||||||
try {
|
try {
|
||||||
final Reader tmp1 = f2.getReader(charset);
|
final Reader tmp1 = f2.getReader(charset);
|
||||||
if (tmp1 == null) {
|
if (tmp1 == null)
|
||||||
return new ReadLineSimple(s, "Cannot open " + f2.getDescription());
|
return new ReadLineSimple(s, "Cannot open " + f2.getDescription());
|
||||||
}
|
|
||||||
return new UncommentReadLine(ReadLineReader.create(tmp1, f2.getDescription()));
|
return uncommentAndMerge(ReadLineReader.create(tmp1, f2.getDescription()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadLine getReadLine(InputStream is, StringLocated s, String description) {
|
private static ReadLine getReadLine(InputStream is, StringLocated s, String description) {
|
||||||
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(is), description));
|
return uncommentAndMerge(ReadLineReader.create(new InputStreamReader(is), description));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadLine getReadLine(SURL url, StringLocated s, Charset charset) {
|
private static ReadLine getReadLine(SURL url, StringLocated s, Charset charset) {
|
||||||
final InputStream tmp = url.openStream();
|
final InputStream tmp = url.openStream();
|
||||||
if (tmp == null) {
|
if (tmp == null)
|
||||||
return new ReadLineSimple(s, "Cannot connect");
|
return new ReadLineSimple(s, "Cannot connect");
|
||||||
|
|
||||||
|
return uncommentAndMerge(ReadLineReader.create(new InputStreamReader(tmp, charset), url.toString()));
|
||||||
}
|
}
|
||||||
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(tmp, charset), url.toString()));
|
|
||||||
|
private static ReadLine uncommentAndMerge(ReadLine reader) {
|
||||||
|
return new UncommentReadLine(new ReadFilterMergeLines().applyFilter(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean containsStartDiagram(FileWithSuffix f2, StringLocated s, Charset charset) throws IOException {
|
static public boolean containsStartDiagram(FileWithSuffix f2, StringLocated s, Charset charset) throws IOException {
|
||||||
@ -145,23 +149,22 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
private static boolean containsStartDiagram(final ReadLine r) throws IOException {
|
private static boolean containsStartDiagram(final ReadLine r) throws IOException {
|
||||||
try {
|
try {
|
||||||
StringLocated s = null;
|
StringLocated s = null;
|
||||||
while ((s = r.readLine()) != null) {
|
while ((s = r.readLine()) != null)
|
||||||
if (StartUtils.isArobaseStartDiagram(s.getString())) {
|
if (StartUtils.isArobaseStartDiagram(s.getString()))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
if (r != null) {
|
if (r != null)
|
||||||
r.close();
|
r.close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringLocated readLine() throws IOException {
|
public StringLocated readLine() throws IOException {
|
||||||
if (finished) {
|
if (finished)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
final StringLocated result = raw.readLine();
|
final StringLocated result = raw.readLine();
|
||||||
if (result != null && StartUtils.isArobaseEndDiagram(result.getString())) {
|
if (result != null && StartUtils.isArobaseEndDiagram(result.getString())) {
|
||||||
finished = true;
|
finished = true;
|
||||||
|
@ -49,9 +49,9 @@ public class ReadFilterAnd implements ReadFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ReadLine applyFilter(ReadLine current) {
|
public ReadLine applyFilter(ReadLine current) {
|
||||||
for (ReadFilter f : all) {
|
for (ReadFilter f : all)
|
||||||
current = f.applyFilter(current);
|
current = f.applyFilter(current);
|
||||||
}
|
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 4;
|
final int beta = 5;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user