From cea4d2b83f68ed2223ab1b07061dd7a7b709d2af Mon Sep 17 00:00:00 2001 From: j-james Date: Tue, 18 Oct 2022 15:11:26 -0700 Subject: Replace Java 11 features with equivalent Java 8 ones --- src/main/model/html/HtmlParser.java | 2 +- src/main/ui/BrowserApp.java | 4 ++-- src/test/model/css/CssParserTest.java | 2 +- src/test/model/html/HtmlParserTest.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/model/html/HtmlParser.java b/src/main/model/html/HtmlParser.java index bfdd57c..d07a2ff 100644 --- a/src/main/model/html/HtmlParser.java +++ b/src/main/model/html/HtmlParser.java @@ -296,7 +296,7 @@ public class HtmlParser { */ private void addNewElementNode() { state = ParserState.HTML; - var node = new ElementNode(currentTag, currentAttributes); + ElementNode node = new ElementNode(currentTag, currentAttributes); if (unfinished.size() != 0) { unfinished.getLast().addChild(node); if (!isSelfClosingTag(currentTag)) { diff --git a/src/main/ui/BrowserApp.java b/src/main/ui/BrowserApp.java index 83880f9..fa47f48 100644 --- a/src/main/ui/BrowserApp.java +++ b/src/main/ui/BrowserApp.java @@ -24,9 +24,9 @@ public class BrowserApp { input = new Scanner(System.in); String pathString = input.next(); - Path path = Path.of(pathString); + Path path = Paths.get(pathString); try { - String file = Files.readString(path); + String file = new String(Files.readAllBytes(path)); HtmlParser parser = new HtmlParser(); println(border); renderHtml(parser.parseHtml(file)); diff --git a/src/test/model/css/CssParserTest.java b/src/test/model/css/CssParserTest.java index a2335f2..42cdd9f 100644 --- a/src/test/model/css/CssParserTest.java +++ b/src/test/model/css/CssParserTest.java @@ -12,7 +12,7 @@ public class CssParserTest { @Test void testIdiomaticCss() { - var idiomaticCss = "body { background-color: '#\\'f0f0f2'; margin: 0; padding: 0; font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe\\\" UI\", 'Open\\' Sans', \"Helvetica Neue\", Helvetica, Arial, sans-serif;}div { width: 600px; margin: 5em auto; padding: 2em; background-color: #fdfdff; border-radius: 0.5em; box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);}a:link, a:visited { color: #38488f; text-decoration: none;}@media (max - width : 700px) { @media () {div { margin: 0 auto; width: auto }}}"; + String idiomaticCss = "body { background-color: '#\\'f0f0f2'; margin: 0; padding: 0; font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe\\\" UI\", 'Open\\' Sans', \"Helvetica Neue\", Helvetica, Arial, sans-serif;}div { width: 600px; margin: 5em auto; padding: 2em; background-color: #fdfdff; border-radius: 0.5em; box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);}a:link, a:visited { color: #38488f; text-decoration: none;}@media (max - width : 700px) { @media () {div { margin: 0 auto; width: auto }}}"; ArrayList>>> expected = new ArrayList<>(); ArrayList> body = new ArrayList<>(); diff --git a/src/test/model/html/HtmlParserTest.java b/src/test/model/html/HtmlParserTest.java index a7093e1..8268abf 100644 --- a/src/test/model/html/HtmlParserTest.java +++ b/src/test/model/html/HtmlParserTest.java @@ -79,7 +79,7 @@ public class HtmlParserTest { expectedAttributes.add(new Pair<>("up", "do'wn")); HtmlParser parser = new HtmlParser(); - var parsed = parser.parseHtml(attributesHtml); + ArrayList parsed = parser.parseHtml(attributesHtml); displayHtmlTree(parsed); assertEqualsHtml(parsed, expected); } -- cgit v1.2.3-70-g09d2