added essential Tag-Modules and Site-Generator
This commit is contained in:
parent
c7d531a10c
commit
169c0a4c68
@ -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());
|
||||
}
|
||||
}
|
||||
|
39
src/main/htmlSites/siteGeneric.java
Normal file
39
src/main/htmlSites/siteGeneric.java
Normal file
@ -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("<!DOCTYPE html>")
|
||||
.append(super.build());
|
||||
return buildString;
|
||||
}
|
||||
}
|
9
src/main/htmlTagModules/moduleBody.java
Normal file
9
src/main/htmlTagModules/moduleBody.java
Normal file
@ -0,0 +1,9 @@
|
||||
package main.htmlTagModules;
|
||||
|
||||
import main.htmlTagsEnum;
|
||||
|
||||
public class moduleBody extends moduleGeneric{
|
||||
public moduleBody(){
|
||||
setTag(htmlTagsEnum.BODY);
|
||||
}
|
||||
}
|
10
src/main/htmlTagModules/moduleDiv.java
Normal file
10
src/main/htmlTagModules/moduleDiv.java
Normal file
@ -0,0 +1,10 @@
|
||||
package main.htmlTagModules;
|
||||
|
||||
import main.htmlTagsEnum;
|
||||
|
||||
public class moduleDiv extends moduleGeneric {
|
||||
|
||||
public moduleDiv(){
|
||||
setTag(htmlTagsEnum.DIV);
|
||||
}
|
||||
}
|
@ -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<moduleGeneric> content = new ArrayList<>();
|
||||
|
||||
|
||||
ArrayList<moduleGeneric> 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</")
|
||||
.append(tag)
|
||||
.append(tag.getTag())
|
||||
.append(">");
|
||||
return buildString;
|
||||
}
|
9
src/main/htmlTagModules/moduleHTML.java
Normal file
9
src/main/htmlTagModules/moduleHTML.java
Normal file
@ -0,0 +1,9 @@
|
||||
package main.htmlTagModules;
|
||||
|
||||
import main.htmlTagsEnum;
|
||||
|
||||
public class moduleHTML extends moduleGeneric{
|
||||
public moduleHTML(){
|
||||
setTag(htmlTagsEnum.HTML);
|
||||
}
|
||||
}
|
9
src/main/htmlTagModules/moduleHead.java
Normal file
9
src/main/htmlTagModules/moduleHead.java
Normal file
@ -0,0 +1,9 @@
|
||||
package main.htmlTagModules;
|
||||
|
||||
import main.htmlTagsEnum;
|
||||
|
||||
public class moduleHead extends moduleGeneric {
|
||||
public moduleHead(){
|
||||
setTag(htmlTagsEnum.HEAD);
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package main.htmlTags;
|
||||
|
||||
public class moduleBody extends moduleGeneric{
|
||||
public moduleBody(){
|
||||
setTag("body");
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package main.htmlTags;
|
||||
|
||||
public class moduleDiv extends moduleGeneric {
|
||||
|
||||
public moduleDiv(){
|
||||
setTag("div");
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ public enum htmlTagsEnum {
|
||||
HEADLINE4("h4"),
|
||||
HEADLINE5("h5"),
|
||||
HEADLINE6("h6"),
|
||||
HTML("html"),
|
||||
INPUT("input"),
|
||||
INTERNETFRAME("iframe"),
|
||||
INSERT("insert"),
|
||||
|
Loading…
Reference in New Issue
Block a user