Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$CSVRecordIterator.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$CSVRecordIterator.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$CSVRecordIterator.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVParser.CSVRecordIterator</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.html" class="el_package">org.apache.commons.csv</a> > <span class="el_class">CSVParser.CSVRecordIterator</span></div><h1>CSVParser.CSVRecordIterator</h1><table class="coverage" ce llspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">19 of 82</td><td class="ctr2">76%</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class=" ctr1">0</td><td class="ctr2">11</td><td class="ctr1">3</td><td class="ctr2">20</td><td class="ctr1">0</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a1"><a href="CSVParser.java.html#L142" class="el_method">getNextRecord()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="78" height="10" title="19" alt="19"/><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="4" alt="4"/></td><td class="ctr2" id="c4">17%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h0">3</td><td class="ctr2" id="i2">4</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a3"><a href="CSVParser.java.html#L163" class="el_method">next()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="29" alt="29"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src=".. /jacoco-resources/greenbar.gif" width="120" height="10" title="6" alt="6"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g0">4</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i0">9</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="CSVParser.java.html#L151" class="el_method">hasNext()</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="82" height="10" title="20" alt="20"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="6" alt="6"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g1">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i1">5</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a0"><a href="CSVParser.java.html#L137" class="el_method">CSVParser.CSVRecordIterator(CSVParser)</a></ td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="24" height="10" title="6" alt="6"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a4"><a href="CSVParser.java.html#L182" class="el_method">remove()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCo Co</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file
Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$Headers.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$Headers.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser$Headers.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVParser.Headers</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.html" class="el_package">org.apache.commons.csv</a> > <span class="el_class">CSVParser.Headers</span></div><h1>CSVParser.Headers</h1><table class="coverage" cellspacing="0" id="coveragetabl e"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</t d><td class="ctr1">0</td><td class="ctr2">4</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="CSVParser.java.html#L462" class="el_method">CSVParser.Headers(Map, List)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">4</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVParser</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.html" class="el_package">org.apache.commons.csv</a> > <span class="el_class">CSVParser</span></div><h1>CSVParser</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class= "sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">29 of 552</td><td class="ctr2">94%</td><td class="bar">3 of 70</td><td class="ctr2">95%</td><td class="ctr1">3</td><td class="ctr2">59</td><td class="ctr1">2 </td><td class="ctr2">122</td><td class="ctr1">0</td><td class="ctr2">22</td></tr></tfoot><tbody><tr><td id="a15"><a href="CSVParser.java.html#L668" class="el_method">nextRecord()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="23" height="10" title="29" alt="29"/><img src="../jacoco-resources/greenbar.gif" width="88" height="10" title="109" alt="109"/></td><td class="ctr2" id="c21">78%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="6" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="46" height="10" title="14" alt="14"/></td><td class="ctr2" id="e5">87%</td><td class="ctr1" id="f0">2</td><td class="ctr2" id="g1">11</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i1">27</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a3"><a href="CSVParser.java.html#L475" class="el_method">createHeaders()</a></td><td class="bar" id="b1"><img src="../jacoco-resourc es/greenbar.gif" width="120" height="10" title="148" alt="148"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="36" alt="36"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g0">19</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i0">35</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a5"><a href="CSVParser.java.html#L345" class="el_method">CSVParser(Reader, CSVFormat, long, long)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="46" height="10" title="57" alt="57"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d7"/><td class="ctr2" id="e7">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g7">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">14</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a0"><a href="CSVPa rser.java.html#L420" class="el_method">addRecordValue(boolean)</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="32" height="10" title="40" alt="40"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d3"><img src="../jacoco-resources/greenbar.gif" width="33" height="10" title="10" alt="10"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g2">6</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">7</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a21"><a href="CSVParser.java.html#L325" class="el_method">parse(URL, Charset, CSVFormat)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="20" alt="20"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d8"/><td class="ctr2" id="e8">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g8">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i 5">4</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a16"><a href="CSVParser.java.html#L203" class="el_method">parse(File, Charset, CSVFormat)</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="15" height="10" title="19" alt="19"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d9"/><td class="ctr2" id="e9">n/a</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g9">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i7">3</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a12"><a href="CSVParser.java.html#L627" class="el_method">getRecords()</a></td><td class="bar" id="b6"><img src="../jacoco-resources/greenbar.gif" width="12" height="10" title="16" alt="16"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d4"><img src="../jacoco-resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" id=" f7">0</td><td class="ctr2" id="g3">2</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i6">4</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">1</td></tr><tr><td id="a20"><a href="CSVParser.java.html#L296" class="el_method">parse(String, CSVFormat)</a></td><td class="bar" id="b7"><img src="../jacoco-resources/greenbar.gif" width="12" height="10" title="15" alt="15"/></td><td class="ctr2" id="c6">100%</td><td class="bar" id="d10"/><td class="ctr2" id="e10">n/a</td><td class="ctr1" id="f8">0</td><td class="ctr2" id="g10">1</td><td class="ctr1" id="h7">0</td><td class="ctr2" id="i8">3</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a17"><a href="CSVParser.java.html#L232" class="el_method">parse(InputStream, Charset, CSVFormat)</a></td><td class="bar" id="b8"><img src="../jacoco-resources/greenbar.gif" width="11" height="10" title="14" alt="14"/></td><td class="ctr2" id="c7">100%</td><td class="bar" id="d11"/><td class="ctr2" id="e11">n /a</td><td class="ctr1" id="f9">0</td><td class="ctr2" id="g11">1</td><td class="ctr1" id="h8">0</td><td class="ctr2" id="i9">3</td><td class="ctr1" id="j8">0</td><td class="ctr2" id="k8">1</td></tr><tr><td id="a18"><a href="CSVParser.java.html#L254" class="el_method">parse(Path, Charset, CSVFormat)</a></td><td class="bar" id="b9"><img src="../jacoco-resources/greenbar.gif" width="11" height="10" title="14" alt="14"/></td><td class="ctr2" id="c8">100%</td><td class="bar" id="d12"/><td class="ctr2" id="e12">n/a</td><td class="ctr1" id="f10">0</td><td class="ctr2" id="g12">1</td><td class="ctr1" id="h9">0</td><td class="ctr2" id="i10">3</td><td class="ctr1" id="j9">0</td><td class="ctr2" id="k9">1</td></tr><tr><td id="a8"><a href="CSVParser.java.html#L566" class="el_method">getHeaderMap()</a></td><td class="bar" id="b10"><img src="../jacoco-resources/greenbar.gif" width="11" height="10" title="14" alt="14"/></td><td class="ctr2" id="c9">100%</td><td class="bar" id="d5"><img src="../ja coco-resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e3">100%</td><td class="ctr1" id="f11">0</td><td class="ctr2" id="g4">2</td><td class="ctr1" id="h10">0</td><td class="ctr2" id="i4">5</td><td class="ctr1" id="j10">0</td><td class="ctr2" id="k10">1</td></tr><tr><td id="a2"><a href="CSVParser.java.html#L443" class="el_method">createEmptyHeaderMap()</a></td><td class="bar" id="b11"><img src="../jacoco-resources/greenbar.gif" width="10" height="10" title="13" alt="13"/></td><td class="ctr2" id="c10">100%</td><td class="bar" id="d6"><img src="../jacoco-resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e4">100%</td><td class="ctr1" id="f12">0</td><td class="ctr2" id="g5">2</td><td class="ctr1" id="h11">0</td><td class="ctr2" id="i13">1</td><td class="ctr1" id="j11">0</td><td class="ctr2" id="k11">1</td></tr><tr><td id="a4"><a href="CSVParser.java.html#L378" class="el_method">CSVParser(Reader, CSVFormat )</a></td><td class="bar" id="b12"><img src="../jacoco-resources/greenbar.gif" width="5" height="10" title="7" alt="7"/></td><td class="ctr2" id="c11">100%</td><td class="bar" id="d13"/><td class="ctr2" id="e13">n/a</td><td class="ctr1" id="f13">0</td><td class="ctr2" id="g13">1</td><td class="ctr1" id="h12">0</td><td class="ctr2" id="i12">2</td><td class="ctr1" id="j12">0</td><td class="ctr2" id="k12">1</td></tr><tr><td id="a1"><a href="CSVParser.java.html#L437" class="el_method">close()</a></td><td class="bar" id="b13"><img src="../jacoco-resources/greenbar.gif" width="5" height="10" title="7" alt="7"/></td><td class="ctr2" id="c12">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="3" height="10" title="1" alt="1"/></td><td class="ctr2" id="e6">50%</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g6">2</td><td class="ctr1" id="h13">0</td><td class="ctr2" id=" i11">3</td><td class="ctr1" id="j13">0</td><td class="ctr2" id="k13">1</td></tr><tr><td id="a19"><a href="CSVParser.java.html#L279" class="el_method">parse(Reader, CSVFormat)</a></td><td class="bar" id="b14"><img src="../jacoco-resources/greenbar.gif" width="4" height="10" title="6" alt="6"/></td><td class="ctr2" id="c13">100%</td><td class="bar" id="d14"/><td class="ctr2" id="e14">n/a</td><td class="ctr1" id="f14">0</td><td class="ctr2" id="g14">1</td><td class="ctr1" id="h14">0</td><td class="ctr2" id="i14">1</td><td class="ctr1" id="j14">0</td><td class="ctr2" id="k14">1</td></tr><tr><td id="a6"><a href="CSVParser.java.html#L540" class="el_method">getCurrentLineNumber()</a></td><td class="bar" id="b15"><img src="../jacoco-resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c14">100%</td><td class="bar" id="d15"/><td class="ctr2" id="e15">n/a</td><td class="ctr1" id="f15">0</td><td class="ctr2" id="g15">1</td><td class="ctr1" id="h15">0</td>< td class="ctr2" id="i15">1</td><td class="ctr1" id="j15">0</td><td class="ctr2" id="k15">1</td></tr><tr><td id="a7"><a href="CSVParser.java.html#L550" class="el_method">getFirstEndOfLine()</a></td><td class="bar" id="b16"><img src="../jacoco-resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c15">100%</td><td class="bar" id="d16"/><td class="ctr2" id="e16">n/a</td><td class="ctr1" id="f16">0</td><td class="ctr2" id="g16">1</td><td class="ctr1" id="h16">0</td><td class="ctr2" id="i16">1</td><td class="ctr1" id="j16">0</td><td class="ctr2" id="k16">1</td></tr><tr><td id="a13"><a href="CSVParser.java.html#L640" class="el_method">isClosed()</a></td><td class="bar" id="b17"><img src="../jacoco-resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c16">100%</td><td class="bar" id="d17"/><td class="ctr2" id="e17">n/a</td><td class="ctr1" id="f17">0</td><td class="ctr2" id="g17">1</td><td class="ctr1" id="h17">0</t d><td class="ctr2" id="i17">1</td><td class="ctr1" id="j17">0</td><td class="ctr2" id="k17">1</td></tr><tr><td id="a9"><a href="CSVParser.java.html#L580" class="el_method">getHeaderMapRaw()</a></td><td class="bar" id="b18"><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="3" alt="3"/></td><td class="ctr2" id="c17">100%</td><td class="bar" id="d18"/><td class="ctr2" id="e18">n/a</td><td class="ctr1" id="f18">0</td><td class="ctr2" id="g18">1</td><td class="ctr1" id="h18">0</td><td class="ctr2" id="i18">1</td><td class="ctr1" id="j18">0</td><td class="ctr2" id="k18">1</td></tr><tr><td id="a10"><a href="CSVParser.java.html#L596" class="el_method">getHeaderNames()</a></td><td class="bar" id="b19"><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="3" alt="3"/></td><td class="ctr2" id="c18">100%</td><td class="bar" id="d19"/><td class="ctr2" id="e19">n/a</td><td class="ctr1" id="f19">0</td><td class="ctr2" id="g19">1</td><td class="ctr1" id="h1 9">0</td><td class="ctr2" id="i19">1</td><td class="ctr1" id="j19">0</td><td class="ctr2" id="k19">1</td></tr><tr><td id="a11"><a href="CSVParser.java.html#L610" class="el_method">getRecordNumber()</a></td><td class="bar" id="b20"><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="3" alt="3"/></td><td class="ctr2" id="c19">100%</td><td class="bar" id="d20"/><td class="ctr2" id="e20">n/a</td><td class="ctr1" id="f20">0</td><td class="ctr2" id="g20">1</td><td class="ctr1" id="h20">0</td><td class="ctr2" id="i20">1</td><td class="ctr1" id="j20">0</td><td class="ctr2" id="k20">1</td></tr><tr><td id="a14"><a href="CSVParser.java.html#L657" class="el_method">iterator()</a></td><td class="bar" id="b21"><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="3" alt="3"/></td><td class="ctr2" id="c20">100%</td><td class="bar" id="d21"/><td class="ctr2" id="e21">n/a</td><td class="ctr1" id="f21">0</td><td class="ctr2" id="g21">1</td><td class="ctr1" id=" h21">0</td><td class="ctr2" id="i21">1</td><td class="ctr1" id="j21">0</td><td class="ctr2" id="k21">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.java.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.java.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVParser.java.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1,713 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVParser.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.source.html" class="el_package">org.apache.commons.csv</a> > <span class="el_source">CSVParser.ja va</span></div><h1>CSVParser.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.csv; + +import static org.apache.commons.csv.Token.Type.TOKEN; + +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.TreeMap; + +/** + * Parses CSV files according to the specified format. + * + * Because CSV appears in many different dialects, the parser supports many formats by allowing the + * specification of a {@link CSVFormat}. + * + * The parser works record wise. It is not possible to go back, once a record has been parsed from the input stream. + * + * <h2>Creating instances</h2> + * <p> + * There are several static factory methods that can be used to create instances for various types of resources: + * </p> + * <ul> + * <li>{@link #parse(java.io.File, Charset, CSVFormat)}</li> + * <li>{@link #parse(String, CSVFormat)}</li> + * <li>{@link #parse(java.net.URL, java.nio.charset.Charset, CSVFormat)}</li> + * </ul> + * <p> + * Alternatively parsers can also be created by passing a {@link Reader} directly to the sole constructor. + * + * For those who like fluent APIs, parsers can be created using {@link CSVFormat#parse(java.io.Reader)} as a shortcut: + * </p> + * <pre> + * for(CSVRecord record : CSVFormat.EXCEL.parse(in)) { + * ... + * } + * </pre> + * + * <h2>Parsing record wise</h2> + * <p> + * To parse a CSV input from a file, you write: + * </p> + * + * <pre> + * File csvData = new File(&quot;/path/to/csv&quot;); + * CSVParser parser = CSVParser.parse(csvData, CSVFormat.RFC4180); + * for (CSVRecord csvRecord : parser) { + * ... + * } + * </pre> + * + * <p> + * This will read the parse the contents of the file using the + * <a href="http://tools.ietf.org/html/rfc4180" target="_blank">RFC 4180</a> format. + * </p> + * + * <p> + * To parse CSV input in a format like Excel, you write: + * </p> + * + * <pre> + * CSVParser parser = CSVParser.parse(csvData, CSVFormat.EXCEL); + * for (CSVRecord csvRecord : parser) { + * ... + * } + * </pre> + * + * <p> + * If the predefined formats don't match the format at hands, custom formats can be defined. More information about + * customising CSVFormats is available in {@link CSVFormat CSVFormat Javadoc}. + * </p> + * + * <h2>Parsing into memory</h2> + * <p> + * If parsing record wise is not desired, the contents of the input can be read completely into memory. + * </p> + * + * <pre> + * Reader in = new StringReader(&quot;a;b\nc;d&quot;); + * CSVParser parser = new CSVParser(in, CSVFormat.EXCEL); + * List&lt;CSVRecord&gt; list = parser.getRecords(); + * </pre> + * + * <p> + * There are two constraints that have to be kept in mind: + * </p> + * + * <ol> + * <li>Parsing into memory starts at the current position of the parser. If you have already parsed records from + * the input, those records will not end up in the in memory representation of your CSV data.</li> + * <li>Parsing into memory may consume a lot of system resources depending on the input. For example if you're + * parsing a 150MB file of CSV data the contents will be read completely into memory.</li> + * </ol> + * + * <h2>Notes</h2> + * <p> + * Internal parser state is completely covered by the format and the reader-state. + * </p> + * + * @see <a href="package-summary.html">package documentation for more details</a> + */ +public final class CSVParser implements Iterable<CSVRecord>, Closeable { + +<span class="fc" id="L137"> class CSVRecordIterator implements Iterator<CSVRecord> {</span> + private CSVRecord current; + + private CSVRecord getNextRecord() { + try { +<span class="fc" id="L142"> return CSVParser.this.nextRecord();</span> +<span class="nc" id="L143"> } catch (final IOException e) {</span> +<span class="nc" id="L144"> throw new IllegalStateException(</span> +<span class="nc" id="L145"> e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);</span> + } + } + + @Override + public boolean hasNext() { +<span class="fc bfc" id="L151" title="All 2 branches covered."> if (CSVParser.this.isClosed()) {</span> +<span class="fc" id="L152"> return false;</span> + } +<span class="fc bfc" id="L154" title="All 2 branches covered."> if (this.current == null) {</span> +<span class="fc" id="L155"> this.current = this.getNextRecord();</span> + } + +<span class="fc bfc" id="L158" title="All 2 branches covered."> return this.current != null;</span> + } + + @Override + public CSVRecord next() { +<span class="fc bfc" id="L163" title="All 2 branches covered."> if (CSVParser.this.isClosed()) {</span> +<span class="fc" id="L164"> throw new NoSuchElementException("CSVParser has been closed");</span> + } +<span class="fc" id="L166"> CSVRecord next = this.current;</span> +<span class="fc" id="L167"> this.current = null;</span> + +<span class="fc bfc" id="L169" title="All 2 branches covered."> if (next == null) {</span> + // hasNext() wasn't called before +<span class="fc" id="L171"> next = this.getNextRecord();</span> +<span class="fc bfc" id="L172" title="All 2 branches covered."> if (next == null) {</span> +<span class="fc" id="L173"> throw new NoSuchElementException("No more CSV records available");</span> + } + } + +<span class="fc" id="L177"> return next;</span> + } + + @Override + public void remove() { +<span class="fc" id="L182"> throw new UnsupportedOperationException();</span> + } + } + + /** + * Creates a parser for the given {@link File}. + * + * @param file + * a CSV file. Must not be null. + * @param charset + * A Charset + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new parser + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either file or format are null. + * @throws IOException + * If an I/O error occurs + */ + @SuppressWarnings("resource") + public static CSVParser parse(final File file, final Charset charset, final CSVFormat format) throws IOException { +<span class="fc" id="L203"> Assertions.notNull(file, "file");</span> +<span class="fc" id="L204"> Assertions.notNull(format, "format");</span> +<span class="fc" id="L205"> return new CSVParser(new InputStreamReader(new FileInputStream(file), charset), format);</span> + } + + /** + * Creates a CSV parser using the given {@link CSVFormat}. + * + * <p> + * If you do not read all records from the given {@code reader}, you should call {@link #close()} on the parser, + * unless you close the {@code reader}. + * </p> + * + * @param inputStream + * an InputStream containing CSV-formatted input. Must not be null. + * @param charset + * a Charset. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new CSVParser configured with the given reader and format. + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either reader or format are null. + * @throws IOException + * If there is a problem reading the header or skipping the first record + * @since 1.5 + */ + @SuppressWarnings("resource") + public static CSVParser parse(final InputStream inputStream, final Charset charset, final CSVFormat format) + throws IOException { +<span class="fc" id="L232"> Assertions.notNull(inputStream, "inputStream");</span> +<span class="fc" id="L233"> Assertions.notNull(format, "format");</span> +<span class="fc" id="L234"> return parse(new InputStreamReader(inputStream, charset), format);</span> + } + + /** + * Creates a parser for the given {@link Path}. + * + * @param path + * a CSV file. Must not be null. + * @param charset + * A Charset + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new parser + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either file or format are null. + * @throws IOException + * If an I/O error occurs + * @since 1.5 + */ + public static CSVParser parse(final Path path, final Charset charset, final CSVFormat format) throws IOException { +<span class="fc" id="L254"> Assertions.notNull(path, "path");</span> +<span class="fc" id="L255"> Assertions.notNull(format, "format");</span> +<span class="fc" id="L256"> return parse(Files.newInputStream(path), charset, format);</span> + } + + /** + * Creates a CSV parser using the given {@link CSVFormat} + * + * <p> + * If you do not read all records from the given {@code reader}, you should call {@link #close()} on the parser, + * unless you close the {@code reader}. + * </p> + * + * @param reader + * a Reader containing CSV-formatted input. Must not be null. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new CSVParser configured with the given reader and format. + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either reader or format are null. + * @throws IOException + * If there is a problem reading the header or skipping the first record + * @since 1.5 + */ + public static CSVParser parse(final Reader reader, final CSVFormat format) throws IOException { +<span class="fc" id="L279"> return new CSVParser(reader, format);</span> + } + + /** + * Creates a parser for the given {@link String}. + * + * @param string + * a CSV string. Must not be null. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new parser + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either string or format are null. + * @throws IOException + * If an I/O error occurs + */ + public static CSVParser parse(final String string, final CSVFormat format) throws IOException { +<span class="fc" id="L296"> Assertions.notNull(string, "string");</span> +<span class="fc" id="L297"> Assertions.notNull(format, "format");</span> + +<span class="fc" id="L299"> return new CSVParser(new StringReader(string), format);</span> + } + + // the following objects are shared to reduce garbage + + /** + * Creates a parser for the given URL. + * + * <p> + * If you do not read all records from the given {@code url}, you should call {@link #close()} on the parser, unless + * you close the {@code url}. + * </p> + * + * @param url + * a URL. Must not be null. + * @param charset + * the charset for the resource. Must not be null. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @return a new parser + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either url, charset or format are null. + * @throws IOException + * If an I/O error occurs + */ + public static CSVParser parse(final URL url, final Charset charset, final CSVFormat format) throws IOException { +<span class="fc" id="L325"> Assertions.notNull(url, "url");</span> +<span class="fc" id="L326"> Assertions.notNull(charset, "charset");</span> +<span class="fc" id="L327"> Assertions.notNull(format, "format");</span> + +<span class="fc" id="L329"> return new CSVParser(new InputStreamReader(url.openStream(), charset), format);</span> + } + + private final CSVFormat format; + + /** A mapping of column names to column indices */ + private final Map<String, Integer> headerMap; + + /** The column order to avoid re-computing it. */ + private final List<String> headerNames; + + private final Lexer lexer; + + private final CSVRecordIterator csvRecordIterator; + + /** A record buffer for getRecord(). Grows as necessary and is reused. */ +<span class="fc" id="L345"> private final List<String> recordList = new ArrayList<>();</span> + + /** + * The next record number to assign. + */ + private long recordNumber; + + /** + * Lexer offset when the parser does not start parsing at the beginning of the source. Usually used in combination + * with {@link #recordNumber}. + */ + private final long characterOffset; + +<span class="fc" id="L358"> private final Token reusableToken = new Token();</span> + + /** + * Customized CSV parser using the given {@link CSVFormat} + * + * <p> + * If you do not read all records from the given {@code reader}, you should call {@link #close()} on the parser, + * unless you close the {@code reader}. + * </p> + * + * @param reader + * a Reader containing CSV-formatted input. Must not be null. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either reader or format are null. + * @throws IOException + * If there is a problem reading the header or skipping the first record + */ + public CSVParser(final Reader reader, final CSVFormat format) throws IOException { +<span class="fc" id="L378"> this(reader, format, 0, 1);</span> +<span class="fc" id="L379"> }</span> + + /** + * Customized CSV parser using the given {@link CSVFormat} + * + * <p> + * If you do not read all records from the given {@code reader}, you should call {@link #close()} on the parser, + * unless you close the {@code reader}. + * </p> + * + * @param reader + * a Reader containing CSV-formatted input. Must not be null. + * @param format + * the CSVFormat used for CSV parsing. Must not be null. + * @param characterOffset + * Lexer offset when the parser does not start parsing at the beginning of the source. + * @param recordNumber + * The next record number to assign + * @throws IllegalArgumentException + * If the parameters of the format are inconsistent or if either reader or format are null. + * @throws IOException + * If there is a problem reading the header or skipping the first record + * @since 1.1 + */ + @SuppressWarnings("resource") + public CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber) +<span class="fc" id="L405"> throws IOException {</span> +<span class="fc" id="L406"> Assertions.notNull(reader, "reader");</span> +<span class="fc" id="L407"> Assertions.notNull(format, "format");</span> + +<span class="fc" id="L409"> this.format = format;</span> +<span class="fc" id="L410"> this.lexer = new Lexer(format, new ExtendedBufferedReader(reader));</span> +<span class="fc" id="L411"> this.csvRecordIterator = new CSVRecordIterator();</span> +<span class="fc" id="L412"> final Headers headers = createHeaders();</span> +<span class="fc" id="L413"> this.headerMap = headers.headerMap;</span> +<span class="fc" id="L414"> this.headerNames = headers.headerNames;</span> +<span class="fc" id="L415"> this.characterOffset = characterOffset;</span> +<span class="fc" id="L416"> this.recordNumber = recordNumber - 1;</span> +<span class="fc" id="L417"> }</span> + + private void addRecordValue(final boolean lastRecord) { +<span class="fc" id="L420"> final String input = this.reusableToken.content.toString();</span> +<span class="fc bfc" id="L421" title="All 2 branches covered."> final String inputClean = this.format.getTrim() ? input.trim() : input;</span> +<span class="fc bfc" id="L422" title="All 6 branches covered."> if (lastRecord && inputClean.isEmpty() && this.format.getTrailingDelimiter()) {</span> +<span class="fc" id="L423"> return;</span> + } +<span class="fc" id="L425"> final String nullString = this.format.getNullString();</span> +<span class="fc bfc" id="L426" title="All 2 branches covered."> this.recordList.add(inputClean.equals(nullString) ? null : inputClean);</span> +<span class="fc" id="L427"> }</span> + + /** + * Closes resources. + * + * @throws IOException + * If an I/O error occurs + */ + @Override + public void close() throws IOException { +<span class="pc bpc" id="L437" title="1 of 2 branches missed."> if (this.lexer != null) {</span> +<span class="fc" id="L438"> this.lexer.close();</span> + } +<span class="fc" id="L440"> }</span> + + private Map<String, Integer> createEmptyHeaderMap() { +<span class="fc bfc" id="L443" title="All 2 branches covered."> return this.format.getIgnoreHeaderCase() ?</span> + new TreeMap<>(String.CASE_INSENSITIVE_ORDER) : + new LinkedHashMap<>(); + } + + /** + * Header information based on name and position. + */ + private static final class Headers { + /** + * Header column positions (0-based) + */ + final Map<String, Integer> headerMap; + + /** + * Header names in column order + */ + final List<String> headerNames; + +<span class="fc" id="L462"> Headers(final Map<String, Integer> headerMap, final List<String> headerNames) {</span> +<span class="fc" id="L463"> this.headerMap = headerMap;</span> +<span class="fc" id="L464"> this.headerNames = headerNames;</span> +<span class="fc" id="L465"> }</span> + } + + /** + * Creates the name to index mapping if the format defines a header. + * + * @return null if the format has no header. + * @throws IOException if there is a problem reading the header or skipping the first record + */ + private Headers createHeaders() throws IOException { +<span class="fc" id="L475"> Map<String, Integer> hdrMap = null;</span> +<span class="fc" id="L476"> List<String> headerNames = null;</span> +<span class="fc" id="L477"> final String[] formatHeader = this.format.getHeader();</span> +<span class="fc bfc" id="L478" title="All 2 branches covered."> if (formatHeader != null) {</span> +<span class="fc" id="L479"> hdrMap = createEmptyHeaderMap();</span> +<span class="fc" id="L480"> String[] headerRecord = null;</span> +<span class="fc bfc" id="L481" title="All 2 branches covered."> if (formatHeader.length == 0) {</span> + // read the header from the first line of the file +<span class="fc" id="L483"> final CSVRecord nextRecord = this.nextRecord();</span> +<span class="fc bfc" id="L484" title="All 2 branches covered."> if (nextRecord != null) {</span> +<span class="fc" id="L485"> headerRecord = nextRecord.values();</span> + } +<span class="fc" id="L487"> } else {</span> +<span class="fc bfc" id="L488" title="All 2 branches covered."> if (this.format.getSkipHeaderRecord()) {</span> +<span class="fc" id="L489"> this.nextRecord();</span> + } +<span class="fc" id="L491"> headerRecord = formatHeader;</span> + } + + // build the name to index mappings +<span class="fc bfc" id="L495" title="All 2 branches covered."> if (headerRecord != null) {</span> +<span class="fc bfc" id="L496" title="All 2 branches covered."> for (int i = 0; i < headerRecord.length; i++) {</span> +<span class="fc" id="L497"> final String header = headerRecord[i];</span> +<span class="fc bfc" id="L498" title="All 4 branches covered."> final boolean emptyHeader = header == null || header.trim().isEmpty();</span> +<span class="fc bfc" id="L499" title="All 4 branches covered."> if (emptyHeader && !this.format.getAllowMissingColumnNames()) {</span> +<span class="fc" id="L500"> throw new IllegalArgumentException(</span> +<span class="fc" id="L501"> "A header name is missing in " + Arrays.toString(headerRecord));</span> + } + // Note: This will always allow a duplicate header if the header is empty +<span class="fc bfc" id="L504" title="All 4 branches covered."> final boolean containsHeader = header != null && hdrMap.containsKey(header);</span> +<span class="fc bfc" id="L505" title="All 6 branches covered."> if (containsHeader && !emptyHeader && !this.format.getAllowDuplicateHeaderNames()) {</span> +<span class="fc" id="L506"> throw new IllegalArgumentException(</span> +<span class="fc" id="L507"> String.format(</span> + "The header contains a duplicate name: \"%s\" in %s. If this is valid then use CSVFormat.withAllowDuplicateHeaderNames().", +<span class="fc" id="L509"> header, Arrays.toString(headerRecord)));</span> + } +<span class="fc bfc" id="L511" title="All 2 branches covered."> if (header != null) {</span> +<span class="fc" id="L512"> hdrMap.put(header, Integer.valueOf(i));</span> +<span class="fc bfc" id="L513" title="All 2 branches covered."> if (headerNames == null) {</span> +<span class="fc" id="L514"> headerNames = new ArrayList<>(headerRecord.length);</span> + } +<span class="fc" id="L516"> headerNames.add(header);</span> + } + } + } + } +<span class="fc bfc" id="L521" title="All 2 branches covered."> if (headerNames == null) {</span> +<span class="fc" id="L522"> headerNames = Collections.emptyList(); //immutable</span> + } else { +<span class="fc" id="L524"> headerNames = Collections.unmodifiableList(headerNames);</span> + } +<span class="fc" id="L526"> return new Headers(hdrMap, headerNames);</span> + } + + /** + * Returns the current line number in the input stream. + * + * <p> + * <strong>ATTENTION:</strong> If your CSV input has multi-line values, the returned number does not correspond to + * the record number. + * </p> + * + * @return current line number + */ + public long getCurrentLineNumber() { +<span class="fc" id="L540"> return this.lexer.getCurrentLineNumber();</span> + } + + /** + * Gets the first end-of-line string encountered. + * + * @return the first end-of-line string + * @since 1.5 + */ + public String getFirstEndOfLine() { +<span class="fc" id="L550"> return lexer.getFirstEol();</span> + } + + /** + * Returns a copy of the header map. + * <p> + * The map keys are column names. The map values are 0-based indices. + * </p> + * <p> + * Note: The map can only provide a one-to-one mapping when the format did not + * contain null or duplicate column names. + * </p> + * + * @return a copy of the header map. + */ + public Map<String, Integer> getHeaderMap() { +<span class="fc bfc" id="L566" title="All 2 branches covered."> if (this.headerMap == null) {</span> +<span class="fc" id="L567"> return null;</span> + } +<span class="fc" id="L569"> final Map<String, Integer> map = createEmptyHeaderMap();</span> +<span class="fc" id="L570"> map.putAll(this.headerMap);</span> +<span class="fc" id="L571"> return map;</span> + } + + /** + * Returns the header map. + * + * @return the header map. + */ + Map<String, Integer> getHeaderMapRaw() { +<span class="fc" id="L580"> return this.headerMap;</span> + } + + /** + * Returns a read-only list of header names that iterates in column order. + * <p> + * Note: The list provides strings that can be used as keys in the header map. + * The list will not contain null column names if they were present in the input + * format. + * </p> + * + * @return read-only list of header names that iterates in column order. + * @see #getHeaderMap() + * @since 1.7 + */ + public List<String> getHeaderNames() { +<span class="fc" id="L596"> return headerNames;</span> + } + + /** + * Returns the current record number in the input stream. + * + * <p> + * <strong>ATTENTION:</strong> If your CSV input has multi-line values, the returned number does not correspond to + * the line number. + * </p> + * + * @return current record number + */ + public long getRecordNumber() { +<span class="fc" id="L610"> return this.recordNumber;</span> + } + + /** + * Parses the CSV input according to the given format and returns the content as a list of + * {@link CSVRecord CSVRecords}. + * + * <p> + * The returned content starts at the current parse-position in the stream. + * </p> + * + * @return list of {@link CSVRecord CSVRecords}, may be empty + * @throws IOException + * on parse error or input read-failure + */ + public List<CSVRecord> getRecords() throws IOException { + CSVRecord rec; +<span class="fc" id="L627"> final List<CSVRecord> records = new ArrayList<>();</span> +<span class="fc bfc" id="L628" title="All 2 branches covered."> while ((rec = this.nextRecord()) != null) {</span> +<span class="fc" id="L629"> records.add(rec);</span> + } +<span class="fc" id="L631"> return records;</span> + } + + /** + * Gets whether this parser is closed. + * + * @return whether this parser is closed. + */ + public boolean isClosed() { +<span class="fc" id="L640"> return this.lexer.isClosed();</span> + } + + /** + * Returns an iterator on the records. + * + * <p> + * An {@link IOException} caught during the iteration are re-thrown as an + * {@link IllegalStateException}. + * </p> + * <p> + * If the parser is closed a call to {@link Iterator#next()} will throw a + * {@link NoSuchElementException}. + * </p> + */ + @Override + public Iterator<CSVRecord> iterator() { +<span class="fc" id="L657"> return csvRecordIterator;</span> + } + + /** + * Parses the next record from the current point in the stream. + * + * @return the record as an array of values, or {@code null} if the end of the stream has been reached + * @throws IOException + * on parse error or input read-failure + */ + CSVRecord nextRecord() throws IOException { +<span class="fc" id="L668"> CSVRecord result = null;</span> +<span class="fc" id="L669"> this.recordList.clear();</span> +<span class="fc" id="L670"> StringBuilder sb = null;</span> +<span class="fc" id="L671"> final long startCharPosition = lexer.getCharacterPosition() + this.characterOffset;</span> + do { +<span class="fc" id="L673"> this.reusableToken.reset();</span> +<span class="fc" id="L674"> this.lexer.nextToken(this.reusableToken);</span> +<span class="pc bpc" id="L675" title="2 of 6 branches missed."> switch (this.reusableToken.type) {</span> + case TOKEN: +<span class="fc" id="L677"> this.addRecordValue(false);</span> +<span class="fc" id="L678"> break;</span> + case EORECORD: +<span class="fc" id="L680"> this.addRecordValue(true);</span> +<span class="fc" id="L681"> break;</span> + case EOF: +<span class="fc bfc" id="L683" title="All 2 branches covered."> if (this.reusableToken.isReady) {</span> +<span class="fc" id="L684"> this.addRecordValue(true);</span> + } + break; + case INVALID: +<span class="nc" id="L688"> throw new IOException("(line " + this.getCurrentLineNumber() + ") invalid parse sequence");</span> + case COMMENT: // Ignored currently +<span class="fc bfc" id="L690" title="All 2 branches covered."> if (sb == null) { // first comment for this record</span> +<span class="fc" id="L691"> sb = new StringBuilder();</span> + } else { +<span class="fc" id="L693"> sb.append(Constants.LF);</span> + } +<span class="fc" id="L695"> sb.append(this.reusableToken.content);</span> +<span class="fc" id="L696"> this.reusableToken.type = TOKEN; // Read another token</span> +<span class="fc" id="L697"> break;</span> + default: +<span class="nc" id="L699"> throw new IllegalStateException("Unexpected Token type: " + this.reusableToken.type);</span> + } +<span class="fc bfc" id="L701" title="All 2 branches covered."> } while (this.reusableToken.type == TOKEN);</span> + +<span class="fc bfc" id="L703" title="All 2 branches covered."> if (!this.recordList.isEmpty()) {</span> +<span class="fc" id="L704"> this.recordNumber++;</span> +<span class="fc bfc" id="L705" title="All 2 branches covered."> final String comment = sb == null ? null : sb.toString();</span> +<span class="fc" id="L706"> result = new CSVRecord(this, this.recordList.toArray(new String[this.recordList.size()]),</span> + comment, this.recordNumber, startCharPosition); + } +<span class="fc" id="L709"> return result;</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVPrinter</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.html" class="el_package">org.apache.commons.csv</a> > <span class="el_class">CSVPrinter</span></div><h1>CSVPrinter</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td cla ss="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">16 of 282</td><td class="ctr2">94%</td><td class="bar">7 of 45</td><td class="ctr2">84%</td><td class="ctr1">5</td><td class="ctr2">36</td><td class="ctr1 ">3</td><td class="ctr2">73</td><td class="ctr1">0</td><td class="ctr2">13</td></tr></tfoot><tbody><tr><td id="a6"><a href="CSVPrinter.java.html#L197" class="el_method">printComment(String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="25" height="10" title="16" alt="16"/><img src="../jacoco-resources/greenbar.gif" width="94" height="10" title="59" alt="59"/></td><td class="ctr2" id="c12">78%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="55" height="10" title="6" alt="6"/><img src="../jacoco-resources/greenbar.gif" width="64" height="10" title="7" alt="7"/></td><td class="ctr2" id="e5">53%</td><td class="ctr1" id="f0">4</td><td class="ctr2" id="g0">8</td><td class="ctr1" id="h0">3</td><td class="ctr2" id="i0">18</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="CSVPrinter.java.html#L76" class="el_method">CSVPrinter(Appendable, CSVFormat)</a></td><td class="bar" id="b1"><im g src="../jacoco-resources/greenbar.gif" width="86" height="10" title="54" alt="54"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../jacoco-resources/greenbar.gif" width="92" height="10" title="10" alt="10"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g1">6</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">13</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a10"><a href="CSVPrinter.java.html#L315" class="el_method">printRecords(Iterable)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="57" height="10" title="36" alt="36"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d3"><img src="../jacoco-resources/greenbar.gif" width="55" height="10" title="6" alt="6"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g2">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">8</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a12"><a href="CSVPrinter.java.html#L380" class="el_method">printRecords(ResultSet)</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="51" height="10" title="32" alt="32"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d4"><img src="../jacoco-resources/greenbar.gif" width="55" height="10" title="6" alt="6"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g3">4</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">7</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a1"><a href="CSVPrinter.java.html#L132" class="el_method">close(boolean)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="27" height="10" title="17" alt="17"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d5"><img src="../jacoco-resources/greenbar.gif" width="55" height="10" title ="6" alt="6"/></td><td class="ctr2" id="e3">100%</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g4">4</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">5</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a8"><a href="CSVPrinter.java.html#L251" class="el_method">printRecord(Iterable)</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="25" height="10" title="16" alt="16"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d6"><img src="../jacoco-resources/greenbar.gif" width="18" height="10" title="2" alt="2"/></td><td class="ctr2" id="e4">100%</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g5">2</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">5</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a5"><a href="CSVPrinter.java.html#L171" class="el_method">print(Object)</a></td><td class="bar" id="b6"><img src="../jacoco-resources/greenbar.gif" wi dth="19" height="10" title="12" alt="12"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d7"/><td class="ctr2" id="e7">n/a</td><td class="ctr1" id="f7">0</td><td class="ctr2" id="g7">1</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i6">3</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">1</td></tr><tr><td id="a9"><a href="CSVPrinter.java.html#L271" class="el_method">printRecord(Object[])</a></td><td class="bar" id="b7"><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="10" alt="10"/></td><td class="ctr2" id="c6">100%</td><td class="bar" id="d8"/><td class="ctr2" id="e8">n/a</td><td class="ctr1" id="f8">0</td><td class="ctr2" id="g8">1</td><td class="ctr1" id="h7">0</td><td class="ctr2" id="i7">3</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a3"><a href="CSVPrinter.java.html#L148" class="el_method">flush()</a></td><td class="bar" id="b8"><img src="../jacoco-resources/greenbar.gif" width="14" he ight="10" title="9" alt="9"/></td><td class="ctr2" id="c7">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="9" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="9" height="10" title="1" alt="1"/></td><td class="ctr2" id="e6">50%</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g6">2</td><td class="ctr1" id="h8">0</td><td class="ctr2" id="i8">3</td><td class="ctr1" id="j8">0</td><td class="ctr2" id="k8">1</td></tr><tr><td id="a7"><a href="CSVPrinter.java.html#L233" class="el_method">println()</a></td><td class="bar" id="b9"><img src="../jacoco-resources/greenbar.gif" width="14" height="10" title="9" alt="9"/></td><td class="ctr2" id="c8">100%</td><td class="bar" id="d9"/><td class="ctr2" id="e9">n/a</td><td class="ctr1" id="f9">0</td><td class="ctr2" id="g9">1</td><td class="ctr1" id="h9">0</td><td class="ctr2" id="i9">3</td><td class="ctr1" id="j9">0</td><td class="ctr2" id="k9">1</td></tr><tr><td id="a11"><a hr ef="CSVPrinter.java.html#L366" class="el_method">printRecords(Object[])</a></td><td class="bar" id="b10"><img src="../jacoco-resources/greenbar.gif" width="8" height="10" title="5" alt="5"/></td><td class="ctr2" id="c9">100%</td><td class="bar" id="d10"/><td class="ctr2" id="e10">n/a</td><td class="ctr1" id="f10">0</td><td class="ctr2" id="g10">1</td><td class="ctr1" id="h10">0</td><td class="ctr2" id="i10">2</td><td class="ctr1" id="j10">0</td><td class="ctr2" id="k10">1</td></tr><tr><td id="a0"><a href="CSVPrinter.java.html#L120" class="el_method">close()</a></td><td class="bar" id="b11"><img src="../jacoco-resources/greenbar.gif" width="6" height="10" title="4" alt="4"/></td><td class="ctr2" id="c10">100%</td><td class="bar" id="d11"/><td class="ctr2" id="e11">n/a</td><td class="ctr1" id="f11">0</td><td class="ctr2" id="g11">1</td><td class="ctr1" id="h11">0</td><td class="ctr2" id="i11">2</td><td class="ctr1" id="j11">0</td><td class="ctr2" id="k11">1</td></tr><tr><td id="a4"><a href="CSVPrinter.java.html#L159" class="el_method">getOut()</a></td><td class="bar" id="b12"><img src="../jacoco-resources/greenbar.gif" width="4" height="10" title="3" alt="3"/></td><td class="ctr2" id="c11">100%</td><td class="bar" id="d12"/><td class="ctr2" id="e12">n/a</td><td class="ctr1" id="f12">0</td><td class="ctr2" id="g12">1</td><td class="ctr1" id="h12">0</td><td class="ctr2" id="i12">1</td><td class="ctr1" id="j12">0</td><td class="ctr2" id="k12">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file Added: dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.java.html ============================================================================== --- dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.java.html (added) +++ dev/commons/csv/1.8-RC2/site/jacoco/org.apache.commons.csv/CSVPrinter.java.html Sun Feb 2 01:23:05 2020 @@ -0,0 +1,390 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CSVPrinter.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons CSV</a> > <a href="index.source.html" class="el_package">org.apache.commons.csv</a> > <span class="el_source">CSVPrinter. java</span></div><h1>CSVPrinter.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.csv; + +import static org.apache.commons.csv.Constants.CR; +import static org.apache.commons.csv.Constants.LF; +import static org.apache.commons.csv.Constants.SP; + +import java.io.Closeable; +import java.io.Flushable; +import java.io.IOException; +import java.sql.Clob; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; + +/** + * Prints values in a {@link CSVFormat CSV format}. + * + * <p>Values can be appended to the output by calling the {@link #print(Object)} method. + * Values are printed according to {@link String#valueOf(Object)}. + * To complete a record the {@link #println()} method has to be called. + * Comments can be appended by calling {@link #printComment(String)}. + * However a comment will only be written to the output if the {@link CSVFormat} supports comments. + * </p> + * + * <p>The printer also supports appending a complete record at once by calling {@link #printRecord(Object...)} + * or {@link #printRecord(Iterable)}. + * Furthermore {@link #printRecords(Object...)}, {@link #printRecords(Iterable)} and {@link #printRecords(ResultSet)} + * methods can be used to print several records at once. + * </p> + * + * <p>Example:</p> + * + * <pre> + * try (CSVPrinter printer = new CSVPrinter(new FileWriter("csv.txt"), CSVFormat.EXCEL)) { + * printer.printRecord("id", "userName", "firstName", "lastName", "birthday"); + * printer.printRecord(1, "john73", "John", "Doe", LocalDate.of(1973, 9, 15)); + * printer.println(); + * printer.printRecord(2, "mary", "Mary", "Meyer", LocalDate.of(1985, 3, 29)); + * } catch (IOException ex) { + * ex.printStackTrace(); + * } + * </pre> + * + * <p>This code will write the following to csv.txt:</p> + * <pre> + * id,userName,firstName,lastName,birthday + * 1,john73,John,Doe,1973-09-15 + * + * 2,mary,Mary,Meyer,1985-03-29 + * </pre> + */ +public final class CSVPrinter implements Flushable, Closeable { + + /** The place that the values get written. */ + private final Appendable out; + private final CSVFormat format; + + /** True if we just began a new record. */ +<span class="fc" id="L76"> private boolean newRecord = true;</span> + + /** + * Creates a printer that will print values to the given stream following the CSVFormat. + * <p> + * Currently, only a pure encapsulation format or a pure escaping format is supported. Hybrid formats (encapsulation + * and escaping with a different character) are not supported. + * </p> + * + * @param out + * stream to which to print. Must not be null. + * @param format + * the CSV format. Must not be null. + * @throws IOException + * thrown if the optional header cannot be printed. + * @throws IllegalArgumentException + * thrown if the parameters of the format are inconsistent or if either out or format are null. + */ +<span class="fc" id="L94"> public CSVPrinter(final Appendable out, final CSVFormat format) throws IOException {</span> +<span class="fc" id="L95"> Assertions.notNull(out, "out");</span> +<span class="fc" id="L96"> Assertions.notNull(format, "format");</span> + +<span class="fc" id="L98"> this.out = out;</span> +<span class="fc" id="L99"> this.format = format;</span> + // TODO: Is it a good idea to do this here instead of on the first call to a print method? + // It seems a pain to have to track whether the header has already been printed or not. +<span class="fc bfc" id="L102" title="All 2 branches covered."> if (format.getHeaderComments() != null) {</span> +<span class="fc bfc" id="L103" title="All 2 branches covered."> for (final String line : format.getHeaderComments()) {</span> +<span class="fc bfc" id="L104" title="All 2 branches covered."> if (line != null) {</span> +<span class="fc" id="L105"> this.printComment(line);</span> + } + } + } +<span class="fc bfc" id="L109" title="All 4 branches covered."> if (format.getHeader() != null && !format.getSkipHeaderRecord()) {</span> +<span class="fc" id="L110"> this.printRecord((Object[]) format.getHeader());</span> + } +<span class="fc" id="L112"> }</span> + + // ====================================================== + // printing implementation + // ====================================================== + + @Override + public void close() throws IOException { +<span class="fc" id="L120"> close(false);</span> +<span class="fc" id="L121"> }</span> + + /** + * Closes the underlying stream with an optional flush first. + * @param flush whether to flush before the actual close. + * + * @throws IOException + * If an I/O error occurs + * @since 1.6 + */ + public void close(final boolean flush) throws IOException { +<span class="fc bfc" id="L132" title="All 4 branches covered."> if (flush || format.getAutoFlush()) {</span> +<span class="fc" id="L133"> flush();</span> + } +<span class="fc bfc" id="L135" title="All 2 branches covered."> if (out instanceof Closeable) {</span> +<span class="fc" id="L136"> ((Closeable) out).close();</span> + } +<span class="fc" id="L138"> }</span> + + /** + * Flushes the underlying stream. + * + * @throws IOException + * If an I/O error occurs + */ + @Override + public void flush() throws IOException { +<span class="pc bpc" id="L148" title="1 of 2 branches missed."> if (out instanceof Flushable) {</span> +<span class="fc" id="L149"> ((Flushable) out).flush();</span> + } +<span class="fc" id="L151"> }</span> + + /** + * Gets the target Appendable. + * + * @return the target Appendable. + */ + public Appendable getOut() { +<span class="fc" id="L159"> return this.out;</span> + } + + /** + * Prints the string as the next value on the line. The value will be escaped or encapsulated as needed. + * + * @param value + * value to be output. + * @throws IOException + * If an I/O error occurs + */ + public void print(final Object value) throws IOException { +<span class="fc" id="L171"> format.print(value, out, newRecord);</span> +<span class="fc" id="L172"> newRecord = false;</span> +<span class="fc" id="L173"> }</span> + + /** + * Prints a comment on a new line among the delimiter separated values. + * + * <p> + * Comments will always begin on a new line and occupy at least one full line. The character specified to start + * comments and a space will be inserted at the beginning of each new line in the comment. + * </p> + * + * <p> + * If comments are disabled in the current CSV format this method does nothing. + * </p> + * + * <p>This method detects line breaks inside the comment string and inserts {@link CSVFormat#getRecordSeparator()} + * to start a new line of the comment. Note that this might produce unexpected results for formats that do not use + * line breaks as record separator.</p> + * + * @param comment + * the comment to output + * @throws IOException + * If an I/O error occurs + */ + public void printComment(final String comment) throws IOException { +<span class="fc bfc" id="L197" title="All 2 branches covered."> if (!format.isCommentMarkerSet()) {</span> +<span class="fc" id="L198"> return;</span> + } +<span class="pc bpc" id="L200" title="1 of 2 branches missed."> if (!newRecord) {</span> +<span class="nc" id="L201"> println();</span> + } +<span class="fc" id="L203"> out.append(format.getCommentMarker().charValue());</span> +<span class="fc" id="L204"> out.append(SP);</span> +<span class="fc bfc" id="L205" title="All 2 branches covered."> for (int i = 0; i < comment.length(); i++) {</span> +<span class="fc" id="L206"> final char c = comment.charAt(i);</span> +<span class="pc bpc" id="L207" title="1 of 3 branches missed."> switch (c) {</span> + case CR: +<span class="nc bnc" id="L209" title="All 4 branches missed."> if (i + 1 < comment.length() && comment.charAt(i + 1) == LF) {</span> +<span class="nc" id="L210"> i++;</span> + } + //$FALL-THROUGH$ break intentionally excluded. + case LF: +<span class="fc" id="L214"> println();</span> +<span class="fc" id="L215"> out.append(format.getCommentMarker().charValue());</span> +<span class="fc" id="L216"> out.append(SP);</span> +<span class="fc" id="L217"> break;</span> + default: +<span class="fc" id="L219"> out.append(c);</span> + break; + } + } +<span class="fc" id="L223"> println();</span> +<span class="fc" id="L224"> }</span> + + /** + * Outputs the record separator. + * + * @throws IOException + * If an I/O error occurs + */ + public void println() throws IOException { +<span class="fc" id="L233"> format.println(out);</span> +<span class="fc" id="L234"> newRecord = true;</span> +<span class="fc" id="L235"> }</span> + + /** + * Prints the given values a single record of delimiter separated values followed by the record separator. + * + * <p> + * The values will be quoted if needed. Quotes and newLine characters will be escaped. This method adds the record + * separator to the output after printing the record, so there is no need to call {@link #println()}. + * </p> + * + * @param values + * values to output. + * @throws IOException + * If an I/O error occurs + */ + public void printRecord(final Iterable<?> values) throws IOException { +<span class="fc bfc" id="L251" title="All 2 branches covered."> for (final Object value : values) {</span> +<span class="fc" id="L252"> print(value);</span> +<span class="fc" id="L253"> }</span> +<span class="fc" id="L254"> println();</span> +<span class="fc" id="L255"> }</span> + + /** + * Prints the given values a single record of delimiter separated values followed by the record separator. + * + * <p> + * The values will be quoted if needed. Quotes and newLine characters will be escaped. This method adds the record + * separator to the output after printing the record, so there is no need to call {@link #println()}. + * </p> + * + * @param values + * values to output. + * @throws IOException + * If an I/O error occurs + */ + public void printRecord(final Object... values) throws IOException { +<span class="fc" id="L271"> format.printRecord(out, values);</span> +<span class="fc" id="L272"> newRecord = true;</span> +<span class="fc" id="L273"> }</span> + + /** + * Prints all the objects in the given collection handling nested collections/arrays as records. + * + * <p> + * If the given collection only contains simple objects, this method will print a single record like + * {@link #printRecord(Iterable)}. If the given collections contains nested collections/arrays those nested elements + * will each be printed as records using {@link #printRecord(Object...)}. + * </p> + * + * <p> + * Given the following data structure: + * </p> + * + * <pre> + * <code> + * List&lt;String[]&gt; data = ... + * data.add(new String[]{ "A", "B", "C" }); + * data.add(new String[]{ "1", "2", "3" }); + * data.add(new String[]{ "A1", "B2", "C3" }); + * </code> + * </pre> + * + * <p> + * Calling this method will print: + * </p> + * + * <pre> + * <code> + * A, B, C + * 1, 2, 3 + * A1, B2, C3 + * </code> + * </pre> + * + * @param values + * the values to print. + * @throws IOException + * If an I/O error occurs + */ + public void printRecords(final Iterable<?> values) throws IOException { +<span class="fc bfc" id="L315" title="All 2 branches covered."> for (final Object value : values) {</span> +<span class="fc bfc" id="L316" title="All 2 branches covered."> if (value instanceof Object[]) {</span> +<span class="fc" id="L317"> this.printRecord((Object[]) value);</span> +<span class="fc bfc" id="L318" title="All 2 branches covered."> } else if (value instanceof Iterable) {</span> +<span class="fc" id="L319"> this.printRecord((Iterable<?>) value);</span> + } else { +<span class="fc" id="L321"> this.printRecord(value);</span> + } +<span class="fc" id="L323"> }</span> +<span class="fc" id="L324"> }</span> + + /** + * Prints all the objects in the given array handling nested collections/arrays as records. + * + * <p> + * If the given array only contains simple objects, this method will print a single record like + * {@link #printRecord(Object...)}. If the given collections contains nested collections/arrays those nested + * elements will each be printed as records using {@link #printRecord(Object...)}. + * </p> + * + * <p> + * Given the following data structure: + * </p> + * + * <pre> + * <code> + * String[][] data = new String[3][] + * data[0] = String[]{ "A", "B", "C" }; + * data[1] = new String[]{ "1", "2", "3" }; + * data[2] = new String[]{ "A1", "B2", "C3" }; + * </code> + * </pre> + * + * <p> + * Calling this method will print: + * </p> + * + * <pre> + * <code> + * A, B, C + * 1, 2, 3 + * A1, B2, C3 + * </code> + * </pre> + * + * @param values + * the values to print. + * @throws IOException + * If an I/O error occurs + */ + public void printRecords(final Object... values) throws IOException { +<span class="fc" id="L366"> printRecords(Arrays.asList(values));</span> +<span class="fc" id="L367"> }</span> + + /** + * Prints all the objects in the given JDBC result set. + * + * @param resultSet + * result set the values to print. + * @throws IOException + * If an I/O error occurs + * @throws SQLException + * if a database access error occurs + */ + public void printRecords(final ResultSet resultSet) throws SQLException, IOException { +<span class="fc" id="L380"> final int columnCount = resultSet.getMetaData().getColumnCount();</span> +<span class="fc bfc" id="L381" title="All 2 branches covered."> while (resultSet.next()) {</span> +<span class="fc bfc" id="L382" title="All 2 branches covered."> for (int i = 1; i <= columnCount; i++) {</span> +<span class="fc" id="L383"> final Object object = resultSet.getObject(i);</span> +<span class="fc bfc" id="L384" title="All 2 branches covered."> print(object instanceof Clob ? ((Clob) object).getCharacterStream() : object);</span> + } +<span class="fc" id="L386"> println();</span> + } +<span class="fc" id="L388"> }</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.5.201910111838</span></div></body></html> \ No newline at end of file