Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.html Sun Mar 1 12:14:29 2015 @@ -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>KeepCommand</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_class">KeepCommand</span></div><h1>KeepCommand</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 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">2</td><td class="ctr1">0</td><td class= "ctr2">4</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="KeepCommand.java.html#L55" class="el_method">accept(CommandVisitor)</a></td><td class="bar" id="b0"><img src="../.resources/greenbar.gif" width="120" height="10" title="5" alt="5"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">2</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="KeepCommand.java.html#L44" class="el_method">KeepCommand(Object)</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="96" height="10" title="4" alt="4"/></td><td class="ctr2" id="c1">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">2</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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.java.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.java.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.java.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,58 @@ +<?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>KeepCommand.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 Text</a> > <a href="index.source.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_source">KeepCommand.java</span></div><h1> KeepCommand.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.text.diff; + +/** + * Command representing the keeping of one object present in both sequences. + * <p> + * When one object of the first sequence <code>equals</code> another objects in + * the second sequence at the right place, the {@link EditScript edit script} + * transforming the first sequence into the second sequence uses an instance of + * this class to represent the keeping of this object. The objects embedded in + * these type of commands always come from the first sequence. + * </p> + * + * @see StringsComparator + * @see EditScript + * + * @since 1.0 + */ +public class KeepCommand<T> extends EditCommand<T> { + + /** + * Simple constructor. Creates a new instance of KeepCommand + * + * @param object the object belonging to both sequences (the object is a + * reference to the instance in the first sequence which is known + * to be equal to an instance in the second sequence) + */ + public KeepCommand(final T object) { +<span class="fc" id="L44"> super(object);</span> +<span class="fc" id="L45"> }</span> + + /** + * Accept a visitor. When a <code>KeepCommand</code> accepts a visitor, it + * calls its {@link CommandVisitor#visitKeepCommand visitKeepCommand} method. + * + * @param visitor the visitor to be accepted + */ + @Override + public void accept(final CommandVisitor<T> visitor) { +<span class="fc" id="L55"> visitor.visitKeepCommand(getObject());</span> +<span class="fc" id="L56"> }</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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/KeepCommand.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.html Sun Mar 1 12:14:29 2015 @@ -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>ReplacementsFinder</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_class">ReplacementsFinder</span></div><h1>ReplacementsFinder</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 65</td><td class="ctr2">100%</td><td class="bar">0 of 4</td><td class="ctr2">100%</td><td class="ctr1">0</td><td class="ctr2">6</td><td class= "ctr1">0</td><td class="ctr2">17</td><td class="ctr1">0</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a3"><a href="ReplacementsFinder.java.html#L92" class="el_method">visitKeepCommand(Object)</a></td><td class="bar" id="b0"><img src="../.resources/greenbar.gif" width="120" height="10" title="34" alt="34"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../.resources/greenbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">7</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="ReplacementsFinder.java.html#L66" class="el_method">ReplacementsFinder(ReplacementsHandler)</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="67" height="10" title="19" alt="19"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td clas s="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">6</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="ReplacementsFinder.java.html#L79" class="el_method">visitInsertCommand(Object)</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="21" height="10" title="6" alt="6"/></td><td class="ctr2" id="c2">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">2</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a1"><a href="ReplacementsFinder.java.html#L108" class="el_method">visitDeleteCommand(Object)</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="21" height="10" title="6" alt="6"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d 3"/><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">2</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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.java.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.java.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.java.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,112 @@ +<?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>ReplacementsFinder.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 Text</a> > <a href="index.source.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_source">ReplacementsFinder.java</s pan></div><h1>ReplacementsFinder.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.text.diff; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class handles sequences of replacements resulting from a comparison. + * <p> + * The comparison of two objects sequences leads to the identification of common + * parts and parts which only belong to the first or to the second sequence. The + * common parts appear in the edit script in the form of <em>keep</em> commands, + * they can be considered as synchronization objects between the two sequences. + * These synchronization objects split the two sequences in synchronized + * sub-sequences. The first sequence can be transformed into the second one by + * replacing each synchronized sub-sequence of the first sequence by the + * corresponding sub-sequence of the second sequence. This is a synthetic way to + * see an {@link EditScript edit script}, replacing individual + * {@link DeleteCommand delete}, {@link KeepCommand keep} and + * {@link InsertCommand insert} commands by fewer replacements acting on + * complete sub-sequences. + * </p> + * <p> + * This class is devoted to perform this interpretation. It visits an + * {@link EditScript edit script} (because it implements the + * {@link CommandVisitor CommandVisitor} interface) and calls a user-supplied + * handler implementing the {@link ReplacementsHandler ReplacementsHandler} + * interface to process the sub-sequences. + * </p> + * + * @see ReplacementsHandler + * @see EditScript + * @see StringsComparator + * + * @since 1.0 + */ +public class ReplacementsFinder<T> implements CommandVisitor<T> { + + private final List<T> pendingInsertions; + private final List<T> pendingDeletions; + private int skipped; + + /** Handler to call when synchronized sequences are found. */ + private final ReplacementsHandler<T> handler; + + /** + * Simple constructor. Creates a new instance of {@link ReplacementsFinder}. + * + * @param handler handler to call when synchronized sequences are found + */ +<span class="fc" id="L66"> public ReplacementsFinder(final ReplacementsHandler<T> handler) {</span> +<span class="fc" id="L67"> pendingInsertions = new ArrayList<T>();</span> +<span class="fc" id="L68"> pendingDeletions = new ArrayList<T>();</span> +<span class="fc" id="L69"> skipped = 0;</span> +<span class="fc" id="L70"> this.handler = handler;</span> +<span class="fc" id="L71"> }</span> + + /** + * Add an object to the pending insertions set. + * + * @param object object to insert + */ + public void visitInsertCommand(final T object) { +<span class="fc" id="L79"> pendingInsertions.add(object);</span> +<span class="fc" id="L80"> }</span> + + /** + * Handle a synchronization object. + * <p> + * When a synchronization object is identified, the pending insertions and + * pending deletions sets are provided to the user handler as subsequences. + * </p> + * + * @param object synchronization object detected + */ + public void visitKeepCommand(final T object) { +<span class="fc bfc" id="L92" title="All 4 branches covered."> if (pendingDeletions.isEmpty() && pendingInsertions.isEmpty()) {</span> +<span class="fc" id="L93"> ++skipped;</span> + } else { +<span class="fc" id="L95"> handler.handleReplacement(skipped, pendingDeletions, pendingInsertions);</span> +<span class="fc" id="L96"> pendingDeletions.clear();</span> +<span class="fc" id="L97"> pendingInsertions.clear();</span> +<span class="fc" id="L98"> skipped = 1;</span> + } +<span class="fc" id="L100"> }</span> + + /** + * Add an object to the pending deletions set. + * + * @param object object to delete + */ + public void visitDeleteCommand(final T object) { +<span class="fc" id="L108"> pendingDeletions.add(object);</span> +<span class="fc" id="L109"> }</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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/ReplacementsFinder.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator$Snake.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator$Snake.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator$Snake.html Sun Mar 1 12:14:29 2015 @@ -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>StringsComparator.Snake</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_class">StringsComparator.Snake</span></div><h1>StringsComparator.Snake</h1><table class="coverage" cellspacing="0" id="coveragetab le"><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 21</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">4< /td><td class="ctr1">0</td><td class="ctr2">8</td><td class="ctr1">0</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a3"><a href="StringsComparator.java.html#L294" class="el_method">StringsComparator.Snake(int, int, int)</a></td><td class="bar" id="b0"><img src="../.resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">5</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="StringsComparator.java.html#L306" class="el_method">getStart()</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="30" height="10" title="3" alt="3"/></td><td class="ctr2" id="c1">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><tr><td id="a1"><a href="StringsComparator.java.html#L315" class="el_method">getEnd()</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="30" height="10" title="3" alt="3"/></td><td class="ctr2" id="c2">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="a0"><a href="StringsComparator.java.html#L324" class="el_method">getDiag()</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="30" height="10" title="3" alt="3"/></td><td class="ctr2" id="c3">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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator$Snake.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.html Sun Mar 1 12:14:29 2015 @@ -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>StringsComparator</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_class">StringsComparator</span></div><h1>StringsComparator</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">5 of 546</td><td class="ctr2">99%</td><td class="bar">3 of 82</td><td class="ctr2">96%</td><td class="ctr1">3</td><td class="ctr2">46</td><td class="c tr1">1</td><td class="ctr2">71</td><td class="ctr1">0</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a2"><a href="StringsComparator.java.html#L183" class="el_method">getMiddleSnake(int, int, int, int)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="1" height="10" title="5" alt="5"/><img src="../.resources/greenbar.gif" width="118" height="10" title="326" alt="326"/></td><td class="ctr2" id="c4">98%</td><td class="bar" id="d1"><img src="../.resources/redbar.gif" width="2" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="117" height="10" title="51" alt="51"/></td><td class="ctr2" id="e1">98%</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g0">27</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">37</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="StringsComparator.java.html#L125" class="el_method">buildScript(int, int, int, int, EditScript)</a></td><td clas s="bar" id="b1"><img src="../.resources/greenbar.gif" width="51" height="10" title="143" alt="143"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="4" height="10" title="2" alt="2"/><img src="../.resources/greenbar.gif" width="50" height="10" title="22" alt="22"/></td><td class="ctr2" id="e2">92%</td><td class="ctr1" id="f0">2</td><td class="ctr2" id="g1">13</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">20</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="StringsComparator.java.html#L263" class="el_method">buildSnake(int, int, int, int)</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="10" height="10" title="30" alt="30"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"><img src="../.resources/greenbar.gif" width="13" height="10" title="6" alt="6"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f2">0</td><td class ="ctr2" id="g2">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i3">4</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a4"><a href="StringsComparator.java.html#L85" class="el_method">StringsComparator(String, String)</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="9" height="10" title="25" alt="25"/></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="i2">7</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a3"><a href="StringsComparator.java.html#L109" class="el_method">getScript()</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="6" height="10" title="17" alt="17"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td c lass="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">3</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.2.201409121644</span></div></body></html> \ No newline at end of file Propchange: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.java.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.java.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.java.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,329 @@ +<?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>StringsComparator.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 Text</a> > <a href="index.source.html" class="el_package">org.apache.commons.text.diff</a> > <span class="el_source">StringsComparator.java</spa n></div><h1>StringsComparator.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.text.diff; + +/** + * <p> + * It is guaranteed that the comparisons will always be done as + * <code>o1.equals(o2)</code> where <code>o1</code> belongs to the first + * sequence and <code>o2</code> belongs to the second sequence. This can + * be important if subclassing is used for some elements in the first + * sequence and the <code>equals</code> method is specialized. + * </p> + * <p> + * Comparison can be seen from two points of view: either as giving the smallest + * modification allowing to transform the first sequence into the second one, or + * as giving the longest sequence which is a subsequence of both initial + * sequences. The <code>equals</code> method is used to compare objects, so any + * object can be put into sequences. Modifications include deleting, inserting + * or keeping one object, starting from the beginning of the first sequence. + * </p> + * <p> + * This class implements the comparison algorithm, which is the very efficient + * algorithm from Eugene W. Myers + * <a href="http://www.cis.upenn.edu/~bcpierce/courses/dd/papers/diff.ps"> + * An O(ND) Difference Algorithm and Its Variations</a>. This algorithm produces + * the shortest possible {@link EditScript edit script} containing all the + * {@link EditCommand commands} needed to transform the first sequence into + * the second one. + * + * <p> + * This code has been adapted from Apache Commons Collections 4.0. + * </p> + * + * @see EditScript + * @see EditCommand + * @see CommandVisitor + * + * @since 1.0 + */ +public class StringsComparator { + + /** + * First character sequence. + */ + private final String left; + /** + * Second character sequence. + */ + private final String right; + + /** Temporary variables. */ + private final int[] vDown; + private final int[] vUp; + + /** + * Simple constructor. + * <p> + * Creates a new instance of StringsComparator. + * </p> + * <p> + * It is <em>guaranteed</em> that the comparisons will always be done as + * <code>o1.equals(o2)</code> where <code>o1</code> belongs to the first + * sequence and <code>o2</code> belongs to the second sequence. This can be + * important if subclassing is used for some elements in the first sequence + * and the <code>equals</code> method is specialized. + * </p> + * + * @param left first character sequence to be compared + * @param right second character sequence to be compared + */ +<span class="fc" id="L85"> public StringsComparator(String left, String right) {</span> +<span class="fc" id="L86"> this.left = left;</span> +<span class="fc" id="L87"> this.right = right;</span> + +<span class="fc" id="L89"> final int size = left.length() + right.length() + 2;</span> +<span class="fc" id="L90"> vDown = new int[size];</span> +<span class="fc" id="L91"> vUp = new int[size];</span> +<span class="fc" id="L92"> }</span> + + /** + * Get the {@link EditScript} object. + * <p> + * It is guaranteed that the objects embedded in the {@link InsertCommand + * insert commands} come from the second sequence and that the objects + * embedded in either the {@link DeleteCommand delete commands} or + * {@link KeepCommand keep commands} come from the first sequence. This can + * be important if subclassing is used for some elements in the first + * sequence and the <code>equals</code> method is specialized. + * </p> + * + * @return the edit script resulting from the comparison of the two + * sequences + */ + public EditScript<Character> getScript() { +<span class="fc" id="L109"> final EditScript<Character> script = new EditScript<Character>();</span> +<span class="fc" id="L110"> buildScript(0, left.length(), 0, right.length(), script);</span> +<span class="fc" id="L111"> return script;</span> + } + + /** + * Build an edit script. + * + * @param start1 the begin of the first sequence to be compared + * @param end1 the end of the first sequence to be compared + * @param start2 the begin of the second sequence to be compared + * @param end2 the end of the second sequence to be compared + * @param script the edited script + */ + private void buildScript(final int start1, final int end1, final int start2, final int end2, + final EditScript<Character> script) { +<span class="fc" id="L125"> final Snake middle = getMiddleSnake(start1, end1, start2, end2);</span> + +<span class="pc bpc" id="L127" title="1 of 10 branches missed."> if (middle == null</span> + || middle.getStart() == end1 && middle.getDiag() == end1 - end2 + || middle.getEnd() == start1 && middle.getDiag() == start1 - start2) { + +<span class="fc" id="L131"> int i = start1;</span> +<span class="fc" id="L132"> int j = start2;</span> +<span class="fc bfc" id="L133" title="All 4 branches covered."> while (i < end1 || j < end2) {</span> +<span class="pc bpc" id="L134" title="1 of 6 branches missed."> if (i < end1 && j < end2 && left.charAt(i) == right.charAt(j)) {</span> +<span class="fc" id="L135"> script.append(new KeepCommand<Character>(left.charAt(i)));</span> +<span class="fc" id="L136"> ++i;</span> +<span class="fc" id="L137"> ++j;</span> + } else { +<span class="fc bfc" id="L139" title="All 2 branches covered."> if (end1 - start1 > end2 - start2) {</span> +<span class="fc" id="L140"> script.append(new DeleteCommand<Character>(left.charAt(i)));</span> +<span class="fc" id="L141"> ++i;</span> + } else { +<span class="fc" id="L143"> script.append(new InsertCommand<Character>(right.charAt(j)));</span> +<span class="fc" id="L144"> ++j;</span> + } + } + } + +<span class="fc" id="L149"> } else {</span> + +<span class="fc" id="L151"> buildScript(start1, middle.getStart(),</span> + start2, middle.getStart() - middle.getDiag(), + script); +<span class="fc bfc" id="L154" title="All 2 branches covered."> for (int i = middle.getStart(); i < middle.getEnd(); ++i) {</span> +<span class="fc" id="L155"> script.append(new KeepCommand<Character>(left.charAt(i)));</span> + } +<span class="fc" id="L157"> buildScript(middle.getEnd(), end1,</span> + middle.getEnd() - middle.getDiag(), end2, + script); + } +<span class="fc" id="L161"> }</span> + + /** + * Get the middle snake corresponding to two subsequences of the + * main sequences. + * <p> + * The snake is found using the MYERS Algorithm (this algorithms has + * also been implemented in the GNU diff program). This algorithm is + * explained in Eugene Myers article: + * <a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps"> + * An O(ND) Difference Algorithm and Its Variations</a>. + * </p> + * + * @param start1 the begin of the first sequence to be compared + * @param end1 the end of the first sequence to be compared + * @param start2 the begin of the second sequence to be compared + * @param end2 the end of the second sequence to be compared + * @return the middle snake + */ + private Snake getMiddleSnake(int start1, int end1, int start2, int end2) { + // Myers Algorithm + // Initialisations +<span class="fc" id="L183"> final int m = end1 - start1;</span> +<span class="fc" id="L184"> final int n = end2 - start2;</span> +<span class="fc bfc" id="L185" title="All 4 branches covered."> if (m == 0 || n == 0) {</span> +<span class="fc" id="L186"> return null;</span> + } + +<span class="fc" id="L189"> final int delta = m - n;</span> +<span class="fc" id="L190"> final int sum = n + m;</span> +<span class="fc bfc" id="L191" title="All 2 branches covered."> final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;</span> +<span class="fc" id="L192"> vDown[1+offset] = start1;</span> +<span class="fc" id="L193"> vUp[1+offset] = end1 + 1;</span> + +<span class="pc bpc" id="L195" title="1 of 2 branches missed."> for (int d = 0; d <= offset ; ++d) {</span> + // Down +<span class="fc bfc" id="L197" title="All 2 branches covered."> for (int k = -d; k <= d; k += 2) {</span> + // First step + +<span class="fc" id="L200"> final int i = k + offset;</span> +<span class="fc bfc" id="L201" title="All 6 branches covered."> if (k == -d || k != d && vDown[i-1] < vDown[i+1]) {</span> +<span class="fc" id="L202"> vDown[i] = vDown[i+1];</span> + } else { +<span class="fc" id="L204"> vDown[i] = vDown[i-1] + 1;</span> + } + +<span class="fc" id="L207"> int x = vDown[i];</span> +<span class="fc" id="L208"> int y = x - start1 + start2 - k;</span> + +<span class="fc bfc" id="L210" title="All 6 branches covered."> while (x < end1 && y < end2 && left.charAt(x) == right.charAt(y)) {</span> +<span class="fc" id="L211"> vDown[i] = ++x;</span> +<span class="fc" id="L212"> ++y;</span> + } + // Second step +<span class="fc bfc" id="L215" title="All 6 branches covered."> if (delta % 2 != 0 && delta - d <= k && k <= delta + d) {</span> +<span class="fc bfc" id="L216" title="All 2 branches covered."> if (vUp[i-delta] <= vDown[i]) {</span> +<span class="fc" id="L217"> return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2);</span> + } + } + } + + // Up +<span class="fc bfc" id="L223" title="All 2 branches covered."> for (int k = delta - d; k <= delta + d; k += 2) {</span> + // First step +<span class="fc" id="L225"> final int i = k + offset - delta;</span> +<span class="fc bfc" id="L226" title="All 6 branches covered."> if (k == delta - d</span> + || k != delta + d && vUp[i+1] <= vUp[i-1]) { +<span class="fc" id="L228"> vUp[i] = vUp[i+1] - 1;</span> + } else { +<span class="fc" id="L230"> vUp[i] = vUp[i-1];</span> + } + +<span class="fc" id="L233"> int x = vUp[i] - 1;</span> +<span class="fc" id="L234"> int y = x - start1 + start2 - k;</span> +<span class="fc bfc" id="L235" title="All 6 branches covered."> while (x >= start1 && y >= start2</span> + && left.charAt(x) == right.charAt(y)) { +<span class="fc" id="L237"> vUp[i] = x--;</span> +<span class="fc" id="L238"> y--;</span> + } + // Second step +<span class="fc bfc" id="L241" title="All 6 branches covered."> if (delta % 2 == 0 && -d <= k && k <= d ) {</span> +<span class="fc bfc" id="L242" title="All 2 branches covered."> if (vUp[i] <= vDown[i + delta]) {</span> +<span class="fc" id="L243"> return buildSnake(vUp[i], k + start1 - start2, end1, end2);</span> + } + } + } + } + + // this should not happen +<span class="nc" id="L250"> throw new RuntimeException("Internal Error");</span> + } + + /** + * Build a snake. + * + * @param start the value of the start of the snake + * @param diag the value of the diagonal of the snake + * @param end1 the value of the end of the first sequence to be compared + * @param end2 the value of the end of the second sequence to be compared + * @return the snake built + */ + private Snake buildSnake(final int start, final int diag, final int end1, final int end2) { +<span class="fc" id="L263"> int end = start;</span> +<span class="fc bfc" id="L264" title="All 6 branches covered."> while (end - diag < end2</span> + && end < end1 + && left.charAt(end) == right.charAt(end - diag)) { +<span class="fc" id="L267"> ++end;</span> + } +<span class="fc" id="L269"> return new Snake(start, end, diag);</span> + } + + /** + * This class is a simple placeholder to hold the end part of a path + * under construction in a {@link StringsComparator StringsComparator}. + */ + private static class Snake { + + /** Start index. */ + private final int start; + + /** End index. */ + private final int end; + + /** Diagonal number. */ + private final int diag; + + /** + * Simple constructor. Creates a new instance of Snake with specified indices. + * + * @param start start index of the snake + * @param end end index of the snake + * @param diag diagonal number + */ +<span class="fc" id="L294"> public Snake(final int start, final int end, final int diag) {</span> +<span class="fc" id="L295"> this.start = start;</span> +<span class="fc" id="L296"> this.end = end;</span> +<span class="fc" id="L297"> this.diag = diag;</span> +<span class="fc" id="L298"> }</span> + + /** + * Get the start index of the snake. + * + * @return start index of the snake + */ + public int getStart() { +<span class="fc" id="L306"> return start;</span> + } + + /** + * Get the end index of the snake. + * + * @return end index of the snake + */ + public int getEnd() { +<span class="fc" id="L315"> return end;</span> + } + + /** + * Get the diagonal number of the snake. + * + * @return diagonal number of the snake + */ + public int getDiag() { +<span class="fc" id="L324"> return diag;</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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/StringsComparator.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.html Sun Mar 1 12:14:29 2015 @@ -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>org.apache.commons.text.diff</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Text</a> > <span class="el_package">org.apache.commons.text.diff</span></div><h1>org.apache.commons.text.diff</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><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr>< td>Total</td><td class="bar">5 of 740</td><td class="ctr2">99%</td><td class="bar">3 of 88</td><td class="ctr2">97%</td><td class="ctr1">3</td><td class="ctr2">72</td><td class="ctr1">1</td><td class="ctr2">132</td><td class="ctr1">0</td><td class="ctr2">28</td><td class="ctr1">0</td><td class="ctr2">8</td></tr></tfoot><tbody><tr><td id="a6"><a href="StringsComparator.html" class="el_class">StringsComparator</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="1" height="10" title="5" alt="5"/><img src="../.resources/greenbar.gif" width="118" height="10" title="541" alt="541"/></td><td class="ctr2" id="c7">99%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="4" height="10" title="3" alt="3"/><img src="../.resources/greenbar.gif" width="115" height="10" title="79" alt="79"/></td><td class="ctr2" id="e2">96%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g0">46</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">71</td><td c lass="ctr1" id="j0">0</td><td class="ctr2" id="k1">5</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a2"><a href="EditScript.html" class="el_class">EditScript</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="15" height="10" title="72" alt="72"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../.resources/greenbar.gif" width="2" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">8</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">20</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k0">7</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a5"><a href="ReplacementsFinder.html" class="el_class">ReplacementsFinder</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="14" height="10" title="65" alt="65"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"><img src="../.resources/greenbar.gif" width="5" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">6</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">17</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">4</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr><tr><td id="a7"><a href="StringsComparator$Snake.html" class="el_class">StringsComparator.Snake</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="4" height="10" title="21" alt="21"/></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">4</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">8</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">4</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">1</td></tr><tr><td id="a0"><a href="DeleteCommand.html" class="el_cl ass">DeleteCommand</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">2</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">4</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">2</td><td class="ctr1" id="l4">0</td><td class="ctr2" id="m4">1</td></tr><tr><td id="a3"><a href="InsertCommand.html" class="el_class">InsertCommand</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></td><td class="ctr2" id="c4">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">2</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">4</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">2</td><td class="ctr1" id="l5">0</td><td class="ctr2" id="m5">1</td></tr><tr><td id="a4"><a href="KeepCommand.html" class="el_class">KeepCommand</a></td><td class="bar" id="b6"><img src="../.resources/greenbar.gif" width="1" 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</td><td class="ctr2" id="g6">2</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i6">4</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">2</td><td class="ctr1" id="l6">0</td><td class="ctr2" id="m6">1</td></tr><tr><td id="a1"><a href="EditCommand.html" class="el_class">EditCommand</a></td><td class="bar" id="b7"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></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">2</td><td class="ctr1" id="h7">0</td><td class="ctr2" id="i7">4</td><td class="ctr1" id="j7">0</td><td class ="ctr2" id="k7">2</td><td class="ctr1" id="l7">0</td><td class="ctr2" id="m7">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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.source.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.source.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.source.html Sun Mar 1 12:14:29 2015 @@ -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>org.apache.commons.text.diff</title><script type="text/javascript" src="../.resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Text</a> > <span class="el_package">org.apache.commons.text.diff</span></div><h1>org.apache.commons.text.diff</h1><table class="coverage" cellspacing="0" id="covera getable"><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><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td> <td class="bar">5 of 740</td><td class="ctr2">99%</td><td class="bar">3 of 88</td><td class="ctr2">97%</td><td class="ctr1">3</td><td class="ctr2">72</td><td class="ctr1">1</td><td class="ctr2">132</td><td class="ctr1">0</td><td class="ctr2">28</td><td class="ctr1">0</td><td class="ctr2">8</td></tr></tfoot><tbody><tr><td id="a6"><a href="StringsComparator.java.html" class="el_source">StringsComparator.java</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="1" height="10" title="5" alt="5"/><img src="../.resources/greenbar.gif" width="118" height="10" title="562" alt="562"/></td><td class="ctr2" id="c6">99%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="4" height="10" title="3" alt="3"/><img src="../.resources/greenbar.gif" width="115" height="10" title="79" alt="79"/></td><td class="ctr2" id="e2">96%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g0">50</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">79</td><td cla ss="ctr1" id="j0">0</td><td class="ctr2" id="k0">9</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">2</td></tr><tr><td id="a2"><a href="EditScript.java.html" class="el_source">EditScript.java</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="15" height="10" title="72" alt="72"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../.resources/greenbar.gif" width="2" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">8</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">20</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">7</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a5"><a href="ReplacementsFinder.java.html" class="el_source">ReplacementsFinder.java</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="13" height="10" title="65" alt="65"/></td><td class="ctr2" id="c1">100% </td><td class="bar" id="d1"><img src="../.resources/greenbar.gif" width="5" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">6</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">17</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">4</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr><tr><td id="a4"><a href="KeepCommand.java.html" class="el_source">KeepCommand.java</a></td><td class="bar" id="b3"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></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">2</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">4</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">2</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">1</td></tr><tr><td id="a3"><a href="InsertCommand.java.html" cl ass="el_source">InsertCommand.java</a></td><td class="bar" id="b4"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">2</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">4</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">2</td><td class="ctr1" id="l4">0</td><td class="ctr2" id="m4">1</td></tr><tr><td id="a1"><a href="EditCommand.java.html" class="el_source">EditCommand.java</a></td><td class="bar" id="b5"><img src="../.resources/greenbar.gif" width="1" height="10" title="9" alt="9"/></td><td class="ctr2" id="c4">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">2</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">4</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">2</td><td class="ctr1" id="l5" >0</td><td class="ctr2" id="m5">1</td></tr><tr><td id="a0"><a >href="DeleteCommand.java.html" >class="el_source">DeleteCommand.java</a></td><td class="bar" id="b6"><img >src="../.resources/greenbar.gif" width="1" 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</td><td class="ctr2" >id="g6">2</td><td class="ctr1" id="h6">0</td><td class="ctr2" >id="i6">4</td><td class="ctr1" id="j6">0</td><td class="ctr2" >id="k6">2</td><td class="ctr1" id="l6">0</td><td class="ctr2" >id="m6">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/sandbox/commons-text/jacoco/org.apache.commons.text.diff/index.source.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.html Sun Mar 1 12:14:29 2015 @@ -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>FuzzyScore</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.similarity</a> > <span class="el_class">FuzzyScore</span></div><h1>FuzzyScore</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortabl e" 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">6 of 84</td><td class="ctr2">93%</td><td class="bar">0 of 16</td><td class="ctr2">100%</td><td class="ctr1">1</td><td class="ctr2">11</td><td class="ctr1">1</td><td class="ctr2">23</td><td class="ctr1">1</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a0"><a href="FuzzyScore.java.html#L50" class="el_method">compare(CharSequence, CharSequence)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="9" height="10" title="6" alt="6"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g1">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="FuzzyScore.java.html#L80" class="el_method">compare(CharSequence, CharSequence, Locale)</a></td><td class="bar" id="b1"><img src="../.resources/greenbar.gif" width="120" height="10" title="75" alt="75"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../.resources/greenbar.gif" width="120" height="10" title="16" alt="16"/></td><td class="ctr2" id="e0">100%</t d><td class="ctr1" id="f1">0</td><td class="ctr2" id="g0">9</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i0">21</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="FuzzyScore.java.html#L34" class="el_method">FuzzyScore()</a></td><td class="bar" id="b2"><img src="../.resources/greenbar.gif" width="4" height="10" title="3" alt="3"/></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></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/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.java.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.java.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.java.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,134 @@ +<?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>FuzzyScore.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 Text</a> > <a href="index.source.html" class="el_package">org.apache.commons.text.similarity</a> > <span class="el_source">FuzzyScore.java</span></div> <h1>FuzzyScore.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.text.similarity; + +import java.util.Locale; + +/** + * A matching algorithm that is similar to the searching algorithms implemented in editors such + * as Sublime Text, TextMate, Atom and others. + * + * <p> + * One point is given for every matched character. Subsequent matches yield two bonus points. A higher score + * indicates a higher similarity. + * </p> + * + * <p> + * This code has been adapted from Apache Commons Lang 3.3. + * </p> + */ +<span class="fc" id="L34">public class FuzzyScore implements StringMetric<Integer> {</span> + + /** + * <p> + * Find the Fuzzy Score which indicates the similarity score between two + * Strings. This method uses the default locale. + * </p> + * + * @param term a full term that should be matched against, must not be null + * @param query the query that will be matched against a term, must not be + * null + * @return result score + * @throws IllegalArgumentException if either String input {@code null} + */ + @Override + public Integer compare(CharSequence term, CharSequence query) { +<span class="nc" id="L50"> return compare(term, query, Locale.getDefault());</span> + } + + /** + * <p> + * Find the Fuzzy Score which indicates the similarity score between two + * Strings. + * </p> + * + * <pre> + * score.compare(null, null, null) = IllegalArgumentException + * score.compare("", "", Locale.ENGLISH) = 0 + * score.compare("Workshop", "b", Locale.ENGLISH) = 0 + * score.compare("Room", "o", Locale.ENGLISH) = 1 + * score.compare("Workshop", "w", Locale.ENGLISH) = 1 + * score.compare("Workshop", "ws", Locale.ENGLISH) = 2 + * score.compare("Workshop", "wo", Locale.ENGLISH) = 4 + * score.compare("Apache Software Foundation", "asf", Locale.ENGLISH) = 3 + * </pre> + * + * @param term a full term that should be matched against, must not be null + * @param query the query that will be matched against a term, must not be + * null + * @param locale This string matching logic is case insensitive. A locale is + * necessary to normalize both Strings to lower case. + * @return result score + * @throws IllegalArgumentException if either String input {@code null} or + * Locale input {@code null} + */ + public Integer compare(CharSequence term, CharSequence query, Locale locale) { +<span class="fc bfc" id="L80" title="All 4 branches covered."> if (term == null || query == null) {</span> +<span class="fc" id="L81"> throw new IllegalArgumentException("Strings must not be null");</span> +<span class="fc bfc" id="L82" title="All 2 branches covered."> } else if (locale == null) {</span> +<span class="fc" id="L83"> throw new IllegalArgumentException("Locale must not be null");</span> + } + + // fuzzy logic is case insensitive. We normalize the Strings to lower + // case right from the start. Turning characters to lower case + // via Character.toLowerCase(char) is unfortunately insufficient + // as it does not accept a locale. +<span class="fc" id="L90"> final String termLowerCase = term.toString().toLowerCase(locale);</span> +<span class="fc" id="L91"> final String queryLowerCase = query.toString().toLowerCase(locale);</span> + + // the resulting score +<span class="fc" id="L94"> int score = 0;</span> + + // the position in the term which will be scanned next for potential + // query character matches +<span class="fc" id="L98"> int termIndex = 0;</span> + + // index of the previously matched character in the term +<span class="fc" id="L101"> int previousMatchingCharacterIndex = Integer.MIN_VALUE;</span> + +<span class="fc bfc" id="L103" title="All 2 branches covered."> for (int queryIndex = 0; queryIndex < queryLowerCase.length(); queryIndex++) {</span> +<span class="fc" id="L104"> final char queryChar = queryLowerCase.charAt(queryIndex);</span> + +<span class="fc" id="L106"> boolean termCharacterMatchFound = false;</span> + for (; termIndex < termLowerCase.length() +<span class="fc bfc" id="L108" title="All 4 branches covered."> && !termCharacterMatchFound; termIndex++) {</span> +<span class="fc" id="L109"> final char termChar = termLowerCase.charAt(termIndex);</span> + +<span class="fc bfc" id="L111" title="All 2 branches covered."> if (queryChar == termChar) {</span> + // simple character matches result in one point +<span class="fc" id="L113"> score++;</span> + + // subsequent character matches further improve + // the score. +<span class="fc bfc" id="L117" title="All 2 branches covered."> if (previousMatchingCharacterIndex + 1 == termIndex) {</span> +<span class="fc" id="L118"> score += 2;</span> + } + +<span class="fc" id="L121"> previousMatchingCharacterIndex = termIndex;</span> + + // we can leave the nested loop. Every character in the + // query can match at most one character in the term. +<span class="fc" id="L125"> termCharacterMatchFound = true;</span> + } + } + } + +<span class="fc" id="L130"> return score;</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/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/FuzzyScore.java.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.html Sun Mar 1 12:14:29 2015 @@ -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>HammingDistance</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 Text</a> > <a href="index.html" class="el_package">org.apache.commons.text.similarity</a> > <span class="el_class">HammingDistance</span></div><h1>HammingDistance</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">5 of 43</td><td class="ctr2">88%</td><td class="bar">1 of 10</td><td class="ctr2">90%</td><td class="ctr1">1</td><td class="ctr2">7</td><td class="ctr 1">1</td><td class="ctr2">10</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="HammingDistance.java.html#L57" class="el_method">compare(CharSequence, CharSequence)</a></td><td class="bar" id="b0"><img src="../.resources/redbar.gif" width="15" height="10" title="5" alt="5"/><img src="../.resources/greenbar.gif" width="105" height="10" title="35" alt="35"/></td><td class="ctr2" id="c1">88%</td><td class="bar" id="d0"><img src="../.resources/redbar.gif" width="12" height="10" title="1" alt="1"/><img src="../.resources/greenbar.gif" width="108" height="10" title="9" alt="9"/></td><td class="ctr2" id="e0">90%</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">6</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">9</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="HammingDistance.java.html#L28" class="el_method">HammingDistance()</a></td><td class="bar" id="b1"><img src="../.resourc es/greenbar.gif" width="9" height="10" title="3" alt="3"/></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/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.java.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.java.html (added) +++ websites/production/commons/content/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.java.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,77 @@ +<?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>HammingDistance.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 Text</a> > <a href="index.source.html" class="el_package">org.apache.commons.text.similarity</a> > <span class="el_source">HammingDistance.java</s pan></div><h1>HammingDistance.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.text.similarity; + +/** + * The hamming distance between two strings of equal length is the number of + * positions at which the corresponding symbols are different. + * + * <p> + * For further explanation about the Hamming Distance, take a look at its + * Wikipedia page at http://en.wikipedia.org/wiki/Hamming_distance. + * </p> + */ +<span class="fc" id="L28">public class HammingDistance implements StringMetric<Integer> {</span> + + /** + * Find the Hamming Distance between two strings with the same + * length. + * + * <p>The distance starts with zero, and for each occurrence of a + * different character in either String, it increments the distance + * by 1, and finally return its value.</p> + * + * <p>Since the Hamming Distance can only be calculated between strings of equal length, input of different lengths + * will throw IllegalArgumentException</p> + * + * <pre> + * distance.compare("", "") = 0 + * distance.compare("pappa", "pappa") = 0 + * distance.compare("1011101", "1011111") = 1 + * distance.compare("ATCG", "ACCC") = 2 + * distance.compare("karolin", "kerstin" = 3 + * </pre> + * + * @param left the first CharSequence, must not be null + * @param right the second CharSequence, must not be null + * @return distance + * @throws IllegalArgumentException if either input is {@code null} or + * if they do not have the same length + */ + @Override + public Integer compare(CharSequence left, CharSequence right) { +<span class="fc bfc" id="L57" title="All 4 branches covered."> if (left == null || right == null) {</span> +<span class="fc" id="L58"> throw new IllegalArgumentException("Strings must not be null");</span> + } + +<span class="pc bpc" id="L61" title="1 of 2 branches missed."> if (left.length() != right.length()) {</span> +<span class="nc" id="L62"> throw new IllegalArgumentException("Strings must have the same length");</span> + } + +<span class="fc" id="L65"> int distance = 0;</span> + +<span class="fc bfc" id="L67" title="All 2 branches covered."> for (int i = 0; i < left.length(); i++) {</span> +<span class="fc bfc" id="L68" title="All 2 branches covered."> if (left.charAt(i) != right.charAt(i)) {</span> +<span class="fc" id="L69"> distance++;</span> + } + } + +<span class="fc" id="L73"> return distance;</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/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/HammingDistance.java.html ------------------------------------------------------------------------------ svn:eol-style = native