-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-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;
- }
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+public class Back {\r
+ public String str;\r
+ public boolean dec;\r
+ public boolean cr;\r
+ \r
+ public Back(String string, boolean decrement, boolean newline) {\r
+ str = string;\r
+ dec = decrement;\r
+ cr = newline;\r
+ }\r
}
\ No newline at end of file
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-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
-
- @SuppressWarnings("rawtypes")
- private static Null<?> singleton = new Null();
- public static Null<?> singleton() { return singleton;}
- }
-
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+\r
+public interface Cache<G extends XGen<G>> {\r
+ public void dynamic(G hgen, Code<G> code);\r
+ \r
+ public static class Null<N extends XGen<N>> implements Cache<N> {\r
+ @Override\r
+ public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ private static Null<?> singleton = new Null();\r
+ public static Null<?> singleton() { return singleton;}\r
+ }\r
+\r
}
\ No newline at end of file
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.Trans;
-import org.onap.aaf.misc.xgen.html.State;
-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;
-
-
- private ArrayList<Section<G>> sections = new ArrayList<Section<G>>();
- 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 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;
- }
-
- 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;
- }
- }
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+import java.io.OutputStreamWriter;\r
+import java.io.Writer;\r
+import java.util.ArrayList;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.env.Env;\r
+import org.onap.aaf.misc.env.Trans;\r
+import org.onap.aaf.misc.xgen.html.State;\r
+import org.onap.aaf.misc.xgen.html.Thematic;\r
+\r
+\r
+public abstract class CacheGen<G extends XGen<G>> {\r
+ public static final int NO_FLAGS = 0x0;\r
+ public final static int PRETTY = 0x1;\r
+ public final static int XML = 0x2;\r
+ public final static int HTML4 = 0x4;\r
+ public final static int HTML5 = 0x8;\r
+\r
+ \r
+ private ArrayList<Section<G>> sections = new ArrayList<Section<G>>();\r
+ private int flags;\r
+ private final Thematic thematic;\r
+\r
+ public CacheGen(int flags, Code<G> code) throws APIException, IOException {\r
+ this.flags = flags;\r
+ final XGenBuff<G> buff = new XGenBuff<G>(flags,this);\r
+ // Run to gather Strings and Code Class Segments\r
+ buff.run(new Cache<G>() {\r
+ @Override\r
+ public void dynamic(G hgen, Code<G> code) {\r
+ sections.add(buff.newSection());\r
+ sections.add(new Dynamic(hgen.getIndent(),code));\r
+ }\r
+ },code);\r
+ sections.add(buff.newSection());\r
+ \r
+ // If Code implements thematic, set for later\r
+ thematic = code instanceof Thematic?(Thematic)code:null;\r
+\r
+ }\r
+ \r
+ public abstract G create(int htmlStyle, Writer w);\r
+\r
+ public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException {\r
+ replay(state, trans, new OutputStreamWriter(os), theme);\r
+ }\r
+ \r
+ public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException {\r
+ if(thematic!=null) {\r
+ theme = thematic.themeResolve(theme);\r
+ }\r
+ /* Theme\r
+ trans.setTheme(theme);\r
+ int htmlStyle = state.htmlVer(theme);\r
+ */\r
+ \r
+ XGenBuff<G> buff = new XGenBuff<G>(flags,this);\r
+ \r
+ // forward\r
+ int indent = 0;\r
+ Section<G> s;\r
+ int i=0;\r
+ @SuppressWarnings("unchecked")\r
+ Section<G>[] reverse = new Section[sections.size()];\r
+ for(Section<G> section : sections) {\r
+ s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread\r
+ int tempIndent = s.getIndent();\r
+ s.setIndent(indent);\r
+ s.forward(w);\r
+ s.setIndent(tempIndent);\r
+ indent = tempIndent;\r
+ reverse[i++]=s;\r
+ }\r
+\r
+ for(--i;i>=0;--i) {\r
+ reverse[i].back(w);\r
+ }\r
+ w.flush();\r
+ }\r
+ \r
+ private class Dynamic extends Section<G> {\r
+ private Code<G> code;\r
+ \r
+ public Dynamic(int indent, Code<G> code) {\r
+ this.code = code;\r
+ this.indent = indent;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {\r
+ // Clone Dynamic to make Thread Safe\r
+ Dynamic d = new Dynamic(indent,code);\r
+ buff.setIndent(indent);\r
+ if(code instanceof DynamicCode) {\r
+ buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code);\r
+ } else {\r
+ buff.run((Cache<G>)Cache.Null.singleton(), code);\r
+ }\r
+ Section<G> s = buff.newSection();\r
+ d.indent = s.indent;\r
+ d.forward = s.forward;\r
+ d.backward = s.backward;\r
+ return d;\r
+ }\r
+ }\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-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;
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.IOException;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+\r
+public interface Code<G extends XGen<G>> {\r
+ public void code(Cache<G> cache, G xgen) throws APIException, IOException;\r
}
\ No newline at end of file
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-import java.io.IOException;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.Trans;
-import org.onap.aaf.misc.xgen.html.State;
-
-/**
- * Special Code Interface to gain access to Transaction
- * and State information
- * @author Jonathan
- *
- */
-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);
- }
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.IOException;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.env.Env;\r
+import org.onap.aaf.misc.env.Trans;\r
+import org.onap.aaf.misc.xgen.html.State;\r
+\r
+/**\r
+ * Special Code Interface to gain access to Transaction\r
+ * and State information\r
+ * @author Jonathan\r
+ *\r
+ */\r
+public abstract class DynamicCode<G extends XGen<G>, AS extends State<Env>, TRANS extends Trans> implements Code<G> {\r
+ public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException;\r
+ \r
+ // We expect not to have this section of the code engaged at any time\r
+ public void code(final Cache<G> cache, final G xgen) throws APIException, IOException {\r
+ code(null, null,cache,xgen);\r
+ }\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-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;
- }
-
- public void spot(int spot) {
- this.spot = spot;
- }
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+public class Mark {\r
+ // package on purpose\r
+ int spot = 0;\r
+ public String comment;\r
+ \r
+ public Mark() {\r
+ comment = null; \r
+ }\r
+ \r
+ public Mark(String string) {\r
+ comment = string;\r
+ }\r
+\r
+ public void spot(int spot) {\r
+ this.spot = spot;\r
+ }\r
}
\ No newline at end of file
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-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;
- }
-
- 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;
- }
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.env.Env;\r
+import org.onap.aaf.misc.env.Trans;\r
+import org.onap.aaf.misc.xgen.html.State;\r
+\r
+public class Section<G extends XGen<G>> {\r
+ protected int indent;\r
+ protected String forward;\r
+ protected String backward;\r
+ \r
+ // Default is to use the set Strings (static) \r
+ public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException {\r
+ return this;\r
+ }\r
+ \r
+ public int getIndent() {\r
+ return indent;\r
+ }\r
+\r
+ public void setIndent(int indent) {\r
+ this.indent = indent;\r
+ }\r
+\r
+ public void forward(Writer w) throws IOException {\r
+ w.write(forward);\r
+ }\r
+ \r
+ public void back(Writer w) throws IOException {\r
+ w.write(backward);\r
+ }\r
+ \r
+ public String toString() {\r
+ return forward;\r
+ }\r
}
\ No newline at end of file
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Stack;
-
-import org.onap.aaf.misc.env.util.IndentPrintWriter;
-import org.onap.aaf.misc.env.util.StringBuilderWriter;
-
-public class XGen<RT extends XGen<RT>> {
-
- public static 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;
- 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("<");
- break;
- case '>':
- forward.append(">");
- break;
- case '&':
- forward.append("&");
- 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();
- }
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.PrintWriter;\r
+import java.io.Writer;\r
+import java.util.Stack;\r
+\r
+import org.onap.aaf.misc.env.util.IndentPrintWriter;\r
+import org.onap.aaf.misc.env.util.StringBuilderWriter;\r
+\r
+public class XGen<RT extends XGen<RT>> {\r
+\r
+ public static int COMMENT_COLUMN = 40;\r
+ private StringBuilder backSB = new StringBuilder();\r
+ private Stack<Back> backStack = new Stack<Back>();\r
+ \r
+ protected XGen(Writer w) {\r
+ forward = new IndentPrintWriter(w);\r
+ }\r
+\r
+ public int pushBack(Back b) {\r
+ int rv = backStack.size();\r
+ backStack.push(b);\r
+ return rv;\r
+ }\r
+\r
+ public boolean pretty = false;\r
+ protected IndentPrintWriter forward;\r
+\r
+ public IndentPrintWriter getWriter() {\r
+ return forward;\r
+ }\r
+\r
+ protected PrintWriter back = new PrintWriter(\r
+ new StringBuilderWriter(backSB));\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT pretty() {\r
+ pretty = true;\r
+ return (RT) this;\r
+ }\r
+\r
+ protected void prettyln(PrintWriter pw) {\r
+ if(pretty)pw.println();\r
+ }\r
+\r
+ public RT leaf(Mark mark, String tag, String ... args) {\r
+ mark.spot = backStack.size();\r
+ return leaf(tag, args);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT leaf(String tag, String ... attrs) {\r
+ forward.append('<');\r
+ forward.append(tag);\r
+ addAttrs(attrs);\r
+ forward.append('>');\r
+ back.append("</");\r
+ back.append(tag);\r
+ back.append('>');\r
+ backStack.push(new Back(backSB.toString(), false, true));\r
+ backSB.setLength(0);\r
+ return (RT)this;\r
+ }\r
+\r
+ public RT incr(String tag, String ... args) {\r
+ return incr(null, tag, false, args);\r
+ }\r
+\r
+ public RT incr(String tag, boolean oneLine, String ... args) {\r
+ return incr(null, tag, oneLine, args);\r
+ }\r
+\r
+ public RT incr(Mark mark) {\r
+ return incr(mark,mark.comment, false, new String[0]);\r
+ }\r
+\r
+ public RT incr(Mark mark, String tag, String ... attrs) {\r
+ return incr(mark, tag, false, attrs);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) {\r
+ forward.append('<');\r
+ forward.append(tag);\r
+ addAttrs(attrs);\r
+ forward.append('>');\r
+ \r
+ back.append("</");\r
+ back.append(tag);\r
+ back.append('>');\r
+ \r
+ if(pretty) {\r
+ if(mark!=null && mark.comment!=null) {\r
+ int fi = forward.getIndent()*IndentPrintWriter.INDENT;\r
+ for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) {\r
+ back.append(' ');\r
+ }\r
+ back.append("<!-- end ");\r
+ back.append(mark.comment);\r
+ back.append(" -->");\r
+ \r
+ forward.toCol(COMMENT_COLUMN);\r
+ forward.append("<!-- begin ");\r
+ forward.append(mark.comment);\r
+ forward.append(" -->");\r
+ }\r
+ forward.inc();\r
+ if(!oneLine) {\r
+ forward.println();\r
+ }\r
+ back.println();\r
+ }\r
+ if(mark!=null)mark.spot = backStack.size();\r
+ backStack.push(new Back(backSB.toString(),true, false));\r
+ backSB.setLength(0);\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT tagOnly(String tag, String ... attrs) {\r
+ forward.append('<');\r
+ forward.append(tag);\r
+ addAttrs(attrs);\r
+ forward.append(" />");\r
+ if(pretty) {\r
+ forward.println();\r
+ }\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT text(String txt) {\r
+ forward.append(txt);\r
+ return (RT)this;\r
+ }\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ public RT xml(String txt) {\r
+ for(int i=0; i<txt.length();++i) {\r
+ char c = txt.charAt(i);\r
+ switch(c) {\r
+ case '<':\r
+ forward.append("<");\r
+ break;\r
+ case '>':\r
+ forward.append(">");\r
+ break;\r
+ case '&':\r
+ forward.append("&");\r
+ break;\r
+ default:\r
+ forward.append(c);\r
+ }\r
+ }\r
+ return (RT)this;\r
+ }\r
+\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT textCR(int tabs, String txt) {\r
+ for(int i=0;i<tabs;++i) {\r
+ forward.append(" ");\r
+ }\r
+ forward.append(txt);\r
+ if(pretty)forward.println();\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT value() {\r
+ Mark mark = new Mark();\r
+ mark.spot = backStack.size()-1;\r
+ end(mark);\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT value(String txt) {\r
+ forward.append(txt);\r
+ Mark mark = new Mark();\r
+ mark.spot = backStack.size()-1;\r
+ end(mark);\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT value(String txt, int levels) {\r
+ forward.append(txt);\r
+ Mark mark = new Mark();\r
+ mark.spot = backStack.size()-levels;\r
+ end(mark);\r
+ return (RT)this;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT end(Mark mark) {\r
+ int size = backStack.size();\r
+ Back c;\r
+ boolean println = false;\r
+ for(int i=mark==null?0:mark.spot;i<size;++i) {\r
+ c = backStack.pop();\r
+ if(c.dec)forward.dec();\r
+ forward.append(c.str);\r
+ println = c.cr;\r
+ }\r
+ if(pretty && println) {\r
+ forward.println();\r
+ }\r
+ return (RT)this;\r
+ }\r
+\r
+ public RT end() {\r
+ Mark mark = new Mark();\r
+ mark.spot=backStack.size()-1;\r
+ if(mark.spot<0)mark.spot=0;\r
+ return end(mark);\r
+ }\r
+\r
+ public RT end(int i) {\r
+ Mark mark = new Mark();\r
+ mark.spot=backStack.size()-i;\r
+ if(mark.spot<0)mark.spot=0;\r
+ return end(mark);\r
+ }\r
+\r
+ public void endAll() {\r
+ end(new Mark());\r
+ forward.flush();\r
+ }\r
+\r
+ protected void addAttrs(String[] attrs) {\r
+ if(attrs!=null) {\r
+ for(String attr : attrs) {\r
+ if(attr!=null && attr.length()>0) {\r
+ forward.append(' ');\r
+ String[] split = attr.split("=",2);\r
+ switch(split.length) {\r
+ case 0:\r
+ break;\r
+ case 1:\r
+ forward.append(split[0]);\r
+// forward.append("=\"\"");\r
+ break;\r
+ default:\r
+ forward.append(split[0]);\r
+ forward.append("=\"");\r
+ forward.append(split[1]);\r
+ forward.append('"');\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public RT comment(String string) {\r
+ if(pretty) {\r
+ forward.print("<!-- ");\r
+ forward.print(string);\r
+ forward.println(" -->");\r
+ }\r
+ return (RT)this;\r
+ }\r
+\r
+ public void setIndent(int indent) {\r
+ forward.setIndent(indent);\r
+ forward.toIndent();\r
+ }\r
+\r
+ public int getIndent() {\r
+ return forward.getIndent();\r
+ }\r
+\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen;
-
-import java.io.IOException;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.Trans;
-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));
- }
-
- /**
- * 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();
- }
-
- 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;
- }
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import java.io.IOException;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.env.Env;\r
+import org.onap.aaf.misc.env.Trans;\r
+import org.onap.aaf.misc.env.util.StringBuilderWriter;\r
+import org.onap.aaf.misc.xgen.html.State;\r
+\r
+public class XGenBuff<G extends XGen<G>> {\r
+ private G xgen;\r
+ private StringBuilder sb;\r
+ // private String forward, backward;\r
+ \r
+ public XGenBuff(int flags, CacheGen<G> cg) {\r
+ sb = new StringBuilder();\r
+ xgen = cg.create(flags, new StringBuilderWriter(sb));\r
+ }\r
+\r
+ /**\r
+ * Normal case of building up Cached HTML without transaction info\r
+ * \r
+ * @param cache\r
+ * @param code\r
+ * @throws APIException\r
+ * @throws IOException\r
+ */\r
+ public void run(Cache<G> cache, Code<G> code) throws APIException, IOException {\r
+ code.code(cache, xgen);\r
+ }\r
+\r
+ /**\r
+ * Special Case where code is dynamic, so give access to State and Trans info\r
+ * \r
+ * @param state\r
+ * @param trans\r
+ * @param cache\r
+ * @param code\r
+ * @throws APIException\r
+ * @throws IOException\r
+ */\r
+ @SuppressWarnings({ "unchecked", "rawtypes" })\r
+ public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException {\r
+ code.code(state, trans, cache, xgen);\r
+ }\r
+ \r
+ public int getIndent() {\r
+ return xgen.getIndent();\r
+ }\r
+\r
+ public void setIndent(int indent) {\r
+ xgen.setIndent(indent);\r
+ }\r
+\r
+ public Section<G> newSection() {\r
+ Section<G> s = new Section<G>();\r
+ s.indent = xgen.getIndent();\r
+ s.forward = sb.toString();\r
+ sb.setLength(0);\r
+ s.backward = sb.toString();\r
+ sb.setLength(0);\r
+ return s;\r
+ }\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-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\">";
-
- 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 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 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 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 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
-// 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);
-// }
-// }
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.xgen.Mark;\r
+\r
+public class HTML4Gen extends HTMLGen {\r
+ private final static String DOCTYPE = \r
+ /*\r
+ "<!DOCTYPE HTML PUBLIC " +\r
+ "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +\r
+ "\"http://www.w3.org/TR/html3/loose.dtd\">";\r
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +\r
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";\r
+ */\r
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +\r
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";\r
+\r
+ public HTML4Gen(Writer w) {\r
+ super(w);\r
+ }\r
+\r
+ @Override\r
+ public HTMLGen html(String ... attrib) {\r
+ forward.println(DOCTYPE);\r
+ return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en");\r
+ \r
+ }\r
+\r
+ @Override\r
+ public Mark head() {\r
+ Mark head = new Mark("head");\r
+ incr(head);\r
+ return head;\r
+ }\r
+\r
+ @Override\r
+ public Mark body(String ... attrs) {\r
+ Mark body = new Mark("body");\r
+ incr(body,"body",attrs);\r
+ return body;\r
+ }\r
+ \r
+ @Override\r
+ public HTML4Gen charset(String charset) {\r
+ forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset=");\r
+ forward.append(charset);\r
+ forward.append("\">");\r
+ prettyln(forward);\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public Mark header(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="header";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+ @Override\r
+ public Mark footer(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="footer";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+ @Override\r
+ public Mark section(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="section";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+ @Override\r
+ public Mark article(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="attrib";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+ @Override\r
+ public Mark aside(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="aside";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+ @Override\r
+ public Mark nav(String ... attribs) {\r
+ String[] a = new String[attribs.length+1];\r
+ a[0]="nav";\r
+ System.arraycopy(attribs, 0, a, 1, attribs.length);\r
+ return divID(a);\r
+ }\r
+\r
+// @Override\r
+// protected void importCSS(Imports imports) {\r
+// if(imports.css.size()==1) {\r
+// cssInline(imports.css.get(0));\r
+// } else {\r
+// text("<style type=\"text/css\">");\r
+// prettyln(forward);\r
+// forward.inc();\r
+// for(String str : imports.css) {\r
+// forward.print("@import url(\"");\r
+// forward.print(imports.themePath(null));\r
+// forward.print(str);\r
+// forward.print("\");");\r
+// prettyln(forward);\r
+// }\r
+// forward.dec();\r
+// forward.print("</style>");\r
+// prettyln(forward);\r
+// }\r
+// }\r
+ \r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-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 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]-->");
- }
- */
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.xgen.Mark;\r
+\r
+public class HTML5Gen extends HTMLGen {\r
+ public HTML5Gen(Writer w) {\r
+ super(w);\r
+ }\r
+\r
+ @Override\r
+ public HTMLGen html(String ... attrib) {\r
+ //forward.println("<!DOCTYPE html>");\r
+ incr("html",attrib);\r
+ return this;\r
+ }\r
+ \r
+ @Override\r
+ public Mark head() {\r
+ Mark head = new Mark("head");\r
+ incr(head).directive("meta","charset=utf-8");\r
+ return head;\r
+ }\r
+\r
+ @Override\r
+ public Mark body(String ... attrs) {\r
+ Mark body = new Mark("body");\r
+ incr(body,"body",attrs);\r
+ //chromeFrame();\r
+ return body;\r
+ }\r
+ \r
+ @Override\r
+ public HTML5Gen charset(String charset) {\r
+ forward.append("<meta charset=\"");\r
+ forward.append(charset);\r
+ forward.append("\">");\r
+ prettyln(forward);\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public Mark header(String ... attribs) {\r
+ Mark mark = new Mark("header");\r
+ incr(mark, mark.comment, attribs);\r
+ return mark;\r
+ }\r
+\r
+ @Override\r
+ public Mark footer(String ... attribs) {\r
+ Mark mark = new Mark("footer");\r
+ incr(mark, mark.comment, attribs);\r
+ return mark;\r
+ }\r
+\r
+ @Override\r
+ public Mark section(String ... attribs) {\r
+ Mark mark = new Mark("section");\r
+ incr(mark, mark.comment,attribs);\r
+ return mark;\r
+ }\r
+\r
+ @Override\r
+ public Mark article(String ... attribs) {\r
+ Mark mark = new Mark("article");\r
+ incr(mark, mark.comment,attribs);\r
+ return mark;\r
+ }\r
+\r
+ @Override\r
+ public Mark aside(String ... attribs) {\r
+ Mark mark = new Mark("aside");\r
+ incr(mark, mark.comment,attribs);\r
+ return mark;\r
+ }\r
+\r
+ @Override\r
+ public Mark nav(String ... attribs) {\r
+ Mark mark = new Mark("nav");\r
+ incr(mark, mark.comment,attribs);\r
+ return mark;\r
+ }\r
+ \r
+\r
+// @Override\r
+// protected void importCSS(Imports imports) {\r
+// if(imports.css.size() == 1) {\r
+// cssInline(imports.css.get(0));\r
+// } else {\r
+// for(String str : imports.css) {\r
+// forward.print("<link rel=\"stylesheet\" href=\"");\r
+// forward.print(imports.themePath(null));\r
+// forward.print(str);\r
+// forward.println("\">");\r
+// }\r
+// }\r
+// }\r
+//\r
+\r
+ /*\r
+ public void chromeFrame() {\r
+ this.textCR(0,"<!--[if IE]>");\r
+ Mark mark = new Mark();\r
+ this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js")\r
+ .end(mark);\r
+ this.incr(mark, "style")\r
+ .textCR(0,".chromeFrameInstallDefaultStyle {")\r
+ .textCR(1,"width: 100%; /* default is 800px * /")\r
+ .textCR(1,"border: 5px solid blue;")\r
+ .textCR(0,"}")\r
+ .end(mark);\r
+\r
+ this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script\r
+ // "if IE without GCF, prompt goes here"\r
+ this.text("Please load this plugin to run ClientSide Websockets")\r
+ .end(mark);\r
+\r
+ this.incr(mark, "script")\r
+ .textCR(0, "// The conditional ensures that this code will only execute in IE,")\r
+ .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry")\r
+ .textCR(0, "window.attachEvent('onload', function() {")\r
+ .textCR(1,"CFInstall.check({")\r
+ .textCR(2,"mode: 'inline', // the default")\r
+ .textCR(2,"node: 'prompt'")\r
+ .textCR(1, "});")\r
+ .textCR(0, "});")\r
+ .end(mark);\r
+ \r
+ this.textCR(0,"<![endif]-->");\r
+ }\r
+ */\r
+\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.onap.aaf.misc.env.APIException;
-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);
- }
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.xgen.CacheGen;\r
+import org.onap.aaf.misc.xgen.Code;\r
+\r
+public class HTMLCacheGen extends CacheGen<HTMLGen> {\r
+ protected int flags;\r
+\r
+ public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException {\r
+ super(flags, code);\r
+ this.flags = flags;\r
+ }\r
+\r
+ @Override\r
+ public HTMLGen create(int htmlStyle, Writer w) {\r
+ HTMLGen hg;\r
+ switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) {\r
+ case CacheGen.HTML4:\r
+ hg = new HTML4Gen(w);\r
+ break;\r
+ case CacheGen.HTML5:\r
+ default:\r
+ hg = new HTML5Gen(w);\r
+ break;\r
+\r
+ }\r
+ hg.pretty = (htmlStyle&CacheGen.PRETTY)>0;\r
+ return hg;\r
+ }\r
+\r
+ protected HTMLGen clone(Writer w) {\r
+ return create(flags,w);\r
+ }\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-import java.io.Writer;
-
-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);
- }
-//
-// 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
-// }
-// }
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.xgen.Mark;\r
+import org.onap.aaf.misc.xgen.XGen;\r
+\r
+public abstract class HTMLGen extends XGen<HTMLGen> {\r
+ public static final String A = "a";\r
+ public static final String P = "p";\r
+ public static final String LI = "li";\r
+ public static final String OL = "ol";\r
+ public static final String UL = "ul";\r
+ \r
+ \r
+ public static final String TABLE = "table";\r
+ public static final String THEAD = "thead";\r
+ public static final String TBODY = "tbody";\r
+ public static final String TR = "tr";\r
+ public static final String TH = "th";\r
+ public static final String TD = "td";\r
+ \r
+ public static final String TITLE = "title";\r
+ public static final String H1 = "h1";\r
+ public static final String H2 = "h2";\r
+ public static final String H3 = "h3";\r
+ public static final String H4 = "h4";\r
+ public static final String H5 = "h5";\r
+ \r
+ \r
+ \r
+ // --------------------------- HTML Version Specific -----------------------\r
+ public abstract HTMLGen html(String ... attributes);\r
+ public abstract HTMLGen charset(String charset);\r
+ public abstract Mark head();\r
+ public abstract Mark body(String ... attribs);\r
+\r
+ \r
+ // HTML 5 has simplified sectioning\r
+ public abstract Mark header(String ... attribs);\r
+ public abstract Mark footer(String ... attribs);\r
+ public abstract Mark section(String ... attribs);\r
+ public abstract Mark article(String ... attribs);\r
+ public abstract Mark aside(String ... attribs);\r
+ public abstract Mark nav(String ... attribs);\r
+\r
+ // --------------------------- HTML Version Specific -----------------------\r
+\r
+ public HTMLGen imports(Imports imports) {\r
+ //this.imports=imports;\r
+ for(String str : imports.css) {\r
+ forward.print("<link rel=\"stylesheet\" href=\"");\r
+ forward.print(imports.themePath(null));\r
+ forward.print(str);\r
+ forward.println("\">");\r
+ }\r
+\r
+ for(String str : imports.js) {\r
+ forward.print("<script type=\"text/javascript\" src=\"");\r
+ forward.print(imports.themePath(null));\r
+ forward.print(str);\r
+ forward.println("\"></script>");\r
+ }\r
+ return this;\r
+ }\r
+ \r
+ public HTMLGen jsVars(String ... attrs) {\r
+ forward.println("<script type=text/javascript>");\r
+ if(attrs!=null) {\r
+ for(int i=0; i<attrs.length;++i) {\r
+ forward.append(' ');\r
+ String[] split = attrs[i].split("=",2);\r
+ switch(split.length) {\r
+ case 2:\r
+ forward.print(" var ");\r
+ forward.append(split[0]);\r
+ forward.append("='");\r
+ forward.append(split[1]);\r
+ forward.println("';");\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ forward.println("</script>");\r
+ return this;\r
+ }\r
+\r
+ public HTMLGen(Writer w) {\r
+ super(w);\r
+ }\r
+\r
+ /**\r
+ * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...>\r
+ * @param tag\r
+ * @param attrs\r
+ * @return\r
+ */\r
+ public HTMLGen directive(String tag, String ... attrs) {\r
+ forward.append('<');\r
+ forward.append(tag);\r
+ addAttrs(attrs);\r
+ forward.append('>');\r
+ if(pretty) {\r
+ forward.println();\r
+ }\r
+ return this;\r
+ }\r
+\r
+ public Mark divID(String ... attrs) {\r
+ Mark div;\r
+ if(attrs.length>0) {\r
+ div = new Mark(attrs[0]);\r
+ attrs[0]="id="+attrs[0];\r
+ } else {\r
+ div = new Mark();\r
+ }\r
+ incr(div, "div", attrs);\r
+ return div;\r
+ }\r
+\r
+ public HTMLGen img(String ... attrs) {\r
+ return tagOnly("img", attrs);\r
+ }\r
+ \r
+ /**\r
+ * Input Cheesecake... creates a Label and Field in the form of Table Rows.\r
+ * Make sure you create a table first, ie. incr(HTMLGen.TABLE);\r
+ * \r
+ * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will\r
+ * validate there is data in the fields before submitting. "required" does nothing for label, but allows for\r
+ * easy CSS coding... "label[required] { ... }", so that colors can be changed\r
+ * \r
+ * @param id\r
+ * @param label\r
+ * @param required\r
+ * @param attrs\r
+ * @return\r
+ */\r
+ public HTMLGen input(String id, String label, boolean required, String ... attrs) {\r
+ Mark mtr = new Mark(TR);\r
+ Mark mtd = new Mark(TD);\r
+ incr(mtr);\r
+ incr(mtd);\r
+ incr("label",true, "for="+id,required?"required":null).text(label).end();\r
+ end(mtd);\r
+ String nattrs[] = new String[attrs.length+(required?3:2)];\r
+ nattrs[0]="id="+id;\r
+ nattrs[1]="name="+id;\r
+ System.arraycopy(attrs, 0, nattrs, 2, attrs.length);\r
+ if(required) {\r
+ nattrs[nattrs.length-1]="required";\r
+ }\r
+ incr(mtd);\r
+ tagOnly("input",nattrs);\r
+ end(mtr);\r
+ return this;\r
+ }\r
+ \r
+ // Common tags that do not have standard endings. These are here to help people who don't know to pick directive \r
+ public HTMLGen br() {\r
+ forward.append("<br>");\r
+ if(pretty) {\r
+ forward.println();\r
+ }\r
+ return this;\r
+ }\r
+\r
+ public HTMLGen p(String ... text) {\r
+ forward.append("<p>");\r
+ for(String s : text) {\r
+ forward.append(s);\r
+ }\r
+ if(pretty) {\r
+ forward.println();\r
+ }\r
+ return this;\r
+ }\r
+\r
+ public HTMLGen hr() {\r
+ forward.append("<hr>");\r
+ if(pretty) {\r
+ forward.println();\r
+ }\r
+ return this;\r
+ }\r
+\r
+ public JSGen js(Mark mark) {\r
+ return new JSGen(mark, this);\r
+ }\r
+\r
+ public JSGen js() {\r
+ return js(null);\r
+ }\r
+//\r
+// protected void cssInline(String filename) {\r
+// File file = new File(imports.webDir,filename);\r
+// try {\r
+// String line;\r
+// BufferedReader br = new BufferedReader(new FileReader(file));\r
+// try {\r
+// forward.print("<style>");\r
+// prettyln(forward);\r
+// while((line=br.readLine())!=null) {\r
+// forward.print((pretty?line:line.trim()));\r
+// prettyln(forward);\r
+// } \r
+// }finally {\r
+// forward.print("</style>");\r
+// prettyln(forward);\r
+// br.close();\r
+// }\r
+// } catch (IOException e) {\r
+// e.printStackTrace();\r
+// // Can't read, suffice to import normally?\r
+// // for now, just skip\r
+// }\r
+// }\r
+ \r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Imports implements Thematic{
- List<String> css,js;
- public final int backdots;
-// public final File webDir;
- private String theme;
-
- public Imports(int backdots) {
-// this.webDir = webDir;
-
- css = new ArrayList<String>();
- js = new ArrayList<String>();
- 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;
- }
-
- /**
- * 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;
- }
-
- public StringBuilder dots(StringBuilder src) {
- for(int i=0;i<backdots;++i) {
- src.append("../");
- }
- return src;
- }
-
-};
-
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+public class Imports implements Thematic{\r
+ List<String> css,js;\r
+ public final int backdots;\r
+// public final File webDir;\r
+ private String theme;\r
+ \r
+ public Imports(int backdots) {\r
+// this.webDir = webDir;\r
+ \r
+ css = new ArrayList<String>();\r
+ js = new ArrayList<String>();\r
+ this.backdots = backdots;\r
+ theme = "";\r
+ }\r
+ \r
+ public Imports css(String str) {\r
+ css.add(str);\r
+ return this;\r
+ }\r
+ \r
+ public Imports js(String str) {\r
+ js.add(str);\r
+ return this;\r
+ }\r
+\r
+ public Imports theme(String str) {\r
+ theme = str==null?"":str;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports\r
+ * \r
+ * @param theTheme\r
+ * @return\r
+ */\r
+ @Override\r
+ public String themePath(String theTheme) {\r
+ StringBuilder src = dots(new StringBuilder());\r
+ if(theTheme==null||theTheme.length()==0) {\r
+ src.append(theme);\r
+ if(theme.length()>0)src.append('/');\r
+ } else {\r
+ src.append(theTheme);\r
+ src.append('/');\r
+ }\r
+\r
+ return src.toString();\r
+ }\r
+ \r
+ /**\r
+ * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports\r
+ * \r
+ * @param theTheme\r
+ * @return\r
+ */\r
+ @Override\r
+ public String themeResolve(String theTheme) {\r
+ return (theTheme==null||theTheme.length()==0)\r
+ ?theme\r
+ :theTheme;\r
+ }\r
+\r
+ public StringBuilder dots(StringBuilder src) {\r
+ for(int i=0;i<backdots;++i) {\r
+ src.append("../");\r
+ }\r
+ return src;\r
+ }\r
+ \r
+};\r
+\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.onap.aaf.misc.env.util.IndentPrintWriter;
-import org.onap.aaf.misc.xgen.Back;
-import org.onap.aaf.misc.xgen.Mark;
-
-
-public class JSGen {
- 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 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;
- }
-
- 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 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);
- }
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.FileReader;\r
+import java.io.IOException;\r
+\r
+import org.onap.aaf.misc.env.util.IndentPrintWriter;\r
+import org.onap.aaf.misc.xgen.Back;\r
+import org.onap.aaf.misc.xgen.Mark;\r
+\r
+\r
+public class JSGen {\r
+ private HTMLGen htmlGen;\r
+ private IndentPrintWriter ipw;\r
+ private Mark mark;\r
+\r
+ public JSGen(Mark mark, HTMLGen hg) {\r
+ this.mark = mark==null?new Mark():mark;\r
+ hg.incr(this.mark, "script", "language=javascript", "type=text/javascript");\r
+ htmlGen = hg;\r
+ ipw = hg.getWriter();\r
+ }\r
+\r
+ public JSGen inline(String filename, int tabstop) throws IOException {\r
+ BufferedReader br = new BufferedReader(new FileReader(filename));\r
+ int indent = htmlGen.getIndent();\r
+ try {\r
+ boolean pretty = htmlGen.pretty;\r
+ String line, el;\r
+ int l, end;\r
+ while((line=br.readLine())!=null) {\r
+ if(pretty) {\r
+ String[] elements = line.split("\t");\r
+ \r
+ for(int i=0; i<elements.length;++i) {\r
+ el = elements[i];\r
+ l = el.length();\r
+ if(l==0) {// was a Tab\r
+ ipw.print(" ");\r
+ } else {\r
+ el = el.trim();\r
+ l = l-el.length();\r
+ end = l/tabstop;\r
+ for(int j=0;j<end;++j) {\r
+ ipw.print(" ");\r
+ }\r
+ end = l%tabstop;\r
+ for(int j=0;j<end;++j) {\r
+ ipw.print(' ');\r
+ }\r
+ if(i>0) ipw.print(' ');\r
+ ipw.print(el);\r
+ }\r
+ }\r
+ ipw.println();\r
+ } else {\r
+ ipw.print(line.trim());\r
+ }\r
+ }\r
+ } finally {\r
+ htmlGen.setIndent(indent);\r
+ try {\r
+ br.close();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return this;\r
+ }\r
+ \r
+ public JSGen pst(String ... lines) {\r
+ return pst(null, lines);\r
+ }\r
+ \r
+ public JSGen pst(Mark jm, String ... lines) {\r
+ if(lines.length>0) ipw.append(lines[0]);\r
+ ipw.append('(');\r
+ for(int i=1;i<lines.length;++i) {\r
+ ipw.print(lines[i]);\r
+ ipw.print(", ");\r
+ }\r
+ Back back;\r
+\r
+ if(htmlGen.pretty) {\r
+ back = new Back(");\n",false,false);\r
+ } else {\r
+ back = new Back(");",false,false);\r
+ }\r
+ int spot = htmlGen.pushBack(back);\r
+ if(jm!=null)jm.spot(spot);\r
+ return this;\r
+ }\r
+ \r
+ public JSGen li(String ... lines) {\r
+ int current = ipw.getIndent();\r
+ for(int i=0;i<lines.length;++i) {\r
+ if(i==1)ipw.inc();\r
+ if(i>0)ipw.println();\r
+ ipw.print(lines[i]);\r
+ }\r
+ ipw.setIndent(current);\r
+ ipw.append(';');\r
+ if(htmlGen.pretty)ipw.println();\r
+ return this;\r
+ }\r
+ \r
+ public JSGen text(String text) {\r
+ ipw.append(text);\r
+ if(htmlGen.pretty)ipw.println();\r
+ return this;\r
+ }\r
+\r
+ public JSGen function(String name, String ... params) {\r
+ return function(null, name, params);\r
+ }\r
+ \r
+ public JSGen jqfunc(Mark mark, String name, String ... params) {\r
+ pst(mark,"$").function(name, params);\r
+ return this;\r
+ }\r
+ \r
+ public JSGen function(Mark jm, String name, String ... params) {\r
+ ipw.print("function ");\r
+ ipw.print(name);\r
+ ipw.print('(');\r
+ for(int i=0;i<params.length;++i) {\r
+ if(i!=0)ipw.print(", ");\r
+ ipw.print(params[i]);\r
+ }\r
+ ipw.print(") {");\r
+ if(htmlGen.pretty) {\r
+ ipw.println();\r
+ ipw.inc();\r
+ }\r
+ int spot = htmlGen.pushBack(new Back("}",true,true));\r
+ if(jm!=null)jm.spot(spot); \r
+ return this;\r
+ }\r
+ \r
+ public JSGen cb(String ... lines) {\r
+ return cb(null,lines);\r
+ }\r
+\r
+ public JSGen cb(Mark jm, String ... lines) {\r
+ int current = ipw.getIndent();\r
+ for(int i=0;i<lines.length;++i) {\r
+ if(i==1)ipw.inc();\r
+ if(i>0)ipw.println();\r
+ ipw.print(lines[i]);\r
+ }\r
+ ipw.setIndent(current);\r
+ ipw.print('{');\r
+ if(htmlGen.pretty) {\r
+ ipw.println();\r
+ ipw.inc();\r
+ }\r
+ int spot = htmlGen.pushBack(new Back("}",true,true));\r
+ if(jm!=null)jm.spot(spot); \r
+ return this;\r
+\r
+ }\r
+\r
+ \r
+ public JSGen comment(String ... lines) {\r
+ if(htmlGen.pretty) {\r
+ for(int i=0;i<lines.length;++i) {\r
+ ipw.print("// ");\r
+ ipw.println(lines[i]);\r
+ }\r
+ }\r
+ return this;\r
+ }\r
+ \r
+ public JSGen end(Mark mark) {\r
+ htmlGen.end(mark);\r
+ return this;\r
+ }\r
+ \r
+ public HTMLGen done() {\r
+ return htmlGen.end(mark);\r
+ }\r
+ \r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-import org.onap.aaf.misc.env.Env;
-
-public interface State<ENV extends Env> {
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import org.onap.aaf.misc.env.Env;\r
+\r
+public interface State<ENV extends Env> {\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.html;
-
-public interface Thematic {
- String themePath(String theTheme);
- String themeResolve(String theTheme);
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+public interface Thematic {\r
+ String themePath(String theTheme);\r
+ String themeResolve(String theTheme);\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.xml;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.xgen.CacheGen;
-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);
- }
-
- @Override
- public XMLGen create(int style, Writer w) {
- XMLGen xg = new XMLGen(w);
- xg.pretty = (style & PRETTY)==PRETTY;
- return xg;
- }
-
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.xml;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.xgen.CacheGen;\r
+import org.onap.aaf.misc.xgen.Code;\r
+\r
+public class XMLCacheGen extends CacheGen<XMLGen> {\r
+\r
+ public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException,\r
+ IOException {\r
+ super(flags, code);\r
+ }\r
+\r
+ @Override\r
+ public XMLGen create(int style, Writer w) {\r
+ XMLGen xg = new XMLGen(w);\r
+ xg.pretty = (style & PRETTY)==PRETTY;\r
+ return xg;\r
+ }\r
+\r
+}\r
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.xgen.xml;
-
-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\"?>";
- }
-
- public XMLGen xml() {
- forward.println(XML_TAG);
- return this;
- }
-}
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.xml;\r
+\r
+import java.io.Writer;\r
+\r
+import org.onap.aaf.misc.xgen.XGen;;\r
+\r
+public class XMLGen extends XGen<XMLGen> {\r
+ private final String XML_TAG; \r
+ \r
+ public XMLGen(Writer w) {\r
+ this(w,"UTF-8");\r
+ }\r
+ \r
+ public XMLGen(Writer w, String encoding) {\r
+ super(w);\r
+ XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>"; \r
+ }\r
+\r
+ public XMLGen xml() {\r
+ forward.println(XML_TAG);\r
+ return this;\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.junit.Test;\r
+\r
+public class JU_BackTest {\r
+\r
+ @Test\r
+ public void testBackConstructor() {\r
+ Back back = new Back("String", true, false);\r
+\r
+ assertEquals(back.str, "String");\r
+ assertEquals(back.dec, true);\r
+ assertEquals(back.cr, false);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.junit.Test;\r
+\r
+public class JU_MarkTest {\r
+\r
+ @Test\r
+ public void testMark() {\r
+ Mark mark = new Mark();\r
+ assertEquals(mark.spot, 0);\r
+ assertEquals(mark.comment, null);\r
+\r
+ mark = new Mark("New Comment");\r
+ mark.spot(10);\r
+ assertEquals(mark.spot, 10);\r
+ assertEquals(mark.comment, "New Comment");\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.junit.Test;\r
+import org.onap.aaf.misc.xgen.Cache.Null;\r
+\r
+public class JU_NullCacheTest {\r
+\r
+ @Test\r
+ public void testNullIsSingleton() {\r
+ Null<?> singleton = Cache.Null.singleton();\r
+ assertEquals(singleton, Cache.Null.singleton());\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.onap.aaf.misc.env.APIException;\r
+\r
+public class JU_SectionTest {\r
+\r
+ @Mock\r
+ private Writer writer;\r
+\r
+ @Before\r
+ public void setup() {\r
+ writer = mock(Writer.class);\r
+ }\r
+\r
+ @Test\r
+ @SuppressWarnings({ "rawtypes", "unchecked" })\r
+ public void test() throws APIException, IOException {\r
+ Section section = new Section();\r
+ section.forward = "Forward";\r
+ section.backward = "Backward";\r
+\r
+ section.setIndent(10);\r
+ section.forward(writer);\r
+ section.back(writer);\r
+\r
+ assertEquals(section.use(null, null, null), section);\r
+ assertEquals(section.getIndent(), 10);\r
+ assertEquals(section.toString(), "Forward");\r
+\r
+ verify(writer).write("Forward");\r
+ verify(writer).write("Backward");\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import static org.mockito.Matchers.anyInt;\r
+import static org.mockito.Mockito.atLeast;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+\r
+public class JU_HTML4GenTest {\r
+\r
+ private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""\r
+ + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";\r
+\r
+ private String charset = "utf-8";\r
+\r
+ private final String CHARSET_LINE = "<meta http-equiv=\"Content-type\" content=\"text.hml; charset=" + charset\r
+ + "\">";\r
+\r
+ @Mock\r
+ Writer w;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ w = mock(Writer.class);\r
+ }\r
+\r
+ @Test\r
+ public void testHTML() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.html("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+ for (char ch : DOCTYPE.toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "html".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ verify(w, atLeast(1)).write(anyInt());\r
+ }\r
+\r
+ @Test\r
+ public void testHead() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.head();\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "head".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testBody() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.body("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "body".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testCharSet() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.charset(charset);\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : CHARSET_LINE.toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testHeader() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.header("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "header".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testFooter() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.footer("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "footer".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testSection() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.section("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "section".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testArticle() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.article("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "attrib".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testAside() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.aside("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "aside".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testNav() throws IOException {\r
+\r
+ HTML4Gen gen = new HTML4Gen(w);\r
+\r
+ gen.nav("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "nav".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "div".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import static org.mockito.Matchers.anyInt;\r
+import static org.mockito.Mockito.atLeast;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+\r
+public class JU_HTML5GenTest {\r
+\r
+ private final static String DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""\r
+ + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";\r
+\r
+ private String charset = "utf-8";\r
+\r
+ private final String CHARSET_LINE = "<meta charset=\"" + charset + "\">";\r
+\r
+ @Mock\r
+ Writer w;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ w = mock(Writer.class);\r
+ }\r
+\r
+ @Test\r
+ public void testHTML() throws IOException {\r
+\r
+ HTML5Gen gen = new HTML5Gen(w);\r
+\r
+ gen.html("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "html".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ verify(w, atLeast(1)).write(anyInt());\r
+ }\r
+\r
+ @Test\r
+ public void testHead() throws IOException {\r
+\r
+ HTML5Gen gen = new HTML5Gen(w);\r
+\r
+ gen.head();\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "head".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testBody() throws IOException {\r
+\r
+ HTML5Gen gen = new HTML5Gen(w);\r
+\r
+ gen.body("attributes");\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : "body".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+ for (char ch : "attributes".toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testCharSet() throws IOException {\r
+\r
+ HTML5Gen gen = new HTML5Gen(w);\r
+\r
+ gen.charset(charset);\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ for (char ch : CHARSET_LINE.toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(w, atLeast(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen.html;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class JU_ImportsTest {\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ }\r
+\r
+ @Test\r
+ public void test() {\r
+ Imports imports = new Imports(2);\r
+ imports.css("styles.css");\r
+ imports.js("main.js");\r
+ imports.theme("New Theme");\r
+\r
+ assertEquals("New Theme", imports.themeResolve(null));\r
+ assertEquals("New Theme", imports.themeResolve(""));\r
+ assertEquals("The Theme", imports.themeResolve("The Theme"));\r
+\r
+ assertEquals("build/../../", imports.dots(new StringBuilder("build/")).toString());\r
+ assertEquals("../../Theme/", imports.themePath("Theme"));\r
+ assertEquals("../../New Theme/", imports.themePath(""));\r
+ assertEquals("../../New Theme/", imports.themePath(null));\r
+\r
+ imports.theme(null);\r
+ assertEquals("../../", imports.themePath(null));\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen.xml;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.onap.aaf.misc.xgen.Code;\r
+\r
+public class JU_XMLCacheGenTest {\r
+\r
+ @Mock\r
+ Writer writer;\r
+\r
+ @Mock\r
+ Code code;\r
+\r
+ @Before\r
+ public void setup() {\r
+\r
+ code = mock(Code.class);\r
+ writer = mock(Writer.class);\r
+ }\r
+\r
+ @Test\r
+ public void test() throws APIException, IOException {\r
+ XMLCacheGen cacheGen = new XMLCacheGen(0, code);\r
+ assertEquals(cacheGen.PRETTY, 1);\r
+\r
+ XMLGen xgen = cacheGen.create(1, writer);\r
+ assertEquals(0, xgen.getIndent());\r
+\r
+ xgen.setIndent(10);\r
+ assertEquals(10, xgen.getIndent());\r
+ xgen.comment("Comment");\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.xml;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.times;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+\r
+public class JU_XMLGenTest {\r
+\r
+ @Mock\r
+ private Writer writer;\r
+\r
+ String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";\r
+\r
+ Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ writer = mock(Writer.class);\r
+ }\r
+\r
+ @Test\r
+ public void testXMLGenWriter() throws IOException {\r
+ XMLGen xmlGen = new XMLGen(writer);\r
+\r
+ xmlGen.xml();\r
+\r
+ for (char ch : XML_TAG.toCharArray()) {\r
+ Integer times = map.get(ch);\r
+ map.put(ch, (times == null ? 0 : times) + 1);\r
+ }\r
+\r
+ for (char ch : map.keySet()) {\r
+ verify(writer, times(map.get(ch))).write(ch);\r
+ }\r
+ }\r
+}
\ No newline at end of file