From 6a4d236fb092ca4a651736796b25bed381b46155 Mon Sep 17 00:00:00 2001 From: Andrey Ruzhanskiy <andrey.ruzhanskiy@tu-dresden.de> Date: Fri, 12 Jul 2019 14:21:37 +0200 Subject: [PATCH] Added new Exception, first code cleanup. --- build.gradle | 9 +- .../de/tudresden/inf/mci/brailleplot/App.java | 50 +++++++- .../commandline/CommandLineParser.java | 2 +- .../brailleplot/commandline/SettingType.java | 1 - .../JavaPropertiesConfigurationValidator.java | 13 +++ .../configparser/ValidProperty.java | 2 +- .../exporter/AbstractBrailleTableParser.java | 7 ++ .../exporter/AbstractDocumentBuilder.java | 24 ++++ .../brailleplot/exporter/BrailleAlphabet.java | 5 +- .../exporter/BrailleGerman6Dots.java | 108 ------------------ .../exporter/BrailleGerman8Dots.java | 19 --- .../mci/brailleplot/exporter/JsonParser.java | 8 ++ .../brailleplot/exporter/NormalBuilder.java | 40 +++++-- .../exporter/NotSupportedFileExtension.java | 25 ++++ .../brailleplot/exporter/PrintDirector.java | 7 +- .../exporter/PropertiesParser.java | 11 ++ .../mci/brailleplot/exporter/XmlParser.java | 8 ++ .../printabledata/BrailleCell6.java | 15 ++- .../exporter/PrintDirectorTest.java | 5 +- 19 files changed, 209 insertions(+), 150 deletions(-) create mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractBrailleTableParser.java delete mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman6Dots.java delete mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman8Dots.java create mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/JsonParser.java create mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NotSupportedFileExtension.java create mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PropertiesParser.java create mode 100644 src/main/java/de/tudresden/inf/mci/brailleplot/exporter/XmlParser.java diff --git a/build.gradle b/build.gradle index 5cffa0a7..1234b366 100644 --- a/build.gradle +++ b/build.gradle @@ -16,8 +16,8 @@ plugins { id 'checkstyle' } -sourceCompatibility = 11 -targetCompatibility = 11 +sourceCompatibility = 12 +targetCompatibility = 12 repositories { // Use jcenter for resolving your dependencies. @@ -38,6 +38,11 @@ dependencies { // Units compile group: 'javax.measure', name: 'unit-api', version: '2.0-PRD' compile group: 'tec.units', name: 'unit-ri', version: '1.0.3' + + // Parsing + compile group: 'javax.json', name: 'javax.json-api', version: '1.0' + compile group: 'org.glassfish', name: 'javax.json', version: '1.1.4' + } test { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/App.java b/src/main/java/de/tudresden/inf/mci/brailleplot/App.java index eb229134..02d9cbb6 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/App.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/App.java @@ -1,8 +1,7 @@ package de.tudresden.inf.mci.brailleplot; -import de.tudresden.inf.mci.brailleplot.configparser.Format; -import de.tudresden.inf.mci.brailleplot.configparser.Printer; +import de.tudresden.inf.mci.brailleplot.configparser.*; import de.tudresden.inf.mci.brailleplot.exporter.PrintDirector; import de.tudresden.inf.mci.brailleplot.exporter.PrinterConfiguration; @@ -139,6 +138,12 @@ public final class App { // Config Parsing + // TODO make it default if nothing is found in p. + Optional<String> configPath = settingsReader.getSetting(SettingType.PRINTER_CONFIG_PATH); + JavaPropertiesConfigurationParser configParser = new JavaPropertiesConfigurationParser(configPath.get()); + Printer indexV4Printer = configParser.getPrinter(); + indexV4Printer.getProperty("brailletable").toString(); + Format A4Format = configParser.getFormat("A4"); @@ -151,8 +156,7 @@ public final class App { System.out.println("Nein"); } - MatrixData<Boolean> data = new SimpleMatrixDataImpl<Boolean>(new Printer(), new Format(), 20, 18, true); - + MatrixData<Boolean> data = new SimpleMatrixDataImpl<Boolean>(indexV4Printer, A4Format, 18, 20, true); PrintDirector printD = new PrintDirector(PrinterConfiguration.NORMALPRINTER); printD.print("Index Everest-D V4", data); /* @@ -169,5 +173,43 @@ public final class App { return EXIT_SUCCESS; } +/* + public void dummyConfigurationParsing() { + + String workingDir = System.getProperty("user.dir"); + String defaultConfigPath = workingDir + "/defaultConfig.properties"; + String concreteConfigPath = workingDir + "/dummyPrinterConfig.properties"; + + // create parser and parse default config + try { + JavaPropertiesConfigurationParser configParser = new JavaPropertiesConfigurationParser(defaultConfigPath); + Printer defaultPrinter = configParser.getPrinter(); + Format defaultFormat = configParser.getFormat("default"); + // parse concrete configuration with set defaults + configParser = new JavaPropertiesConfigurationParser( + concreteConfigPath, + defaultPrinter, + defaultFormat + ); + Printer printerConfig = configParser.getPrinter(); + for (String property : printerConfig.getPropertyNames()) { + System.out.println("Property: " + property + "=" + printerConfig.getProperty(property)); + } + + for (String formatName : configParser.getFormatNames()) { + System.out.println("Format: " + formatName); + Format formatConfig = configParser.getFormat(formatName); + for (String property : formatConfig.getPropertyNames()) { + System.out.println("Property: " + property + "=" + formatConfig.getProperty(property)); + } + } + } catch (ConfigurationValidationException e) { + System.out.println(e.getMessage()); + } catch (ConfigurationParsingException e) { + System.out.println(e.getMessage()); + } + + } +*/ } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java index f36ad63a..81e77493 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParser.java @@ -24,7 +24,7 @@ public class CommandLineParser { mOptions.addOption("h", SettingType.DISPLAY_HELP.toString(), false, "Print help and exit") .addOption("c", SettingType.CSV_LOCATION.toString(), true, "Path to CSV") .addOption("s", SettingType.SEMANTIC_MAPPING.toString(), true, "Literal for semantic mapping") - .addOption("p", SettingType.PRINTER_CONFIG_PATH.toString(), true, "path to printer configuration file"); + .addOption("p", SettingType.PRINTER_CONFIG_PATH.toString(), true, "Path to printer configuration file"); } /** diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/SettingType.java b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/SettingType.java index 010c9c52..7f807c86 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/SettingType.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/commandline/SettingType.java @@ -11,7 +11,6 @@ public enum SettingType { CSV_LOCATION("csv-path"), PRINTER_CONFIG_PATH("printer-config-path"), SEMANTIC_MAPPING("semantic-mapping"); - private final String mName; SettingType(final String name) { diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java index 8b9e0070..11939d36 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java @@ -1,5 +1,7 @@ package de.tudresden.inf.mci.brailleplot.configparser; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -25,6 +27,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { Predicate<String> requireDouble = JavaPropertiesConfigurationValidator::checkIfDouble; Predicate<String> requireBoolean = JavaPropertiesConfigurationValidator::checkIfBoolean; Predicate<String> requirePositive = JavaPropertiesConfigurationValidator::checkIfPositive; + Predicate<String> requireFileExists = JavaPropertiesConfigurationValidator::checkIfFileExists; // Definition of valid printer properties Map<String, Predicate<String>> p = new HashMap<>(); @@ -38,6 +41,7 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { p.put("max.characterDistance", requireDouble.and(requirePositive)); p.put("min.lineDistance", requireDouble.and(requirePositive)); p.put("max.lineDistance", requireDouble.and(requirePositive)); + p.put("brailletable", requireFileExists); // Definition of valid format properties Map<String, Predicate<String>> f = new HashMap<>(); @@ -146,4 +150,13 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { return false; } } + + private static boolean checkIfFileExists(final String filePath){ + try { + FileInputStream stream = new FileInputStream(filePath); + } catch (FileNotFoundException e) { + return false; + } + return true; + } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java index fcf5002e..1e6cab25 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/ValidProperty.java @@ -5,7 +5,7 @@ package de.tudresden.inf.mci.brailleplot.configparser; * @author Leonard Kupper * @version 2019.06.04 */ -abstract class ValidProperty { +public abstract class ValidProperty { String mName; String mValue; diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractBrailleTableParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractBrailleTableParser.java new file mode 100644 index 00000000..e3dfb087 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractBrailleTableParser.java @@ -0,0 +1,7 @@ +package de.tudresden.inf.mci.brailleplot.exporter; + +public interface AbstractBrailleTableParser { + + int getValue(String key); + +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractDocumentBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractDocumentBuilder.java index 7dca2511..3defff7a 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractDocumentBuilder.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/AbstractDocumentBuilder.java @@ -1,5 +1,7 @@ package de.tudresden.inf.mci.brailleplot.exporter; +import de.tudresden.inf.mci.brailleplot.configparser.Printer; import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; +import de.tudresden.inf.mci.brailleplot.printabledata.SimpleMatrixDataImpl; /** * This Class provides an Extension Point for further implementation @@ -17,6 +19,11 @@ public abstract class AbstractDocumentBuilder { protected byte[] mDocument; + private MatrixData data; + + + AbstractBrailleTableParser mParser; + /** * Complex method for complex construction of an Document for the printer. * @param data Raw Data to be printed without any escapesequences @@ -34,4 +41,21 @@ public abstract class AbstractDocumentBuilder { return mDocument; } + protected void setParser() throws NotSupportedFileExtension { + //read brailletablepath + Printer printer = data.getPrinterConfig(); + String brailleTablePath = printer.getProperty("brailletable").toString(); + + //read which kind of parser is needed (properties, json, xml,...) + String fileEnding = brailleTablePath.split("\\.")[1]; + switch (fileEnding) { + case "properties": mParser = new PropertiesParser(); + case "json": mParser = new JsonParser(); + case "xml": mParser = new XmlParser(); + default: throw new NotSupportedFileExtension(); + } + + + } + } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleAlphabet.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleAlphabet.java index 3851d818..9e691ba5 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleAlphabet.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleAlphabet.java @@ -11,7 +11,8 @@ import java.util.Map; * @version 28.06.2019 */ -public interface BrailleAlphabet { - public byte[] getValue(BrailleCell6 cell); +public abstract class BrailleAlphabet { + public abstract <T> byte[] getValue(BrailleCell6 cell); + public AbstractBrailleTableParser mParser; public Map<BrailleCell6, byte[]> mAlphabet = new HashMap<>(); } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman6Dots.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman6Dots.java deleted file mode 100644 index edaa2599..00000000 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman6Dots.java +++ /dev/null @@ -1,108 +0,0 @@ -package de.tudresden.inf.mci.brailleplot.exporter; - -import de.tudresden.inf.mci.brailleplot.printabledata.BrailleCell6; - -/** - * This Class represents the German 6 Dot Braille Alphabet. - * - * @author Andrey Ruzhanskiy - * @version 28.06.2019 - */ - -public class BrailleGerman6Dots implements BrailleAlphabet{ - - @Override - public byte[] getValue(BrailleCell6 cell) { - if(cell == null){ - throw new NullPointerException(); - } - return mAlphabet.get(cell); - } - - public BrailleGerman6Dots() { - - /* - Letter A - 1 - */ -/* - BrailleCell A = new BrailleCell(); - A.setFirst(); - mAlphabet.put(A, new byte[0x41]); -*/ - /* - Letter B - 1 - 2 - */ -/* - BrailleCell B = new BrailleCell(); - B.setFirst(); - B.setSecond(); - mAlphabet.put(B, new byte[]{0x42}); -*/ - /* - Letter C - 1 4 - */ -/* - BrailleCell C = new BrailleCell(); - C.setFirst(); - C.setFourth(); - mAlphabet.put(C, new byte[]{0x43}); -*/ - /* - Letter D - 1 4 - 5 - */ -/* - BrailleCell D = new BrailleCell(); - D.setFirst(); - D.setFourth(); - D.setFifth(); - mAlphabet.put(D, new byte[]{0x44}); -*/ - /* - Letter E - 1 - 5 - */ -/* - BrailleCell E = new BrailleCell(); - E.setFirst(); - E.setFifth(); - mAlphabet.put(E, new byte[]{0x45}); -*/ - /* - Letter F - 1 4 - 2 - */ -/* - BrailleCell F = new BrailleCell(); - F.setFirst(); - F.setSecond(); - F.setFourth(); - mAlphabet.put(F, new byte[]{0x46}); -*/ - /* - Letter G - 1 4 - 2 5 - */ -/* - BrailleCell G = new BrailleCell(); - G.setFirst(); - G.setSecond(); - G.setFourth(); - G.setFifth(); - mAlphabet.put(G, new byte[]{0x47}); -*/ - - - - - - } -} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman8Dots.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman8Dots.java deleted file mode 100644 index 0b5c55ee..00000000 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/BrailleGerman8Dots.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.tudresden.inf.mci.brailleplot.exporter; - - -import de.tudresden.inf.mci.brailleplot.printabledata.BrailleCell6; - -/** - * Implements the Braille German 8 Dots Alphabet. - * @author Andrey Ruzhanskiy - * @version 28.06.2019 - */ -public class BrailleGerman8Dots implements BrailleAlphabet { - @Override - public byte[] getValue(BrailleCell6 cell) { - if (cell == null){ - throw new NullPointerException(); - } - return mAlphabet.get(cell); - } -} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/JsonParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/JsonParser.java new file mode 100644 index 00000000..429708cb --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/JsonParser.java @@ -0,0 +1,8 @@ +package de.tudresden.inf.mci.brailleplot.exporter; + +public class JsonParser implements AbstractBrailleTableParser { + @Override + public int getValue(String key) { + return 0; + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NormalBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NormalBuilder.java index f4636ba9..522d900c 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NormalBuilder.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NormalBuilder.java @@ -1,29 +1,55 @@ package de.tudresden.inf.mci.brailleplot.exporter; +import de.tudresden.inf.mci.brailleplot.configparser.Printer; +import de.tudresden.inf.mci.brailleplot.configparser.ValidProperty; +import de.tudresden.inf.mci.brailleplot.printabledata.BrailleCell6; import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; import java.util.Iterator; +import java.util.Properties; + /** * Class representing a normal Document (for example a .txt) to print without * any Escapesequences. * @author Andrey Ruzhanskiy + * @version */ +@SuppressWarnings("checkstyle:MagicNumber") public class NormalBuilder extends AbstractDocumentBuilder { @Override public byte[] assemble(final MatrixData data) { - if(data == null) { + if (data == null) { throw new NullPointerException(); } - //6 Point Braille - Iterator iter = data.getDotIterator(2, 3); - while (iter.hasNext()){ - for (int i = 0; i < 6; i++) { + try { + setParser(); + } catch (NotSupportedFileExtension e) { + throw new RuntimeException(); + } + + + + + Iterator<BrailleCell6<Boolean>> iter = data.getBrailleCell6Iterator(); + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + - } + + // data.getFormatConfig().getProperty() + while (iter.hasNext()) { + stream.write(mParser.getValue(iter.next().toShortString())); } - return null; + + return stream.toByteArray(); + } + + protected NormalBuilder(){ + } + } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NotSupportedFileExtension.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NotSupportedFileExtension.java new file mode 100644 index 00000000..407a4354 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/NotSupportedFileExtension.java @@ -0,0 +1,25 @@ +package de.tudresden.inf.mci.brailleplot.exporter; + +/** + * Exception Class for not recogniced/not supported FIleExtension for brailletables. + * Used in NormalBuilder. + * @author Andrey Ruzhanskiy + * @version 11.07.2019 + */ + +public class NotSupportedFileExtension extends Exception { + + public NotSupportedFileExtension() { } + + public NotSupportedFileExtension(final String message) { + super(message); + } + + public NotSupportedFileExtension(final Throwable cause) { + super(cause); + } + + public NotSupportedFileExtension(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirector.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirector.java index edbef1db..61d57f8a 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirector.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirector.java @@ -18,6 +18,7 @@ public class PrintDirector { private PrintService mService; private String mPrinterName; private DocFlavor mDocflavor; + private AbstractBrailleTableParser mParser; /** @@ -54,6 +55,7 @@ public class PrintDirector { return false; } + /** * Method for setting the Printer. * @param printerName @@ -74,7 +76,7 @@ public class PrintDirector { @SuppressWarnings("checkstyle:MagicNumber") public <T> void print(final String printerName, final MatrixData<T> data) { - if (printerName == null || data == null){ + if (printerName == null || data == null) { throw new NullPointerException(); } setUpDoc(); @@ -101,11 +103,12 @@ public class PrintDirector { */ private void print(final byte[] data) { - if(data == null){ + if (data == null) { throw new NullPointerException(); } Doc doc = new SimpleDoc(data, mDocflavor, null); PrintRequestAttributeSet asset = new HashPrintRequestAttributeSet(); + mService = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob job = mService.createPrintJob(); try { job.print(doc, asset); diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PropertiesParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PropertiesParser.java new file mode 100644 index 00000000..e5f69bdb --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/PropertiesParser.java @@ -0,0 +1,11 @@ +package de.tudresden.inf.mci.brailleplot.exporter; + +public class PropertiesParser implements AbstractBrailleTableParser { + + + + @Override + public int getValue(String key) { + return 0; + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/XmlParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/XmlParser.java new file mode 100644 index 00000000..eda622c7 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/exporter/XmlParser.java @@ -0,0 +1,8 @@ +package de.tudresden.inf.mci.brailleplot.exporter; + +public class XmlParser implements AbstractBrailleTableParser { + @Override + public int getValue(String key) { + return 0; + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java index 37e75db4..585252f1 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java @@ -49,7 +49,7 @@ public final class BrailleCell6<T> { * @param vals An array of values to obtain the values from. * @throws IllegalArgumentException If the length is not equal to 6. */ - BrailleCell6(final T[] vals) { + public BrailleCell6(final T[] vals) { if (vals.length != DOT_COUNT) { throw new IllegalArgumentException("Input Array must be of length " + DOT_COUNT); } @@ -101,4 +101,17 @@ public final class BrailleCell6<T> { } return sb.toString(); } + + public String toShortString(){ + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mDots.length; i++) { + if(Boolean.parseBoolean(mDots[i].toString())) { + sb.append("1"); + } else { + sb.append("0"); + } + + } + return sb.toString(); + } } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirectorTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirectorTest.java index 7d85a421..2b13583b 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirectorTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/exporter/PrintDirectorTest.java @@ -20,7 +20,8 @@ public class PrintDirectorTest { public void testPrinterDoesNotExist(){ Assertions.assertEquals(false, PrintDirector.printerExists("kek")); } - +/* + @Test public void testNullPointerInPrintString(){ Assertions.assertThrows(NullPointerException.class, () -> { @@ -30,5 +31,5 @@ public class PrintDirectorTest { }); }); } - +*/ } -- GitLab