From 7e966914050e66219689001ff4ab601a49eef0ac Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 7 Sep 2018 13:43:23 -0500 Subject: Mass whitespace changes (Style Warnings) Issue-ID: AAF-473 Change-Id: Ia1b3825a527bd56299949b5962bb9354dffbeef8 Signed-off-by: Instrumental --- .../java/org/onap/aaf/misc/rosetta/InJson.java | 24 ++--- .../main/java/org/onap/aaf/misc/rosetta/InXML.java | 120 ++++++++++----------- .../java/org/onap/aaf/misc/rosetta/JaxInfo.java | 52 ++++----- .../java/org/onap/aaf/misc/rosetta/JaxSet.java | 6 +- .../java/org/onap/aaf/misc/rosetta/Ladder.java | 6 +- .../java/org/onap/aaf/misc/rosetta/Marshal.java | 2 +- .../java/org/onap/aaf/misc/rosetta/OutJax.java | 4 +- .../java/org/onap/aaf/misc/rosetta/OutJson.java | 52 ++++----- .../java/org/onap/aaf/misc/rosetta/OutRaw.java | 2 +- .../java/org/onap/aaf/misc/rosetta/OutXML.java | 60 +++++------ .../java/org/onap/aaf/misc/rosetta/Parsed.java | 8 +- .../main/java/org/onap/aaf/misc/rosetta/Prop.java | 2 +- .../main/java/org/onap/aaf/misc/rosetta/Saved.java | 36 +++---- .../java/org/onap/aaf/misc/rosetta/XmlEscape.java | 24 ++--- .../org/onap/aaf/misc/rosetta/env/RosettaDF.java | 6 +- .../org/onap/aaf/misc/rosetta/env/RosettaData.java | 22 ++-- .../onap/aaf/misc/rosetta/marshal/DataWriter.java | 2 +- .../onap/aaf/misc/rosetta/marshal/DocMarshal.java | 8 +- .../onap/aaf/misc/rosetta/marshal/FieldArray.java | 16 +-- .../onap/aaf/misc/rosetta/marshal/ObjArray.java | 16 +-- .../onap/aaf/misc/rosetta/marshal/ObjMarshal.java | 22 ++-- 21 files changed, 245 insertions(+), 245 deletions(-) (limited to 'misc/rosetta/src/main') diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java index 353261a0..582c750c 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java @@ -32,7 +32,7 @@ public class InJson implements Parse { public Parsed parse(Reader r, Parsed parsed) throws ParseException { // First things first, if there's a "leftover" event, process that immediately State state = (State)parsed.state; - if(state.unsent > 0) { + if (state.unsent > 0) { parsed.event = state.unsent; state.unsent = 0; return parsed; @@ -45,13 +45,13 @@ public class InJson implements Parse { boolean go = true; try { // Gather data from Reader, looking for special characters when not in Quotes - while(go && (ch=r.read())>=0) { - if(state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content + while (go && (ch=r.read())>=0) { + if (state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content c=(char)ch; // Character is a quote. - if(c=='"') { - if(inQuotes) { - if(escaped) { // if escaped Quote, add to data. + if (c=='"') { + if (inQuotes) { + if (escaped) { // if escaped Quote, add to data. sb.append(c); escaped = false; } else { @@ -62,9 +62,9 @@ public class InJson implements Parse { inQuotes = true; } } else { // Not a Quote - if(inQuotes) { - if(c=='\\') { - if(escaped) { + if (inQuotes) { + if (c=='\\') { + if (escaped) { sb.append("\\\\"); escaped = false; } else { @@ -80,7 +80,7 @@ public class InJson implements Parse { parsed.isString = false; break; case Parse.START_OBJ: - if(state.braces++ == 0) { + if (state.braces++ == 0) { parsed.event = START_DOC; state.unsent = c; } else { @@ -89,7 +89,7 @@ public class InJson implements Parse { go = false; break; case Parse.END_OBJ: - if(--state.braces == 0) { + if (--state.braces == 0) { parsed.event = c; state.unsent = END_DOC; } else { @@ -99,7 +99,7 @@ public class InJson implements Parse { break; // These three end the data gathering, and send it along with the event that is ending the data gathering case Parse.NEXT: - if(parsed.name.startsWith("__")) { + if (parsed.name.startsWith("__")) { parsed.event = Parse.ATTRIB; parsed.name = parsed.name.substring(2); } else { diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java index 91b7c57d..175a2aa2 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java @@ -51,13 +51,13 @@ public class InXML implements Parse { State state = parsed.state; // OK, before anything else, see if there is leftover processing, if so, do it! - if(state.unevaluated!=null) { + if (state.unevaluated!=null) { DerTag dt = state.unevaluated; state.unevaluated = null; - if(!state.greatExp.eval(parsed, dt))return parsed; + if (!state.greatExp.eval(parsed, dt))return parsed; } - if(state.hasAttributes()) { + if (state.hasAttributes()) { Prop prop = state.pop(); parsed.event = Parse.ATTRIB; parsed.name = prop.tag; @@ -73,14 +73,14 @@ public class InXML implements Parse { boolean go = true; try { - while(go && (ch=r.read())>=0) { + while (go && (ch=r.read())>=0) { c = (char)ch; - if(c == '"') { - if(state.greatExp instanceof LeafExpectations) { // within a set of Tags, make a Quote + if (c == '"') { + if (state.greatExp instanceof LeafExpectations) { // within a set of Tags, make a Quote sb.append(c); } else { - if(inQuotes) { - if(escaped) { + if (inQuotes) { + if (escaped) { sb.append('\\'); sb.append(c); escaped = false; @@ -92,11 +92,11 @@ public class InXML implements Parse { inQuotes = true; } } - } else if(inQuotes) { + } else if (inQuotes) { sb.append(c); - } else if(c=='&') { + } else if (c=='&') { XmlEscape.xmlEscape(sb,r); - } else if(c=='\\') { + } else if (c=='\\') { escaped=true; } else { switch(c) { @@ -106,9 +106,9 @@ public class InXML implements Parse { break; default: // don't add Whitespace to start of SB... saves removing later - if(sb.length()>0) { + if (sb.length()>0) { sb.append(c); - } else if(!Character.isWhitespace(c)) { + } else if (!Character.isWhitespace(c)) { sb.append(c); } } @@ -142,16 +142,16 @@ public class InXML implements Parse { String tag = null; try { - if((ch = r.read())<0) throw new ParseException("Reader content ended before complete"); - if(ch=='?') { + if ((ch = r.read())<0) throw new ParseException("Reader content ended before complete"); + if (ch=='?') { isXmlInfo = true; } // TODO Check for !-- comments do { c=(char)ch; - if(c=='"') { - if(inQuotes) { - if(escaped) { + if (c=='"') { + if (inQuotes) { + if (escaped) { sb.append(c); escaped = false; } else { @@ -160,7 +160,7 @@ public class InXML implements Parse { } else { inQuotes = true; } - } else if(inQuotes) { + } else if (inQuotes) { sb.append(c); } else { switch(c) { @@ -184,13 +184,13 @@ public class InXML implements Parse { // sb.setLength(0); // break; case '?': - if(!isXmlInfo)sb.append(c); + if (!isXmlInfo)sb.append(c); break; default: sb.append(c); } } - } while(go && (ch=r.read())>=0); + } while (go && (ch=r.read())>=0); } catch (IOException e) { throw new ParseException(e); } @@ -198,14 +198,14 @@ public class InXML implements Parse { } private void endField(String tag, StringBuilder sb) { - if(name==null) { + if (name==null) { name = sb.toString(); sb.setLength(0); } else { String value = sb.toString(); sb.setLength(0); - if(tag !=null && value != null) { - if(props==null)props = new ArrayList<>(); + if (tag !=null && value != null) { + if (props==null)props = new ArrayList<>(); props.add(new Prop(tag,value)); } } @@ -217,7 +217,7 @@ public class InXML implements Parse { sb.append(" Tag\n"); sb.append(" Name: "); sb.append(name); - if(props!=null) for(Prop p : props) { + if (props!=null) for (Prop p : props) { sb.append("\n "); sb.append(p.tag); sb.append("=\""); @@ -250,7 +250,7 @@ public class InXML implements Parse { } public void push(Prop prop) { - if(attribs==null) { + if (attribs==null) { attribs = new ArrayList<>(); idx = 0; } @@ -259,9 +259,9 @@ public class InXML implements Parse { public Prop pop() { Prop rv = null; - if(attribs!=null) { + if (attribs!=null) { rv = attribs.get(idx++); - if(idx>=attribs.size())attribs = null; + if (idx>=attribs.size())attribs = null; } return rv; } @@ -282,8 +282,8 @@ public class InXML implements Parse { // Recursively look back for any namespaces protected Map getNS() { - if(ns!=null)return ns; - if(prev!=null) { + if (ns!=null)return ns; + if (prev!=null) { return prev.getNS(); } return null; @@ -291,47 +291,47 @@ public class InXML implements Parse { private void addNS(Prop prop) { Map existingNS = getNS(); - if(ns==null)ns = new HashMap<>(); + if (ns==null)ns = new HashMap<>(); // First make a copy of previous NSs so that we have everything we need, but can overwrite, if necessary - if(existingNS!=null && ns!=existingNS) { + if (existingNS!=null && ns!=existingNS) { ns.putAll(ns); } ns.put(prop.tag, prop.value); } private JaxInfo getDerived(State state, JaxInfo ji, DerTag derTag) throws ParseException { - if(derTag==null)return ji; + if (derTag==null)return ji; List props = derTag.props; Prop derived = null; - if(props!=null) { + if (props!=null) { // Load Namespaces (if any) - for(Prop prop : props) { - if(prop.tag.startsWith("xmlns:")) { + for (Prop prop : props) { + if (prop.tag.startsWith("xmlns:")) { addNS(prop); } } - for(Prop prop : props) { - if(prop.tag.endsWith(":type")) { + for (Prop prop : props) { + if (prop.tag.endsWith(":type")) { int idx = prop.tag.indexOf(':'); String potentialNS = "xmlns:"+prop.tag.substring(0,idx); Map ns = getNS(); boolean noNamespace = false; - if(ns==null) { + if (ns==null) { noNamespace = true; } else { String nsVal = ns.get(potentialNS); - if(nsVal==null) noNamespace = true; + if (nsVal==null) noNamespace = true; else { derived = new Prop(Parsed.EXTENSION_TAG,prop.value); state.push(derived); } } - if(noNamespace) { + if (noNamespace) { throw new ParseException(prop.tag + " utilizes an invalid Namespace prefix"); } - } else if(!prop.tag.startsWith("xmlns")) { + } else if (!prop.tag.startsWith("xmlns")) { state.push(prop); } } @@ -348,10 +348,10 @@ public class InXML implements Parse { // @Override public boolean eval(Parsed parsed, DerTag derTag) throws ParseException { - if(derTag.isXmlInfo) { + if (derTag.isXmlInfo) { parsed.event = START_DOC; - } else if(ji.name.equals(derTag.name)) { - if(derTag.isEndTag) { + } else if (ji.name.equals(derTag.name)) { + if (derTag.isEndTag) { parsed.event = END_DOC; parsed.state.greatExp = prev; } else { @@ -374,22 +374,22 @@ public class InXML implements Parse { // @Override public boolean eval(Parsed parsed, DerTag derTag) throws ParseException { - if(derTag.isEndTag && ji.name.equals(derTag.name)) { + if (derTag.isEndTag && ji.name.equals(derTag.name)) { parsed.state.greatExp = prev; parsed.event = END_OBJ; - if(printName)parsed.name = ji.name; + if (printName)parsed.name = ji.name; } else { //Standard Members - for(JaxInfo memb : ji.members) { - if(memb.name.equals(derTag.name)) { + for (JaxInfo memb : ji.members) { + if (memb.name.equals(derTag.name)) { parsed.name = memb.name; - if(memb.isArray) { + if (memb.isArray) { parsed.state.unevaluated = derTag; // evaluate within Array Context parsed.event = START_ARRAY; parsed.state.greatExp = new ArrayExpectations(parsed.state,memb,this); return false; - } else if(memb.isObject()) { - if(derTag.isEndTag) { + } else if (memb.isObject()) { + if (derTag.isEndTag) { throw new ParseException("Unexpected End Tag '); } else { parsed.event = START_OBJ; @@ -398,7 +398,7 @@ public class InXML implements Parse { return false; } } else { // a leaf - if(derTag.isEndTag) { + if (derTag.isEndTag) { throw new ParseException("Misplaced End Tag '); } else { parsed.state.greatExp = new LeafExpectations(parsed.state,memb, this); @@ -421,7 +421,7 @@ public class InXML implements Parse { // @Override public boolean eval(Parsed parsed, DerTag derTag) throws ParseException { - if(ji.name.equals(derTag.name) && derTag.isEndTag) { + if (ji.name.equals(derTag.name) && derTag.isEndTag) { parsed.event = NEXT; parsed.isString = ji.isString; parsed.state.greatExp = prev; @@ -435,18 +435,18 @@ public class InXML implements Parse { private static class ArrayExpectations extends GreatExpectations { public ArrayExpectations(State state, JaxInfo ji, GreatExpectations prev) throws ParseException { super(state, ji, prev,null); - if(state.arrayInfo==null)state.arrayInfo=new Stack(); + if (state.arrayInfo==null)state.arrayInfo=new Stack(); state.arrayInfo.push(new ArrayState()); } // @Override public boolean eval(Parsed parsed, DerTag derTag) throws ParseException { - if(ji.name.equals(derTag.name) && !derTag.isEndTag) { - if(ji.isObject()) { - if(derTag.isEndTag) { + if (ji.name.equals(derTag.name) && !derTag.isEndTag) { + if (ji.isObject()) { + if (derTag.isEndTag) { throw new ParseException("Unexpected End Tag '); } else { ArrayState ai = parsed.state.arrayInfo.peek(); - if(ai.firstObj || ai.didNext) { + if (ai.firstObj || ai.didNext) { ai.firstObj = false; ai.didNext = false; parsed.event = START_OBJ; @@ -459,7 +459,7 @@ public class InXML implements Parse { } } } else { // a leave - if(derTag.isEndTag) { + if (derTag.isEndTag) { throw new ParseException("Misplaced End Tag '); } else { parsed.state.greatExp = new LeafExpectations(parsed.state, ji, this); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java index edc5f787..d209f02f 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java @@ -65,22 +65,22 @@ public class JaxInfo { public int getType() { - if(isArray)return ARRAY; - else if(members!=null)return OBJECT; + if (isArray)return ARRAY; + else if (members!=null)return OBJECT; return DATA; } public JaxInfo getDerived(String derivedName) { JaxInfo derived; // Lazy Instantiation - if(extensions == null) { + if (extensions == null) { extensions = new HashMap<>(); derived = null; } else { derived = extensions.get(derivedName); } - if(derived == null) { + if (derived == null) { //TODO for the moment, Classes are in same package Package pkg = clss.getPackage(); try { @@ -95,8 +95,8 @@ public class JaxInfo { } public static JaxInfo get(JaxInfo[] fields, String name) { - for(JaxInfo f : fields) { - if(name.equals(f.name)) return f; + for (JaxInfo f : fields) { + if (name.equals(f.name)) return f; } return null; } @@ -128,7 +128,7 @@ public class JaxInfo { */ public static JaxInfo build(Class cls, String ... rootNns) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException { String defaultNS; - if(rootNns.length>0 && rootNns[0]!=null) { + if (rootNns.length>0 && rootNns[0]!=null) { defaultNS = rootNns[0]; } else { Package pkg = cls.getPackage(); @@ -136,15 +136,15 @@ public class JaxInfo { defaultNS = xs==null?"":xs.namespace(); } String name; - if(rootNns.length>1) { + if (rootNns.length>1) { name = rootNns[1]; } else { XmlRootElement xre = cls.getAnnotation(XmlRootElement.class); - if(xre!=null) { + if (xre!=null) { name = xre.name(); } else { XmlType xt = cls.getAnnotation(XmlType.class); - if(xt!=null) { + if (xt!=null) { name=xt.name(); } else { throw new ParseException("Need a JAXB Object with XmlRootElement, or stipulate in parms"); @@ -162,10 +162,10 @@ public class JaxInfo { Class cls = clazz; // Build up Method names from JAXB Annotations XmlType xt; - while((xt = cls.getAnnotation(XmlType.class))!=null) { - if(fields==null)fields = new ArrayList<>(); - for(String field : xt.propOrder()) { - if("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array + while ((xt = cls.getAnnotation(XmlType.class))!=null) { + if (fields==null)fields = new ArrayList<>(); + for (String field : xt.propOrder()) { + if ("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array Field rf = cls.getDeclaredField(field); Class ft = rf.getType(); @@ -175,27 +175,27 @@ public class JaxInfo { String namespace = defaultNS; XmlElement xe = rf.getAnnotation(XmlElement.class); - if(xe!=null) { + if (xe!=null) { xmlName=xe.name(); required = xe.required(); nillable = false; - if(DEFAULT.equals(xmlName)) { + if (DEFAULT.equals(xmlName)) { xmlName = field; } namespace = xe.namespace(); - if(DEFAULT.equals(namespace)) { + if (DEFAULT.equals(namespace)) { namespace = defaultNS; } } // If object is a List, then it is possible multiple, per XML/JAXB evaluation - if(ft.isAssignableFrom(List.class)) { + if (ft.isAssignableFrom(List.class)) { Type t = rf.getGenericType(); String classname = t.toString(); int start = classname.indexOf('<'); int end = classname.indexOf('>'); Class genClass = Class.forName(classname.substring(start+1, end)); xe = genClass.getAnnotation(XmlElement.class); - if(xe!=null && !DEFAULT.equals(xe.namespace())) { + if (xe!=null && !DEFAULT.equals(xe.namespace())) { namespace = xe.namespace(); } // add recursed recursed member, marked as array @@ -208,7 +208,7 @@ public class JaxInfo { } cls = cls.getSuperclass(); }; - if(fields!=null) { + if (fields!=null) { JaxInfo[] rv = new JaxInfo[fields.size()]; fields.toArray(rv); return rv; @@ -219,17 +219,17 @@ public class JaxInfo { public StringBuilder dump(StringBuilder sb, int idx) { - for(int i=0;i { members = new TreeMap<>(); XmlType xmltype = cls.getAnnotation(XmlType.class); Class paramType[] = new Class[] {String.class}; - for(String str : xmltype.propOrder()) { + for (String str : xmltype.propOrder()) { try { String setName = "set" + Character.toUpperCase(str.charAt(0)) + str.subSequence(1, str.length()); Method meth = cls.getMethod(setName,paramType ); - if(meth!=null) { + if (meth!=null) { members.put(str, new Setter(meth) { public void set(T o, Object t) throws ParseException { try { @@ -78,7 +78,7 @@ public class JaxSet { synchronized(jsets) { @SuppressWarnings("unchecked") JaxSet js = (JaxSet)jsets.get(cls); - if(js == null) { + if (js == null) { jsets.put(cls, js = new JaxSet<>(cls)); } return js; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java index 5e03ac91..6ff627b9 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java @@ -55,7 +55,7 @@ public class Ladder { public void top() { rung = struts.length-1; - while(rung>0 && struts[rung]==null)--rung; + while (rung>0 && struts[rung]==null)--rung; } public int howHigh() { @@ -63,7 +63,7 @@ public class Ladder { } public void jumpTo(int rung) { - if(rung>=struts.length) { + if (rung>=struts.length) { Object[] temp = new Object[init_size*((rung/init_size)+1)]; System.arraycopy(struts, 0, temp, 0, struts.length); struts = temp; @@ -83,7 +83,7 @@ public class Ladder { public void ascend() { ++rung; - if(rung>=struts.length) { + if (rung>=struts.length) { Object[] temp = new Object[struts.length+init_size]; System.arraycopy(struts, 0, temp, 0, struts.length); struts = temp; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java index 4b8d2bf3..3729d1e3 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java @@ -59,7 +59,7 @@ public abstract class Marshal implements Parse { @Override public Void next() { - if(!hasNext()) { + if (!hasNext()) { throw new NoSuchElementException(); } return null; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java index 2716c8be..4fb52d86 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java @@ -35,8 +35,8 @@ public class OutJax extends Out { public void extract(IN in, Writer writer, Parse parse, boolean... options) throws IOException, ParseException { Parsed p = parse.newParsed(); JaxEval je = this.jaxEval; - while((p = parse.parse(in,p.reuse())).valid()) { - if(je==null)throw new ParseException("Incomplete content"); + while ((p = parse.parse(in,p.reuse())).valid()) { + if (je==null)throw new ParseException("Incomplete content"); je = je.eval(p); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java index d0a26784..6c868378 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java @@ -33,7 +33,7 @@ public class OutJson extends Out { public void extract(IN in, Writer writer, Parse prs, boolean ... options) throws IOException, ParseException { Parsed p = prs.newParsed(); IndentPrintWriter ipw; - if(options.length>0 && options[0]) { // is Pretty + if (options.length>0 && options[0]) { // is Pretty ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); writer = ipw; } else { @@ -47,13 +47,13 @@ public class OutJson extends Out { char afterName=0, beforeName=0, maybe = 0, prev=0; int count = 0; - while((p = prs.parse(in,p.reuse())).valid()) { + while ((p = prs.parse(in,p.reuse())).valid()) { ++count; switch(p.event) { case 1: continue; case 2: - if(count==2) { // it's empty, write open/close on it's own + if (count==2) { // it's empty, write open/close on it's own writer.append('{'); writer.append('}'); } @@ -61,7 +61,7 @@ public class OutJson extends Out { return; case '{': afterName = '{'; - if(jsonLevel.peek().printObjectName) { + if (jsonLevel.peek().printObjectName) { print = true; } else { // don't print names on first print=false; @@ -70,7 +70,7 @@ public class OutJson extends Out { jsonLevel.push(new LevelStack(true)); break; case '}': - if(p.hasData()) { // if we have data, we print that, so may need to prepend a comma. + if (p.hasData()) { // if we have data, we print that, so may need to prepend a comma. maybe = jsonLevel.peek().listItem(); } else { // No data means just print, p.name = ""; // XML tags come through with names, but no data @@ -81,7 +81,7 @@ public class OutJson extends Out { break; case '[': afterName = p.event; - if((prev==',' && !hadData) || prev==']')maybe=','; + if ((prev==',' && !hadData) || prev==']')maybe=','; else maybe = jsonLevel.peek().listItem(); jsonLevel.push(new LevelStack(false)); @@ -89,8 +89,8 @@ public class OutJson extends Out { break; case ']': afterName = p.event; - if(p.hasData()) { - if(prev==',' && !hadData)maybe=','; + if (p.hasData()) { + if (prev==',' && !hadData)maybe=','; else maybe = jsonLevel.peek().listItem(); } else { p.name = ""; // XML tags come through with names, but no data @@ -101,7 +101,7 @@ public class OutJson extends Out { break; case 3: case ',': - if(!p.hasData()) { + if (!p.hasData()) { p.isString=false; print=false; } else { @@ -113,36 +113,36 @@ public class OutJson extends Out { print = true; } - if(maybe!=0) { - if(ipw==null)writer.append(maybe); + if (maybe!=0) { + if (ipw==null)writer.append(maybe); else ipw.println(maybe); maybe = 0; } - if(beforeName!=0) { - if(ipw==null)writer.append(beforeName); + if (beforeName!=0) { + if (ipw==null)writer.append(beforeName); else ipw.println(beforeName); beforeName = 0; } - if(print) { - if(p.hasName()) { + if (print) { + if (p.hasName()) { writer.append('"'); - if(p.event==3)writer.append("__"); + if (p.event==3)writer.append("__"); writer.append(p.name); writer.append("\":"); } - if(p.hasData()) { - if(p.isString) { + if (p.hasData()) { + if (p.isString) { writer.append('"'); escapedWrite(writer, p.sb); writer.append('"'); - } else if(p.sb.length()>0) { + } else if (p.sb.length()>0) { writer.append(p.sb); } } } - if(afterName!=0) { - if(ipw==null)writer.append(afterName); + if (afterName!=0) { + if (ipw==null)writer.append(afterName); else { switch(afterName) { case '{': @@ -155,7 +155,7 @@ public class OutJson extends Out { ipw.print(afterName); break; case ']': - if(prev=='}' || prev==',')ipw.println(); + if (prev=='}' || prev==',')ipw.println(); ipw.dec(); ipw.print(afterName); break; @@ -170,7 +170,7 @@ public class OutJson extends Out { afterName = 0; } - if(ipw!=null) { + if (ipw!=null) { switch(p.event) { case '[': ipw.inc(); @@ -187,11 +187,11 @@ public class OutJson extends Out { private void escapedWrite(Writer writer, StringBuilder sb) throws IOException { char c; - for(int i=0;i void extract(IN in, Writer writer, Parse prs, boolean ... options) throws IOException, ParseException { Parsed p = prs.newParsed(); - while((p = prs.parse(in,p.reuse())).valid()) { + while ((p = prs.parse(in,p.reuse())).valid()) { writer.append(p.toString()); writer.append('\n'); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java index a887cb96..6472c88e 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java @@ -43,9 +43,9 @@ public class OutXML extends Out{ public OutXML(String root, String ... params) { this.root = root; props = new ArrayList<>(); - for(String p : params) { + for (String p : params) { String[] tv=p.split("="); - if(tv.length==2) + if (tv.length==2) props.add(new Prop(tv[0],tv[1])); } } @@ -71,8 +71,8 @@ public class OutXML extends Out{ boolean pretty = (options.length>0&&options[0]); IndentPrintWriter ipw; - if(pretty) { - if(writer instanceof IndentPrintWriter) { + if (pretty) { + if (writer instanceof IndentPrintWriter) { ipw = (IndentPrintWriter)writer; } else { writer = ipw = new IndentPrintWriter(writer); @@ -82,19 +82,19 @@ public class OutXML extends Out{ } boolean closeTag = false; Level level = new Level(null); - while((p = prs.parse(in,p.reuse())).valid()) { - if(!p.hasName() && level.multi!=null) { + while ((p = prs.parse(in,p.reuse())).valid()) { + if (!p.hasName() && level.multi!=null) { p.name=level.multi; } - if(closeTag && p.event!=Parse.ATTRIB) { + if (closeTag && p.event!=Parse.ATTRIB) { writer.append('>'); - if(pretty)writer.append('\n'); + if (pretty)writer.append('\n'); closeTag = false; } switch(p.event) { case Parse.START_DOC: - if(!(options.length>1&&options[1])) // if not a fragment, print XML Info data - if(pretty)ipw.println(XML_INFO); + if (!(options.length>1&&options[1])) // if not a fragment, print XML Info data + if (pretty)ipw.println(XML_INFO); else writer.append(XML_INFO); break; case Parse.END_DOC: @@ -102,21 +102,21 @@ public class OutXML extends Out{ case Parse.START_OBJ: stack.push(level); level = new Level(level); - if(p.hasName()) { + if (p.hasName()) { closeTag = tag(writer,level.sbw,pretty,pretty,p.name,null); - } else if(root!=null && stack.size()==1) { // first Object + } else if (root!=null && stack.size()==1) { // first Object closeTag = tag(writer,level.sbw,pretty,pretty,root,null); // Write Root Props - for(Prop prop : props) { + for (Prop prop : props) { attrib(writer,pretty,prop.tag, prop.value,level); } } - if(pretty)ipw.inc(); + if (pretty)ipw.inc(); break; case Parse.END_OBJ: - if(p.hasData()) + if (p.hasData()) closeTag = tag(writer,writer,pretty,false,p.name, XmlEscape.convert(p.sb)); - if(pretty)ipw.dec(); + if (pretty)ipw.dec(); writer.append(level.sbw.getBuffer()); level = stack.pop(); break; @@ -124,16 +124,16 @@ public class OutXML extends Out{ level.multi = p.name; break; case Parse.END_ARRAY: - if(p.hasData()) + if (p.hasData()) closeTag = tag(writer,writer,pretty,false, p.name, XmlEscape.convert(p.sb)); level.multi=null; break; case Parse.ATTRIB: - if(p.hasData()) + if (p.hasData()) attrib(writer,pretty,p.name, XmlEscape.convert(p.sb), level); break; case Parse.NEXT: - if(p.hasData()) + if (p.hasData()) closeTag = tag(writer,writer,pretty, false,p.name, XmlEscape.convert(p.sb)); break; } @@ -156,15 +156,15 @@ public class OutXML extends Out{ public boolean hasPrinted(String ns, String value, boolean create) { boolean rv = false; - if(nses==null) { - if(prev!=null)rv = prev.hasPrinted(ns, value, false); + if (nses==null) { + if (prev!=null)rv = prev.hasPrinted(ns, value, false); } else { String v = nses.get(ns); return value.equals(v); // note: accomodates not finding NS as well } - if(create && !rv) { - if(nses == null) nses = new HashMap<>(); + if (create && !rv) { + if (nses == null) nses = new HashMap<>(); nses.put(ns, value); } return rv; @@ -177,25 +177,25 @@ public class OutXML extends Out{ private boolean tag(Writer fore, Writer aft, boolean pretty, boolean returns, String tag, String data) throws IOException { fore.append('<'); fore.append(tag); - if(data!=null) { + if (data!=null) { fore.append('>'); // if no data, it may need some attributes... fore.append(data); - if(returns)fore.append('\n'); + if (returns)fore.append('\n'); } aft.append(""); - if(pretty)aft.append('\n'); + if (pretty)aft.append('\n'); return data==null; } private void attrib(Writer fore, boolean pretty, String tag, String value, Level level) throws IOException { String realTag = tag.startsWith("__")?tag.substring(2):tag; // remove __ - if(realTag.equals(Parsed.EXTENSION_TAG)) { // Convert Derived name into XML defined Inheritance + if (realTag.equals(Parsed.EXTENSION_TAG)) { // Convert Derived name into XML defined Inheritance fore.append(" xsi:type=\""); fore.append(value); fore.append('"'); - if(!level.hasPrinted(XMLNS_XSI, XML_SCHEMA_INSTANCE,true)) { + if (!level.hasPrinted(XMLNS_XSI, XML_SCHEMA_INSTANCE,true)) { fore.append(' '); fore.append(XMLNS_XSI); fore.append("=\""); @@ -203,8 +203,8 @@ public class OutXML extends Out{ fore.append("\""); } } else { - if(realTag.startsWith("xmlns:") ) { - if(level.hasPrinted(realTag, value, true)) { + if (realTag.startsWith("xmlns:") ) { + if (level.hasPrinted(realTag, value, true)) { return; } } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java index a4c679db..29a86de8 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java @@ -73,15 +73,15 @@ public class Parsed { public String toString() { StringBuilder sb2 = new StringBuilder(); - if(event<40)sb2.append((int)event); + if (event<40)sb2.append((int)event); else sb2.append(event); sb2.append(" - "); sb2.append(name); - if(sb.length()>0) { + if (sb.length()>0) { sb2.append(" : "); - if(isString)sb2.append('"'); + if (isString)sb2.append('"'); sb2.append(sb); - if(isString)sb2.append('"'); + if (isString)sb2.append('"'); } return sb2.toString(); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java index ae9c8934..d46fc8be 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java @@ -31,7 +31,7 @@ class Prop { public Prop(String t_equals_v) { String[] tv = t_equals_v.split("="); - if(tv.length>1) { + if (tv.length>1) { tag = tv[0]; value = tv[1]; } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java index a596b705..efb4ce4b 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java @@ -50,20 +50,20 @@ public class Saved extends Out implements Parse{ // @Override public void extract(IN in, Writer ignore, Parse parser, boolean ... options) throws IOException, ParseException { Parsed p = parser.newParsed(); - if(!append) { + if (!append) { // reuse array if not too big - if(content==null||content.length>INIT_SIZE*3) { + if (content==null||content.length>INIT_SIZE*3) { content = new Content[INIT_SIZE]; idx = -1; } else do { content[idx]=null; - } while(--idx>=0); + } while (--idx>=0); } // Note: idx needs to be -1 on initialization and no appendages - while((p = parser.parse(in,p.reuse())).valid()) { - if(!(append && (p.event==START_DOC || p.event==END_DOC))) { // skip any start/end of document in appendages - if(++idx>=content.length) { + while ((p = parser.parse(in,p.reuse())).valid()) { + if (!(append && (p.event==START_DOC || p.event==END_DOC))) { // skip any start/end of document in appendages + if (++idx>=content.length) { Content temp[] = new Content[content.length*2]; System.arraycopy(content, 0, temp, 0, idx); content = temp; @@ -76,7 +76,7 @@ public class Saved extends Out implements Parse{ // @Override public Parsed parse(Reader ignore, Parsed parsed) throws ParseException { int i; - if((i=parsed.state.count++)<=idx) + if ((i=parsed.state.count++)<=idx) content[i].load(parsed); else parsed.event = Parse.NONE; @@ -85,9 +85,9 @@ public class Saved extends Out implements Parse{ public Content[] cut(char event, int count) { append = true; - for(int i=idx;i>=0;--i) { - if(content[i].event==event) count--; - if(count==0) { + for (int i=idx;i>=0;--i) { + if (content[i].event==event) count--; + if (count==0) { Content[] appended = new Content[idx-i+1]; System.arraycopy(content, i, appended, 0, appended.length); idx = i-1; @@ -98,8 +98,8 @@ public class Saved extends Out implements Parse{ } public void paste(Content[] appended) { - if(appended!=null) { - if(idx+appended.length>content.length) { + if (appended!=null) { + if (idx+appended.length>content.length) { Content temp[] = new Content[content.length*2]; System.arraycopy(content, 0, temp, 0, idx); content = temp; @@ -134,7 +134,7 @@ public class Saved extends Out implements Parse{ p.isString = isString; p.event = event; p.name = name; - if(str!=null) + if (str!=null) p.sb.append(str); } @@ -144,14 +144,14 @@ public class Saved extends Out implements Parse{ sb.append(" - "); sb.append(name); sb.append(": "); - if(isString)sb.append('"'); + if (isString)sb.append('"'); sb.append(str); - if(isString)sb.append('"'); + if (isString)sb.append('"'); sb.append(' '); - if(props!=null) { + if (props!=null) { boolean comma = false; - for(Prop prop : props) { - if(comma)sb.append(','); + for (Prop prop : props) { + if (comma)sb.append(','); else comma = true; sb.append(prop.tag); sb.append('='); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java index 1b0eec07..3007ea95 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java @@ -36,13 +36,13 @@ public class XmlEscape { try { int c; StringBuilder esc = new StringBuilder(); - for(int cnt = 0;cnt<9 /*max*/; ++cnt) { - if((c=r.read())<0)throw new ParseException("Invalid Data: Unfinished Escape Sequence"); - if(c!=';') { + for (int cnt = 0;cnt<9 /*max*/; ++cnt) { + if ((c=r.read())<0)throw new ParseException("Invalid Data: Unfinished Escape Sequence"); + if (c!=';') { esc.append((char)c); } else { // evaluate Integer i = charMap.get(esc.toString()); - if(i==null) { + if (i==null) { // leave in nasty XML format for now. sb.append('&'); sb.append(esc); @@ -69,20 +69,20 @@ public class XmlEscape { public static String convert(StringBuilder insb) { int idx, ch; StringBuilder sb=null; - for(idx=0;idx=160 || ch==34 || ch==38 || ch==39 || ch==60 || ch==62) { + if (ch>=160 || ch==34 || ch==38 || ch==39 || ch==60 || ch==62) { sb = new StringBuilder(); sb.append(insb,0,idx); break; } } - if(sb==null)return insb.toString(); + if (sb==null)return insb.toString(); - for(int i=idx;i es: charMap.entrySet()) { - if(es.getValue()>=160); // save small space... note that no longer has amp, etc. + for ( Entry es: charMap.entrySet()) { + if (es.getValue()>=160); // save small space... note that no longer has amp, etc. intMap.put(es.getValue(), es.getKey()); } } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java index 69926974..a95da8ea 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java @@ -217,7 +217,7 @@ public class RosettaDF extends BaseDataFactory implements DataFactory { * @return */ public RosettaDF rootMarshal(Marshal marshal) { - if(marshal instanceof DocMarshal) { + if (marshal instanceof DocMarshal) { this.marshal = marshal; } else { this.marshal = DocMarshal.root(marshal); @@ -229,7 +229,7 @@ public class RosettaDF extends BaseDataFactory implements DataFactory { Out out = getOut(outType); TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env? try { - if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if (marshal==null) { // Unknown marshaller... do working XML marshal/extraction StringWriter sw = new StringWriter(); jaxMar.marshal(trans.debug(), t, sw, options); out.extract(new StringReader(sw.toString()), new OutputStreamWriter(os), inXML,options); @@ -247,7 +247,7 @@ public class RosettaDF extends BaseDataFactory implements DataFactory { Out out = getOut(outType); TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env? try { - if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if (marshal==null) { // Unknown marshaller... do working XML marshal/extraction StringWriter sw = new StringWriter(); jaxMar.marshal(trans.debug(), t, sw, options); out.extract(new StringReader(sw.toString()), writer, inXML,options); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java index 97f68dae..fa29dcdc 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java @@ -129,7 +129,7 @@ public class RosettaData implements Data{ Parse in = df.getIn(inType); TimeTaken tt = in.start(trans); try { - if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if (df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction StringWriter sw = new StringWriter(); df.jaxMar.marshal(trans.debug(), t, sw, options); saved.extract(new StringReader(xml = sw.toString()), (Writer)null, df.inXML); @@ -169,15 +169,15 @@ public class RosettaData implements Data{ Out out = df.getOut(outType); TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? try { - if(outType==TYPE.XML) { - if(xml==null) { + if (outType==TYPE.XML) { + if (xml==null) { StringWriter sw = new StringWriter(); out.extract(null, sw, saved, options); xml = sw.toString(); } return xml; } else { // is JSON - if(json==null) { + if (json==null) { StringWriter sw = new StringWriter(); out.extract(null, sw, saved, options); json = sw.toString(); @@ -197,9 +197,9 @@ public class RosettaData implements Data{ Out out = df.getOut(outType); TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? try { - if(outType==TYPE.XML && xml!=null) { + if (outType==TYPE.XML && xml!=null) { os.write(xml.getBytes()); - } else if(outType==TYPE.JSON && json!=null) { + } else if (outType==TYPE.JSON && json!=null) { os.write(json.getBytes()); } else { out.extract(null, os, saved, options); @@ -217,9 +217,9 @@ public class RosettaData implements Data{ Out out = df.getOut(outType); TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? try { - if(outType==TYPE.XML && xml!=null) { + if (outType==TYPE.XML && xml!=null) { writer.append(xml); - } else if(outType==TYPE.JSON && json!=null) { + } else if (outType==TYPE.JSON && json!=null) { writer.append(json); } else { out.extract(null, writer, saved, options); @@ -260,7 +260,7 @@ public class RosettaData implements Data{ Out out = df.getOut(outType); TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? try { - if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if (df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction StringWriter sw = new StringWriter(); df.jaxMar.marshal(trans.debug(), t, sw, options); out.extract(new StringReader(xml = sw.toString()), writer, df.inXML,options); @@ -278,8 +278,8 @@ public class RosettaData implements Data{ Out out = df.getOut(outType); TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? try { - if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction - if(outType.equals(TYPE.XML)) { + if (df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if (outType.equals(TYPE.XML)) { df.jaxMar.marshal(trans.debug(), t, os, options); } else { StringWriter sw = new StringWriter(); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java index 849a3214..0617e01d 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java @@ -127,7 +127,7 @@ public abstract class DataWriter { // String in "HexString" or the processing in // "String.format" //sb.append("0x"); - for(int i=0;i>4)]); sb.append(chars[b&0xF]); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java index 6cabe068..1fa17010 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java @@ -40,18 +40,18 @@ public class DocMarshal extends Marshal { public Parsed parse(T t, Parsed parsed) throws ParseException { Ladder> ladder = parsed.state.ladder; Iterator iter = ladder.peek(); - if(iter==null) { + if (iter==null) { ladder.push(PENDING_ITERATOR); parsed.event = START_DOC; } else if (DONE_ITERATOR.equals(iter)) { } else { ladder.ascend(); // look at field info Iterator currFieldIter = ladder.peek(); - if(!DONE_ITERATOR.equals(currFieldIter)){ + if (!DONE_ITERATOR.equals(currFieldIter)){ parsed = root.parse(t, parsed); } ladder.descend(); - if(DONE_ITERATOR.equals(currFieldIter) || parsed.event==NONE) { + if (DONE_ITERATOR.equals(currFieldIter) || parsed.event==NONE) { parsed.event = END_DOC; ladder.push(DONE_ITERATOR); } @@ -68,7 +68,7 @@ public class DocMarshal extends Marshal { @Override public Void next() { - if(!hasNext()) { + if (!hasNext()) { throw new NoSuchElementException(); } return null; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java index 48f3608d..abc19b26 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java @@ -44,9 +44,9 @@ public abstract class FieldArray extends Marshal { public Parsed parse(T t, Parsed parsed) throws ParseException { Ladder> ladder = parsed.state.ladder; Iterator iter = ladder.peek(); - if(iter==null) { + if (iter==null) { List list = data(t); - if(list.isEmpty() && parsed.state.smallest) { + if (list.isEmpty() && parsed.state.smallest) { ladder.push(DONE_ITERATOR); } else { ladder.push(new ListIterator(list)); @@ -59,24 +59,24 @@ public abstract class FieldArray extends Marshal { Iterator memIter = ladder.peek(); ListIterator mems = (ListIterator)iter; S mem; - if(memIter==null) { + if (memIter==null) { mem=mems.next(); - } else if(!DONE_ITERATOR.equals(memIter)) { + } else if (!DONE_ITERATOR.equals(memIter)) { mem=mems.peek(); - } else if(iter.hasNext()) { + } else if (iter.hasNext()) { mem=null; ladder.push(null); } else { mem=null; } - if(mem!=null) { + if (mem!=null) { parsed.isString=dataWriter.write(mem, parsed.sb); parsed.event = NEXT; } ladder.descend(); - if(mem==null) { - if(iter.hasNext()) { + if (mem==null) { + if (iter.hasNext()) { parsed.event = NEXT; } else { parsed.event = END_ARRAY; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java index 384e0c98..9c64e83d 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java @@ -44,9 +44,9 @@ public abstract class ObjArray extends Marshal { public Parsed parse(T t, Parsed parsed) throws ParseException { Ladder> ladder = parsed.state.ladder; Iterator iter = ladder.peek(); - if(iter==null) { + if (iter==null) { List list = data(t); - if(list.isEmpty() && parsed.state.smallest) { + if (list.isEmpty() && parsed.state.smallest) { ladder.push(DONE_ITERATOR); } else { ladder.push(new ListIterator(list)); @@ -58,22 +58,22 @@ public abstract class ObjArray extends Marshal { Iterator memIter = ladder.peek(); ListIterator mems = (ListIterator)iter; S mem; - if(memIter==null) { + if (memIter==null) { mem=mems.next(); - } else if(!DONE_ITERATOR.equals(memIter)) { + } else if (!DONE_ITERATOR.equals(memIter)) { mem=mems.peek(); - } else if(iter.hasNext()) { + } else if (iter.hasNext()) { mem=null; ladder.push(null); } else { mem=null; } - if(mem!=null) + if (mem!=null) parsed = subMarshaller.parse(mem, parsed); ladder.descend(); - if(mem==null) { - if(iter.hasNext()) { + if (mem==null) { + if (iter.hasNext()) { parsed.event = NEXT; } else { parsed.event = END_ARRAY; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java index 31e214b5..d96a44d0 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java @@ -47,9 +47,9 @@ public abstract class ObjMarshal extends Marshal { */ @SuppressWarnings("unchecked") protected void add(Marshal pm) { - if(pml==null) { + if (pml==null) { pml = new Marshal[Ladder.DEFAULT_INIT_SIZE]; - } else if(end>pml.length) { + } else if (end>pml.length) { Object temp[] = pml; pml = new Marshal[pml.length+Ladder.DEFAULT_INIT_SIZE]; System.arraycopy(temp, 0, pml, 0, pml.length); @@ -66,8 +66,8 @@ public abstract class ObjMarshal extends Marshal { public Parsed parse(T in, Parsed parsed) throws ParseException { Ladder> ladder = parsed.state.ladder; Iterator> iter = (Iterator>)ladder.peek(); - if(iter==null) { - if(pml.length>0) { + if (iter==null) { + if (pml.length>0) { ladder.push(new FieldsIterator()); parsed.event = START_OBJ; } else { @@ -78,22 +78,22 @@ public abstract class ObjMarshal extends Marshal { ladder.ascend(); // look at field info Iterator currFieldIter = ladder.peek(); Marshal marshal; - if(currFieldIter==null) { + if (currFieldIter==null) { marshal=fields.next(); - } else if(!DONE_ITERATOR.equals(currFieldIter)) { + } else if (!DONE_ITERATOR.equals(currFieldIter)) { marshal=fields.peek(); - if(marshal==null && fields.hasNext())marshal=fields.next(); - } else if(fields.hasNext()) { + if (marshal==null && fields.hasNext())marshal=fields.next(); + } else if (fields.hasNext()) { marshal=fields.next(); ladder.push(null); } else { marshal=null; } - if(marshal!=null) + if (marshal!=null) parsed = marshal.parse(in, parsed); ladder.descend(); - if(marshal==null || parsed.event==NONE) { + if (marshal==null || parsed.event==NONE) { parsed.event = END_OBJ; ladder.push(DONE_ITERATOR); } @@ -111,7 +111,7 @@ public abstract class ObjMarshal extends Marshal { @Override public Marshal next() { - if(!hasNext()) { + if (!hasNext()) { throw new NoSuchElementException(); } return pml[++idx]; -- cgit 1.2.3-korg