Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.html Thu Aug 14 19:48:06 2014 @@ -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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>CSVRecord</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">CSVRecord</span></div><h1>CSVRecord</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclic k="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">1 of 214</td><td class="ctr2">100%</td><td class="bar">1 of 24</td><td class="ctr2">96%</td><td class="ctr1">1</td><td class="ctr2">29</td><td class="ctr1">0</td><td class="ctr2">38 </td><td class="ctr1">0</td><td class="ctr2">17</td></tr></tfoot><tbody><tr><td id="a0"><a href="CSVRecord.java.html#L52" class="el_method">CSVRecord(String[], Map, String, long)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="1" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="33" height="10" title="18" alt="18"/></td><td class="ctr2" id="c16">95%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="20" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="20" height="10" title="1" alt="1"/></td><td class="ctr2" id="e5">50%</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g5">2</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i2">6</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a3"><a href="CSVRecord.java.html#L95" class="el_method">get(String)</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="120" height="10" tit le="64" alt="64"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../.resources/greenbar.gif" width="80" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">3</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i0">10</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a10"><a href="CSVRecord.java.html#L190" class="el_method">putIn(Map)</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="73" height="10" title="39" alt="39"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"><img src="../.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="g0">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i1">8</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a8"><a href="CSVRecord.j ava.html#L171" class="el_method">isSet(String)</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="33" height="10" title="18" alt="18"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d3"><img src="../.resources/greenbar.gif" width="80" height="10" title="4" alt="4"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g2">3</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="a6"><a href="CSVRecord.java.html#L149" class="el_method">isConsistent()</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="26" height="10" title="14" alt="14"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d4"><img src="../.resources/greenbar.gif" width="80" height="10" title="4" alt="4"/></td><td class="ctr2" id="e3">100%</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g3">3</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><tr><td id="a7"><a href="CSVRecord.java.html#L160" class="el_method">isMapped(String)</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="22" height="10" title="12" alt="12"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d5"><img src="../.resources/greenbar.gif" width="80" height="10" title="4" alt="4"/></td><td class="ctr2" id="e4">100%</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g4">3</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">1</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a14"><a href="CSVRecord.java.html#L227" class="el_method">toMap()</a></td><td class="bar" id="b6"><img src="../.resources/greenbar.gif" width="16" height="10" title="9" alt="9"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">0</t d><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i6">1</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">1</td></tr><tr><td id="a1"><a href="CSVRecord.java.html#L67" class="el_method">get(Enum)</a></td><td class="bar" id="b7"><img src="../.resources/greenbar.gif" width="9" height="10" title="5" alt="5"/></td><td class="ctr2" id="c6">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="h7">0</td><td class="ctr2" id="i7">1</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a2"><a href="CSVRecord.java.html#L78" class="el_method">get(int)</a></td><td class="bar" id="b8"><img src="../.resources/greenbar.gif" width="9" height="10" title="5" alt="5"/></td><td class="ctr2" id="c7">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="h8">0</td><td class="ctr2" id="i8">1</td><td class="ctr1" id="j8">0</td><td class="ctr2" id="k8">1</td></tr><tr><td id="a9"><a href="CSVRecord.java.html#L180" class="el_method">iterator()</a></td><td class="bar" id="b9"><img src="../.resources/greenbar.gif" width="7" height="10" title="4" alt="4"/></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">1</td><td class="ctr1" id="j9">0</td><td class="ctr2" id="k9">1</td></tr><tr><td id="a11"><a href="CSVRecord.java.html#L208" class="el_method">size()</a></td><td class="bar" id="b10"><img src="../.resources/greenbar.gif" width="7" height="10" title="4" alt="4"/></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">1</td><td class="ctr1" id="j10">0</td><td class="ctr2" id="k10">1</td></tr><tr><td id="a13"><a href="CSVRecord.java.html#L218" class="el_method">toList()</a></td><td class="bar" id="b11"><img src="../.resources/greenbar.gif" width="7" 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">1</td><td class="ctr1" id="j11">0</td><td class="ctr2" id="k11">1</td></tr><tr><td id="a15"><a href="CSVRecord.java.html#L238" class="el_method">toString()</a></td><td class="bar" id="b12"><img src="../.resources/greenbar.gif" width="7" height="10" title="4" alt="4"/></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><tr><td id="a12"><a href="CSVRecord.java.html#L35" class="el_method">static {...}</a></td><td class="bar" id="b13"><img src="../.resources/greenbar.gif" width="7" height="10" title="4" alt="4"/></td><td class="ctr2" id="c12">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="h13">0</td><td class="ctr2" id="i13">1</td><td class="ctr1" id="j13">0</td><td class="ctr2" id="k13">1</td></tr><tr><td id="a4"><a href="CSVRecord.java.html#L120" class="el_method">getComment()</a></td><td class="bar" id="b14"><img src="../.resources/greenbar.gif" width="5" height="10" title="3" alt="3"/></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" i d="j14">0</td><td class="ctr2" id="k14">1</td></tr><tr><td id="a5"><a href="CSVRecord.java.html#L135" class="el_method">getRecordNumber()</a></td><td class="bar" id="b15"><img src="../.resources/greenbar.gif" width="5" height="10" title="3" alt="3"/></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="a16"><a href="CSVRecord.java.html#L242" class="el_method">values()</a></td><td class="bar" id="b16"><img src="../.resources/greenbar.gif" width="5" height="10" title="3" alt="3"/></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></tbody></table><div >class="footer"><span class="right">Created with <a >href="http://www.eclemma.org/jacoco">JaCoCo</a> >0.7.1.201405082137</span></div></body></html> \ No newline at end of file
Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.java.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.java.html Thu Aug 14 19:48:06 2014 @@ -0,0 +1,247 @@ +<?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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>CSVRecord.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">CSVRecord.java</span></div><h1>CSVRecord.j ava</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 java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * A CSV record parsed from a CSV file. + * + * @version $Id: CSVRecord.java 1617066 2014-08-10 08:50:05Z britter $ + */ +public final class CSVRecord implements Serializable, Iterable<String> { + +<span class="fc" id="L35"> private static final String[] EMPTY_STRING_ARRAY = new String[0];</span> + + private static final long serialVersionUID = 1L; + + /** The accumulated comments (if any) */ + private final String comment; + + /** The column name to index mapping. */ + private final Map<String, Integer> mapping; + + /** The record number. */ + private final long recordNumber; + + /** The values of the record */ + private final String[] values; + + CSVRecord(final String[] values, final Map<String, Integer> mapping, +<span class="fc" id="L52"> final String comment, final long recordNumber) {</span> +<span class="fc" id="L53"> this.recordNumber = recordNumber;</span> +<span class="pc bpc" id="L54" title="1 of 2 branches missed."> this.values = values != null ? values : EMPTY_STRING_ARRAY;</span> +<span class="fc" id="L55"> this.mapping = mapping;</span> +<span class="fc" id="L56"> this.comment = comment;</span> +<span class="fc" id="L57"> }</span> + + /** + * Returns a value by {@link Enum}. + * + * @param e + * an enum + * @return the String at the given enum String + */ + public String get(final Enum<?> e) { +<span class="fc" id="L67"> return get(e.toString());</span> + } + + /** + * Returns a value by index. + * + * @param i + * a column index (0-based) + * @return the String at the given index + */ + public String get(final int i) { +<span class="fc" id="L78"> return values[i];</span> + } + + /** + * Returns a value by name. + * + * @param name + * the name of the column to be retrieved. + * @return the column value, maybe null depending on {@link CSVFormat#getNullString()}. + * @throws IllegalStateException + * if no header mapping was provided + * @throws IllegalArgumentException + * if {@code name} is not mapped or if the record is inconsistent + * @see #isConsistent() + * @see CSVFormat#withNullString(String) + */ + public String get(final String name) { +<span class="fc bfc" id="L95" title="All 2 branches covered."> if (mapping == null) {</span> +<span class="fc" id="L96"> throw new IllegalStateException(</span> + "No header mapping was specified, the record values can't be accessed by name"); + } +<span class="fc" id="L99"> final Integer index = mapping.get(name);</span> +<span class="fc bfc" id="L100" title="All 2 branches covered."> if (index == null) {</span> +<span class="fc" id="L101"> throw new IllegalArgumentException(String.format("Mapping for %s not found, expected one of %s", name,</span> +<span class="fc" id="L102"> mapping.keySet()));</span> + } + try { +<span class="fc" id="L105"> return values[index.intValue()];</span> +<span class="fc" id="L106"> } catch (final ArrayIndexOutOfBoundsException e) {</span> +<span class="fc" id="L107"> throw new IllegalArgumentException(String.format(</span> + "Index for header '%s' is %d but CSVRecord only has %d values!", name, index, +<span class="fc" id="L109"> Integer.valueOf(values.length)));</span> + } + } + + /** + * Returns the comment for this record, if any. + * + * @return the comment for this record, or null if no comment for this + * record is available. + */ + public String getComment() { +<span class="fc" id="L120"> return comment;</span> + } + + /** + * Returns the number of this record in the parsed CSV file. + * + * <p> + * <strong>ATTENTION:</strong> If your CSV input has multi-line values, the returned number does not correspond to + * the current line number of the parser that created this record. + * </p> + * + * @return the number of this record. + * @see CSVParser#getCurrentLineNumber() + */ + public long getRecordNumber() { +<span class="fc" id="L135"> return recordNumber;</span> + } + + /** + * Tells whether the record size matches the header size. + * + * <p> + * Returns true if the sizes for this record match and false if not. Some programs can export files that fail this + * test but still produce parsable files. + * </p> + * + * @return true of this record is valid, false if not + */ + public boolean isConsistent() { +<span class="fc bfc" id="L149" title="All 4 branches covered."> return mapping == null || mapping.size() == values.length;</span> + } + + /** + * Checks whether a given column is mapped, i.e. its name has been defined to the parser. + * + * @param name + * the name of the column to be retrieved. + * @return whether a given column is mapped. + */ + public boolean isMapped(final String name) { +<span class="fc bfc" id="L160" title="All 4 branches covered."> return mapping != null && mapping.containsKey(name);</span> + } + + /** + * Checks whether a given columns is mapped and has a value. + * + * @param name + * the name of the column to be retrieved. + * @return whether a given columns is mapped and has a value + */ + public boolean isSet(final String name) { +<span class="fc bfc" id="L171" title="All 4 branches covered."> return isMapped(name) && mapping.get(name).intValue() < values.length;</span> + } + + /** + * Returns an iterator over the values of this record. + * + * @return an iterator over the values of this record. + */ + public Iterator<String> iterator() { +<span class="fc" id="L180"> return toList().iterator();</span> + } + + /** + * Puts all values of this record into the given Map. + * + * @param map The Map to populate. + * @return the given map. + */ + <M extends Map<String, String>> M putIn(final M map) { +<span class="fc bfc" id="L190" title="All 2 branches covered."> if (mapping == null) {</span> +<span class="fc" id="L191"> return map;</span> + } +<span class="fc bfc" id="L193" title="All 2 branches covered."> for (final Entry<String, Integer> entry : mapping.entrySet()) {</span> +<span class="fc" id="L194"> final int col = entry.getValue().intValue();</span> +<span class="fc bfc" id="L195" title="All 2 branches covered."> if (col < values.length) {</span> +<span class="fc" id="L196"> map.put(entry.getKey(), values[col]);</span> + } +<span class="fc" id="L198"> }</span> +<span class="fc" id="L199"> return map;</span> + } + + /** + * Returns the number of values in this record. + * + * @return the number of values. + */ + public int size() { +<span class="fc" id="L208"> return values.length;</span> + } + + /** + * Converts the values to a List. + * + * TODO: Maybe make this public? + * @return a new List + */ + private List<String> toList() { +<span class="fc" id="L218"> return Arrays.asList(values);</span> + } + + /** + * Copies this record into a new Map. The new map is not connect + * + * @return A new Map. The map is empty if the record has no headers. + */ + public Map<String, String> toMap() { +<span class="fc" id="L227"> return putIn(new HashMap<String, String>(values.length));</span> + } + + /** + * Returns a string representation of the contents of this record. The result is constructed by passing the internal + * values array to {@link Arrays#toString(Object[])}. + * + * @return a String representation of this record. + */ + @Override + public String toString() { +<span class="fc" id="L238"> return Arrays.toString(values);</span> + } + + String[] values() { +<span class="fc" id="L242"> return values;</span> + } + + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVRecord.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.html Thu Aug 14 19:48:06 2014 @@ -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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>Constants</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">Constants</span></div><h1>Constants</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclic k="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">3 of 7</td><td class="ctr2">57%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">1</td><td class="ctr2">2</td>< td class="ctr1">1</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="Constants.java.html#L25" class="el_method">Constants()</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="90" height="10" title="3" alt="3"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="Constants.java.html#L36" class="el_method">static {...}</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class= "ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.java.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.java.html Thu Aug 14 19:48:06 2014 @@ -0,0 +1,76 @@ +<?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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>Constants.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">Constants.java</span></div><h1>Constants.j ava</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; + +/** + * Constants for this package. + * + * @version $Id: Constants.java 1582822 2014-03-28 16:52:17Z sebb $ + */ +<span class="nc" id="L25">final class Constants {</span> + + static final char BACKSPACE = '\b'; + static final char COMMA = ','; + + /** + * Starts a comment, the remainder of the line is the comment. + */ + static final char COMMENT = '#'; + + static final char CR = '\r'; +<span class="fc" id="L36"> static final Character DOUBLE_QUOTE_CHAR = Character.valueOf('"');</span> + static final char BACKSLASH = '\\'; + static final char FF = '\f'; + static final char LF = '\n'; + static final char SP = ' '; + static final char TAB = '\t'; + + /** ASCII record separator */ + static final char RS = 30; + + /** ASCII unit separator */ + static final char US = 31; + + static final String EMPTY = ""; + + /** The end of stream symbol */ + static final int END_OF_STREAM = -1; + + /** Undefined state for the lookahead char */ + static final int UNDEFINED = -2; + + /** According to RFC 4180, line breaks are delimited by CRLF */ + static final String CRLF = "\r\n"; + + /** + * Unicode line separator. + */ + static final String LINE_SEPARATOR = "\u2028"; + + /** + * Unicode paragraph separator. + */ + static final String PARAGRAPH_SEPARATOR = "\u2029"; + + /** + * Unicode next line. + */ + static final String NEXT_LINE = "\u0085"; + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Constants.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html Thu Aug 14 19:48:06 2014 @@ -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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>ExtendedBufferedReader</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">ExtendedBufferedReader</span></div><h1>ExtendedBufferedReader</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">0 of 178</td><td class="ctr2">100%</td><td class="bar">1 of >32</td><td class="ctr2">97%</td><td class="ctr1">1</td><td >class="ctr2">25</td><td class="ctr1">0</td><td class="ctr2">43</td><td class="ctr1">0</td><td class="ctr2">9</td></tr></tfoot><tbody><tr><td id="a7"><a href="ExtendedBufferedReader.java.html#L78" class="el_method">read(char[], int, int)</a></td><td class="bar" id="b0"><img src="../.resources/greenbar.gif" width="120" height="10" title="74" alt="74"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="7" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="112" height="10" title="15" alt="15"/></td><td class="ctr2" id="e3">94%</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">9</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">15</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a6"><a href="ExtendedBufferedReader.java.html#L56" class="el_method">read()</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="40" height="10" title="25" alt="25"/></td><td clas s="ctr2" id="c1">100%</td><td class="bar" id="d2"><img src="../.resources/greenbar.gif" width="45" 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="g2">4</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i2">5</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="ExtendedBufferedReader.java.html#L154" class="el_method">getCurrentLineNumber()</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="38" height="10" title="24" alt="24"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d1"><img src="../.resources/greenbar.gif" width="60" height="10" title="8" alt="8"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g1">5</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i6">3</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a8"><a href="ExtendedBufferedRead er.java.html#L118" class="el_method">readLine()</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="32" height="10" title="20" alt="20"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d3"><img src="../.resources/greenbar.gif" width="15" height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">2</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i1">6</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a1"><a href="ExtendedBufferedReader.java.html#L40" class="el_method">ExtendedBufferedReader(Reader)</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="16" height="10" title="10" alt="10"/></td><td class="ctr2" id="c4">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="i3">4</td><td class="ctr1 " id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a5"><a href="ExtendedBufferedReader.java.html#L140" class="el_method">lookAhead()</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="16" height="10" title="10" alt="10"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i4">4</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a0"><a href="ExtendedBufferedReader.java.html#L173" class="el_method">close()</a></td><td class="bar" id="b6"><img src="../.resources/greenbar.gif" width="14" height="10" title="9" alt="9"/></td><td class="ctr2" id="c6">100%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i5">4</td><td class="ctr1" id="j6">0 </td><td class="ctr2" id="k6">1</td></tr><tr><td id="a3"><a href="ExtendedBufferedReader.java.html#L73" class="el_method">getLastChar()</a></td><td class="bar" id="b7"><img src="../.resources/greenbar.gif" width="4" height="10" title="3" alt="3"/></td><td class="ctr2" id="c7">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="h7">0</td><td class="ctr2" id="i7">1</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a4"><a href="ExtendedBufferedReader.java.html#L161" class="el_method">isClosed()</a></td><td class="bar" id="b8"><img src="../.resources/greenbar.gif" width="4" height="10" title="3" alt="3"/></td><td class="ctr2" id="c8">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="h8">0</td><td class="ctr2" id="i8">1</td><td class="ctr1" id="j8">0</td><td cl ass="ctr2" id="k8">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html Thu Aug 14 19:48:06 2014 @@ -0,0 +1,179 @@ +<?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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>ExtendedBufferedReader.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">ExtendedBufferedReader.java</ span></div><h1>ExtendedBufferedReader.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.END_OF_STREAM; +import static org.apache.commons.csv.Constants.LF; +import static org.apache.commons.csv.Constants.UNDEFINED; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; + +/** + * A special buffered reader which supports sophisticated read access. + * <p> + * In particular the reader supports a look-ahead option, which allows you to see the next char returned by + * {@link #read()}. + * + * @version $Id: ExtendedBufferedReader.java 1512625 2013-08-10 11:07:15Z britter $ + */ +final class ExtendedBufferedReader extends BufferedReader { + + /** The last char returned */ +<span class="fc" id="L40"> private int lastChar = UNDEFINED;</span> + + /** The count of EOLs (CR/LF/CRLF) seen so far */ +<span class="fc" id="L43"> private long eolCounter = 0;</span> + + private boolean closed; + + /** + * Created extended buffered reader using default buffer-size + */ + ExtendedBufferedReader(final Reader reader) { +<span class="fc" id="L51"> super(reader);</span> +<span class="fc" id="L52"> }</span> + + @Override + public int read() throws IOException { +<span class="fc" id="L56"> final int current = super.read();</span> +<span class="fc bfc" id="L57" title="All 6 branches covered."> if (current == CR || (current == LF && lastChar != CR)) {</span> +<span class="fc" id="L58"> eolCounter++;</span> + } +<span class="fc" id="L60"> lastChar = current;</span> +<span class="fc" id="L61"> return lastChar;</span> + } + + /** + * Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by + * any of the read methods. This will not include a character read using the {@link #lookAhead()} method. If no + * character has been read then this will return {@link Constants#UNDEFINED}. If the end of the stream was reached + * on the last read then this will return {@link Constants#END_OF_STREAM}. + * + * @return the last character that was read + */ + int getLastChar() { +<span class="fc" id="L73"> return lastChar;</span> + } + + @Override + public int read(final char[] buf, final int offset, final int length) throws IOException { +<span class="fc bfc" id="L78" title="All 2 branches covered."> if (length == 0) {</span> +<span class="fc" id="L79"> return 0;</span> + } + +<span class="fc" id="L82"> final int len = super.read(buf, offset, length);</span> + +<span class="fc bfc" id="L84" title="All 2 branches covered."> if (len > 0) {</span> + +<span class="fc bfc" id="L86" title="All 2 branches covered."> for (int i = offset; i < offset + len; i++) {</span> +<span class="fc" id="L87"> final char ch = buf[i];</span> +<span class="fc bfc" id="L88" title="All 2 branches covered."> if (ch == LF) {</span> +<span class="fc bfc" id="L89" title="All 4 branches covered."> if (CR != (i > 0 ? buf[i - 1] : lastChar)) {</span> +<span class="fc" id="L90"> eolCounter++;</span> + } +<span class="fc bfc" id="L92" title="All 2 branches covered."> } else if (ch == CR) {</span> +<span class="fc" id="L93"> eolCounter++;</span> + } + } + +<span class="fc" id="L97"> lastChar = buf[offset + len - 1];</span> + +<span class="pc bpc" id="L99" title="1 of 2 branches missed."> } else if (len == -1) {</span> +<span class="fc" id="L100"> lastChar = END_OF_STREAM;</span> + } + +<span class="fc" id="L103"> return len;</span> + } + + /** + * Calls {@link BufferedReader#readLine()} which drops the line terminator(s). This method should only be called + * when processing a comment, otherwise information can be lost. + * <p> + * Increments {@link #eolCounter} + * <p> + * Sets {@link #lastChar} to {@link Constants#END_OF_STREAM} at EOF, otherwise to LF + * + * @return the line that was read, or null if reached EOF. + */ + @Override + public String readLine() throws IOException { +<span class="fc" id="L118"> final String line = super.readLine();</span> + +<span class="fc bfc" id="L120" title="All 2 branches covered."> if (line != null) {</span> +<span class="fc" id="L121"> lastChar = LF; // needed for detecting start of line</span> +<span class="fc" id="L122"> eolCounter++;</span> + } else { +<span class="fc" id="L124"> lastChar = END_OF_STREAM;</span> + } + +<span class="fc" id="L127"> return line;</span> + } + + /** + * Returns the next character in the current reader without consuming it. So the next call to {@link #read()} will + * still return this value. Does not affect line number or last character. + * + * @return the next character + * + * @throws IOException + * if there is an error in reading + */ + int lookAhead() throws IOException { +<span class="fc" id="L140"> super.mark(1);</span> +<span class="fc" id="L141"> final int c = super.read();</span> +<span class="fc" id="L142"> super.reset();</span> + +<span class="fc" id="L144"> return c;</span> + } + + /** + * Returns the current line number + * + * @return the current line number + */ + long getCurrentLineNumber() { + // Check if we are at EOL or EOF or just starting +<span class="fc bfc" id="L154" title="All 8 branches covered."> if (lastChar == CR || lastChar == LF || lastChar == UNDEFINED || lastChar == END_OF_STREAM) {</span> +<span class="fc" id="L155"> return eolCounter; // counter is accurate</span> + } +<span class="fc" id="L157"> return eolCounter + 1; // Allow for counter being incremented only at EOL</span> + } + + public boolean isClosed() { +<span class="fc" id="L161"> return closed;</span> + } + + /** + * Closes the stream. + * + * @throws IOException + * If an I/O error occurs + */ + @Override + public void close() throws IOException { + // Set ivars before calling super close() in case close() throws an IOException. +<span class="fc" id="L173"> closed = true;</span> +<span class="fc" id="L174"> lastChar = END_OF_STREAM;</span> +<span class="fc" id="L175"> super.close();</span> +<span class="fc" id="L176"> }</span> + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.html Thu Aug 14 19:48:06 2014 @@ -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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>Lexer</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">Lexer</span></div><h1>Lexer</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSor t(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">52 of 585</td><td class="ctr2">91%</td><td class="bar">9 of 120</td><td class="ctr2">92%</td><td class="ctr1">9</td><td class="ctr2">82</td><td class="ctr1">8</td><td class="ctr2">131</td><td c lass="ctr1">0</td><td class="ctr2">19</td></tr></tfoot><tbody><tr><td id="a14"><a href="Lexer.java.html#L242" class="el_method">parseEncapsulatedToken(Token)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="32" height="10" title="41" alt="41"/><img src="../.resources/greenbar.gif" width="73" height="10" title="94" alt="94"/></td><td class="ctr2" id="c18">70%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="10" height="10" title="3" alt="3"/><img src="../.resources/greenbar.gif" width="50" height="10" title="15" alt="15"/></td><td class="ctr2" id="e12">83%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g1">10</td><td class="ctr1" id="h0">3</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="a17"><a href="Lexer.java.html#L318" class="el_method">readEscape()</a></td><td class="bar" id="b1"><img src="../.resources/redbar.gif" width="4" height="10" title="6" alt="6"/><i mg src="../.resources/greenbar.gif" width="19" height="10" title="25" alt="25"/></td><td class="ctr2" id="c17">81%</td><td class="bar" id="d1"><img src="../.resources/redbar.gif" width="10" height="10" title="3" alt="3"/><img src="../.resources/greenbar.gif" width="23" height="10" title="7" alt="7"/></td><td class="ctr2" id="e14">70%</td><td class="ctr1" id="f1">3</td><td class="ctr2" id="g2">9</td><td class="ctr1" id="h1">3</td><td class="ctr2" id="i3">12</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a13"><a href="Lexer.java.html#L86" class="el_method">nextToken(Token)</a></td><td class="bar" id="b2"><img src="../.resources/redbar.gif" width="3" height="10" title="5" alt="5"/><img src="../.resources/greenbar.gif" width="116" height="10" title="148" alt="148"/></td><td class="ctr2" id="c16">97%</td><td class="bar" id="d2"><img src="../.resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="116" height="10" title="35" alt="35"/></td><td class="ctr2" id="e10">97%</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g0">19</td><td class="ctr1" id="h2">2</td><td class="ctr2" id="i0">39</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a15"><a href="Lexer.java.html#L189" class="el_method">parseSimpleToken(Token, int)</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="62" height="10" title="80" alt="80"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d5"><img src="../.resources/greenbar.gif" width="40" height="10" title="12" alt="12"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g3">7</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i2">22</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a11"><a href="Lexer.java.html#L62" class="el_method">Lexer(CSVFormat, ExtendedBufferedReader)</a></td><td class="bar" id="b4"><img src ="../.resources/greenbar.gif" width="28" height="10" title="36" alt="36"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d15"/><td class="ctr2" id="e15">n/a</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g15">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">9</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a18"><a href="Lexer.java.html#L349" class="el_method">trimTrailingSpaces(StringBuilder)</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="19" height="10" title="25" alt="25"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d4"><img src="../.resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="16" height="10" title="5" alt="5"/></td><td class="ctr2" id="e13">83%</td><td class="ctr1" id="f3">1</td><td class="ctr2" id="g6">4</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">6</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a16"><a href="Lexer.java.html#L365" class="el_method">readEndOfLine(int)</a></td><td class="bar" id="b6"><img src="../.resources/greenbar.gif" width="17" height="10" title="22" alt="22"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d6"><img src="../.resources/greenbar.gif" width="26" height="10" title="8" alt="8"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f7">0</td><td class="ctr2" id="g4">5</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="a7"><a href="Lexer.java.html#L417" class="el_method">isMetaChar(int)</a></td><td class="bar" id="b7"><img src="../.resources/greenbar.gif" width="15" height="10" title="20" alt="20"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d3"><img src="../.resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="23" height="1 0" title="7" alt="7"/></td><td class="ctr2" id="e11">88%</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g5">5</td><td class="ctr1" id="h7">0</td><td class="ctr2" id="i8">1</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a9"><a href="Lexer.java.html#L390" class="el_method">isStartOfLine(int)</a></td><td class="bar" id="b8"><img src="../.resources/greenbar.gif" width="10" height="10" title="13" alt="13"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d7"><img src="../.resources/greenbar.gif" width="20" height="10" title="6" alt="6"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" id="f8">0</td><td class="ctr2" id="g7">4</td><td class="ctr1" id="h8">0</td><td class="ctr2" id="i9">1</td><td class="ctr1" id="j8">0</td><td class="ctr2" id="k8">1</td></tr><tr><td id="a10"><a href="Lexer.java.html#L380" class="el_method">isWhitespace(int)</a></td><td class="bar" id="b9"><img src="../.resources/greenbar.gif" width="9" height="10 " title="12" alt="12"/></td><td class="ctr2" id="c6">100%</td><td class="bar" id="d8"><img src="../.resources/greenbar.gif" width="13" height="10" title="4" alt="4"/></td><td class="ctr2" id="e3">100%</td><td class="ctr1" id="f9">0</td><td class="ctr2" id="g8">3</td><td class="ctr1" id="h9">0</td><td class="ctr2" id="i10">1</td><td class="ctr1" id="j9">0</td><td class="ctr2" id="k9">1</td></tr><tr><td id="a4"><a href="Lexer.java.html#L401" class="el_method">isDelimiter(int)</a></td><td class="bar" id="b10"><img src="../.resources/greenbar.gif" width="6" height="10" title="8" alt="8"/></td><td class="ctr2" id="c7">100%</td><td class="bar" id="d9"><img src="../.resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e4">100%</td><td class="ctr1" id="f10">0</td><td class="ctr2" id="g9">2</td><td class="ctr1" id="h10">0</td><td class="ctr2" id="i11">1</td><td class="ctr1" id="j10">0</td><td class="ctr2" id="k10">1</td></tr><tr><td id="a6"><a href="Lexe r.java.html#L405" class="el_method">isEscape(int)</a></td><td class="bar" id="b11"><img src="../.resources/greenbar.gif" width="6" height="10" title="8" alt="8"/></td><td class="ctr2" id="c8">100%</td><td class="bar" id="d10"><img src="../.resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e5">100%</td><td class="ctr1" id="f11">0</td><td class="ctr2" id="g10">2</td><td class="ctr1" id="h11">0</td><td class="ctr2" id="i12">1</td><td class="ctr1" id="j11">0</td><td class="ctr2" id="k11">1</td></tr><tr><td id="a8"><a href="Lexer.java.html#L409" class="el_method">isQuoteChar(int)</a></td><td class="bar" id="b12"><img src="../.resources/greenbar.gif" width="6" height="10" title="8" alt="8"/></td><td class="ctr2" id="c9">100%</td><td class="bar" id="d11"><img src="../.resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e6">100%</td><td class="ctr1" id="f12">0</td><td class="ctr2" id="g11">2</td><td class="ctr1" id="h12">0</td><td class="ctr2" id="i13">1</td><td class="ctr1" id="j12">0</td><td class="ctr2" id="k12">1</td></tr><tr><td id="a3"><a href="Lexer.java.html#L413" class="el_method">isCommentStart(int)</a></td><td class="bar" id="b13"><img src="../.resources/greenbar.gif" width="6" height="10" title="8" alt="8"/></td><td class="ctr2" id="c10">100%</td><td class="bar" id="d12"><img src="../.resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e7">100%</td><td class="ctr1" id="f13">0</td><td class="ctr2" id="g12">2</td><td class="ctr1" id="h13">0</td><td class="ctr2" id="i14">1</td><td class="ctr1" id="j13">0</td><td class="ctr2" id="k13">1</td></tr><tr><td id="a12"><a href="Lexer.java.html#L292" class="el_method">mapNullToDisabled(Character)</a></td><td class="bar" id="b14"><img src="../.resources/greenbar.gif" width="5" height="10" title="7" alt="7"/></td><td class="ctr2" id="c11">100%</td><td class="bar" id="d13"><img src="../.resources/greenba r.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e8">100%</td><td class="ctr1" id="f14">0</td><td class="ctr2" id="g13">2</td><td class="ctr1" id="h14">0</td><td class="ctr2" id="i15">1</td><td class="ctr1" id="j14">0</td><td class="ctr2" id="k14">1</td></tr><tr><td id="a5"><a href="Lexer.java.html#L397" class="el_method">isEndOfFile(int)</a></td><td class="bar" id="b15"><img src="../.resources/greenbar.gif" width="5" height="10" title="7" alt="7"/></td><td class="ctr2" id="c12">100%</td><td class="bar" id="d14"><img src="../.resources/greenbar.gif" width="6" height="10" title="2" alt="2"/></td><td class="ctr2" id="e9">100%</td><td class="ctr1" id="f15">0</td><td class="ctr2" id="g14">2</td><td class="ctr1" id="h15">0</td><td class="ctr2" id="i16">1</td><td class="ctr1" id="j15">0</td><td class="ctr2" id="k15">1</td></tr><tr><td id="a1"><a href="Lexer.java.html#L301" class="el_method">getCurrentLineNumber()</a></td><td class="bar" id="b16"><img src="../.reso urces/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c13">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="i17">1</td><td class="ctr1" id="j16">0</td><td class="ctr2" id="k16">1</td></tr><tr><td id="a2"><a href="Lexer.java.html#L373" class="el_method">isClosed()</a></td><td class="bar" id="b17"><img src="../.resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c14">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</td><td class="ctr2" id="i18">1</td><td class="ctr1" id="j17">0</td><td class="ctr2" id="k17">1</td></tr><tr><td id="a0"><a href="Lexer.java.html#L430" class="el_method">close()</a></td><td class="bar" id="b18"><img src="../.resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c15">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="i7">2</td><td class="ctr1" id="j18">0</td><td class="ctr2" id="k18">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.java.html (added) +++ websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.java.html Thu Aug 14 19:48:06 2014 @@ -0,0 +1,433 @@ +<?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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>Lexer.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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">Lexer.java</span></div><h1>Lexer.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.BACKSPACE; +import static org.apache.commons.csv.Constants.CR; +import static org.apache.commons.csv.Constants.END_OF_STREAM; +import static org.apache.commons.csv.Constants.FF; +import static org.apache.commons.csv.Constants.LF; +import static org.apache.commons.csv.Constants.TAB; +import static org.apache.commons.csv.Constants.UNDEFINED; +import static org.apache.commons.csv.Token.Type.COMMENT; +import static org.apache.commons.csv.Token.Type.EOF; +import static org.apache.commons.csv.Token.Type.EORECORD; +import static org.apache.commons.csv.Token.Type.INVALID; +import static org.apache.commons.csv.Token.Type.TOKEN; + +import java.io.Closeable; +import java.io.IOException; + +/** + * + * + * @version $Id: Lexer.java 1612390 2014-07-21 19:42:40Z britter $ + */ +final class Lexer implements Closeable { + + /** + * Constant char to use for disabling comments, escapes and encapsulation. The value -2 is used because it + * won't be confused with an EOF signal (-1), and because the Unicode value {@code FFFE} would be encoded as two + * chars (using surrogates) and thus there should never be a collision with a real text char. + */ + private static final char DISABLED = '\ufffe'; + + private final char delimiter; + private final char escape; + private final char quoteChar; + private final char commentStart; + + private final boolean ignoreSurroundingSpaces; + private final boolean ignoreEmptyLines; + + /** The input stream */ + private final ExtendedBufferedReader reader; + + /** INTERNAL API. but ctor needs to be called dynamically by PerformanceTest class */ +<span class="fc" id="L62"> Lexer(final CSVFormat format, final ExtendedBufferedReader reader) {</span> +<span class="fc" id="L63"> this.reader = reader;</span> +<span class="fc" id="L64"> this.delimiter = format.getDelimiter();</span> +<span class="fc" id="L65"> this.escape = mapNullToDisabled(format.getEscapeCharacter());</span> +<span class="fc" id="L66"> this.quoteChar = mapNullToDisabled(format.getQuoteCharacter());</span> +<span class="fc" id="L67"> this.commentStart = mapNullToDisabled(format.getCommentMarker());</span> +<span class="fc" id="L68"> this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces();</span> +<span class="fc" id="L69"> this.ignoreEmptyLines = format.getIgnoreEmptyLines();</span> +<span class="fc" id="L70"> }</span> + + /** + * Returns the next token. + * <p/> + * A token corresponds to a term, a record change or an end-of-file indicator. + * + * @param token + * an existing Token object to reuse. The caller is responsible to initialize the Token. + * @return the next token found + * @throws java.io.IOException + * on stream access error + */ + Token nextToken(final Token token) throws IOException { + + // get the last read char (required for empty line detection) +<span class="fc" id="L86"> int lastChar = reader.getLastChar();</span> + + // read the next char and set eol +<span class="fc" id="L89"> int c = reader.read();</span> + /* + * Note: The following call will swallow LF if c == CR. But we don't need to know if the last char was CR or LF + * - they are equivalent here. + */ +<span class="fc" id="L94"> boolean eol = readEndOfLine(c);</span> + + // empty line detection: eol AND (last char was EOL or beginning) +<span class="fc bfc" id="L97" title="All 2 branches covered."> if (ignoreEmptyLines) {</span> +<span class="fc bfc" id="L98" title="All 4 branches covered."> while (eol && isStartOfLine(lastChar)) {</span> + // go on char ahead ... +<span class="fc" id="L100"> lastChar = c;</span> +<span class="fc" id="L101"> c = reader.read();</span> +<span class="fc" id="L102"> eol = readEndOfLine(c);</span> + // reached end of file without any content (empty line at the end) +<span class="fc bfc" id="L104" title="All 2 branches covered."> if (isEndOfFile(c)) {</span> +<span class="fc" id="L105"> token.type = EOF;</span> + // don't set token.isReady here because no content +<span class="fc" id="L107"> return token;</span> + } + } + } + + // did we reach eof during the last iteration already ? EOF +<span class="fc bfc" id="L113" title="All 6 branches covered."> if (isEndOfFile(lastChar) || (!isDelimiter(lastChar) && isEndOfFile(c))) {</span> +<span class="fc" id="L114"> token.type = EOF;</span> + // don't set token.isReady here because no content +<span class="fc" id="L116"> return token;</span> + } + +<span class="fc bfc" id="L119" title="All 4 branches covered."> if (isStartOfLine(lastChar) && isCommentStart(c)) {</span> +<span class="fc" id="L120"> final String line = reader.readLine();</span> +<span class="pc bpc" id="L121" title="1 of 2 branches missed."> if (line == null) {</span> +<span class="nc" id="L122"> token.type = EOF;</span> + // don't set token.isReady here because no content +<span class="nc" id="L124"> return token;</span> + } +<span class="fc" id="L126"> final String comment = line.trim();</span> +<span class="fc" id="L127"> token.content.append(comment);</span> +<span class="fc" id="L128"> token.type = COMMENT;</span> +<span class="fc" id="L129"> return token;</span> + } + + // important: make sure a new char gets consumed in each iteration +<span class="fc bfc" id="L133" title="All 2 branches covered."> while (token.type == INVALID) {</span> + // ignore whitespaces at beginning of a token +<span class="fc bfc" id="L135" title="All 2 branches covered."> if (ignoreSurroundingSpaces) {</span> +<span class="fc bfc" id="L136" title="All 4 branches covered."> while (isWhitespace(c) && !eol) {</span> +<span class="fc" id="L137"> c = reader.read();</span> +<span class="fc" id="L138"> eol = readEndOfLine(c);</span> + } + } + + // ok, start of token reached: encapsulated, or token +<span class="fc bfc" id="L143" title="All 2 branches covered."> if (isDelimiter(c)) {</span> + // empty token return TOKEN("") +<span class="fc" id="L145"> token.type = TOKEN;</span> +<span class="fc bfc" id="L146" title="All 2 branches covered."> } else if (eol) {</span> + // empty token return EORECORD("") + // noop: token.content.append(""); +<span class="fc" id="L149"> token.type = EORECORD;</span> +<span class="fc bfc" id="L150" title="All 2 branches covered."> } else if (isQuoteChar(c)) {</span> + // consume encapsulated token +<span class="fc" id="L152"> parseEncapsulatedToken(token);</span> +<span class="fc bfc" id="L153" title="All 2 branches covered."> } else if (isEndOfFile(c)) {</span> + // end of file return EOF() + // noop: token.content.append(""); +<span class="fc" id="L156"> token.type = EOF;</span> +<span class="fc" id="L157"> token.isReady = true; // there is data at EOF</span> + } else { + // next token must be a simple token + // add removed blanks when not ignoring whitespace chars... +<span class="fc" id="L161"> parseSimpleToken(token, c);</span> + } + } +<span class="fc" id="L164"> return token;</span> + } + + /** + * Parses a simple token. + * <p/> + * Simple token are tokens which are not surrounded by encapsulators. A simple token might contain escaped + * delimiters (as \, or \;). The token is finished when one of the following conditions become true: + * <ul> + * <li>end of line has been reached (EORECORD)</li> + * <li>end of stream has been reached (EOF)</li> + * <li>an unescaped delimiter has been reached (TOKEN)</li> + * </ul> + * + * @param token + * the current token + * @param ch + * the current character + * @return the filled token + * @throws IOException + * on stream access error + */ + private Token parseSimpleToken(final Token token, int ch) throws IOException { + // Faster to use while(true)+break than while(token.type == INVALID) + while (true) { +<span class="fc bfc" id="L189" title="All 2 branches covered."> if (readEndOfLine(ch)) {</span> +<span class="fc" id="L190"> token.type = EORECORD;</span> +<span class="fc" id="L191"> break;</span> +<span class="fc bfc" id="L192" title="All 2 branches covered."> } else if (isEndOfFile(ch)) {</span> +<span class="fc" id="L193"> token.type = EOF;</span> +<span class="fc" id="L194"> token.isReady = true; // There is data at EOF</span> +<span class="fc" id="L195"> break;</span> +<span class="fc bfc" id="L196" title="All 2 branches covered."> } else if (isDelimiter(ch)) {</span> +<span class="fc" id="L197"> token.type = TOKEN;</span> +<span class="fc" id="L198"> break;</span> +<span class="fc bfc" id="L199" title="All 2 branches covered."> } else if (isEscape(ch)) {</span> +<span class="fc" id="L200"> final int unescaped = readEscape();</span> +<span class="fc bfc" id="L201" title="All 2 branches covered."> if (unescaped == Constants.END_OF_STREAM) { // unexpected char after escape</span> +<span class="fc" id="L202"> token.content.append((char) ch).append((char) reader.getLastChar());</span> + } else { +<span class="fc" id="L204"> token.content.append((char) unescaped);</span> + } +<span class="fc" id="L206"> ch = reader.read(); // continue</span> +<span class="fc" id="L207"> } else {</span> +<span class="fc" id="L208"> token.content.append((char) ch);</span> +<span class="fc" id="L209"> ch = reader.read(); // continue</span> + } + } + +<span class="fc bfc" id="L213" title="All 2 branches covered."> if (ignoreSurroundingSpaces) {</span> +<span class="fc" id="L214"> trimTrailingSpaces(token.content);</span> + } + +<span class="fc" id="L217"> return token;</span> + } + + /** + * Parses an encapsulated token. + * <p/> + * Encapsulated tokens are surrounded by the given encapsulating-string. The encapsulator itself might be included + * in the token using a doubling syntax (as "", '') or using escaping (as in \", \'). Whitespaces before and after + * an encapsulated token are ignored. The token is finished when one of the following conditions become true: + * <ul> + * <li>an unescaped encapsulator has been reached, and is followed by optional whitespace then:</li> + * <ul> + * <li>delimiter (TOKEN)</li> + * <li>end of line (EORECORD)</li> + * </ul> + * <li>end of stream has been reached (EOF)</li> </ul> + * + * @param token + * the current token + * @return a valid token object + * @throws IOException + * on invalid state: EOF before closing encapsulator or invalid character before delimiter or EOL + */ + private Token parseEncapsulatedToken(final Token token) throws IOException { + // save current line number in case needed for IOE +<span class="fc" id="L242"> final long startLineNumber = getCurrentLineNumber();</span> + int c; + while (true) { +<span class="fc" id="L245"> c = reader.read();</span> + +<span class="fc bfc" id="L247" title="All 2 branches covered."> if (isEscape(c)) {</span> +<span class="fc" id="L248"> final int unescaped = readEscape();</span> +<span class="pc bpc" id="L249" title="1 of 2 branches missed."> if (unescaped == Constants.END_OF_STREAM) { // unexpected char after escape</span> +<span class="nc" id="L250"> token.content.append((char) c).append((char) reader.getLastChar());</span> + } else { +<span class="fc" id="L252"> token.content.append((char) unescaped);</span> + } +<span class="fc bfc" id="L254" title="All 2 branches covered."> } else if (isQuoteChar(c)) {</span> +<span class="fc bfc" id="L255" title="All 2 branches covered."> if (isQuoteChar(reader.lookAhead())) {</span> + // double or escaped encapsulator -> add single encapsulator to token +<span class="fc" id="L257"> c = reader.read();</span> +<span class="fc" id="L258"> token.content.append((char) c);</span> + } else { + // token finish mark (encapsulator) reached: ignore whitespace till delimiter + while (true) { +<span class="fc" id="L262"> c = reader.read();</span> +<span class="fc bfc" id="L263" title="All 2 branches covered."> if (isDelimiter(c)) {</span> +<span class="fc" id="L264"> token.type = TOKEN;</span> +<span class="fc" id="L265"> return token;</span> +<span class="fc bfc" id="L266" title="All 2 branches covered."> } else if (isEndOfFile(c)) {</span> +<span class="fc" id="L267"> token.type = EOF;</span> +<span class="fc" id="L268"> token.isReady = true; // There is data at EOF</span> +<span class="fc" id="L269"> return token;</span> +<span class="fc bfc" id="L270" title="All 2 branches covered."> } else if (readEndOfLine(c)) {</span> +<span class="fc" id="L271"> token.type = EORECORD;</span> +<span class="fc" id="L272"> return token;</span> +<span class="pc bpc" id="L273" title="1 of 2 branches missed."> } else if (!isWhitespace(c)) {</span> + // error invalid char between token and next delimiter +<span class="nc" id="L275"> throw new IOException("(line " + getCurrentLineNumber() +</span> + ") invalid char between encapsulated token and delimiter"); + } + } + } +<span class="pc bpc" id="L280" title="1 of 2 branches missed."> } else if (isEndOfFile(c)) {</span> + // error condition (end of file before end of token) +<span class="nc" id="L282"> throw new IOException("(startline " + startLineNumber +</span> + ") EOF reached before encapsulated token finished"); + } else { + // consume character +<span class="fc" id="L286"> token.content.append((char) c);</span> + } + } + } + + private char mapNullToDisabled(final Character c) { +<span class="fc bfc" id="L292" title="All 2 branches covered."> return c == null ? DISABLED : c.charValue();</span> + } + + /** + * Returns the current line number + * + * @return the current line number + */ + long getCurrentLineNumber() { +<span class="fc" id="L301"> return reader.getCurrentLineNumber();</span> + } + + // TODO escape handling needs more work + /** + * Handle an escape sequence. + * The current character must be the escape character. + * On return, the next character is available by calling {@link ExtendedBufferedReader#getLastChar()} + * on the input stream. + * + * @return the unescaped character (as an int) or {@link Constants#END_OF_STREAM} if char following the escape is + * invalid. + * @throws IOException if there is a problem reading the stream or the end of stream is detected: + * the escape character is not allowed at end of strem + */ + int readEscape() throws IOException { + // the escape char has just been read (normally a backslash) +<span class="fc" id="L318"> final int ch = reader.read();</span> +<span class="pc bpc" id="L319" title="3 of 8 branches missed."> switch (ch) {</span> + case 'r': +<span class="fc" id="L321"> return CR;</span> + case 'n': +<span class="fc" id="L323"> return LF;</span> + case 't': +<span class="nc" id="L325"> return TAB;</span> + case 'b': +<span class="nc" id="L327"> return BACKSPACE;</span> + case 'f': +<span class="nc" id="L329"> return FF;</span> + case CR: + case LF: + case FF: // TODO is this correct? + case TAB: // TODO is this correct? Do tabs need to be escaped? + case BACKSPACE: // TODO is this correct? +<span class="fc" id="L335"> return ch;</span> + case END_OF_STREAM: +<span class="fc" id="L337"> throw new IOException("EOF whilst processing escape sequence");</span> + default: + // Now check for meta-characters +<span class="fc bfc" id="L340" title="All 2 branches covered."> if (isMetaChar(ch)) {</span> +<span class="fc" id="L341"> return ch;</span> + } + // indicate unexpected char - available from in.getLastChar() +<span class="fc" id="L344"> return END_OF_STREAM;</span> + } + } + + void trimTrailingSpaces(final StringBuilder buffer) { +<span class="fc" id="L349"> int length = buffer.length();</span> +<span class="pc bpc" id="L350" title="1 of 4 branches missed."> while (length > 0 && Character.isWhitespace(buffer.charAt(length - 1))) {</span> +<span class="fc" id="L351"> length = length - 1;</span> + } +<span class="fc bfc" id="L353" title="All 2 branches covered."> if (length != buffer.length()) {</span> +<span class="fc" id="L354"> buffer.setLength(length);</span> + } +<span class="fc" id="L356"> }</span> + + /** + * Greedily accepts \n, \r and \r\n This checker consumes silently the second control-character... + * + * @return true if the given or next character is a line-terminator + */ + boolean readEndOfLine(int ch) throws IOException { + // check if we have \r\n... +<span class="fc bfc" id="L365" title="All 4 branches covered."> if (ch == CR && reader.lookAhead() == LF) {</span> + // note: does not change ch outside of this method! +<span class="fc" id="L367"> ch = reader.read();</span> + } +<span class="fc bfc" id="L369" title="All 4 branches covered."> return ch == LF || ch == CR;</span> + } + + boolean isClosed() { +<span class="fc" id="L373"> return reader.isClosed();</span> + } + + /** + * @return true if the given char is a whitespace character + */ + boolean isWhitespace(final int ch) { +<span class="fc bfc" id="L380" title="All 4 branches covered."> return !isDelimiter(ch) && Character.isWhitespace((char) ch);</span> + } + + /** + * Checks if the current character represents the start of a line: a CR, LF or is at the start of the file. + * + * @param ch the character to check + * @return true if the character is at the start of a line. + */ + boolean isStartOfLine(final int ch) { +<span class="fc bfc" id="L390" title="All 6 branches covered."> return ch == LF || ch == CR || ch == UNDEFINED;</span> + } + + /** + * @return true if the given character indicates end of file + */ + boolean isEndOfFile(final int ch) { +<span class="fc bfc" id="L397" title="All 2 branches covered."> return ch == END_OF_STREAM;</span> + } + + boolean isDelimiter(final int ch) { +<span class="fc bfc" id="L401" title="All 2 branches covered."> return ch == delimiter;</span> + } + + boolean isEscape(final int ch) { +<span class="fc bfc" id="L405" title="All 2 branches covered."> return ch == escape;</span> + } + + boolean isQuoteChar(final int ch) { +<span class="fc bfc" id="L409" title="All 2 branches covered."> return ch == quoteChar;</span> + } + + boolean isCommentStart(final int ch) { +<span class="fc bfc" id="L413" title="All 2 branches covered."> return ch == commentStart;</span> + } + + private boolean isMetaChar(final int ch) { +<span class="pc bpc" id="L417" title="1 of 8 branches missed."> return ch == delimiter ||</span> + ch == escape || + ch == quoteChar || + ch == commentStart; + } + + /** + * Closes resources. + * + * @throws IOException + * If an I/O error occurs + */ + public void close() throws IOException { +<span class="fc" id="L430"> reader.close();</span> +<span class="fc" id="L431"> }</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.1.201405082137</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/Lexer.java.html ------------------------------------------------------------------------------ svn:eol-style = native