[text] Format nit.
Repository: commons-text Updated Branches: refs/heads/master 788e7ef9c -> 40b15c9a2 Format nit. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/40b15c9a Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/40b15c9a Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/40b15c9a Branch: refs/heads/master Commit: 40b15c9a285ee57d1d05001e01b9f4c7916c0347 Parents: 788e7ef Author: Gary Gregory Authored: Mon Feb 12 08:29:24 2018 -0700 Committer: Gary Gregory Committed: Mon Feb 12 08:29:24 2018 -0700 -- .../org/apache/commons/text/StrMatcher.java | 884 ++- 1 file changed, 446 insertions(+), 438 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/40b15c9a/src/main/java/org/apache/commons/text/StrMatcher.java -- diff --git a/src/main/java/org/apache/commons/text/StrMatcher.java b/src/main/java/org/apache/commons/text/StrMatcher.java index 357118c..9af8dff 100644 --- a/src/main/java/org/apache/commons/text/StrMatcher.java +++ b/src/main/java/org/apache/commons/text/StrMatcher.java @@ -1,438 +1,446 @@ -/* - * 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; - -import java.util.Arrays; - -/** - * A matcher class that can be queried to determine if a character array - * portion matches. - * - * This class comes complete with various factory methods. - * If these do not suffice, you can subclass and implement your own matcher. - * - * @since 1.0 - */ -public abstract class StrMatcher { - -/** - * Matches the comma character. - */ -private static final StrMatcher COMMA_MATCHER = new CharMatcher(','); -/** - * Matches the tab character. - */ -private static final StrMatcher TAB_MATCHER = new CharMatcher('\t'); -/** - * Matches the space character. - */ -private static final StrMatcher SPACE_MATCHER = new CharMatcher(' '); -/** - * Matches the same characters as StringTokenizer, - * namely space, tab, newline, formfeed. - */ -private static final StrMatcher SPLIT_MATCHER = new CharSetMatcher(" \t\n\r\f".toCharArray()); -/** - * Matches the String trim() whitespace characters. - */ -private static final StrMatcher TRIM_MATCHER = new TrimMatcher(); -/** - * Matches the double quote character. - */ -private static final StrMatcher SINGLE_QUOTE_MATCHER = new CharMatcher('\''); -/** - * Matches the double quote character. - */ -private static final StrMatcher DOUBLE_QUOTE_MATCHER = new CharMatcher('"'); -/** - * Matches the single or double quote character. - */ -private static final StrMatcher QUOTE_MATCHER = new CharSetMatcher("'\"".toCharArray()); -/** - * Matches no characters. - */ -private static final StrMatcher NONE_MATCHER = new NoMatcher(); - -// --- - -/** - * Returns a matcher which matches the comma character. - * - * @return a matcher for a comma - */ -public static StrMatcher commaMatcher() { -return COMMA_MATCHER; -} - -/** - * Returns a matcher which matches the tab character. - * - * @return a matcher for a tab - */ -public static StrMatcher tabMatcher() { -return TAB_MATCHER; -} - -/** - * Returns a matcher which matches the space character. - * - * @return a matcher for a space - */ -public static StrMatcher spaceMatcher() { -return SPACE_MATCHER; -} - -/** - * Matches the same characters as StringTokenizer, - * namely space, tab, newline and formfeed. - * - * @return the split matcher - */ -public static StrMatcher splitMatcher() { -return SPLIT_MATCHER; -} - -/** - * Matches the String trim() whitespace characters. - * - * @return the trim matcher - */ -public static StrMatcher tri
[text] Format nit.
Repository: commons-text Updated Branches: refs/heads/master 6afbdc8a4 -> 0f06a6bc7 Format nit. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/0f06a6bc Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/0f06a6bc Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/0f06a6bc Branch: refs/heads/master Commit: 0f06a6bc7ad320656f64bde81c339197cf6f58cf Parents: 6afbdc8 Author: Gary Gregory Authored: Sun Feb 11 10:51:32 2018 -0700 Committer: Gary Gregory Committed: Sun Feb 11 10:51:32 2018 -0700 -- .../commons/text/diff/ReplacementsFinder.java | 250 ++- 1 file changed, 126 insertions(+), 124 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/0f06a6bc/src/main/java/org/apache/commons/text/diff/ReplacementsFinder.java -- diff --git a/src/main/java/org/apache/commons/text/diff/ReplacementsFinder.java b/src/main/java/org/apache/commons/text/diff/ReplacementsFinder.java index 46f1b88..2c58ef5 100644 --- a/src/main/java/org/apache/commons/text/diff/ReplacementsFinder.java +++ b/src/main/java/org/apache/commons/text/diff/ReplacementsFinder.java @@ -1,124 +1,126 @@ -/* - * 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. - * - * 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 keep 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. - * - * - * 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. - * - * - * @see ReplacementsHandler - * @see EditScript - * @see StringsComparator - * - * @param object type - * @since 1.0 - */ -public class ReplacementsFinder implements CommandVisitor { - -/** - * List of pending insertions. - */ -private final List pendingInsertions; -/** - * List of pending deletions. - */ -private final List pendingDeletions; -/** - * Count of elements skipped. - */ -private int skipped; - -/** Handler to call when synchronized sequences are found. */ -private final ReplacementsHandler handler; - -/** - * Simple constructor. Creates a new instance of {@link ReplacementsFinder}. - * - * @param handler handler to call when synchronized sequences are found - */ -public ReplacementsFinder(final ReplacementsHandler handler) { -pendingInsertions = new ArrayList<>(); -pendingDeletions = new ArrayList<>(); -skipped = 0; -this.handler = handler; -} - -/** - * Add an object to the pending insertions set. - * - * @param object object to insert - */ -@Override -public void visitInsertCommand(final T object) { -pendingInsertions.add(object); -} - -/** - * Handle a synchronization object. - * - * When a synchronization object is identi