diff options
| author | 2015-02-28 23:36:47 -0500 | |
|---|---|---|
| committer | 2015-02-28 23:36:47 -0500 | |
| commit | 88671184e20b3ad3791125cf96c83ca048cb2861 (patch) | |
| tree | 6c86f1ea61666ff2584b434d5f8df4d3fd83263c /src/cuchaz/enigma/convert/MatchesWriter.java | |
| parent | switch to better-maintained version of JSyntaxPane (diff) | |
| download | enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.tar.gz enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.tar.xz enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.zip | |
refactor converter a bit for upcoming convert gui
Diffstat (limited to 'src/cuchaz/enigma/convert/MatchesWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/convert/MatchesWriter.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/convert/MatchesWriter.java b/src/cuchaz/enigma/convert/MatchesWriter.java new file mode 100644 index 0000000..49ffb6d --- /dev/null +++ b/src/cuchaz/enigma/convert/MatchesWriter.java | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | package cuchaz.enigma.convert; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileWriter; | ||
| 5 | import java.io.IOException; | ||
| 6 | |||
| 7 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 8 | |||
| 9 | |||
| 10 | public class MatchesWriter { | ||
| 11 | |||
| 12 | public static void write(Matches matches, File file) | ||
| 13 | throws IOException { | ||
| 14 | try (FileWriter out = new FileWriter(file)) { | ||
| 15 | for (ClassMatch match : matches) { | ||
| 16 | writeMatch(out, match); | ||
| 17 | } | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | private static void writeMatch(FileWriter out, ClassMatch match) | ||
| 22 | throws IOException { | ||
| 23 | writeClasses(out, match.sourceClasses); | ||
| 24 | out.write(":"); | ||
| 25 | writeClasses(out, match.destClasses); | ||
| 26 | out.write("\n"); | ||
| 27 | } | ||
| 28 | |||
| 29 | private static void writeClasses(FileWriter out, Iterable<ClassEntry> classes) | ||
| 30 | throws IOException { | ||
| 31 | boolean isFirst = true; | ||
| 32 | for (ClassEntry entry : classes) { | ||
| 33 | if (isFirst) { | ||
| 34 | isFirst = false; | ||
| 35 | } else { | ||
| 36 | out.write(","); | ||
| 37 | } | ||
| 38 | out.write(entry.toString()); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||