X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=misc%2Fxgen%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fmisc%2Fxgen%2FCacheGen.java;h=eb58fc254501ac19fdf12653d63345e5ee90527e;hb=7e966914050e66219689001ff4ab601a49eef0ac;hp=74b590da6e1ef66171e68c65b2722d44cb2c9b18;hpb=f3e4bd6e45c0a103c0336e6d030eca5de2d4110f;p=aaf%2Fauthz.git diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java index 74b590da..eb58fc25 100644 --- a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java @@ -35,97 +35,97 @@ import org.onap.aaf.misc.xgen.html.Thematic; public abstract class CacheGen> { - public static final int NO_FLAGS = 0x0; - public final static int PRETTY = 0x1; - public final static int XML = 0x2; - public final static int HTML4 = 0x4; - public final static int HTML5 = 0x8; + public static final int NO_FLAGS = 0x0; + public final static int PRETTY = 0x1; + public final static int XML = 0x2; + public final static int HTML4 = 0x4; + public final static int HTML5 = 0x8; - - private ArrayList> sections = new ArrayList>(); - private int flags; - private final Thematic thematic; + + private ArrayList> sections = new ArrayList<>(); + private int flags; + private final Thematic thematic; - public CacheGen(int flags, Code code) throws APIException, IOException { - this.flags = flags; - final XGenBuff buff = new XGenBuff(flags,this); - // Run to gather Strings and Code Class Segments - buff.run(new Cache() { - @Override - public void dynamic(G hgen, Code code) { - sections.add(buff.newSection()); - sections.add(new Dynamic(hgen.getIndent(),code)); - } - },code); - sections.add(buff.newSection()); - - // If Code implements thematic, set for later - thematic = code instanceof Thematic?(Thematic)code:null; + public CacheGen(int flags, Code code) throws APIException, IOException { + this.flags = flags; + final XGenBuff buff = new XGenBuff(flags,this); + // Run to gather Strings and Code Class Segments + buff.run(new Cache() { + @Override + public void dynamic(G hgen, Code code) { + sections.add(buff.newSection()); + sections.add(new Dynamic(hgen.getIndent(),code)); + } + },code); + sections.add(buff.newSection()); + + // If Code implements thematic, set for later + thematic = code instanceof Thematic?(Thematic)code:null; - } - - public abstract G create(int htmlStyle, Writer w); + } + + public abstract G create(int htmlStyle, Writer w); - public void replay(State state, Trans trans, OutputStream os, String theme) throws IOException, APIException { - replay(state, trans, new OutputStreamWriter(os), theme); - } - - public void replay(State 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 buff = new XGenBuff(flags,this); - - // forward - int indent = 0; - Section s; - int i=0; - @SuppressWarnings("unchecked") - Section[] reverse = new Section[sections.size()]; - for(Section section : sections) { - s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread - int tempIndent = s.getIndent(); - s.setIndent(indent); - s.forward(w); - s.setIndent(tempIndent); - indent = tempIndent; - reverse[i++]=s; - } + public void replay(State state, Trans trans, OutputStream os, String theme) throws IOException, APIException { + replay(state, trans, new OutputStreamWriter(os), theme); + } + + public void replay(State 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 buff = new XGenBuff(flags,this); + + // forward + int indent = 0; + Section s; + int i=0; + @SuppressWarnings("unchecked") + Section[] reverse = new Section[sections.size()]; + for (Section 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 { - private Code code; - - public Dynamic(int indent, Code code) { - this.code = code; - this.indent = indent; - } + for (--i;i>=0;--i) { + reverse[i].back(w); + } + w.flush(); + } + + private class Dynamic extends Section { + private Code code; + + public Dynamic(int indent, Code code) { + this.code = code; + this.indent = indent; + } - @SuppressWarnings("unchecked") - public Section use(State state, Trans trans, XGenBuff 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)code); - } else { - buff.run((Cache)Cache.Null.singleton(), code); - } - Section s = buff.newSection(); - d.indent = s.indent; - d.forward = s.forward; - d.backward = s.backward; - return d; - } - } + @SuppressWarnings("unchecked") + public Section use(State state, Trans trans, XGenBuff 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)code); + } else { + buff.run((Cache)Cache.Null.singleton(), code); + } + Section s = buff.newSection(); + d.indent = s.indent; + d.forward = s.forward; + d.backward = s.backward; + return d; + } + } }