Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/CSVRecord.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/CSVRecord.java.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/CSVRecord.java.html Wed Nov 26 15:56:58 2014 @@ -0,0 +1,263 @@ +<?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$ + */ +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; + + private final long characterPosition; + + /** 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, final String comment, final long recordNumber, +<span class="fc" id="L54"> long characterPosition) {</span> +<span class="fc" id="L55"> this.recordNumber = recordNumber;</span> +<span class="pc bpc" id="L56" title="1 of 2 branches missed."> this.values = values != null ? values : EMPTY_STRING_ARRAY;</span> +<span class="fc" id="L57"> this.mapping = mapping;</span> +<span class="fc" id="L58"> this.comment = comment;</span> +<span class="fc" id="L59"> this.characterPosition = characterPosition;</span> +<span class="fc" id="L60"> }</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="L70"> 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="L81"> 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="L98" title="All 2 branches covered."> if (mapping == null) {</span> +<span class="fc" id="L99"> throw new IllegalStateException(</span> + "No header mapping was specified, the record values can't be accessed by name"); + } +<span class="fc" id="L102"> final Integer index = mapping.get(name);</span> +<span class="fc bfc" id="L103" title="All 2 branches covered."> if (index == null) {</span> +<span class="fc" id="L104"> throw new IllegalArgumentException(String.format("Mapping for %s not found, expected one of %s", name,</span> +<span class="fc" id="L105"> mapping.keySet()));</span> + } + try { +<span class="fc" id="L108"> return values[index.intValue()];</span> +<span class="fc" id="L109"> } catch (final ArrayIndexOutOfBoundsException e) {</span> +<span class="fc" id="L110"> throw new IllegalArgumentException(String.format(</span> + "Index for header '%s' is %d but CSVRecord only has %d values!", name, index, +<span class="fc" id="L112"> Integer.valueOf(values.length)));</span> + } + } + + /** + * Returns the start position of this record as a character position in the source stream. This may or may not + * correspond to the byte position depending on the character set. + * + * @return the position of this record in the source stream. + */ + public long getCharacterPosition() { +<span class="fc" id="L123"> return characterPosition;</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="L132"> 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="L147"> 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="L161" 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="L172" 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="L183" 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. + */ + @Override + public Iterator<String> iterator() { +<span class="fc" id="L193"> 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="L204" title="All 2 branches covered."> if (mapping == null) {</span> +<span class="fc" id="L205"> return map;</span> + } +<span class="fc bfc" id="L207" title="All 2 branches covered."> for (final Entry<String, Integer> entry : mapping.entrySet()) {</span> +<span class="fc" id="L208"> final int col = entry.getValue().intValue();</span> +<span class="fc bfc" id="L209" title="All 2 branches covered."> if (col < values.length) {</span> +<span class="fc" id="L210"> map.put(entry.getKey(), values[col]);</span> + } +<span class="fc" id="L212"> }</span> +<span class="fc" id="L213"> return map;</span> + } + + /** + * Returns the number of values in this record. + * + * @return the number of values. + */ + public int size() { +<span class="fc" id="L222"> 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="L233"> 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="L242"> return putIn(new HashMap<String, String>(values.length));</span> + } + + /** + * Returns a string representation of the contents of this record. The result is constructed by comment, mapping, + * recordNumber and by passing the internal values array to {@link Arrays#toString(Object[])}. + * + * @return a String representation of this record. + */ + @Override + public String toString() { +<span class="nc" id="L253"> return "CSVRecord [comment=" + comment + ", mapping=" + mapping +</span> + ", recordNumber=" + recordNumber + ", values=" + +<span class="nc" id="L255"> Arrays.toString(values) + "]";</span> + } + + String[] values() { +<span class="fc" id="L259"> return values;</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file
Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/CSVRecord.java.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/CSVRecord.java.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.html Wed Nov 26 15:56:58 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.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.java.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.java.html Wed Nov 26 15:56:58 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$ + */ +<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.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.java.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Constants.java.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html Wed Nov 26 15:56:58 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 191</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">26</td><td class="ctr1">0</td><td class="ctr2">45</td><td class="ctr1">0</td><td class="ctr2">10</td></tr></tfoot><tbody><tr><td id="a8"><a href="ExtendedBufferedReader.java.html#L83" class="el_method">read(char[], int, int)</a></td><td class="bar" id="b0"><img src="../.resources/greenbar.gif" width="120" height="10" title="81" alt="81"/></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">16</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a7"><a href="ExtendedBufferedReader.java.html#L60" class="el_method">read()</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="45" height="10" title="31" alt="31"/></td><td cla ss="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="i1">6</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#L160" class="el_method">getCurrentLineNumber()</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="35" 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="i5">3</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a9"><a href="ExtendedBufferedRea der.java.html#L124" class="el_method">readLine()</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="29" 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="i2">6</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a6"><a href="ExtendedBufferedReader.java.html#L146" class="el_method">lookAhead()</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="14" 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="a0"><a href="ExtendedBufferedReader.java.html#L188" class="el_method">close()</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="13" height="10" title="9" alt="9"/></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="a1"><a href="ExtendedBufferedReader.java.html#L41" class="el_method">ExtendedBufferedReader(Reader)</a></td><td class="bar" id="b6"><img src="../.resources/greenbar.gif" width="10" height="10" title="7" alt="7"/></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="i6">3</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#L78" 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#L172" class="el_method">getPosition()</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 class="ctr2" id="k8">1</td></tr><tr><td id="a5"><a href="ExtendedBufferedReader.java.html#L176" class="el_method">isClosed()</a></td><td class="bar" id="b9"><img src="../.resources/greenbar.gif" width="4" height="10" title="3" alt="3"/></td><td class="ctr2" id="c9">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></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html Wed Nov 26 15:56:58 2014 @@ -0,0 +1,194 @@ +<?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()}. This reader also tracks how many characters have been read with {@link #getPosition()}. + * </p> + * + * @version $Id$ + */ +final class ExtendedBufferedReader extends BufferedReader { + + /** The last char returned */ +<span class="fc" id="L41"> private int lastChar = UNDEFINED;</span> + + /** The count of EOLs (CR/LF/CRLF) seen so far */ + private long eolCounter; + + /** The position, which is number of characters read so far */ + private long position; + + private boolean closed; + + /** + * Created extended buffered reader using default buffer-size + */ + ExtendedBufferedReader(final Reader reader) { +<span class="fc" id="L55"> super(reader);</span> +<span class="fc" id="L56"> }</span> + + @Override + public int read() throws IOException { +<span class="fc" id="L60"> final int current = super.read();</span> +<span class="fc bfc" id="L61" title="All 6 branches covered."> if (current == CR || (current == LF && lastChar != CR)) {</span> +<span class="fc" id="L62"> eolCounter++;</span> + } +<span class="fc" id="L64"> lastChar = current;</span> +<span class="fc" id="L65"> this.position++;</span> +<span class="fc" id="L66"> 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="L78"> return lastChar;</span> + } + + @Override + public int read(final char[] buf, final int offset, final int length) throws IOException { +<span class="fc bfc" id="L83" title="All 2 branches covered."> if (length == 0) {</span> +<span class="fc" id="L84"> return 0;</span> + } + +<span class="fc" id="L87"> final int len = super.read(buf, offset, length);</span> + +<span class="fc bfc" id="L89" title="All 2 branches covered."> if (len > 0) {</span> + +<span class="fc bfc" id="L91" title="All 2 branches covered."> for (int i = offset; i < offset + len; i++) {</span> +<span class="fc" id="L92"> final char ch = buf[i];</span> +<span class="fc bfc" id="L93" title="All 2 branches covered."> if (ch == LF) {</span> +<span class="fc bfc" id="L94" title="All 4 branches covered."> if (CR != (i > 0 ? buf[i - 1] : lastChar)) {</span> +<span class="fc" id="L95"> eolCounter++;</span> + } +<span class="fc bfc" id="L97" title="All 2 branches covered."> } else if (ch == CR) {</span> +<span class="fc" id="L98"> eolCounter++;</span> + } + } + +<span class="fc" id="L102"> lastChar = buf[offset + len - 1];</span> + +<span class="pc bpc" id="L104" title="1 of 2 branches missed."> } else if (len == -1) {</span> +<span class="fc" id="L105"> lastChar = END_OF_STREAM;</span> + } + +<span class="fc" id="L108"> position += len;</span> +<span class="fc" id="L109"> 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="L124"> final String line = super.readLine();</span> + +<span class="fc bfc" id="L126" title="All 2 branches covered."> if (line != null) {</span> +<span class="fc" id="L127"> lastChar = LF; // needed for detecting start of line</span> +<span class="fc" id="L128"> eolCounter++;</span> + } else { +<span class="fc" id="L130"> lastChar = END_OF_STREAM;</span> + } + +<span class="fc" id="L133"> 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="L146"> super.mark(1);</span> +<span class="fc" id="L147"> final int c = super.read();</span> +<span class="fc" id="L148"> super.reset();</span> + +<span class="fc" id="L150"> 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="L160" title="All 8 branches covered."> if (lastChar == CR || lastChar == LF || lastChar == UNDEFINED || lastChar == END_OF_STREAM) {</span> +<span class="fc" id="L161"> return eolCounter; // counter is accurate</span> + } +<span class="fc" id="L163"> return eolCounter + 1; // Allow for counter being incremented only at EOL</span> + } + + /** + * Gets the character position in the reader. + * + * @return the current position in the reader (counting characters, not bytes since this is a Reader) + */ + long getPosition() { +<span class="fc" id="L172"> return this.position;</span> + } + + public boolean isClosed() { +<span class="fc" id="L176"> 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="L188"> closed = true;</span> +<span class="fc" id="L189"> lastChar = END_OF_STREAM;</span> +<span class="fc" id="L190"> super.close();</span> +<span class="fc" id="L191"> }</span> + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/ExtendedBufferedReader.java.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.html Wed Nov 26 15:56:58 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 589</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">83</td><td class="ctr1">8</td><td class="ctr2">132</td><td c lass="ctr1">0</td><td class="ctr2">20</td></tr></tfoot><tbody><tr><td id="a15"><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="c19">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="a18"><a href="Lexer.java.html#L327" 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="c18">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="a14"><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="c17">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="a16"><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="a12"><a href="Lexer.java.html#L61" 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="a19"><a href="Lexer.java.html#L358" 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="a17"><a href="Lexer.java.html#L374" 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="a8"><a href="Lexer.java.html#L426" 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="a10"><a href="Lexer.java.html#L399" 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="a11"><a href="Lexer.java.html#L389" class="el_method">isWhitespace(int)</a></td><td class="bar" id="b9"><img src="../.resources/greenbar.gif" width="9" height="1 0" 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="a5"><a href="Lexer.java.html#L410" 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="a7"><a href="Lex er.java.html#L414" 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="a9"><a href="Lexer.java.html#L418" 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="a4"><a href="Lexer.java.html#L422" 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="a13"><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/greenb ar.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="a6"><a href="Lexer.java.html#L406" 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="a2"><a href="Lexer.java.html#L301" class="el_method">getCurrentLineNumber()</a></td><td class="bar" id="b16"><img src="../.res ources/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="a1"><a href="Lexer.java.html#L310" class="el_method">getCharacterPosition()</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="a3"><a href="Lexer.java.html#L382" class="el_method">isClosed()</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="i19">1</td><td class="ctr1" id="j18">0</td><td class="ctr2" id="k18">1</td></tr><tr><td id="a0"><a href="Lexer.java.html#L440" class="el_method">close()</a></td><td class="bar" id="b19"><img src="../.resources/greenbar.gif" width="3" height="10" title="4" alt="4"/></td><td class="ctr2" id="c16">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="h19">0</td><td class="ctr2" id="i7">2</td><td class="ctr1" id="j19">0</td><td class="ctr2" id="k19">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.java.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.java.html Wed Nov 26 15:56:58 2014 @@ -0,0 +1,443 @@ +<?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; + +/** + * Lexical analyzer. + * + * @version $Id$ + */ +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; + +<span class="fc" id="L61"> Lexer(final CSVFormat format, final ExtendedBufferedReader reader) {</span> +<span class="fc" id="L62"> this.reader = reader;</span> +<span class="fc" id="L63"> this.delimiter = format.getDelimiter();</span> +<span class="fc" id="L64"> this.escape = mapNullToDisabled(format.getEscapeCharacter());</span> +<span class="fc" id="L65"> this.quoteChar = mapNullToDisabled(format.getQuoteCharacter());</span> +<span class="fc" id="L66"> this.commentStart = mapNullToDisabled(format.getCommentMarker());</span> +<span class="fc" id="L67"> this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces();</span> +<span class="fc" id="L68"> this.ignoreEmptyLines = format.getIgnoreEmptyLines();</span> +<span class="fc" id="L69"> }</span> + + /** + * Returns the next token. + * <p> + * A token corresponds to a term, a record change or an end-of-file indicator. + * </p> + * + * @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> + } + + /** + * Returns the current character position + * + * @return the current character position + */ + long getCharacterPosition() { +<span class="fc" id="L310"> return reader.getPosition();</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="L327"> final int ch = reader.read();</span> +<span class="pc bpc" id="L328" title="3 of 8 branches missed."> switch (ch) {</span> + case 'r': +<span class="fc" id="L330"> return CR;</span> + case 'n': +<span class="fc" id="L332"> return LF;</span> + case 't': +<span class="nc" id="L334"> return TAB;</span> + case 'b': +<span class="nc" id="L336"> return BACKSPACE;</span> + case 'f': +<span class="nc" id="L338"> 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="L344"> return ch;</span> + case END_OF_STREAM: +<span class="fc" id="L346"> throw new IOException("EOF whilst processing escape sequence");</span> + default: + // Now check for meta-characters +<span class="fc bfc" id="L349" title="All 2 branches covered."> if (isMetaChar(ch)) {</span> +<span class="fc" id="L350"> return ch;</span> + } + // indicate unexpected char - available from in.getLastChar() +<span class="fc" id="L353"> return END_OF_STREAM;</span> + } + } + + void trimTrailingSpaces(final StringBuilder buffer) { +<span class="fc" id="L358"> int length = buffer.length();</span> +<span class="pc bpc" id="L359" title="1 of 4 branches missed."> while (length > 0 && Character.isWhitespace(buffer.charAt(length - 1))) {</span> +<span class="fc" id="L360"> length = length - 1;</span> + } +<span class="fc bfc" id="L362" title="All 2 branches covered."> if (length != buffer.length()) {</span> +<span class="fc" id="L363"> buffer.setLength(length);</span> + } +<span class="fc" id="L365"> }</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="L374" 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="L376"> ch = reader.read();</span> + } +<span class="fc bfc" id="L378" title="All 4 branches covered."> return ch == LF || ch == CR;</span> + } + + boolean isClosed() { +<span class="fc" id="L382"> return reader.isClosed();</span> + } + + /** + * @return true if the given char is a whitespace character + */ + boolean isWhitespace(final int ch) { +<span class="fc bfc" id="L389" 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="L399" 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="L406" title="All 2 branches covered."> return ch == END_OF_STREAM;</span> + } + + boolean isDelimiter(final int ch) { +<span class="fc bfc" id="L410" title="All 2 branches covered."> return ch == delimiter;</span> + } + + boolean isEscape(final int ch) { +<span class="fc bfc" id="L414" title="All 2 branches covered."> return ch == escape;</span> + } + + boolean isQuoteChar(final int ch) { +<span class="fc bfc" id="L418" title="All 2 branches covered."> return ch == quoteChar;</span> + } + + boolean isCommentStart(final int ch) { +<span class="fc bfc" id="L422" title="All 2 branches covered."> return ch == commentStart;</span> + } + + private boolean isMetaChar(final int ch) { +<span class="pc bpc" id="L426" 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 + */ + @Override + public void close() throws IOException { +<span class="fc" id="L440"> reader.close();</span> +<span class="fc" id="L441"> }</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.java.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/Lexer.java.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.html Wed Nov 26 15:56:58 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>QuoteMode</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">QuoteMode</span></div><h1>QuoteMode</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">5 of 58</td><td class="ctr2">91%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">4</td><td class="ctr1">0</td><td class="ctr2">5</td> <td class="ctr1">1</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a2"><a href="QuoteMode.java.html#L24" class="el_method">valueOf(String)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="13" height="10" title="5" alt="5"/></td><td class="ctr2" id="c3">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="i1">1</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="QuoteMode.java.html#L24" class="el_method">static {...}</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="120" height="10" title="44" alt="44"/></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="i0">5</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a0"><a href="QuoteMode.java.html#L24" class="el_method">QuoteMode(String, int)</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="13" height="10" title="5" alt="5"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">1</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a3"><a href="QuoteMode.java.html#L24" class="el_method">values()</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="10" height="10" title="4" alt="4"/></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></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.html ------------------------------------------------------------------------------ svn:keywords = Id Added: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.java.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.java.html (added) +++ websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.java.html Wed Nov 26 15:56:58 2014 @@ -0,0 +1,49 @@ +<?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>QuoteMode.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">QuoteMode.java</span></div><h1>QuoteMode.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; + +/** + * Defines quote behavior when printing. + * + * @version $Id$ + */ +<span class="pc" id="L24">public enum QuoteMode {</span> + + /** + * Quotes all fields. + */ +<span class="fc" id="L29"> ALL,</span> + + /** + * Quotes fields which contain special characters such as a delimiter, quote character or any of the characters in + * line separator. + */ +<span class="fc" id="L35"> MINIMAL,</span> + + /** + * Quotes all non-numeric fields. + */ +<span class="fc" id="L40"> NON_NUMERIC,</span> + + /** + * Never quotes fields. When the delimiter occurs in data, it is preceded by the current escape character. If the + * escape character is not set, printing will throw an exception if any characters that require escaping are + * encountered. + */ +<span class="fc" id="L47"> NONE</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.java.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-csv/archives/1.1/jacoco/org.apache.commons.csv/QuoteMode.java.html ------------------------------------------------------------------------------ svn:keywords = Id