diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-10-15 08:19:50 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-10-15 08:35:35 -0500 |
commit | 1296352d8eafee57f982a4342ad79ada4aa56d28 (patch) | |
tree | 355cdb89d85530a861319f892b0f24236e6adc50 /misc/rosetta/src/main | |
parent | bdce7667a6e272e2fa32e298d957a0d9090c5bc9 (diff) |
Sonar Fixes, Formatting
Issue-ID: AAF-1019
Change-Id: Ica49d9e7323aad9622ff9d95cc21b87430c22c54
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'misc/rosetta/src/main')
35 files changed, 272 insertions, 272 deletions
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 582c750c..ab33c2af 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 @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,7 @@ public class InJson implements Parse<Reader, State> { state.unsent = 0; return parsed; } - + int ch; char c; StringBuilder sb = parsed.sb; @@ -48,7 +48,7 @@ public class InJson implements Parse<Reader, State> { 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. + // Character is a quote. if (c=='"') { if (inQuotes) { if (escaped) { // if escaped Quote, add to data. @@ -112,7 +112,7 @@ public class InJson implements Parse<Reader, State> { parsed.event = c; go = false; break; - + // The Escape Sequence, for Quote marks within Quotes case '\\': // Ignore these, unless within quotes, at which point data-gather @@ -141,7 +141,7 @@ public class InJson implements Parse<Reader, State> { public int braces = 0; public char unsent = 0; } - + // @Override public Parsed<State> newParsed() { return new Parsed<State>(new State()); // no State needed 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 175a2aa2..5cd2b1a5 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 @@ -7,9 +7,9 @@ * 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. @@ -40,7 +40,7 @@ public class InXML implements Parse<Reader, State> { public InXML(JaxInfo jaxInfo) { this.jaxInfo = jaxInfo; } - + public InXML(Class<?> cls, String ... rootNs) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException { jaxInfo = JaxInfo.build(cls,rootNs); } @@ -49,7 +49,7 @@ public class InXML implements Parse<Reader, State> { // @Override public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException { State state = parsed.state; - + // OK, before anything else, see if there is leftover processing, if so, do it! if (state.unevaluated!=null) { DerTag dt = state.unevaluated; @@ -71,7 +71,7 @@ public class InXML implements Parse<Reader, State> { StringBuilder sb = parsed.sb, tempSB = new StringBuilder(); boolean go = true; - + try { while (go && (ch=r.read())>=0) { c = (char)ch; @@ -108,7 +108,7 @@ public class InXML implements Parse<Reader, State> { // don't add Whitespace to start of SB... saves removing later if (sb.length()>0) { sb.append(c); - } else if (!Character.isWhitespace(c)) { + } else if (!Character.isWhitespace(c)) { sb.append(c); } } @@ -119,28 +119,28 @@ public class InXML implements Parse<Reader, State> { throw new ParseException(e); } } - + public static final class DerTag { public String name; public boolean isEndTag; public List<Prop> props; private boolean isXmlInfo; - //private String ns; - + //private String ns; + public DerTag() { name=null; isEndTag = false; props = null; isXmlInfo = false; } - + public DerTag parse(Reader r, StringBuilder sb) throws ParseException { int ch; char c; boolean inQuotes = false, escaped = false; boolean go = true; String tag = null; - + try { if ((ch = r.read())<0) throw new ParseException("Reader content ended before complete"); if (ch=='?') { @@ -210,7 +210,7 @@ public class InXML implements Parse<Reader, State> { } } } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(isEndTag?"End":"Start"); @@ -227,7 +227,7 @@ public class InXML implements Parse<Reader, State> { return sb.toString(); } } - + private static class ArrayState { public boolean firstObj = true; public boolean didNext = false; @@ -244,7 +244,7 @@ public class InXML implements Parse<Reader, State> { unevaluated = null; attribs = null;; } - + public boolean hasAttributes() { return attribs!=null && idx<attribs.size(); } @@ -256,7 +256,7 @@ public class InXML implements Parse<Reader, State> { } attribs.add(prop); } - + public Prop pop() { Prop rv = null; if (attribs!=null) { @@ -266,18 +266,18 @@ public class InXML implements Parse<Reader, State> { return rv; } } - + private static abstract class GreatExpectations { protected JaxInfo ji; protected GreatExpectations prev; private Map<String,String> ns; - + public GreatExpectations(State state, JaxInfo curr, GreatExpectations prev, DerTag derTag) throws ParseException { this.prev = prev; ns = null; ji = getDerived(state, curr,derTag); } - + public abstract boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException; // Recursively look back for any namespaces @@ -301,9 +301,9 @@ public class InXML implements Parse<Reader, State> { private JaxInfo getDerived(State state, JaxInfo ji, DerTag derTag) throws ParseException { if (derTag==null)return ji; - + List<Prop> props = derTag.props; - + Prop derived = null; if (props!=null) { // Load Namespaces (if any) @@ -339,13 +339,13 @@ public class InXML implements Parse<Reader, State> { return derived==null?ji:ji.getDerived(derived.value); } } - + private static class RootExpectations extends GreatExpectations { - + public RootExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException { super(state,curr,prev, null); } - + // @Override public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException { if (derTag.isXmlInfo) { @@ -357,13 +357,13 @@ public class InXML implements Parse<Reader, State> { } else { //parsed.name = derTag.name; parsed.event = START_OBJ; - parsed.state.greatExp = new ObjectExpectations(parsed.state,ji, this, false, derTag); + parsed.state.greatExp = new ObjectExpectations(parsed.state,ji, this, false, derTag); } } return false; } } - + private static class ObjectExpectations extends GreatExpectations { private boolean printName; @@ -413,7 +413,7 @@ public class InXML implements Parse<Reader, State> { return false; } } - + private static class LeafExpectations extends GreatExpectations { public LeafExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException { super(state, curr, prev, null); @@ -429,7 +429,7 @@ public class InXML implements Parse<Reader, State> { throw new ParseException("Expected </" + ji.name + '>'); } return false; - } + } } private static class ArrayExpectations extends GreatExpectations { @@ -445,7 +445,7 @@ public class InXML implements Parse<Reader, State> { if (derTag.isEndTag) { throw new ParseException("Unexpected End Tag </" + derTag.name + '>'); } else { - ArrayState ai = parsed.state.arrayInfo.peek(); + ArrayState ai = parsed.state.arrayInfo.peek(); if (ai.firstObj || ai.didNext) { ai.firstObj = false; ai.didNext = false; @@ -473,7 +473,7 @@ public class InXML implements Parse<Reader, State> { parsed.state.arrayInfo.pop(); } return false; - } + } } // @Override public Parsed<State> newParsed() throws ParseException { @@ -484,5 +484,5 @@ public class InXML implements Parse<Reader, State> { public TimeTaken start(Env env) { return env.start("Rosetta XML In", Env.XML); } - + } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java index cb6d2f8c..7e4617be 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java @@ -7,9 +7,9 @@ * 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. 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 d209f02f..b4d5782a 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 @@ -7,9 +7,9 @@ * 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. @@ -39,7 +39,7 @@ public class JaxInfo { public static final int DATA = 0; public static final int ARRAY = 1; public static final int OBJECT = 2; - + public final String name; public final Class<?> clss; public Map<String, JaxInfo> extensions; // Classes, which might be found at runtime, that extend this class. Lazy Instantiation @@ -50,7 +50,7 @@ public class JaxInfo { public final boolean nillable; public String ns; public boolean isObject() {return members!=null;} - + private JaxInfo(String n, String ns, Class<?> c, JaxInfo[] members, boolean string, boolean array, boolean required, boolean nillable) { name = n; this.ns = ns; @@ -62,14 +62,14 @@ public class JaxInfo { this.nillable = nillable; extensions = null; } - + public int getType() { if (isArray)return ARRAY; else if (members!=null)return OBJECT; return DATA; } - + public JaxInfo getDerived(String derivedName) { JaxInfo derived; // Lazy Instantiation @@ -79,7 +79,7 @@ public class JaxInfo { } else { derived = extensions.get(derivedName); } - + if (derived == null) { //TODO for the moment, Classes are in same package Package pkg = clss.getPackage(); @@ -103,7 +103,7 @@ public class JaxInfo { /** * Build up JAXB Information (recursively) - * + * * @param cls * @param rootNns * @return @@ -117,7 +117,7 @@ public class JaxInfo { } /** * Build up JAXB Information (recursively) - * + * * @param cls * @param rootNns * @return @@ -151,10 +151,10 @@ public class JaxInfo { } } } - + return new JaxInfo(name,defaultNS, cls,buildFields(cls,defaultNS),false,false,false,false); } - + // Build up the name and members of this particular class // This is recursive, if a member is a JAXB Object as well. private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException { @@ -168,12 +168,12 @@ public class JaxInfo { if ("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array Field rf = cls.getDeclaredField(field); Class<?> ft = rf.getType(); - + boolean required = false; boolean nillable = false; String xmlName = field; String namespace = defaultNS; - + XmlElement xe = rf.getAnnotation(XmlElement.class); if (xe!=null) { xmlName=xe.name(); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java index 2d7af059..e480b79d 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java @@ -7,9 +7,9 @@ * 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. @@ -30,9 +30,9 @@ import javax.xml.bind.annotation.XmlType; /** * For specific XML class, quickly find a Setter Method which will load the object - * + * * Object type of Setter must match String at this time. - * + * * @author Jonathan * * @param <T> @@ -65,7 +65,7 @@ public class JaxSet<T> { } } } - + public static abstract class Setter<O> { protected final Method meth; public Setter(Method meth) { 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 6ff627b9..6a0a7252 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 @@ -7,9 +7,9 @@ * 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. @@ -25,9 +25,9 @@ package org.onap.aaf.misc.rosetta; /** * A Ladder is a Stack like Storage Class, but where you can ascend and descend while * the elements exists. - * + * * Like an extension ladder, you can make taller as you go - * + * * @author Jonathan * */ @@ -52,16 +52,16 @@ public class Ladder<T> { public void bottom() { rung = 0; } - + public void top() { rung = struts.length-1; while (rung>0 && struts[rung]==null)--rung; } - + public int howHigh() { return rung; } - + public void jumpTo(int rung) { if (rung>=struts.length) { Object[] temp = new Object[init_size*((rung/init_size)+1)]; @@ -70,17 +70,17 @@ public class Ladder<T> { } this.rung = rung; } - + public int height() { return struts.length; } - + public void cutTo(int rungs) { Object[] temp = new Object[rungs]; System.arraycopy(struts, 0, temp, 0, Math.min(rungs, struts.length)); struts = temp; } - + public void ascend() { ++rung; if (rung>=struts.length) { @@ -89,20 +89,20 @@ public class Ladder<T> { struts = temp; } } - + public void descend() { --rung; } - + @SuppressWarnings("unchecked") public T peek() { return (T)struts[rung]; } - + public void push(T t) { struts[rung]=t; } - + @SuppressWarnings("unchecked") public T pop() { T t = (T)struts[rung]; 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 3729d1e3..933df4aa 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 @@ -7,9 +7,9 @@ * 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. @@ -72,9 +72,9 @@ public abstract class Marshal<T> implements Parse<T, Marshal.State> { /** * Typical definition of Done is when Iterator in Ladder is "DONE_ITERATOR" - * + * * It is important, however, that the "Ladder Rung" is set to the right level. - * + * * @param state * @return */ diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java index d36c07ec..51221bc5 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java @@ -7,9 +7,9 @@ * 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. @@ -48,9 +48,9 @@ public class Nulls { public TimeTaken start(Env env) { return env.start("IN", Env.SUB); } - + }; - + public static final Out OUT = new Out() { // @Override diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java index aa2b2992..660af000 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java @@ -7,9 +7,9 @@ * 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. @@ -28,7 +28,7 @@ import java.io.Writer; public abstract class Out { public abstract<IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException; - + public<IN,S> void extract(IN in, OutputStream os, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException { Writer w = new OutputStreamWriter(os); try { @@ -37,7 +37,7 @@ public abstract class Out { w.flush(); } } - + public abstract String logName(); - + } 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 4fb52d86..9f78c2c7 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 @@ -7,9 +7,9 @@ * 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. @@ -39,9 +39,9 @@ public class OutJax extends Out { if (je==null)throw new ParseException("Incomplete content"); je = je.eval(p); } - + } - + @Override public String logName() { return "Rosetta JAX"; 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 2d93bb49..e2f45d1e 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 @@ -7,9 +7,9 @@ * 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. @@ -50,7 +50,7 @@ public class OutJson extends Out { while ((p = prs.parse(in,p.reuse())).valid()) { ++count; switch(p.event) { - case 1: + case 1: continue; case 2: if (count==2) { // it's empty, write open/close on it's own @@ -64,7 +64,7 @@ public class OutJson extends Out { if (jsonLevel.peek().printObjectName) { print = true; } else { // don't print names on first - print=false; + print=false; } maybe=jsonLevel.peek().listItem(); jsonLevel.push(new LevelStack(true)); @@ -72,9 +72,9 @@ public class OutJson extends Out { case '}': 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, + } else { // No data means just print, p.name = ""; // XML tags come through with names, but no data - } + } print = true; jsonLevel.pop(); afterName = p.event; @@ -94,7 +94,7 @@ public class OutJson extends Out { else maybe = jsonLevel.peek().listItem(); } else { p.name = ""; // XML tags come through with names, but no data - } + } jsonLevel.pop(); print = true; @@ -114,7 +114,7 @@ public class OutJson extends Out { } if (maybe!=0) { - if (ipw==null)writer.append(maybe); + if (ipw==null)writer.append(maybe); else ipw.println(maybe); maybe = 0; } @@ -132,7 +132,7 @@ public class OutJson extends Out { if (p.event==3)writer.append("__"); writer.append(p.name); writer.append("\":"); - } + } if (p.hasData()) { if (p.isString) { writer.append('"'); @@ -171,7 +171,7 @@ public class OutJson extends Out { } afterName = 0; } - + if (ipw!=null) { switch(p.event) { case '[': @@ -206,7 +206,7 @@ public class OutJson extends Out { } } - + } @Override @@ -217,11 +217,11 @@ public class OutJson extends Out { private static class LevelStack { public boolean printObjectName=false; private boolean first_n_List=true; - + public LevelStack(boolean printObjectName) { this.printObjectName = printObjectName; } - + public char listItem() { if (first_n_List) { first_n_List=false; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java index f07498b3..fbdf631d 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java @@ -7,9 +7,9 @@ * 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. @@ -29,13 +29,13 @@ public class OutRaw extends Out{ @Override public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { Parsed<S> 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'); } } - + @Override public String logName() { return "Rosetta RAW"; 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 6472c88e..1004da6e 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 @@ -7,9 +7,9 @@ * 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. @@ -34,9 +34,9 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter; public class OutXML extends Out{ private static final String XMLNS_XSI = "xmlns:xsi"; - public static final String XML_INFO = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; + public static final String XML_INFO = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; public static final String XML_SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance"; - + private String root; private List<Prop> props; @@ -49,27 +49,27 @@ public class OutXML extends Out{ props.add(new Prop(tv[0],tv[1])); } } - + public OutXML(JaxInfo jaxInfo) { this(jaxInfo.name,genNS(jaxInfo)); } - + public OutXML(InXML inXML) { this(inXML.jaxInfo.name,genNS(inXML.jaxInfo)); } - + private static String[] genNS(JaxInfo jaxInfo) { return new String[] {"xmlns=" + jaxInfo.ns}; } - - + + @Override public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { Parsed<S> p = prs.newParsed(); Stack<Level> stack = new Stack<Level>(); // If it's an IndentPrintWriter, it is pretty printing. boolean pretty = (options.length>0&&options[0]); - + IndentPrintWriter ipw; if (pretty) { if (writer instanceof IndentPrintWriter) { @@ -114,22 +114,22 @@ public class OutXML extends Out{ 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(); writer.append(level.sbw.getBuffer()); level = stack.pop(); break; - case Parse.START_ARRAY: + case Parse.START_ARRAY: 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: @@ -141,13 +141,13 @@ public class OutXML extends Out{ writer.append(level.sbw.getBuffer()); writer.flush(); } - + private class Level { public final StringBuilderWriter sbw; public String multi; private Level prev; private Map<String,String> nses; - + public Level(Level level) { sbw = new StringBuilderWriter(); multi = null; @@ -162,18 +162,18 @@ public class OutXML extends Out{ 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<>(); nses.put(ns, value); } return rv; } - - - + + + } - + private boolean tag(Writer fore, Writer aft, boolean pretty, boolean returns, String tag, String data) throws IOException { fore.append('<'); fore.append(tag); @@ -188,7 +188,7 @@ public class OutXML extends Out{ 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 @@ -209,7 +209,7 @@ public class OutXML extends Out{ } } fore.append(' '); - fore.append(realTag); + fore.append(realTag); fore.append("=\""); fore.append(value); fore.append('"'); diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java index d068530c..fe2dd3e2 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java @@ -7,9 +7,9 @@ * 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. @@ -26,20 +26,20 @@ import org.onap.aaf.misc.env.TimeTaken; public interface Parse<IN, S> { public Parsed<S> parse(IN in, Parsed<S> parsed) throws ParseException; - + // EVENTS public static final char NONE = 0; public static final char START_DOC = 1; public static final char END_DOC = 2; public static final char ATTRIB = 3; - + public static final char NEXT = ','; public static final char START_OBJ = '{'; public static final char END_OBJ = '}'; public static final char START_ARRAY = '['; public static final char END_ARRAY = ']'; - + public Parsed<S> newParsed() throws ParseException; - public TimeTaken start(Env env); - + public TimeTaken start(Env env); + } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java index 38ea956a..8b1dd8fe 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java @@ -7,9 +7,9 @@ * 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. 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 29a86de8..739d8e52 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 @@ -7,9 +7,9 @@ * 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. @@ -24,9 +24,9 @@ package org.onap.aaf.misc.rosetta; public class Parsed<S> { public static final String EXTENSION_TAG="extension"; - + public boolean isString; - + public StringBuilder sb; public char event; public String name; @@ -48,7 +48,7 @@ public class Parsed<S> { public boolean valid() { return event!=Parse.NONE; } - + public Parsed<S> reuse() { isString=false; sb.setLength(0); @@ -70,7 +70,7 @@ public class Parsed<S> { public boolean hasData() { return sb.length()>0; } - + public String toString() { StringBuilder sb2 = new StringBuilder(); if (event<40)sb2.append((int)event); 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 d46fc8be..4d414c3c 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 @@ -7,9 +7,9 @@ * 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. @@ -28,13 +28,13 @@ class Prop { tag = t; value =v; } - + public Prop(String t_equals_v) { String[] tv = t_equals_v.split("="); if (tv.length>1) { tag = tv[0]; value = tv[1]; - } + } } public String toString() { 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 efb4ce4b..5e88e3a3 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 @@ -7,9 +7,9 @@ * 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. @@ -31,9 +31,9 @@ import org.onap.aaf.misc.env.TimeTaken; import org.onap.aaf.misc.rosetta.Saved.State; /** - * An Out Object that will save off produced Parsed Stream and + * An Out Object that will save off produced Parsed Stream and * a Parse (In) Object that will reproduce Parsed Stream on demand - * + * * @author Jonathan * */ @@ -43,7 +43,7 @@ public class Saved extends Out implements Parse<Reader, State>{ private Content content[]; private int idx; private boolean append = false; - + /** * Read from Parsed Stream and save */ @@ -59,7 +59,7 @@ public class Saved extends Out implements Parse<Reader, State>{ content[idx]=null; } 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 @@ -72,14 +72,14 @@ public class Saved extends Out implements Parse<Reader, State>{ } } } - + // @Override public Parsed<State> parse(Reader ignore, Parsed<State> 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; + else + parsed.event = Parse.NONE; return parsed; } @@ -113,14 +113,14 @@ public class Saved extends Out implements Parse<Reader, State>{ public static class State { public int count = 0; } - + public static class Content { private boolean isString; private char event; private String name; private List<Prop> props; private String str; - + public Content(Parsed<?> p) { isString = p.isString; event = p.event; @@ -137,7 +137,7 @@ public class Saved extends Out implements Parse<Reader, State>{ if (str!=null) p.sb.append(str); } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(event); @@ -161,7 +161,7 @@ public class Saved extends Out implements Parse<Reader, State>{ return sb.toString(); } } - + //// @Override public Parsed<State> newParsed() { Parsed<State> ps = new Parsed<State>(new State()); @@ -184,7 +184,7 @@ public class Saved extends Out implements Parse<Reader, State>{ public TimeTaken start(Env env) { return env.start(ROSETTA_SAVED, 0); } - + @Override public String logName() { return ROSETTA_SAVED; 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 3007ea95..15f42050 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 @@ -7,9 +7,9 @@ * 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. @@ -28,7 +28,7 @@ import java.util.TreeMap; public class XmlEscape { private XmlEscape() {} - + private static final TreeMap<String,Integer> charMap; // see initialization at end private static final TreeMap<Integer,String> intMap; // see initialization at end @@ -38,7 +38,7 @@ public class XmlEscape { 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!=';') { + if (c!=';') { esc.append((char)c); } else { // evaluate Integer i = charMap.get(esc.toString()); @@ -53,19 +53,19 @@ public class XmlEscape { break; } } - - + + } catch (IOException e) { throw new ParseException(e); } } - + public static void xmlEscape(StringBuilder sb, int chr) { sb.append('&'); sb.append(intMap.get(chr)); sb.append(';'); } - + public static String convert(StringBuilder insb) { int idx, ch; StringBuilder sb=null; @@ -77,9 +77,9 @@ public class XmlEscape { break; } } - + if (sb==null)return insb.toString(); - + for (int i=idx;i<insb.length();++i) { ch = insb.charAt(i); if (ch<160) { @@ -361,7 +361,7 @@ public class XmlEscape { charMap.put("clubs",9827); charMap.put("hearts",9829); charMap.put("diams",9830); - + for ( Entry<String, Integer> 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 a95da8ea..b12cce02 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 @@ -7,9 +7,9 @@ * 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. @@ -56,18 +56,18 @@ import org.onap.aaf.misc.rosetta.ParseException; import org.onap.aaf.misc.rosetta.marshal.DocMarshal; public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { - + static InJson inJSON = new InJson(); InXML inXML; static OutJson outJSON = new OutJson(); OutXML outXML; static OutRaw outRAW = new OutRaw(); - + // Temporary until we write JAXB impl... JAXBmar jaxMar; JAXBumar jaxUmar; - + private Parse<Reader,?> defaultIn; private Out defaultOut; private RosettaEnv env; @@ -75,7 +75,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { private TYPE outType; private int defOption; Marshal<T> marshal = null; - + /** * Private constructor to setup Type specific data manipulators @@ -92,13 +92,13 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { RosettaDF(RosettaEnv env, Schema schema, String rootNs, Class<T> cls) throws APIException { this.env = env; try { - // Note: rootNs can be null, in order to derive content from Class. + // Note: rootNs can be null, in order to derive content from Class. JaxInfo ji = rootNs==null?JaxInfo.build(cls):JaxInfo.build(cls,rootNs); // Note: JAXBmar sets qname to null if not exists jaxMar = new JAXBmar(rootNs==null?null:new QName("xmlns",rootNs),cls); // Note: JAXBumar sets schema to null if not exists jaxUmar = new JAXBumar(schema, cls); - + defaultIn = inXML = new InXML(ji); defaultOut = outXML = new OutXML(ji); inType=outType=Data.TYPE.XML; @@ -107,11 +107,11 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { throw new APIException(e); } } - + // @Override public RosettaData<T> newData() { - RosettaData<T> data = new RosettaData<T>(env, this) + RosettaData<T> data = new RosettaData<T>(env, this) .in(inType) .out(outType) .option(defOption); @@ -141,7 +141,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { /** * If exists, first option is "Pretty", second is "Fragment" - * + * * @param options * @return */ @@ -150,7 +150,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { defaultOut = getOut(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type); return this; } - + public Parse<Reader,?> getIn(Data.TYPE type) { switch(type) { case DEFAULT: @@ -163,7 +163,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { return defaultIn; } } - + public Out getOut(Data.TYPE type) { switch(type) { case DEFAULT: @@ -178,7 +178,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { return defaultOut; } } - + public int logType(org.onap.aaf.misc.env.Data.TYPE ot) { switch(ot) { case JSON: @@ -204,15 +204,15 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { public RosettaDF<T> option(int option) { defOption = option; - + return this; } /** * Assigning Root Marshal Object - * + * * Will wrap with DocMarshal Object if not already - * + * * @param marshal * @return */ @@ -224,7 +224,7 @@ public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { } return this; } - + public void direct(Trans trans, T t, OutputStream os, boolean ... options) throws APIException, IOException { Out out = getOut(outType); TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env? 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 36ebde68..006e8133 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 @@ -7,9 +7,9 @@ * 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. @@ -48,7 +48,7 @@ public class RosettaData<T> implements Data<T>{ private boolean options[] = new boolean[] {false, false}; // Temp Storage of XML. Only when we must use JAXB to read in Objects private String xml,json; - + // package on purpose RosettaData(Env env, RosettaDF<T> rosettaDF) { df = rosettaDF; @@ -57,7 +57,7 @@ public class RosettaData<T> implements Data<T>{ inType = df.getInType(); outType = df.getOutType(); // take defaults } - + //Added for junits void setSaved(Saved saved) { this.saved = saved; @@ -68,7 +68,7 @@ public class RosettaData<T> implements Data<T>{ inType = rosettaType; return this; } - + // // @Override public RosettaData<T> out(TYPE rosettaType) { outType = rosettaType; @@ -89,7 +89,7 @@ public class RosettaData<T> implements Data<T>{ } return this; } - + // @Override public RosettaData<T> load(InputStream is) throws APIException { Parse<Reader,?> in = df.getIn(inType); @@ -119,7 +119,7 @@ public class RosettaData<T> implements Data<T>{ json = str; break; default: - + } } catch (Exception e) { throw new APIException(e); @@ -152,7 +152,7 @@ public class RosettaData<T> implements Data<T>{ public Saved getEvents() { return saved; } - + // @Override public T asObject() throws APIException { Out out = df.getOut(TYPE.XML); @@ -206,7 +206,7 @@ public class RosettaData<T> implements Data<T>{ os.write(xml.getBytes()); } else if (outType==TYPE.JSON && json!=null) { os.write(json.getBytes()); - } else { + } else { out.extract(null, os, saved, options); } } catch (Exception e) { @@ -226,7 +226,7 @@ public class RosettaData<T> implements Data<T>{ writer.append(xml); } else if (outType==TYPE.JSON && json!=null) { writer.append(json); - } else { + } else { out.extract(null, writer, saved, options); } } catch (Exception e) { @@ -236,18 +236,18 @@ public class RosettaData<T> implements Data<T>{ } return this; } - + // @Override public Class<T> getTypeClass() { return df.getTypeClass(); } private static final boolean[] emptyOption = new boolean[0]; - + public void direct(InputStream is, OutputStream os) throws APIException, IOException { direct(is,os,emptyOption); } - + public void direct(Reader reader, Writer writer, boolean ... options) throws APIException, IOException { Parse<Reader,?> in = df.getIn(inType); Out out = df.getOut(outType); @@ -302,7 +302,7 @@ public class RosettaData<T> implements Data<T>{ } } - + public void direct(InputStream is, OutputStream os, boolean ... options) throws APIException, IOException { direct(new InputStreamReader(is),new OutputStreamWriter(os), options); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java index 43855d6c..62d7bc1b 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java @@ -7,9 +7,9 @@ * 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. @@ -32,7 +32,7 @@ import org.onap.aaf.misc.env.APIException; /** * An essential Implementation of Env, which will fully function, without any sort * of configuration. - * + * * Use as a basis for Group level Env, just overriding where needed. * @author Jonathan * @@ -62,7 +62,7 @@ public class RosettaEnv extends org.onap.aaf.misc.env.impl.BasicEnv { public RosettaEnv(Properties props) { super(props); } - + @SuppressWarnings("unchecked") @Override public <T> RosettaDF<T> newDataFactory(Class<?>... classes) throws APIException { 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 0617e01d..e546d6dc 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 @@ -7,9 +7,9 @@ * 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. @@ -26,38 +26,38 @@ import javax.xml.datatype.XMLGregorianCalendar; import org.onap.aaf.misc.env.util.Chrono; /** - * We make these objects instead of static functions so they can be passed into + * We make these objects instead of static functions so they can be passed into * FieldArray. - * + * * @author Jonathan * * @param <T> */ public abstract class DataWriter<T> { public abstract boolean write(T t, StringBuilder sb); - + public final static DataWriter<String> STRING = new DataWriter<String>() { @Override public boolean write(String s, StringBuilder sb) { sb.append(s); return true; - } + } }; - + public final static DataWriter<Integer> INTEGER = new DataWriter<Integer>() { @Override public boolean write(Integer i, StringBuilder sb) { sb.append(i); return false; - } + } }; - + public final static DataWriter<Long> LONG = new DataWriter<Long>() { @Override public boolean write(Long t, StringBuilder sb) { sb.append(t); return false; - } + } }; public final static DataWriter<Byte> BYTE = new DataWriter<Byte>() { @@ -65,7 +65,7 @@ public abstract class DataWriter<T> { public boolean write(Byte t, StringBuilder sb) { sb.append(t); return false; - } + } }; public final static DataWriter<Character> CHAR = new DataWriter<Character>() { @@ -73,7 +73,7 @@ public abstract class DataWriter<T> { public boolean write(Character t, StringBuilder sb) { sb.append(t); return true; - } + } }; public final static DataWriter<Boolean> BOOL = new DataWriter<Boolean>() { @@ -81,7 +81,7 @@ public abstract class DataWriter<T> { public boolean write(Boolean t, StringBuilder sb) { sb.append(t); return true; - } + } }; @@ -99,7 +99,7 @@ public abstract class DataWriter<T> { // } return true; } - + }; */ @@ -110,7 +110,7 @@ public abstract class DataWriter<T> { return true; } }; - + public final static DataWriter<XMLGregorianCalendar> DATE_TIME = new DataWriter<XMLGregorianCalendar>() { @Override public boolean write(XMLGregorianCalendar t, StringBuilder sb) { @@ -123,7 +123,7 @@ public abstract class DataWriter<T> { public final static DataWriter<byte[]> HEX_BINARY = new DataWriter<byte[]>() { @Override public boolean write(byte[] ba, StringBuilder sb) { - // FYI, doing this because don't want intermediate + // FYI, doing this because don't want intermediate // String in "HexString" or the processing in // "String.format" //sb.append("0x"); 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 1fa17010..1a7ec972 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 @@ -7,9 +7,9 @@ * 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. @@ -31,11 +31,11 @@ import org.onap.aaf.misc.rosetta.Parsed; public class DocMarshal<T> extends Marshal<T> { private Marshal<T> root; - + public DocMarshal(Marshal<T> root) { this.root = root; } - + @Override public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException { Ladder<Iterator<?>> ladder = parsed.state.ladder; 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 abc19b26..d91286af 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 @@ -7,9 +7,9 @@ * 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. @@ -38,7 +38,7 @@ public abstract class FieldArray<T,S> extends Marshal<T> { this.name = name; dataWriter = dw; } - + @SuppressWarnings("unchecked") @Override public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException { @@ -69,7 +69,7 @@ public abstract class FieldArray<T,S> extends Marshal<T> { } else { mem=null; } - + if (mem!=null) { parsed.isString=dataWriter.write(mem, parsed.sb); parsed.event = NEXT; diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java index 34fa5dd6..9849bf43 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java @@ -7,9 +7,9 @@ * 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. @@ -26,12 +26,12 @@ public abstract class FieldBlob<T> extends FieldMarshal<T>{ super(name); } - protected abstract byte[] data(T t); + protected abstract byte[] data(T t); @Override protected boolean data(T t, StringBuilder sb) { return false; - // unimplemented + // unimplemented //return DataWriter.BYTE_ARRAY.write(data(t),sb); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java index 2418d7af..e0f837a7 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java @@ -7,9 +7,9 @@ * 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. @@ -33,5 +33,5 @@ public abstract class FieldDate<T> extends FieldMarshal<T> { return DataWriter.DATE.write(data(t), sb); } - protected abstract XMLGregorianCalendar data(T t); + protected abstract XMLGregorianCalendar data(T t); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java index ae125617..aa7623cf 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java @@ -7,9 +7,9 @@ * 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. @@ -33,5 +33,5 @@ public abstract class FieldDateTime<T> extends FieldMarshal<T> { return DataWriter.DATE_TIME.write(data(t), sb); } - protected abstract XMLGregorianCalendar data(T t); + protected abstract XMLGregorianCalendar data(T t); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java index fa9e6323..668aede6 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java @@ -7,9 +7,9 @@ * 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. @@ -26,7 +26,7 @@ public abstract class FieldHexBinary<T> extends FieldMarshal<T>{ super(name); } - protected abstract byte[] data(T t); + protected abstract byte[] data(T t); @Override protected boolean data(T t, StringBuilder sb) { diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java index 2e77618b..d76c65a2 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java @@ -7,9 +7,9 @@ * 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. @@ -32,11 +32,11 @@ public abstract class FieldMarshal<T> extends Marshal<T> { public FieldMarshal(String name) { this.name = name; } - + public String getName() { return name; } - + @Override public Parsed<State> parse(T t, Parsed<State> parsed) { parsed.state.ladder.push(DONE_ITERATOR); @@ -55,5 +55,5 @@ public abstract class FieldMarshal<T> extends Marshal<T> { * @return */ protected abstract boolean data(T t, StringBuilder sb); - + }
\ No newline at end of file diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java index 0a5c28ad..072775bc 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java @@ -7,9 +7,9 @@ * 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. @@ -32,5 +32,5 @@ public abstract class FieldNumeric<N,T> extends FieldMarshal<T> { return false; } - protected abstract N data(T t); + protected abstract N data(T t); } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java index e96b6967..d0b1e486 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java @@ -7,9 +7,9 @@ * 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. @@ -26,7 +26,7 @@ public abstract class FieldString<T> extends FieldMarshal<T> { super(name); } - protected abstract String data(T t); + protected abstract String data(T t); @Override final protected boolean data(T t, StringBuilder sb) { diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java index ed8b98c4..4bc23449 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java @@ -7,9 +7,9 @@ * 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. @@ -35,7 +35,7 @@ final class ListIterator<T> implements Iterator<T> { private Iterator<T> delg; public ListIterator(List<T> list) { curr = null; - delg = list.iterator(); + delg = list.iterator(); } @Override public boolean hasNext() { @@ -46,7 +46,7 @@ final class ListIterator<T> implements Iterator<T> { public T next() { return curr = delg.hasNext()?delg.next():null; } - + public T peek() { return curr==null?next():curr; } @@ -55,5 +55,5 @@ final class ListIterator<T> implements Iterator<T> { public void remove() { delg.remove(); } - + }
\ No newline at end of file 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 9c64e83d..f6685234 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 @@ -7,9 +7,9 @@ * 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. 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 d96a44d0..3f5d3732 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 @@ -7,9 +7,9 @@ * 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. @@ -41,23 +41,23 @@ public abstract class ObjMarshal<T> extends Marshal<T> { // Note: Not Using List or ArrayList, because there is no "Peek" concept in their iterator. private Marshal<T>[] pml; private int end=0; - + /** * @param pm */ @SuppressWarnings("unchecked") protected void add(Marshal<T> pm) { if (pml==null) { - pml = new Marshal[Ladder.DEFAULT_INIT_SIZE]; + pml = new Marshal[Ladder.DEFAULT_INIT_SIZE]; } else if (end>pml.length) { - Object temp[] = pml; + Object temp[] = pml; pml = new Marshal[pml.length+Ladder.DEFAULT_INIT_SIZE]; System.arraycopy(temp, 0, pml, 0, pml.length); } pml[end]=pm; ++end; } - + /* (non-Javadoc) * @see org.onap.aaf.misc.rosetta.Parse#parse(java.lang.Object, org.onap.aaf.misc.rosetta.Parsed) */ @@ -120,12 +120,12 @@ public abstract class ObjMarshal<T> extends Marshal<T> { public Marshal<T> peek() { return idx<0?null:pml[idx]; } - + @Override public void remove() { pml[idx]=null; } - + } } |