From 169c0a4c68e4fafe4d5f42d86c2ecc47b7b32a30 Mon Sep 17 00:00:00 2001 From: Legit Cheetah Date: Mon, 5 Feb 2024 16:59:26 +0100 Subject: [PATCH] added essential Tag-Modules and Site-Generator --- src/main/Main.java | 12 ++---- src/main/htmlSites/siteGeneric.java | 39 +++++++++++++++++++ src/main/htmlTagModules/moduleBody.java | 9 +++++ src/main/htmlTagModules/moduleDiv.java | 10 +++++ .../moduleGeneric.java | 19 +++++---- src/main/htmlTagModules/moduleHTML.java | 9 +++++ src/main/htmlTagModules/moduleHead.java | 9 +++++ src/main/htmlTags/moduleBody.java | 7 ---- src/main/htmlTags/moduleDiv.java | 8 ---- src/main/htmlTagsEnum.java | 1 + 10 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 src/main/htmlSites/siteGeneric.java create mode 100644 src/main/htmlTagModules/moduleBody.java create mode 100644 src/main/htmlTagModules/moduleDiv.java rename src/main/{htmlTags => htmlTagModules}/moduleGeneric.java (70%) create mode 100644 src/main/htmlTagModules/moduleHTML.java create mode 100644 src/main/htmlTagModules/moduleHead.java delete mode 100644 src/main/htmlTags/moduleBody.java delete mode 100644 src/main/htmlTags/moduleDiv.java diff --git a/src/main/Main.java b/src/main/Main.java index 9022c4d..da01e1f 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -1,16 +1,10 @@ package main; -import main.htmlTags.*; +import main.htmlSites.siteGeneric; public class Main { public static void main(String[] args) { - moduleBody body = new moduleBody(); - moduleDiv mainDiv = new moduleDiv(); - moduleDiv thirdDiv = new moduleDiv(); - moduleDiv secondDiv = new moduleDiv(); - body.addModule(mainDiv); - mainDiv.addModule(thirdDiv); - body.addModule(secondDiv); - System.out.println(body.build()); + siteGeneric site = new siteGeneric(); + System.out.println(site.build()); } } diff --git a/src/main/htmlSites/siteGeneric.java b/src/main/htmlSites/siteGeneric.java new file mode 100644 index 0000000..bbb5573 --- /dev/null +++ b/src/main/htmlSites/siteGeneric.java @@ -0,0 +1,39 @@ +package main.htmlSites; + +import main.htmlTagModules.moduleBody; +import main.htmlTagModules.moduleGeneric; +import main.htmlTagModules.moduleHead; +import main.htmlTagsEnum; + +public class siteGeneric extends moduleGeneric { + moduleHead head; + moduleBody body; + public siteGeneric(){ + this(new moduleHead(),new moduleBody()); + } + + public siteGeneric(moduleHead head){ + this(head ,new moduleBody()); + } + + public siteGeneric(moduleBody body){ + this(new moduleHead(),body); + } + + siteGeneric(moduleHead head, moduleBody body){ + this.head = head; + this.body = body; + setTag(htmlTagsEnum.HTML); + addModule(this.head); + addModule(this.body); + } + + @Override + public StringBuilder build() { + StringBuilder buildString = new StringBuilder(); + buildString + .append("") + .append(super.build()); + return buildString; + } +} diff --git a/src/main/htmlTagModules/moduleBody.java b/src/main/htmlTagModules/moduleBody.java new file mode 100644 index 0000000..bf7a834 --- /dev/null +++ b/src/main/htmlTagModules/moduleBody.java @@ -0,0 +1,9 @@ +package main.htmlTagModules; + +import main.htmlTagsEnum; + +public class moduleBody extends moduleGeneric{ + public moduleBody(){ + setTag(htmlTagsEnum.BODY); + } +} diff --git a/src/main/htmlTagModules/moduleDiv.java b/src/main/htmlTagModules/moduleDiv.java new file mode 100644 index 0000000..01c6588 --- /dev/null +++ b/src/main/htmlTagModules/moduleDiv.java @@ -0,0 +1,10 @@ +package main.htmlTagModules; + +import main.htmlTagsEnum; + +public class moduleDiv extends moduleGeneric { + + public moduleDiv(){ + setTag(htmlTagsEnum.DIV); + } +} diff --git a/src/main/htmlTags/moduleGeneric.java b/src/main/htmlTagModules/moduleGeneric.java similarity index 70% rename from src/main/htmlTags/moduleGeneric.java rename to src/main/htmlTagModules/moduleGeneric.java index 32a023f..f160588 100644 --- a/src/main/htmlTags/moduleGeneric.java +++ b/src/main/htmlTagModules/moduleGeneric.java @@ -1,14 +1,17 @@ -package main.htmlTags; +package main.htmlTagModules; + +import main.htmlTagsEnum; import java.util.ArrayList; public class moduleGeneric { - String tag = ""; + htmlTagsEnum tag = null; int ID; - ArrayList content = new ArrayList<>(); + ArrayList content = new ArrayList<>(); + public void addModule(moduleGeneric module){ content.add(module); } @@ -21,11 +24,11 @@ public class moduleGeneric { return ID; } - public void setTag(String tag) { + public void setTag(htmlTagsEnum tag) { this.tag = tag; } - public String getTag() { + public htmlTagsEnum getTag() { return tag; } @@ -33,14 +36,14 @@ public class moduleGeneric { StringBuilder buildString = new StringBuilder(); buildString .append("\n<") - .append(tag) + .append(tag.getTag()) .append(">"); - for (main.htmlTags.moduleGeneric moduleGeneric : content) { + for (main.htmlTagModules.moduleGeneric moduleGeneric : content) { buildString.append(moduleGeneric.build()); } buildString .append("\n"); return buildString; } diff --git a/src/main/htmlTagModules/moduleHTML.java b/src/main/htmlTagModules/moduleHTML.java new file mode 100644 index 0000000..90333a5 --- /dev/null +++ b/src/main/htmlTagModules/moduleHTML.java @@ -0,0 +1,9 @@ +package main.htmlTagModules; + +import main.htmlTagsEnum; + +public class moduleHTML extends moduleGeneric{ + public moduleHTML(){ + setTag(htmlTagsEnum.HTML); + } +} diff --git a/src/main/htmlTagModules/moduleHead.java b/src/main/htmlTagModules/moduleHead.java new file mode 100644 index 0000000..988fd8a --- /dev/null +++ b/src/main/htmlTagModules/moduleHead.java @@ -0,0 +1,9 @@ +package main.htmlTagModules; + +import main.htmlTagsEnum; + +public class moduleHead extends moduleGeneric { + public moduleHead(){ + setTag(htmlTagsEnum.HEAD); + } +} diff --git a/src/main/htmlTags/moduleBody.java b/src/main/htmlTags/moduleBody.java deleted file mode 100644 index 20a7ddc..0000000 --- a/src/main/htmlTags/moduleBody.java +++ /dev/null @@ -1,7 +0,0 @@ -package main.htmlTags; - -public class moduleBody extends moduleGeneric{ - public moduleBody(){ - setTag("body"); - } -} diff --git a/src/main/htmlTags/moduleDiv.java b/src/main/htmlTags/moduleDiv.java deleted file mode 100644 index 9653611..0000000 --- a/src/main/htmlTags/moduleDiv.java +++ /dev/null @@ -1,8 +0,0 @@ -package main.htmlTags; - -public class moduleDiv extends moduleGeneric { - - public moduleDiv(){ - setTag("div"); - } -} diff --git a/src/main/htmlTagsEnum.java b/src/main/htmlTagsEnum.java index a666594..cbc1e16 100644 --- a/src/main/htmlTagsEnum.java +++ b/src/main/htmlTagsEnum.java @@ -28,6 +28,7 @@ public enum htmlTagsEnum { HEADLINE4("h4"), HEADLINE5("h5"), HEADLINE6("h6"), + HTML("html"), INPUT("input"), INTERNETFRAME("iframe"), INSERT("insert"),