summaryrefslogtreecommitdiffstats
path: root/misc/xgen
diff options
context:
space:
mode:
Diffstat (limited to 'misc/xgen')
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java18
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java18
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java174
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java2
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java12
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java28
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java52
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java524
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java98
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java206
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java246
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java54
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java418
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java128
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java326
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java4
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java20
-rw-r--r--misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java28
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java14
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java40
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java20
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java10
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java42
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java396
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java134
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java46
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java342
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java38
-rw-r--r--misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java40
29 files changed, 1739 insertions, 1739 deletions
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
index 342e3ace..5bd24b02 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java
@@ -22,13 +22,13 @@
package org.onap.aaf.misc.xgen;
public class Back {
- public String str;
- public boolean dec;
- public boolean cr;
-
- public Back(String string, boolean decrement, boolean newline) {
- str = string;
- dec = decrement;
- cr = newline;
- }
+ public String str;
+ public boolean dec;
+ public boolean cr;
+
+ public Back(String string, boolean decrement, boolean newline) {
+ str = string;
+ dec = decrement;
+ cr = newline;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
index ce90bd13..0f6b0d9c 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java
@@ -23,15 +23,15 @@ package org.onap.aaf.misc.xgen;
public interface Cache<G extends XGen<G>> {
- public void dynamic(G hgen, Code<G> code);
-
- public static class Null<N extends XGen<N>> implements Cache<N> {
- @Override
- public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type
+ public void dynamic(G hgen, Code<G> code);
+
+ public static class Null<N extends XGen<N>> implements Cache<N> {
+ @Override
+ public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type
- @SuppressWarnings("rawtypes")
- private static Null<?> singleton = new Null();
- public static Null<?> singleton() { return singleton;}
- }
+ @SuppressWarnings("rawtypes")
+ private static Null<?> singleton = new Null();
+ public static Null<?> singleton() { return singleton;}
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
index 417f80b7..3edf8b60 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java
@@ -35,97 +35,97 @@ import org.onap.aaf.misc.xgen.html.Thematic;
public abstract class CacheGen<G extends XGen<G>> {
- public static final int NO_FLAGS = 0x0;
- public final static int PRETTY = 0x1;
- public final static int XML = 0x2;
- public final static int HTML4 = 0x4;
- public final static int HTML5 = 0x8;
+ public static final int NO_FLAGS = 0x0;
+ public final static int PRETTY = 0x1;
+ public final static int XML = 0x2;
+ public final static int HTML4 = 0x4;
+ public final static int HTML5 = 0x8;
-
- private ArrayList<Section<G>> sections = new ArrayList<>();
- private int flags;
- private final Thematic thematic;
+
+ private ArrayList<Section<G>> sections = new ArrayList<>();
+ private int flags;
+ private final Thematic thematic;
- public CacheGen(int flags, Code<G> code) throws APIException, IOException {
- this.flags = flags;
- final XGenBuff<G> buff = new XGenBuff<G>(flags,this);
- // Run to gather Strings and Code Class Segments
- buff.run(new Cache<G>() {
- @Override
- public void dynamic(G hgen, Code<G> code) {
- sections.add(buff.newSection());
- sections.add(new Dynamic(hgen.getIndent(),code));
- }
- },code);
- sections.add(buff.newSection());
-
- // If Code implements thematic, set for later
- thematic = code instanceof Thematic?(Thematic)code:null;
+ public CacheGen(int flags, Code<G> code) throws APIException, IOException {
+ this.flags = flags;
+ final XGenBuff<G> buff = new XGenBuff<G>(flags,this);
+ // Run to gather Strings and Code Class Segments
+ buff.run(new Cache<G>() {
+ @Override
+ public void dynamic(G hgen, Code<G> code) {
+ sections.add(buff.newSection());
+ sections.add(new Dynamic(hgen.getIndent(),code));
+ }
+ },code);
+ sections.add(buff.newSection());
+
+ // If Code implements thematic, set for later
+ thematic = code instanceof Thematic?(Thematic)code:null;
- }
-
- public abstract G create(int htmlStyle, Writer w);
+ }
+
+ public abstract G create(int htmlStyle, Writer w);
- public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException {
- replay(state, trans, new OutputStreamWriter(os), theme);
- }
-
- public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException {
- if(thematic!=null) {
- theme = thematic.themeResolve(theme);
- }
- /* Theme
- trans.setTheme(theme);
- int htmlStyle = state.htmlVer(theme);
- */
-
- XGenBuff<G> buff = new XGenBuff<G>(flags,this);
-
- // forward
- int indent = 0;
- Section<G> s;
- int i=0;
- @SuppressWarnings("unchecked")
- Section<G>[] reverse = new Section[sections.size()];
- for(Section<G> section : sections) {
- s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread
- int tempIndent = s.getIndent();
- s.setIndent(indent);
- s.forward(w);
- s.setIndent(tempIndent);
- indent = tempIndent;
- reverse[i++]=s;
- }
+ public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException {
+ replay(state, trans, new OutputStreamWriter(os), theme);
+ }
+
+ public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException {
+ if(thematic!=null) {
+ theme = thematic.themeResolve(theme);
+ }
+ /* Theme
+ trans.setTheme(theme);
+ int htmlStyle = state.htmlVer(theme);
+ */
+
+ XGenBuff<G> buff = new XGenBuff<G>(flags,this);
+
+ // forward
+ int indent = 0;
+ Section<G> s;
+ int i=0;
+ @SuppressWarnings("unchecked")
+ Section<G>[] reverse = new Section[sections.size()];
+ for(Section<G> section : sections) {
+ s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread
+ int tempIndent = s.getIndent();
+ s.setIndent(indent);
+ s.forward(w);
+ s.setIndent(tempIndent);
+ indent = tempIndent;
+ reverse[i++]=s;
+ }
- for(--i;i>=0;--i) {
- reverse[i].back(w);
- }
- w.flush();
- }
-
- private class Dynamic extends Section<G> {
- private Code<G> code;
-
- public Dynamic(int indent, Code<G> code) {
- this.code = code;
- this.indent = indent;
- }
+ for(--i;i>=0;--i) {
+ reverse[i].back(w);
+ }
+ w.flush();
+ }
+
+ private class Dynamic extends Section<G> {
+ private Code<G> code;
+
+ public Dynamic(int indent, Code<G> code) {
+ this.code = code;
+ this.indent = indent;
+ }
- @SuppressWarnings("unchecked")
- public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
- // Clone Dynamic to make Thread Safe
- Dynamic d = new Dynamic(indent,code);
- buff.setIndent(indent);
- if(code instanceof DynamicCode) {
- buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code);
- } else {
- buff.run((Cache<G>)Cache.Null.singleton(), code);
- }
- Section<G> s = buff.newSection();
- d.indent = s.indent;
- d.forward = s.forward;
- d.backward = s.backward;
- return d;
- }
- }
+ @SuppressWarnings("unchecked")
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
+ // Clone Dynamic to make Thread Safe
+ Dynamic d = new Dynamic(indent,code);
+ buff.setIndent(indent);
+ if(code instanceof DynamicCode) {
+ buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code);
+ } else {
+ buff.run((Cache<G>)Cache.Null.singleton(), code);
+ }
+ Section<G> s = buff.newSection();
+ d.indent = s.indent;
+ d.forward = s.forward;
+ d.backward = s.backward;
+ return d;
+ }
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
index 68048431..971a56e4 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java
@@ -26,5 +26,5 @@ import java.io.IOException;
import org.onap.aaf.misc.env.APIException;
public interface Code<G extends XGen<G>> {
- public void code(Cache<G> cache, G xgen) throws APIException, IOException;
+ public void code(Cache<G> cache, G xgen) throws APIException, IOException;
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
index a4194b97..8d4f4eec 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java
@@ -35,10 +35,10 @@ import org.onap.aaf.misc.xgen.html.State;
*
*/
public abstract class DynamicCode<G extends XGen<G>, AS extends State<Env>, TRANS extends Trans> implements Code<G> {
- public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException;
-
- // We expect not to have this section of the code engaged at any time
- public void code(final Cache<G> cache, final G xgen) throws APIException, IOException {
- code(null, null,cache,xgen);
- }
+ public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException;
+
+ // We expect not to have this section of the code engaged at any time
+ public void code(final Cache<G> cache, final G xgen) throws APIException, IOException {
+ code(null, null,cache,xgen);
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
index 80b0680d..f9c06c40 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java
@@ -22,19 +22,19 @@
package org.onap.aaf.misc.xgen;
public class Mark {
- // package on purpose
- int spot = 0;
- public String comment;
-
- public Mark() {
- comment = null;
- }
-
- public Mark(String string) {
- comment = string;
- }
+ // package on purpose
+ int spot = 0;
+ public String comment;
+
+ public Mark() {
+ comment = null;
+ }
+
+ public Mark(String string) {
+ comment = string;
+ }
- public void spot(int spot) {
- this.spot = spot;
- }
+ public void spot(int spot) {
+ this.spot = spot;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
index e73512c3..9f1f2a38 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java
@@ -30,32 +30,32 @@ import org.onap.aaf.misc.env.Trans;
import org.onap.aaf.misc.xgen.html.State;
public class Section<G extends XGen<G>> {
- protected int indent;
- protected String forward;
- protected String backward;
-
- // Default is to use the set Strings (static)
- public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
- return this;
- }
-
- public int getIndent() {
- return indent;
- }
+ protected int indent;
+ protected String forward;
+ protected String backward;
+
+ // Default is to use the set Strings (static)
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {
+ return this;
+ }
+
+ public int getIndent() {
+ return indent;
+ }
- public void setIndent(int indent) {
- this.indent = indent;
- }
+ public void setIndent(int indent) {
+ this.indent = indent;
+ }
- public void forward(Writer w) throws IOException {
- w.write(forward);
- }
-
- public void back(Writer w) throws IOException {
- w.write(backward);
- }
-
- public String toString() {
- return forward;
- }
+ public void forward(Writer w) throws IOException {
+ w.write(forward);
+ }
+
+ public void back(Writer w) throws IOException {
+ w.write(backward);
+ }
+
+ public String toString() {
+ return forward;
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
index 4bb6ee28..7b0a4263 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java
@@ -30,267 +30,267 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter;
public class XGen<RT extends XGen<RT>> {
- private static final int COMMENT_COLUMN = 40;
- private StringBuilder backSB = new StringBuilder();
- private Stack<Back> backStack = new Stack<Back>();
-
- protected XGen(Writer w) {
- forward = new IndentPrintWriter(w);
- }
-
- public int pushBack(Back b) {
- int rv = backStack.size();
- backStack.push(b);
- return rv;
- }
-
- public boolean pretty = false;
- protected IndentPrintWriter forward;
-
- public IndentPrintWriter getWriter() {
- return forward;
- }
-
- protected PrintWriter back = new PrintWriter(
- new StringBuilderWriter(backSB));
-
- @SuppressWarnings("unchecked")
- public RT pretty() {
- pretty = true;
- return (RT) this;
- }
-
- protected void prettyln(PrintWriter pw) {
- if(pretty)pw.println();
- }
-
- public RT leaf(Mark mark, String tag, String ... args) {
- mark.spot = backStack.size();
- return leaf(tag, args);
- }
-
- @SuppressWarnings("unchecked")
- public RT leaf(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
- back.append("</");
- back.append(tag);
- back.append('>');
- backStack.push(new Back(backSB.toString(), false, true));
- backSB.setLength(0);
- return (RT)this;
- }
-
- public RT incr(String tag, String ... args) {
- return incr(null, tag, false, args);
- }
-
- public RT incr(String tag, boolean oneLine, String ... args) {
- return incr(null, tag, oneLine, args);
- }
-
- public RT incr(Mark mark) {
- return incr(mark,mark.comment, false, new String[0]);
- }
-
- public RT incr(Mark mark, String tag, String ... attrs) {
- return incr(mark, tag, false, attrs);
- }
-
- @SuppressWarnings("unchecked")
- public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
-
- back.append("</");
- back.append(tag);
- back.append('>');
-
- if(pretty) {
- if(mark!=null && mark.comment!=null) {
- int fi = forward.getIndent()*IndentPrintWriter.INDENT_MULTIPLIER;
- for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) {
- back.append(' ');
- }
- back.append("<!-- end ");
- back.append(mark.comment);
- back.append(" -->");
-
- forward.toCol(COMMENT_COLUMN);
- forward.append("<!-- begin ");
- forward.append(mark.comment);
- forward.append(" -->");
- }
- forward.inc();
- if(!oneLine) {
- forward.println();
- }
- back.println();
- }
- if(mark!=null)mark.spot = backStack.size();
- backStack.push(new Back(backSB.toString(),true, false));
- backSB.setLength(0);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT tagOnly(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append(" />");
- if(pretty) {
- forward.println();
- }
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT text(String txt) {
- forward.append(txt);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT xml(String txt) {
- for(int i=0; i<txt.length();++i) {
- char c = txt.charAt(i);
- switch(c) {
- case '<':
- forward.append("&lt;");
- break;
- case '>':
- forward.append("&gt;");
- break;
- case '&':
- forward.append("&amp;");
- break;
- default:
- forward.append(c);
- }
- }
- return (RT)this;
- }
-
-
- @SuppressWarnings("unchecked")
- public RT textCR(int tabs, String txt) {
- for(int i=0;i<tabs;++i) {
- forward.append(" ");
- }
- forward.append(txt);
- if(pretty)forward.println();
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value() {
- Mark mark = new Mark();
- mark.spot = backStack.size()-1;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value(String txt) {
- forward.append(txt);
- Mark mark = new Mark();
- mark.spot = backStack.size()-1;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT value(String txt, int levels) {
- forward.append(txt);
- Mark mark = new Mark();
- mark.spot = backStack.size()-levels;
- end(mark);
- return (RT)this;
- }
-
- @SuppressWarnings("unchecked")
- public RT end(Mark mark) {
- int size = backStack.size();
- Back c;
- boolean println = false;
- for(int i=mark==null?0:mark.spot;i<size;++i) {
- c = backStack.pop();
- if(c.dec)forward.dec();
- forward.append(c.str);
- println = c.cr;
- }
- if(pretty && println) {
- forward.println();
- }
- return (RT)this;
- }
-
- public RT end() {
- Mark mark = new Mark();
- mark.spot=backStack.size()-1;
- if(mark.spot<0)mark.spot=0;
- return end(mark);
- }
-
- public RT end(int i) {
- Mark mark = new Mark();
- mark.spot=backStack.size()-i;
- if(mark.spot<0)mark.spot=0;
- return end(mark);
- }
-
- public void endAll() {
- end(new Mark());
- forward.flush();
- }
-
- protected void addAttrs(String[] attrs) {
- if(attrs!=null) {
- for(String attr : attrs) {
- if(attr!=null && attr.length()>0) {
- forward.append(' ');
- String[] split = attr.split("=",2);
- switch(split.length) {
- case 0:
- break;
- case 1:
- forward.append(split[0]);
-// forward.append("=\"\"");
- break;
- default:
- forward.append(split[0]);
- forward.append("=\"");
- forward.append(split[1]);
- forward.append('"');
- break;
- }
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public RT comment(String string) {
- if(pretty) {
- forward.print("<!-- ");
- forward.print(string);
- forward.println(" -->");
- }
- return (RT)this;
- }
-
- public void setIndent(int indent) {
- forward.setIndent(indent);
- forward.toIndent();
- }
-
- public int getIndent() {
- return forward.getIndent();
- }
+ private static final int COMMENT_COLUMN = 40;
+ private StringBuilder backSB = new StringBuilder();
+ private Stack<Back> backStack = new Stack<Back>();
+
+ protected XGen(Writer w) {
+ forward = new IndentPrintWriter(w);
+ }
+
+ public int pushBack(Back b) {
+ int rv = backStack.size();
+ backStack.push(b);
+ return rv;
+ }
+
+ public boolean pretty = false;
+ protected IndentPrintWriter forward;
+
+ public IndentPrintWriter getWriter() {
+ return forward;
+ }
+
+ protected PrintWriter back = new PrintWriter(
+ new StringBuilderWriter(backSB));
+
+ @SuppressWarnings("unchecked")
+ public RT pretty() {
+ pretty = true;
+ return (RT) this;
+ }
+
+ protected void prettyln(PrintWriter pw) {
+ if(pretty)pw.println();
+ }
+
+ public RT leaf(Mark mark, String tag, String ... args) {
+ mark.spot = backStack.size();
+ return leaf(tag, args);
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT leaf(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+ back.append("</");
+ back.append(tag);
+ back.append('>');
+ backStack.push(new Back(backSB.toString(), false, true));
+ backSB.setLength(0);
+ return (RT)this;
+ }
+
+ public RT incr(String tag, String ... args) {
+ return incr(null, tag, false, args);
+ }
+
+ public RT incr(String tag, boolean oneLine, String ... args) {
+ return incr(null, tag, oneLine, args);
+ }
+
+ public RT incr(Mark mark) {
+ return incr(mark,mark.comment, false, new String[0]);
+ }
+
+ public RT incr(Mark mark, String tag, String ... attrs) {
+ return incr(mark, tag, false, attrs);
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+
+ back.append("</");
+ back.append(tag);
+ back.append('>');
+
+ if(pretty) {
+ if(mark!=null && mark.comment!=null) {
+ int fi = forward.getIndent()*IndentPrintWriter.INDENT_MULTIPLIER;
+ for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) {
+ back.append(' ');
+ }
+ back.append("<!-- end ");
+ back.append(mark.comment);
+ back.append(" -->");
+
+ forward.toCol(COMMENT_COLUMN);
+ forward.append("<!-- begin ");
+ forward.append(mark.comment);
+ forward.append(" -->");
+ }
+ forward.inc();
+ if(!oneLine) {
+ forward.println();
+ }
+ back.println();
+ }
+ if(mark!=null)mark.spot = backStack.size();
+ backStack.push(new Back(backSB.toString(),true, false));
+ backSB.setLength(0);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT tagOnly(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append(" />");
+ if(pretty) {
+ forward.println();
+ }
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT text(String txt) {
+ forward.append(txt);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT xml(String txt) {
+ for(int i=0; i<txt.length();++i) {
+ char c = txt.charAt(i);
+ switch(c) {
+ case '<':
+ forward.append("&lt;");
+ break;
+ case '>':
+ forward.append("&gt;");
+ break;
+ case '&':
+ forward.append("&amp;");
+ break;
+ default:
+ forward.append(c);
+ }
+ }
+ return (RT)this;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public RT textCR(int tabs, String txt) {
+ for(int i=0;i<tabs;++i) {
+ forward.append(" ");
+ }
+ forward.append(txt);
+ if(pretty)forward.println();
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value() {
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-1;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value(String txt) {
+ forward.append(txt);
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-1;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT value(String txt, int levels) {
+ forward.append(txt);
+ Mark mark = new Mark();
+ mark.spot = backStack.size()-levels;
+ end(mark);
+ return (RT)this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT end(Mark mark) {
+ int size = backStack.size();
+ Back c;
+ boolean println = false;
+ for(int i=mark==null?0:mark.spot;i<size;++i) {
+ c = backStack.pop();
+ if(c.dec)forward.dec();
+ forward.append(c.str);
+ println = c.cr;
+ }
+ if(pretty && println) {
+ forward.println();
+ }
+ return (RT)this;
+ }
+
+ public RT end() {
+ Mark mark = new Mark();
+ mark.spot=backStack.size()-1;
+ if(mark.spot<0)mark.spot=0;
+ return end(mark);
+ }
+
+ public RT end(int i) {
+ Mark mark = new Mark();
+ mark.spot=backStack.size()-i;
+ if(mark.spot<0)mark.spot=0;
+ return end(mark);
+ }
+
+ public void endAll() {
+ end(new Mark());
+ forward.flush();
+ }
+
+ protected void addAttrs(String[] attrs) {
+ if(attrs!=null) {
+ for(String attr : attrs) {
+ if(attr!=null && attr.length()>0) {
+ forward.append(' ');
+ String[] split = attr.split("=",2);
+ switch(split.length) {
+ case 0:
+ break;
+ case 1:
+ forward.append(split[0]);
+// forward.append("=\"\"");
+ break;
+ default:
+ forward.append(split[0]);
+ forward.append("=\"");
+ forward.append(split[1]);
+ forward.append('"');
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public RT comment(String string) {
+ if(pretty) {
+ forward.print("<!-- ");
+ forward.print(string);
+ forward.println(" -->");
+ }
+ return (RT)this;
+ }
+
+ public void setIndent(int indent) {
+ forward.setIndent(indent);
+ forward.toIndent();
+ }
+
+ public int getIndent() {
+ return forward.getIndent();
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
index d2578a34..5f11e4db 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java
@@ -30,57 +30,57 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter;
import org.onap.aaf.misc.xgen.html.State;
public class XGenBuff<G extends XGen<G>> {
- private G xgen;
- private StringBuilder sb;
- // private String forward, backward;
-
- public XGenBuff(int flags, CacheGen<G> cg) {
- sb = new StringBuilder();
- xgen = cg.create(flags, new StringBuilderWriter(sb));
- }
+ private G xgen;
+ private StringBuilder sb;
+ // private String forward, backward;
+
+ public XGenBuff(int flags, CacheGen<G> cg) {
+ sb = new StringBuilder();
+ xgen = cg.create(flags, new StringBuilderWriter(sb));
+ }
- /**
- * Normal case of building up Cached HTML without transaction info
- *
- * @param cache
- * @param code
- * @throws APIException
- * @throws IOException
- */
- public void run(Cache<G> cache, Code<G> code) throws APIException, IOException {
- code.code(cache, xgen);
- }
+ /**
+ * Normal case of building up Cached HTML without transaction info
+ *
+ * @param cache
+ * @param code
+ * @throws APIException
+ * @throws IOException
+ */
+ public void run(Cache<G> cache, Code<G> code) throws APIException, IOException {
+ code.code(cache, xgen);
+ }
- /**
- * Special Case where code is dynamic, so give access to State and Trans info
- *
- * @param state
- * @param trans
- * @param cache
- * @param code
- * @throws APIException
- * @throws IOException
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException {
- code.code(state, trans, cache, xgen);
- }
-
- public int getIndent() {
- return xgen.getIndent();
- }
+ /**
+ * Special Case where code is dynamic, so give access to State and Trans info
+ *
+ * @param state
+ * @param trans
+ * @param cache
+ * @param code
+ * @throws APIException
+ * @throws IOException
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException {
+ code.code(state, trans, cache, xgen);
+ }
+
+ public int getIndent() {
+ return xgen.getIndent();
+ }
- public void setIndent(int indent) {
- xgen.setIndent(indent);
- }
+ public void setIndent(int indent) {
+ xgen.setIndent(indent);
+ }
- public Section<G> newSection() {
- Section<G> s = new Section<G>();
- s.indent = xgen.getIndent();
- s.forward = sb.toString();
- sb.setLength(0);
- s.backward = sb.toString();
- sb.setLength(0);
- return s;
- }
+ public Section<G> newSection() {
+ Section<G> s = new Section<G>();
+ s.indent = xgen.getIndent();
+ s.forward = sb.toString();
+ sb.setLength(0);
+ s.backward = sb.toString();
+ sb.setLength(0);
+ return s;
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
index 34d798d5..16ac60ae 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java
@@ -26,118 +26,118 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.Mark;
public class HTML4Gen extends HTMLGen {
- private final static String DOCTYPE =
- /*
- "<!DOCTYPE HTML PUBLIC " +
- "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +
- "\"http://www.w3.org/TR/html3/loose.dtd\">";
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
- */
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+ private final static String DOCTYPE =
+ /*
+ "<!DOCTYPE HTML PUBLIC " +
+ "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +
+ "\"http://www.w3.org/TR/html3/loose.dtd\">";
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
+ */
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- public HTML4Gen(Writer w) {
- super(w);
- }
+ public HTML4Gen(Writer w) {
+ super(w);
+ }
- @Override
- public HTMLGen html(String ... attrib) {
- forward.println(DOCTYPE);
- return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en");
-
- }
+ @Override
+ public HTMLGen html(String ... attrib) {
+ forward.println(DOCTYPE);
+ return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en");
+
+ }
- @Override
- public Mark head() {
- Mark head = new Mark("head");
- incr(head);
- return head;
- }
+ @Override
+ public Mark head() {
+ Mark head = new Mark("head");
+ incr(head);
+ return head;
+ }
- @Override
- public Mark body(String ... attrs) {
- Mark body = new Mark("body");
- incr(body,"body",attrs);
- return body;
- }
-
- @Override
- public HTML4Gen charset(String charset) {
- forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset=");
- forward.append(charset);
- forward.append("\">");
- prettyln(forward);
- return this;
- }
+ @Override
+ public Mark body(String ... attrs) {
+ Mark body = new Mark("body");
+ incr(body,"body",attrs);
+ return body;
+ }
+
+ @Override
+ public HTML4Gen charset(String charset) {
+ forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset=");
+ forward.append(charset);
+ forward.append("\">");
+ prettyln(forward);
+ return this;
+ }
- @Override
- public Mark header(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="header";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark header(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="header";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark footer(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="footer";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark footer(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="footer";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark section(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="section";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark section(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="section";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark article(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="attrib";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark article(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="attrib";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark aside(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="aside";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark aside(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="aside";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
- @Override
- public Mark nav(String ... attribs) {
- String[] a = new String[attribs.length+1];
- a[0]="nav";
- System.arraycopy(attribs, 0, a, 1, attribs.length);
- return divID(a);
- }
+ @Override
+ public Mark nav(String ... attribs) {
+ String[] a = new String[attribs.length+1];
+ a[0]="nav";
+ System.arraycopy(attribs, 0, a, 1, attribs.length);
+ return divID(a);
+ }
-// @Override
-// protected void importCSS(Imports imports) {
-// if(imports.css.size()==1) {
-// cssInline(imports.css.get(0));
-// } else {
-// text("<style type=\"text/css\">");
-// prettyln(forward);
-// forward.inc();
-// for(String str : imports.css) {
-// forward.print("@import url(\"");
-// forward.print(imports.themePath(null));
-// forward.print(str);
-// forward.print("\");");
-// prettyln(forward);
-// }
-// forward.dec();
-// forward.print("</style>");
-// prettyln(forward);
-// }
-// }
-
+// @Override
+// protected void importCSS(Imports imports) {
+// if(imports.css.size()==1) {
+// cssInline(imports.css.get(0));
+// } else {
+// text("<style type=\"text/css\">");
+// prettyln(forward);
+// forward.inc();
+// for(String str : imports.css) {
+// forward.print("@import url(\"");
+// forward.print(imports.themePath(null));
+// forward.print(str);
+// forward.print("\");");
+// prettyln(forward);
+// }
+// forward.dec();
+// forward.print("</style>");
+// prettyln(forward);
+// }
+// }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
index f155a65e..5e4cee7e 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java
@@ -26,130 +26,130 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.Mark;
public class HTML5Gen extends HTMLGen {
- public HTML5Gen(Writer w) {
- super(w);
- }
-
- @Override
- public HTMLGen html(String ... attrib) {
- //forward.println("<!DOCTYPE html>");
- incr("html",attrib);
- return this;
- }
-
- @Override
- public Mark head() {
- Mark head = new Mark("head");
- incr(head).directive("meta","charset=utf-8");
- return head;
- }
-
- @Override
- public Mark body(String ... attrs) {
- Mark body = new Mark("body");
- incr(body,"body",attrs);
- //chromeFrame();
- return body;
- }
-
- @Override
- public HTML5Gen charset(String charset) {
- forward.append("<meta charset=\"");
- forward.append(charset);
- forward.append("\">");
- prettyln(forward);
- return this;
- }
-
- @Override
- public Mark header(String ... attribs) {
- Mark mark = new Mark("header");
- incr(mark, mark.comment, attribs);
- return mark;
- }
-
- @Override
- public Mark footer(String ... attribs) {
- Mark mark = new Mark("footer");
- incr(mark, mark.comment, attribs);
- return mark;
- }
-
- @Override
- public Mark section(String ... attribs) {
- Mark mark = new Mark("section");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark article(String ... attribs) {
- Mark mark = new Mark("article");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark aside(String ... attribs) {
- Mark mark = new Mark("aside");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
- @Override
- public Mark nav(String ... attribs) {
- Mark mark = new Mark("nav");
- incr(mark, mark.comment,attribs);
- return mark;
- }
-
-
-// @Override
-// protected void importCSS(Imports imports) {
-// if(imports.css.size() == 1) {
-// cssInline(imports.css.get(0));
-// } else {
-// for(String str : imports.css) {
-// forward.print("<link rel=\"stylesheet\" href=\"");
-// forward.print(imports.themePath(null));
-// forward.print(str);
-// forward.println("\">");
-// }
-// }
-// }
+ public HTML5Gen(Writer w) {
+ super(w);
+ }
+
+ @Override
+ public HTMLGen html(String ... attrib) {
+ //forward.println("<!DOCTYPE html>");
+ incr("html",attrib);
+ return this;
+ }
+
+ @Override
+ public Mark head() {
+ Mark head = new Mark("head");
+ incr(head).directive("meta","charset=utf-8");
+ return head;
+ }
+
+ @Override
+ public Mark body(String ... attrs) {
+ Mark body = new Mark("body");
+ incr(body,"body",attrs);
+ //chromeFrame();
+ return body;
+ }
+
+ @Override
+ public HTML5Gen charset(String charset) {
+ forward.append("<meta charset=\"");
+ forward.append(charset);
+ forward.append("\">");
+ prettyln(forward);
+ return this;
+ }
+
+ @Override
+ public Mark header(String ... attribs) {
+ Mark mark = new Mark("header");
+ incr(mark, mark.comment, attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark footer(String ... attribs) {
+ Mark mark = new Mark("footer");
+ incr(mark, mark.comment, attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark section(String ... attribs) {
+ Mark mark = new Mark("section");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark article(String ... attribs) {
+ Mark mark = new Mark("article");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark aside(String ... attribs) {
+ Mark mark = new Mark("aside");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+ @Override
+ public Mark nav(String ... attribs) {
+ Mark mark = new Mark("nav");
+ incr(mark, mark.comment,attribs);
+ return mark;
+ }
+
+
+// @Override
+// protected void importCSS(Imports imports) {
+// if(imports.css.size() == 1) {
+// cssInline(imports.css.get(0));
+// } else {
+// for(String str : imports.css) {
+// forward.print("<link rel=\"stylesheet\" href=\"");
+// forward.print(imports.themePath(null));
+// forward.print(str);
+// forward.println("\">");
+// }
+// }
+// }
//
- /*
- public void chromeFrame() {
- this.textCR(0,"<!--[if IE]>");
- Mark mark = new Mark();
- this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js")
- .end(mark);
- this.incr(mark, "style")
- .textCR(0,".chromeFrameInstallDefaultStyle {")
- .textCR(1,"width: 100%; /* default is 800px * /")
- .textCR(1,"border: 5px solid blue;")
- .textCR(0,"}")
- .end(mark);
-
- this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script
- // "if IE without GCF, prompt goes here"
- this.text("Please load this plugin to run ClientSide Websockets")
- .end(mark);
-
- this.incr(mark, "script")
- .textCR(0, "// The conditional ensures that this code will only execute in IE,")
- .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry")
- .textCR(0, "window.attachEvent('onload', function() {")
- .textCR(1,"CFInstall.check({")
- .textCR(2,"mode: 'inline', // the default")
- .textCR(2,"node: 'prompt'")
- .textCR(1, "});")
- .textCR(0, "});")
- .end(mark);
-
- this.textCR(0,"<![endif]-->");
- }
- */
+ /*
+ public void chromeFrame() {
+ this.textCR(0,"<!--[if IE]>");
+ Mark mark = new Mark();
+ this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js")
+ .end(mark);
+ this.incr(mark, "style")
+ .textCR(0,".chromeFrameInstallDefaultStyle {")
+ .textCR(1,"width: 100%; /* default is 800px * /")
+ .textCR(1,"border: 5px solid blue;")
+ .textCR(0,"}")
+ .end(mark);
+
+ this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script
+ // "if IE without GCF, prompt goes here"
+ this.text("Please load this plugin to run ClientSide Websockets")
+ .end(mark);
+
+ this.incr(mark, "script")
+ .textCR(0, "// The conditional ensures that this code will only execute in IE,")
+ .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry")
+ .textCR(0, "window.attachEvent('onload', function() {")
+ .textCR(1,"CFInstall.check({")
+ .textCR(2,"mode: 'inline', // the default")
+ .textCR(2,"node: 'prompt'")
+ .textCR(1, "});")
+ .textCR(0, "});")
+ .end(mark);
+
+ this.textCR(0,"<![endif]-->");
+ }
+ */
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
index 74c5a000..0c94d837 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java
@@ -29,31 +29,31 @@ import org.onap.aaf.misc.xgen.CacheGen;
import org.onap.aaf.misc.xgen.Code;
public class HTMLCacheGen extends CacheGen<HTMLGen> {
- protected int flags;
-
- public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException {
- super(flags, code);
- this.flags = flags;
- }
-
- @Override
- public HTMLGen create(int htmlStyle, Writer w) {
- HTMLGen hg;
- switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) {
- case CacheGen.HTML4:
- hg = new HTML4Gen(w);
- break;
- case CacheGen.HTML5:
- default:
- hg = new HTML5Gen(w);
- break;
-
- }
- hg.pretty = (htmlStyle&CacheGen.PRETTY)>0;
- return hg;
- }
-
- protected HTMLGen clone(Writer w) {
- return create(flags,w);
- }
+ protected int flags;
+
+ public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException {
+ super(flags, code);
+ this.flags = flags;
+ }
+
+ @Override
+ public HTMLGen create(int htmlStyle, Writer w) {
+ HTMLGen hg;
+ switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) {
+ case CacheGen.HTML4:
+ hg = new HTML4Gen(w);
+ break;
+ case CacheGen.HTML5:
+ default:
+ hg = new HTML5Gen(w);
+ break;
+
+ }
+ hg.pretty = (htmlStyle&CacheGen.PRETTY)>0;
+ return hg;
+ }
+
+ protected HTMLGen clone(Writer w) {
+ return create(flags,w);
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
index c3359745..b2fb81d1 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java
@@ -27,214 +27,214 @@ import org.onap.aaf.misc.xgen.Mark;
import org.onap.aaf.misc.xgen.XGen;
public abstract class HTMLGen extends XGen<HTMLGen> {
- public static final String A = "a";
- public static final String P = "p";
- public static final String LI = "li";
- public static final String OL = "ol";
- public static final String UL = "ul";
-
-
- public static final String TABLE = "table";
- public static final String THEAD = "thead";
- public static final String TBODY = "tbody";
- public static final String TR = "tr";
- public static final String TH = "th";
- public static final String TD = "td";
-
- public static final String TITLE = "title";
- public static final String H1 = "h1";
- public static final String H2 = "h2";
- public static final String H3 = "h3";
- public static final String H4 = "h4";
- public static final String H5 = "h5";
-
-
-
- // --------------------------- HTML Version Specific -----------------------
- public abstract HTMLGen html(String ... attributes);
- public abstract HTMLGen charset(String charset);
- public abstract Mark head();
- public abstract Mark body(String ... attribs);
-
-
- // HTML 5 has simplified sectioning
- public abstract Mark header(String ... attribs);
- public abstract Mark footer(String ... attribs);
- public abstract Mark section(String ... attribs);
- public abstract Mark article(String ... attribs);
- public abstract Mark aside(String ... attribs);
- public abstract Mark nav(String ... attribs);
-
- // --------------------------- HTML Version Specific -----------------------
-
- public HTMLGen imports(Imports imports) {
- //this.imports=imports;
- for(String str : imports.css) {
- forward.print("<link rel=\"stylesheet\" href=\"");
- forward.print(imports.themePath(null));
- forward.print(str);
- forward.println("\">");
- }
-
- for(String str : imports.js) {
- forward.print("<script type=\"text/javascript\" src=\"");
- forward.print(imports.themePath(null));
- forward.print(str);
- forward.println("\"></script>");
- }
- return this;
- }
-
- public HTMLGen jsVars(String ... attrs) {
- forward.println("<script type=text/javascript>");
- if(attrs!=null) {
- for(int i=0; i<attrs.length;++i) {
- forward.append(' ');
- String[] split = attrs[i].split("=",2);
- switch(split.length) {
- case 2:
- forward.print(" var ");
- forward.append(split[0]);
- forward.append("='");
- forward.append(split[1]);
- forward.println("';");
- break;
- }
- }
- }
- forward.println("</script>");
- return this;
- }
-
- public HTMLGen(Writer w) {
- super(w);
- }
-
- /**
- * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...>
- * @param tag
- * @param attrs
- * @return
- */
- public HTMLGen directive(String tag, String ... attrs) {
- forward.append('<');
- forward.append(tag);
- addAttrs(attrs);
- forward.append('>');
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public Mark divID(String ... attrs) {
- Mark div;
- if(attrs.length>0) {
- div = new Mark(attrs[0]);
- attrs[0]="id="+attrs[0];
- } else {
- div = new Mark();
- }
- incr(div, "div", attrs);
- return div;
- }
-
- public HTMLGen img(String ... attrs) {
- return tagOnly("img", attrs);
- }
-
- /**
- * Input Cheesecake... creates a Label and Field in the form of Table Rows.
- * Make sure you create a table first, ie. incr(HTMLGen.TABLE);
- *
- * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will
- * validate there is data in the fields before submitting. "required" does nothing for label, but allows for
- * easy CSS coding... "label[required] { ... }", so that colors can be changed
- *
- * @param id
- * @param label
- * @param required
- * @param attrs
- * @return
- */
- public HTMLGen input(String id, String label, boolean required, String ... attrs) {
- Mark mtr = new Mark(TR);
- Mark mtd = new Mark(TD);
- incr(mtr);
- incr(mtd);
- incr("label",true, "for="+id,required?"required":null).text(label).end();
- end(mtd);
- String nattrs[] = new String[attrs.length+(required?3:2)];
- nattrs[0]="id="+id;
- nattrs[1]="name="+id;
- System.arraycopy(attrs, 0, nattrs, 2, attrs.length);
- if(required) {
- nattrs[nattrs.length-1]="required";
- }
- incr(mtd);
- tagOnly("input",nattrs);
- end(mtr);
- return this;
- }
-
- // Common tags that do not have standard endings. These are here to help people who don't know to pick directive
- public HTMLGen br() {
- forward.append("<br>");
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public HTMLGen p(String ... text) {
- forward.append("<p>");
- for(String s : text) {
- forward.append(s);
- }
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public HTMLGen hr() {
- forward.append("<hr>");
- if(pretty) {
- forward.println();
- }
- return this;
- }
-
- public JSGen js(Mark mark) {
- return new JSGen(mark, this);
- }
-
- public JSGen js() {
- return js(null);
- }
+ public static final String A = "a";
+ public static final String P = "p";
+ public static final String LI = "li";
+ public static final String OL = "ol";
+ public static final String UL = "ul";
+
+
+ public static final String TABLE = "table";
+ public static final String THEAD = "thead";
+ public static final String TBODY = "tbody";
+ public static final String TR = "tr";
+ public static final String TH = "th";
+ public static final String TD = "td";
+
+ public static final String TITLE = "title";
+ public static final String H1 = "h1";
+ public static final String H2 = "h2";
+ public static final String H3 = "h3";
+ public static final String H4 = "h4";
+ public static final String H5 = "h5";
+
+
+
+ // --------------------------- HTML Version Specific -----------------------
+ public abstract HTMLGen html(String ... attributes);
+ public abstract HTMLGen charset(String charset);
+ public abstract Mark head();
+ public abstract Mark body(String ... attribs);
+
+
+ // HTML 5 has simplified sectioning
+ public abstract Mark header(String ... attribs);
+ public abstract Mark footer(String ... attribs);
+ public abstract Mark section(String ... attribs);
+ public abstract Mark article(String ... attribs);
+ public abstract Mark aside(String ... attribs);
+ public abstract Mark nav(String ... attribs);
+
+ // --------------------------- HTML Version Specific -----------------------
+
+ public HTMLGen imports(Imports imports) {
+ //this.imports=imports;
+ for(String str : imports.css) {
+ forward.print("<link rel=\"stylesheet\" href=\"");
+ forward.print(imports.themePath(null));
+ forward.print(str);
+ forward.println("\">");
+ }
+
+ for(String str : imports.js) {
+ forward.print("<script type=\"text/javascript\" src=\"");
+ forward.print(imports.themePath(null));
+ forward.print(str);
+ forward.println("\"></script>");
+ }
+ return this;
+ }
+
+ public HTMLGen jsVars(String ... attrs) {
+ forward.println("<script type=text/javascript>");
+ if(attrs!=null) {
+ for(int i=0; i<attrs.length;++i) {
+ forward.append(' ');
+ String[] split = attrs[i].split("=",2);
+ switch(split.length) {
+ case 2:
+ forward.print(" var ");
+ forward.append(split[0]);
+ forward.append("='");
+ forward.append(split[1]);
+ forward.println("';");
+ break;
+ }
+ }
+ }
+ forward.println("</script>");
+ return this;
+ }
+
+ public HTMLGen(Writer w) {
+ super(w);
+ }
+
+ /**
+ * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...>
+ * @param tag
+ * @param attrs
+ * @return
+ */
+ public HTMLGen directive(String tag, String ... attrs) {
+ forward.append('<');
+ forward.append(tag);
+ addAttrs(attrs);
+ forward.append('>');
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public Mark divID(String ... attrs) {
+ Mark div;
+ if(attrs.length>0) {
+ div = new Mark(attrs[0]);
+ attrs[0]="id="+attrs[0];
+ } else {
+ div = new Mark();
+ }
+ incr(div, "div", attrs);
+ return div;
+ }
+
+ public HTMLGen img(String ... attrs) {
+ return tagOnly("img", attrs);
+ }
+
+ /**
+ * Input Cheesecake... creates a Label and Field in the form of Table Rows.
+ * Make sure you create a table first, ie. incr(HTMLGen.TABLE);
+ *
+ * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will
+ * validate there is data in the fields before submitting. "required" does nothing for label, but allows for
+ * easy CSS coding... "label[required] { ... }", so that colors can be changed
+ *
+ * @param id
+ * @param label
+ * @param required
+ * @param attrs
+ * @return
+ */
+ public HTMLGen input(String id, String label, boolean required, String ... attrs) {
+ Mark mtr = new Mark(TR);
+ Mark mtd = new Mark(TD);
+ incr(mtr);
+ incr(mtd);
+ incr("label",true, "for="+id,required?"required":null).text(label).end();
+ end(mtd);
+ String nattrs[] = new String[attrs.length+(required?3:2)];
+ nattrs[0]="id="+id;
+ nattrs[1]="name="+id;
+ System.arraycopy(attrs, 0, nattrs, 2, attrs.length);
+ if(required) {
+ nattrs[nattrs.length-1]="required";
+ }
+ incr(mtd);
+ tagOnly("input",nattrs);
+ end(mtr);
+ return this;
+ }
+
+ // Common tags that do not have standard endings. These are here to help people who don't know to pick directive
+ public HTMLGen br() {
+ forward.append("<br>");
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public HTMLGen p(String ... text) {
+ forward.append("<p>");
+ for(String s : text) {
+ forward.append(s);
+ }
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public HTMLGen hr() {
+ forward.append("<hr>");
+ if(pretty) {
+ forward.println();
+ }
+ return this;
+ }
+
+ public JSGen js(Mark mark) {
+ return new JSGen(mark, this);
+ }
+
+ public JSGen js() {
+ return js(null);
+ }
//
-// protected void cssInline(String filename) {
-// File file = new File(imports.webDir,filename);
-// try {
-// String line;
-// BufferedReader br = new BufferedReader(new FileReader(file));
-// try {
-// forward.print("<style>");
-// prettyln(forward);
-// while((line=br.readLine())!=null) {
-// forward.print((pretty?line:line.trim()));
-// prettyln(forward);
-// }
-// }finally {
-// forward.print("</style>");
-// prettyln(forward);
-// br.close();
-// }
-// } catch (IOException e) {
-// e.printStackTrace();
-// // Can't read, suffice to import normally?
-// // for now, just skip
-// }
-// }
-
+// protected void cssInline(String filename) {
+// File file = new File(imports.webDir,filename);
+// try {
+// String line;
+// BufferedReader br = new BufferedReader(new FileReader(file));
+// try {
+// forward.print("<style>");
+// prettyln(forward);
+// while((line=br.readLine())!=null) {
+// forward.print((pretty?line:line.trim()));
+// prettyln(forward);
+// }
+// }finally {
+// forward.print("</style>");
+// prettyln(forward);
+// br.close();
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// // Can't read, suffice to import normally?
+// // for now, just skip
+// }
+// }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
index 17678b3f..00e7f30f 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java
@@ -25,73 +25,73 @@ import java.util.ArrayList;
import java.util.List;
public class Imports implements Thematic{
- List<String> css;
- List<String> js;
- public final int backdots;
- private String theme;
-
- public Imports(int backdots) {
-
- css = new ArrayList<>();
- js = new ArrayList<>();
- this.backdots = backdots;
- theme = "";
- }
-
- public Imports css(String str) {
- css.add(str);
- return this;
- }
-
- public Imports js(String str) {
- js.add(str);
- return this;
- }
+ List<String> css;
+ List<String> js;
+ public final int backdots;
+ private String theme;
+
+ public Imports(int backdots) {
+
+ css = new ArrayList<>();
+ js = new ArrayList<>();
+ this.backdots = backdots;
+ theme = "";
+ }
+
+ public Imports css(String str) {
+ css.add(str);
+ return this;
+ }
+
+ public Imports js(String str) {
+ js.add(str);
+ return this;
+ }
- public Imports theme(String str) {
- theme = str==null?"":str;
- return this;
- }
+ public Imports theme(String str) {
+ theme = str==null?"":str;
+ return this;
+ }
- /**
- * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
- *
- * @param theTheme
- * @return
- */
- @Override
- public String themePath(String theTheme) {
- StringBuilder src = dots(new StringBuilder());
- if(theTheme==null||theTheme.length()==0) {
- src.append(theme);
- if(theme.length()>0)src.append('/');
- } else {
- src.append(theTheme);
- src.append('/');
- }
+ /**
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
+ *
+ * @param theTheme
+ * @return
+ */
+ @Override
+ public String themePath(String theTheme) {
+ StringBuilder src = dots(new StringBuilder());
+ if(theTheme==null||theTheme.length()==0) {
+ src.append(theme);
+ if(theme.length()>0)src.append('/');
+ } else {
+ src.append(theTheme);
+ src.append('/');
+ }
- return src.toString();
- }
-
- /**
- * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
- *
- * @param theTheme
- * @return
- */
- @Override
- public String themeResolve(String theTheme) {
- return (theTheme==null||theTheme.length()==0)
- ?theme
- :theTheme;
- }
+ return src.toString();
+ }
+
+ /**
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports
+ *
+ * @param theTheme
+ * @return
+ */
+ @Override
+ public String themeResolve(String theTheme) {
+ return (theTheme==null||theTheme.length()==0)
+ ?theme
+ :theTheme;
+ }
- public StringBuilder dots(StringBuilder src) {
- for(int i=0;i<backdots;++i) {
- src.append("../");
- }
- return src;
- }
-
+ public StringBuilder dots(StringBuilder src) {
+ for(int i=0;i<backdots;++i) {
+ src.append("../");
+ }
+ return src;
+ }
+
};
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
index 537e9fc5..5d9a507d 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java
@@ -31,174 +31,174 @@ import org.onap.aaf.misc.xgen.Mark;
public class JSGen {
- private HTMLGen htmlGen;
- private IndentPrintWriter ipw;
- private Mark mark;
+ private HTMLGen htmlGen;
+ private IndentPrintWriter ipw;
+ private Mark mark;
- public JSGen(Mark mark, HTMLGen hg) {
- this.mark = mark==null?new Mark():mark;
- hg.incr(this.mark, "script", "language=javascript", "type=text/javascript");
- htmlGen = hg;
- ipw = hg.getWriter();
- }
+ public JSGen(Mark mark, HTMLGen hg) {
+ this.mark = mark==null?new Mark():mark;
+ hg.incr(this.mark, "script", "language=javascript", "type=text/javascript");
+ htmlGen = hg;
+ ipw = hg.getWriter();
+ }
- public JSGen inline(String filename, int tabstop) throws IOException {
- BufferedReader br = new BufferedReader(new FileReader(filename));
- int indent = htmlGen.getIndent();
- try {
- boolean pretty = htmlGen.pretty;
- String line, el;
- int l, end;
- while((line=br.readLine())!=null) {
- if(pretty) {
- String[] elements = line.split("\t");
-
- for(int i=0; i<elements.length;++i) {
- el = elements[i];
- l = el.length();
- if(l==0) {// was a Tab
- ipw.print(" ");
- } else {
- el = el.trim();
- l = l-el.length();
- end = l/tabstop;
- for(int j=0;j<end;++j) {
- ipw.print(" ");
- }
- end = l%tabstop;
- for(int j=0;j<end;++j) {
- ipw.print(' ');
- }
- if(i>0) ipw.print(' ');
- ipw.print(el);
- }
- }
- ipw.println();
- } else {
- ipw.print(line.trim());
- }
- }
- } finally {
- htmlGen.setIndent(indent);
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return this;
- }
-
- public JSGen pst(String ... lines) {
- return pst(null, lines);
- }
-
- public JSGen pst(Mark jm, String ... lines) {
- if(lines.length>0) ipw.append(lines[0]);
- ipw.append('(');
- for(int i=1;i<lines.length;++i) {
- ipw.print(lines[i]);
- ipw.print(", ");
- }
- Back back;
+ public JSGen inline(String filename, int tabstop) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ int indent = htmlGen.getIndent();
+ try {
+ boolean pretty = htmlGen.pretty;
+ String line, el;
+ int l, end;
+ while((line=br.readLine())!=null) {
+ if(pretty) {
+ String[] elements = line.split("\t");
+
+ for(int i=0; i<elements.length;++i) {
+ el = elements[i];
+ l = el.length();
+ if(l==0) {// was a Tab
+ ipw.print(" ");
+ } else {
+ el = el.trim();
+ l = l-el.length();
+ end = l/tabstop;
+ for(int j=0;j<end;++j) {
+ ipw.print(" ");
+ }
+ end = l%tabstop;
+ for(int j=0;j<end;++j) {
+ ipw.print(' ');
+ }
+ if(i>0) ipw.print(' ');
+ ipw.print(el);
+ }
+ }
+ ipw.println();
+ } else {
+ ipw.print(line.trim());
+ }
+ }
+ } finally {
+ htmlGen.setIndent(indent);
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return this;
+ }
+
+ public JSGen pst(String ... lines) {
+ return pst(null, lines);
+ }
+
+ public JSGen pst(Mark jm, String ... lines) {
+ if(lines.length>0) ipw.append(lines[0]);
+ ipw.append('(');
+ for(int i=1;i<lines.length;++i) {
+ ipw.print(lines[i]);
+ ipw.print(", ");
+ }
+ Back back;
- if(htmlGen.pretty) {
- back = new Back(");\n",false,false);
- } else {
- back = new Back(");",false,false);
- }
- int spot = htmlGen.pushBack(back);
- if(jm!=null)jm.spot(spot);
- return this;
- }
-
- public JSGen li(String ... lines) {
- int current = ipw.getIndent();
- for(int i=0;i<lines.length;++i) {
- if(i==1)ipw.inc();
- if(i>0)ipw.println();
- ipw.print(lines[i]);
- }
- ipw.setIndent(current);
- ipw.append(';');
- if(htmlGen.pretty)ipw.println();
- return this;
- }
-
- public JSGen text(String text) {
- ipw.append(text);
- if(htmlGen.pretty)ipw.println();
- return this;
- }
+ if(htmlGen.pretty) {
+ back = new Back(");\n",false,false);
+ } else {
+ back = new Back(");",false,false);
+ }
+ int spot = htmlGen.pushBack(back);
+ if(jm!=null)jm.spot(spot);
+ return this;
+ }
+
+ public JSGen li(String ... lines) {
+ int current = ipw.getIndent();
+ for(int i=0;i<lines.length;++i) {
+ if(i==1)ipw.inc();
+ if(i>0)ipw.println();
+ ipw.print(lines[i]);
+ }
+ ipw.setIndent(current);
+ ipw.append(';');
+ if(htmlGen.pretty)ipw.println();
+ return this;
+ }
+
+ public JSGen text(String text) {
+ ipw.append(text);
+ if(htmlGen.pretty)ipw.println();
+ return this;
+ }
- public JSGen function(String name, String ... params) {
- return function(null, name, params);
- }
-
- public JSGen jqfunc(Mark mark, String name, String ... params) {
- pst(mark,"$").function(name, params);
- return this;
- }
-
- public JSGen function(Mark jm, String name, String ... params) {
- ipw.print("function ");
- ipw.print(name);
- ipw.print('(');
- for(int i=0;i<params.length;++i) {
- if(i!=0)ipw.print(", ");
- ipw.print(params[i]);
- }
- ipw.print(") {");
- if(htmlGen.pretty) {
- ipw.println();
- ipw.inc();
- }
- int spot = htmlGen.pushBack(new Back("}",true,true));
- if(jm!=null)jm.spot(spot);
- return this;
- }
-
- public JSGen cb(String ... lines) {
- return cb(null,lines);
- }
+ public JSGen function(String name, String ... params) {
+ return function(null, name, params);
+ }
+
+ public JSGen jqfunc(Mark mark, String name, String ... params) {
+ pst(mark,"$").function(name, params);
+ return this;
+ }
+
+ public JSGen function(Mark jm, String name, String ... params) {
+ ipw.print("function ");
+ ipw.print(name);
+ ipw.print('(');
+ for(int i=0;i<params.length;++i) {
+ if(i!=0)ipw.print(", ");
+ ipw.print(params[i]);
+ }
+ ipw.print(") {");
+ if(htmlGen.pretty) {
+ ipw.println();
+ ipw.inc();
+ }
+ int spot = htmlGen.pushBack(new Back("}",true,true));
+ if(jm!=null)jm.spot(spot);
+ return this;
+ }
+
+ public JSGen cb(String ... lines) {
+ return cb(null,lines);
+ }
- public JSGen cb(Mark jm, String ... lines) {
- int current = ipw.getIndent();
- for(int i=0;i<lines.length;++i) {
- if(i==1)ipw.inc();
- if(i>0)ipw.println();
- ipw.print(lines[i]);
- }
- ipw.setIndent(current);
- ipw.print('{');
- if(htmlGen.pretty) {
- ipw.println();
- ipw.inc();
- }
- int spot = htmlGen.pushBack(new Back("}",true,true));
- if(jm!=null)jm.spot(spot);
- return this;
+ public JSGen cb(Mark jm, String ... lines) {
+ int current = ipw.getIndent();
+ for(int i=0;i<lines.length;++i) {
+ if(i==1)ipw.inc();
+ if(i>0)ipw.println();
+ ipw.print(lines[i]);
+ }
+ ipw.setIndent(current);
+ ipw.print('{');
+ if(htmlGen.pretty) {
+ ipw.println();
+ ipw.inc();
+ }
+ int spot = htmlGen.pushBack(new Back("}",true,true));
+ if(jm!=null)jm.spot(spot);
+ return this;
- }
+ }
-
- public JSGen comment(String ... lines) {
- if(htmlGen.pretty) {
- for(int i=0;i<lines.length;++i) {
- ipw.print("// ");
- ipw.println(lines[i]);
- }
- }
- return this;
- }
-
- public JSGen end(Mark mark) {
- htmlGen.end(mark);
- return this;
- }
-
- public HTMLGen done() {
- return htmlGen.end(mark);
- }
-
+
+ public JSGen comment(String ... lines) {
+ if(htmlGen.pretty) {
+ for(int i=0;i<lines.length;++i) {
+ ipw.print("// ");
+ ipw.println(lines[i]);
+ }
+ }
+ return this;
+ }
+
+ public JSGen end(Mark mark) {
+ htmlGen.end(mark);
+ return this;
+ }
+
+ public HTMLGen done() {
+ return htmlGen.end(mark);
+ }
+
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
index 5b08efb4..dd8bc56f 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java
@@ -22,6 +22,6 @@
package org.onap.aaf.misc.xgen.html;
public interface Thematic {
- String themePath(String theTheme);
- String themeResolve(String theTheme);
+ String themePath(String theTheme);
+ String themeResolve(String theTheme);
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
index b274fef9..b1110e0d 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java
@@ -30,16 +30,16 @@ import org.onap.aaf.misc.xgen.Code;
public class XMLCacheGen extends CacheGen<XMLGen> {
- public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException,
- IOException {
- super(flags, code);
- }
+ public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException,
+ IOException {
+ super(flags, code);
+ }
- @Override
- public XMLGen create(int style, Writer w) {
- XMLGen xg = new XMLGen(w);
- xg.pretty = (style & PRETTY)==PRETTY;
- return xg;
- }
+ @Override
+ public XMLGen create(int style, Writer w) {
+ XMLGen xg = new XMLGen(w);
+ xg.pretty = (style & PRETTY)==PRETTY;
+ return xg;
+ }
}
diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
index 6683c627..a5d75453 100644
--- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
+++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java
@@ -26,19 +26,19 @@ import java.io.Writer;
import org.onap.aaf.misc.xgen.XGen;;
public class XMLGen extends XGen<XMLGen> {
- private final String XML_TAG;
-
- public XMLGen(Writer w) {
- this(w,"UTF-8");
- }
-
- public XMLGen(Writer w, String encoding) {
- super(w);
- XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>";
- }
+ private final String XML_TAG;
+
+ public XMLGen(Writer w) {
+ this(w,"UTF-8");
+ }
+
+ public XMLGen(Writer w, String encoding) {
+ super(w);
+ XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>";
+ }
- public XMLGen xml() {
- forward.println(XML_TAG);
- return this;
- }
+ public XMLGen xml() {
+ forward.println(XML_TAG);
+ return this;
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
index 6a3eb15e..aa877966 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_BackTest.java
@@ -26,12 +26,12 @@ import org.junit.Test;
public class JU_BackTest {
- @Test
- public void testBackConstructor() {
- Back back = new Back("String", true, false);
+ @Test
+ public void testBackConstructor() {
+ Back back = new Back("String", true, false);
- assertEquals(back.str, "String");
- assertEquals(back.dec, true);
- assertEquals(back.cr, false);
- }
+ assertEquals(back.str, "String");
+ assertEquals(back.dec, true);
+ assertEquals(back.cr, false);
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
index 5aead073..2a66f851 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_DynamicCodeTest.java
@@ -37,29 +37,29 @@ import org.onap.aaf.misc.xgen.html.State;
public class JU_DynamicCodeTest {
- @Test
- public void test() throws APIException, IOException {
- final Cache<HTMLGen> cache1 = new Cache<HTMLGen>() {
+ @Test
+ public void test() throws APIException, IOException {
+ final Cache<HTMLGen> cache1 = new Cache<HTMLGen>() {
- @Override
- public void dynamic(HTMLGen hgen, Code<HTMLGen> code) {
- }
- };
+ @Override
+ public void dynamic(HTMLGen hgen, Code<HTMLGen> code) {
+ }
+ };
- final HTMLGen xgen1 = new HTML4Gen(new PrintWriter(System.out));
- DynamicCode<HTMLGen, State<Env>, Trans> g = new DynamicCode<HTMLGen, State<Env>, Trans>() {
+ final HTMLGen xgen1 = new HTML4Gen(new PrintWriter(System.out));
+ DynamicCode<HTMLGen, State<Env>, Trans> g = new DynamicCode<HTMLGen, State<Env>, Trans>() {
- @Override
- public void code(State<Env> state, Trans trans, Cache<HTMLGen> cache, HTMLGen xgen)
- throws APIException, IOException {
- assertNull(state);
- assertNull(trans);
- assertEquals(cache, cache1);
- assertEquals(xgen, xgen1);
- }
- };
+ @Override
+ public void code(State<Env> state, Trans trans, Cache<HTMLGen> cache, HTMLGen xgen)
+ throws APIException, IOException {
+ assertNull(state);
+ assertNull(trans);
+ assertEquals(cache, cache1);
+ assertEquals(xgen, xgen1);
+ }
+ };
- g.code(cache1, xgen1);
- }
+ g.code(cache1, xgen1);
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
index 200bde6e..9a5378a7 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_MarkTest.java
@@ -26,16 +26,16 @@ import org.junit.Test;
public class JU_MarkTest {
- @Test
- public void testMark() {
- Mark mark = new Mark();
- assertEquals(mark.spot, 0);
- assertEquals(mark.comment, null);
+ @Test
+ public void testMark() {
+ Mark mark = new Mark();
+ assertEquals(mark.spot, 0);
+ assertEquals(mark.comment, null);
- mark = new Mark("New Comment");
- mark.spot(10);
- assertEquals(mark.spot, 10);
- assertEquals(mark.comment, "New Comment");
+ mark = new Mark("New Comment");
+ mark.spot(10);
+ assertEquals(mark.spot, 10);
+ assertEquals(mark.comment, "New Comment");
- }
+ }
} \ No newline at end of file
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
index 5b5f816a..0f996d5c 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_NullCacheTest.java
@@ -27,9 +27,9 @@ import org.onap.aaf.misc.xgen.Cache.Null;
public class JU_NullCacheTest {
- @Test
- public void testNullIsSingleton() {
- Null<?> singleton = Cache.Null.singleton();
- assertEquals(singleton, Cache.Null.singleton());
- }
+ @Test
+ public void testNullIsSingleton() {
+ Null<?> singleton = Cache.Null.singleton();
+ assertEquals(singleton, Cache.Null.singleton());
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
index a45ea158..44ca3a14 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
@@ -34,31 +34,31 @@ import org.onap.aaf.misc.env.APIException;
public class JU_SectionTest {
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Before
- public void setup() {
- writer = mock(Writer.class);
- }
+ @Before
+ public void setup() {
+ writer = mock(Writer.class);
+ }
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void test() throws APIException, IOException {
- Section section = new Section();
- section.forward = "Forward";
- section.backward = "Backward";
+ @Test
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void test() throws APIException, IOException {
+ Section section = new Section();
+ section.forward = "Forward";
+ section.backward = "Backward";
- section.setIndent(10);
- section.forward(writer);
- section.back(writer);
+ section.setIndent(10);
+ section.forward(writer);
+ section.back(writer);
- assertEquals(section.use(null, null, null), section);
- assertEquals(section.getIndent(), 10);
- assertEquals(section.toString(), "Forward");
+ assertEquals(section.use(null, null, null), section);
+ assertEquals(section.getIndent(), 10);
+ assertEquals(section.toString(), "Forward");
- verify(writer).write("Forward");
- verify(writer).write("Backward");
- }
+ verify(writer).write("Forward");
+ verify(writer).write("Backward");
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
index 9160095d..6fa2afb8 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML4GenTest.java
@@ -36,280 +36,280 @@ import org.mockito.Mock;
public class JU_HTML4GenTest {
- private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
- + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+ private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
+ + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- private String charset = "utf-8";
+ private String charset = "utf-8";
- private final String CHARSET_LINE = "<meta http-equiv=\"Content-type\" content=\"text.hml; charset=" + charset
- + "\">";
+ private final String CHARSET_LINE = "<meta http-equiv=\"Content-type\" content=\"text.hml; charset=" + charset
+ + "\">";
- @Mock
- Writer w;
+ @Mock
+ Writer w;
- @Before
- public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
- w = mock(Writer.class);
- }
+ w = mock(Writer.class);
+ }
- @Test
- public void testHTML() throws IOException {
+ @Test
+ public void testHTML() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.html("attributes");
+ gen.html("attributes");
- Map<Character, Integer> map = new TreeMap<>();
- for (char ch : DOCTYPE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ Map<Character, Integer> map = new TreeMap<>();
+ for (char ch : DOCTYPE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "html".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "html".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- verify(w, atLeast(1)).write(anyInt());
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ verify(w, atLeast(1)).write(anyInt());
+ }
- @Test
- public void testHead() throws IOException {
+ @Test
+ public void testHead() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.head();
+ gen.head();
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "head".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "head".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testBody() throws IOException {
+ @Test
+ public void testBody() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.body("attributes");
+ gen.body("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "body".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "body".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testCharSet() throws IOException {
+ @Test
+ public void testCharSet() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.charset(charset);
+ gen.charset(charset);
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : CHARSET_LINE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : CHARSET_LINE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testHeader() throws IOException {
+ @Test
+ public void testHeader() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.header("attributes");
+ gen.header("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "header".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "header".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testFooter() throws IOException {
+ @Test
+ public void testFooter() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.footer("attributes");
+ gen.footer("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "footer".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "footer".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testSection() throws IOException {
+ @Test
+ public void testSection() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.section("attributes");
+ gen.section("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "section".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "section".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testArticle() throws IOException {
+ @Test
+ public void testArticle() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.article("attributes");
+ gen.article("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "attrib".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attrib".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testAside() throws IOException {
+ @Test
+ public void testAside() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.aside("attributes");
+ gen.aside("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "aside".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "aside".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testNav() throws IOException {
+ @Test
+ public void testNav() throws IOException {
- HTML4Gen gen = new HTML4Gen(w);
+ HTML4Gen gen = new HTML4Gen(w);
- gen.nav("attributes");
+ gen.nav("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "nav".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "nav".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "div".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "div".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
index 69ebf89b..6426fae5 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_HTML5GenTest.java
@@ -36,100 +36,100 @@ import org.mockito.Mock;
public class JU_HTML5GenTest {
-// private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
-// + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
+// private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
+// + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- private String charset = "utf-8";
+ private String charset = "utf-8";
- private final String CHARSET_LINE = "<meta charset=\"" + charset + "\">";
+ private final String CHARSET_LINE = "<meta charset=\"" + charset + "\">";
- @Mock
- Writer w;
+ @Mock
+ Writer w;
- @Before
- public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
- w = mock(Writer.class);
- }
+ w = mock(Writer.class);
+ }
- @Test
- public void testHTML() throws IOException {
+ @Test
+ public void testHTML() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.html("attributes");
+ gen.html("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "html".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "html".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- verify(w, atLeast(1)).write(anyInt());
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ verify(w, atLeast(1)).write(anyInt());
+ }
- @Test
- public void testHead() throws IOException {
+ @Test
+ public void testHead() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.head();
+ gen.head();
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "head".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "head".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testBody() throws IOException {
+ @Test
+ public void testBody() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.body("attributes");
+ gen.body("attributes");
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : "body".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
- for (char ch : "attributes".toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : "body".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
+ for (char ch : "attributes".toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
- @Test
- public void testCharSet() throws IOException {
+ @Test
+ public void testCharSet() throws IOException {
- HTML5Gen gen = new HTML5Gen(w);
+ HTML5Gen gen = new HTML5Gen(w);
- gen.charset(charset);
+ gen.charset(charset);
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- for (char ch : CHARSET_LINE.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : CHARSET_LINE.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(w, atLeast(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(w, atLeast(map.get(ch))).write(ch);
+ }
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
index 4a6ce6b8..c9de2d14 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_ImportsTest.java
@@ -27,28 +27,28 @@ import org.junit.Test;
public class JU_ImportsTest {
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public void test() {
- Imports imports = new Imports(2);
- imports.css("styles.css");
- imports.js("main.js");
- imports.theme("New Theme");
-
- assertEquals("New Theme", imports.themeResolve(null));
- assertEquals("New Theme", imports.themeResolve(""));
- assertEquals("The Theme", imports.themeResolve("The Theme"));
-
- assertEquals("build/../../", imports.dots(new StringBuilder("build/")).toString());
- assertEquals("../../Theme/", imports.themePath("Theme"));
- assertEquals("../../New Theme/", imports.themePath(""));
- assertEquals("../../New Theme/", imports.themePath(null));
-
- imports.theme(null);
- assertEquals("../../", imports.themePath(null));
- }
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+ Imports imports = new Imports(2);
+ imports.css("styles.css");
+ imports.js("main.js");
+ imports.theme("New Theme");
+
+ assertEquals("New Theme", imports.themeResolve(null));
+ assertEquals("New Theme", imports.themeResolve(""));
+ assertEquals("The Theme", imports.themeResolve("The Theme"));
+
+ assertEquals("build/../../", imports.dots(new StringBuilder("build/")).toString());
+ assertEquals("../../Theme/", imports.themePath("Theme"));
+ assertEquals("../../New Theme/", imports.themePath(""));
+ assertEquals("../../New Theme/", imports.themePath(null));
+
+ imports.theme(null);
+ assertEquals("../../", imports.themePath(null));
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
index 8bf811be..a52dae3d 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/html/JU_JSGenTest.java
@@ -39,176 +39,176 @@ import org.onap.aaf.misc.xgen.Mark;
public class JU_JSGenTest {
- @Mock
- private HTMLGen hg;
- @Mock
- private Mark mark;
- @Mock
- private IndentPrintWriter writer;
- @Mock
- private Mark jm;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testFileNotFoundException() {
- JSGen gen = new JSGen(mark, hg);
-
- try {
- gen.inline("JSScript", 2);
- fail("This file should not be found.");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void testJSRead() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- JSGen gen = new JSGen(mark, hg);
-
- gen.inline("./sampletest.js", 2);
-
- verify(writer).print("function myFunction() {");
- verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
- verify(writer).print("}");
- verify(writer, times(0)).println();
- }
-
- @Test
- public void testJSReadPrettyPrint() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.inline("./sampletest.js", 2);
-
- verify(writer).print("function myFunction() {");
- verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
- verify(writer).print("}");
- verify(writer, times(3)).println();
- verify(hg).setIndent(0);
- }
-
- @Test
- public void testPst() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst("line 1", "line 2");
-
- verify(writer).append('(');
- verify(writer).append("line 1");
- verify(writer).print("line 2");
- verify(writer, times(1)).print(", ");
- }
-
- @Test
- public void testPstWithMark() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst(jm, "line 1", "line 2");
-
- verify(writer).append('(');
- verify(writer).append("line 1");
- verify(writer).print("line 2");
- verify(writer, times(1)).print(", ");
- }
-
- @Test
- public void testPstWithNoLines() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.pst(jm);
-
- verify(writer).append('(');
- }
-
- @Test
- public void testLi() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(writer.getIndent()).thenReturn(3);
-
- JSGen gen = new JSGen(mark, hg);
-
- gen.li("line 1", "line 2");
-
- verify(writer).setIndent(3);
- verify(writer).inc();
- verify(writer).println();
- verify(writer).print("line 1");
- verify(writer).print("line 2");
-
- hg.pretty = true;
- gen.li("line 1", "line 2");
- verify(writer, times(3)).println();
- }
-
- @Test
- public void testText() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.text("line 1");
-
- verify(writer).append("line 1");
- verify(writer).println();
-
- hg.pretty = false;
- gen.text("line 1");
-
- verify(writer, times(2)).append("line 1");
- }
-
- @Test
- public void testFunction() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- hg.pretty = true;
- JSGen gen = new JSGen(mark, hg);
-
- gen.function("line 1", "line 2", "line 3");
-
- verify(writer).print("function ");
- verify(writer).print("line 1");
- verify(writer).print('(');
-
- verify(writer).print("line 2");
- verify(writer).print("line 3");
- verify(writer, times(1)).print(", ");
- verify(writer).print(") {");
- verify(writer).inc();
- verify(writer).println();
- }
-
- @Test
- public void testFunctionWithMark() throws IOException {
- when(hg.getWriter()).thenReturn(writer);
- when(hg.pushBack(any(Back.class))).thenReturn(3);
- JSGen gen = new JSGen(mark, hg);
-
- gen.function(jm, "line 1", "line 2", "line 3");
-
- verify(writer).print("function ");
- verify(writer).print("line 1");
- verify(writer).print('(');
-
- verify(writer).print("line 2");
- verify(writer).print("line 3");
- verify(writer, times(1)).print(", ");
- verify(writer).print(") {");
- verify(writer, times(0)).inc();
- verify(writer, times(0)).println();
- }
+ @Mock
+ private HTMLGen hg;
+ @Mock
+ private Mark mark;
+ @Mock
+ private IndentPrintWriter writer;
+ @Mock
+ private Mark jm;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testFileNotFoundException() {
+ JSGen gen = new JSGen(mark, hg);
+
+ try {
+ gen.inline("JSScript", 2);
+ fail("This file should not be found.");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testJSRead() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.inline("./sampletest.js", 2);
+
+ verify(writer).print("function myFunction() {");
+ verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
+ verify(writer).print("}");
+ verify(writer, times(0)).println();
+ }
+
+ @Test
+ public void testJSReadPrettyPrint() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.inline("./sampletest.js", 2);
+
+ verify(writer).print("function myFunction() {");
+ verify(writer).print("document.getElementById(\"demo\").innerHTML = \"Paragraph changed.\";");
+ verify(writer).print("}");
+ verify(writer, times(3)).println();
+ verify(hg).setIndent(0);
+ }
+
+ @Test
+ public void testPst() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst("line 1", "line 2");
+
+ verify(writer).append('(');
+ verify(writer).append("line 1");
+ verify(writer).print("line 2");
+ verify(writer, times(1)).print(", ");
+ }
+
+ @Test
+ public void testPstWithMark() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst(jm, "line 1", "line 2");
+
+ verify(writer).append('(');
+ verify(writer).append("line 1");
+ verify(writer).print("line 2");
+ verify(writer, times(1)).print(", ");
+ }
+
+ @Test
+ public void testPstWithNoLines() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.pst(jm);
+
+ verify(writer).append('(');
+ }
+
+ @Test
+ public void testLi() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(writer.getIndent()).thenReturn(3);
+
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.li("line 1", "line 2");
+
+ verify(writer).setIndent(3);
+ verify(writer).inc();
+ verify(writer).println();
+ verify(writer).print("line 1");
+ verify(writer).print("line 2");
+
+ hg.pretty = true;
+ gen.li("line 1", "line 2");
+ verify(writer, times(3)).println();
+ }
+
+ @Test
+ public void testText() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.text("line 1");
+
+ verify(writer).append("line 1");
+ verify(writer).println();
+
+ hg.pretty = false;
+ gen.text("line 1");
+
+ verify(writer, times(2)).append("line 1");
+ }
+
+ @Test
+ public void testFunction() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ hg.pretty = true;
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.function("line 1", "line 2", "line 3");
+
+ verify(writer).print("function ");
+ verify(writer).print("line 1");
+ verify(writer).print('(');
+
+ verify(writer).print("line 2");
+ verify(writer).print("line 3");
+ verify(writer, times(1)).print(", ");
+ verify(writer).print(") {");
+ verify(writer).inc();
+ verify(writer).println();
+ }
+
+ @Test
+ public void testFunctionWithMark() throws IOException {
+ when(hg.getWriter()).thenReturn(writer);
+ when(hg.pushBack(any(Back.class))).thenReturn(3);
+ JSGen gen = new JSGen(mark, hg);
+
+ gen.function(jm, "line 1", "line 2", "line 3");
+
+ verify(writer).print("function ");
+ verify(writer).print("line 1");
+ verify(writer).print('(');
+
+ verify(writer).print("line 2");
+ verify(writer).print("line 3");
+ verify(writer, times(1)).print(", ");
+ verify(writer).print(") {");
+ verify(writer, times(0)).inc();
+ verify(writer, times(0)).println();
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
index c8014dda..5e15fa67 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLCacheGenTest.java
@@ -34,30 +34,30 @@ import org.onap.aaf.misc.xgen.Code;
public class JU_XMLCacheGenTest {
- @Mock
- Writer writer;
+ @Mock
+ Writer writer;
- @Mock
- Code code;
+ @Mock
+ Code code;
- @Before
- public void setup() {
+ @Before
+ public void setup() {
- code = mock(Code.class);
- writer = mock(Writer.class);
- }
+ code = mock(Code.class);
+ writer = mock(Writer.class);
+ }
- @Test
- public void test() throws APIException, IOException {
- XMLCacheGen cacheGen = new XMLCacheGen(0, code);
- assertEquals(cacheGen.PRETTY, 1);
+ @Test
+ public void test() throws APIException, IOException {
+ XMLCacheGen cacheGen = new XMLCacheGen(0, code);
+ assertEquals(cacheGen.PRETTY, 1);
- XMLGen xgen = cacheGen.create(1, writer);
- assertEquals(0, xgen.getIndent());
+ XMLGen xgen = cacheGen.create(1, writer);
+ assertEquals(0, xgen.getIndent());
- xgen.setIndent(10);
- assertEquals(10, xgen.getIndent());
- xgen.comment("Comment");
- }
+ xgen.setIndent(10);
+ assertEquals(10, xgen.getIndent());
+ xgen.comment("Comment");
+ }
}
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
index 1c00b452..18b82393 100644
--- a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
+++ b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
@@ -36,31 +36,31 @@ import org.mockito.Mock;
public class JU_XMLGenTest {
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
+ String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
- Map<Character, Integer> map = new TreeMap<>();
+ Map<Character, Integer> map = new TreeMap<>();
- @Before
- public void setUp() throws Exception {
- writer = mock(Writer.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ writer = mock(Writer.class);
+ }
- @Test
- public void testXMLGenWriter() throws IOException {
- XMLGen xmlGen = new XMLGen(writer);
+ @Test
+ public void testXMLGenWriter() throws IOException {
+ XMLGen xmlGen = new XMLGen(writer);
- xmlGen.xml();
+ xmlGen.xml();
- for (char ch : XML_TAG.toCharArray()) {
- Integer times = map.get(ch);
- map.put(ch, (times == null ? 0 : times) + 1);
- }
+ for (char ch : XML_TAG.toCharArray()) {
+ Integer times = map.get(ch);
+ map.put(ch, (times == null ? 0 : times) + 1);
+ }
- for (char ch : map.keySet()) {
- verify(writer, times(map.get(ch))).write(ch);
- }
- }
+ for (char ch : map.keySet()) {
+ verify(writer, times(map.get(ch))).write(ch);
+ }
+ }
} \ No newline at end of file