X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Futil%2FCSV.java;h=ed4fcde69120a92e950a5c2f43abe736a0ef97ef;hb=a6baa197a8a0333bc90e03a135441cacb7a133b9;hp=c7fada74437fa9d54304940be20a951c58f97b41;hpb=f95fc5f7ae9cf1832eae2451be883477bbd08f16;p=aaf%2Fauthz.git diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java index c7fada74..ed4fcde6 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java @@ -138,33 +138,41 @@ public class CSV { private Writer(final boolean append) throws FileNotFoundException { ps = new PrintStream(new FileOutputStream(csv,append)); } - public void row(Object ... strings) { - if(strings.length>0) { + public void row(Object ... objs) { + if(objs.length>0) { boolean first = true; - boolean quote; - String s; - for(Object o : strings) { + for(Object o : objs) { if(first) { first = false; } else { ps.append(','); } - s = o.toString(); - quote = s.matches(".*[,|\"].*"); - if(quote) { - ps.append('"'); - ps.print(s.replace("\"", "\"\"") - .replace("'", "''") - .replace("\\", "\\\\")); - ps.append('"'); + if(o instanceof String[]) { + for(String str : (String[])o) { + print(str); + } } else { - ps.append(s); + print(o.toString()); } } ps.println(); } } + private void print(String s) { + boolean quote = s.matches(".*[,|\"].*"); + if(quote) { + ps.append('"'); + ps.print(s.replace("\"", "\"\"") + .replace("'", "''") + .replace("\\", "\\\\")); + ps.append('"'); + } else { + ps.append(s); + } + + + } /** * Note: CSV files do not actually support Comments as a standard, but it is useful * @param comment