ソースを参照

Make the IMatcher public API

Provide a static factory method to create a PathMatcher.

Bug: 559526
Change-Id: Ib7a4a1bcc658ac2f2a09d365b5b891669dfd7570
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
tags/v5.7.0.202002241735-m3
Thomas Wolf 4年前
コミット
f2b67be62a

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java ファイルの表示

*/ */
package org.eclipse.jgit.attributes; package org.eclipse.jgit.attributes;


import static org.eclipse.jgit.ignore.internal.IMatcher.NO_MATCH;
import static org.eclipse.jgit.ignore.IMatcher.NO_MATCH;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import org.eclipse.jgit.attributes.Attribute.State; import org.eclipse.jgit.attributes.Attribute.State;
import org.eclipse.jgit.errors.InvalidPatternException; import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.ignore.FastIgnoreRule; import org.eclipse.jgit.ignore.FastIgnoreRule;
import org.eclipse.jgit.ignore.internal.IMatcher;
import org.eclipse.jgit.ignore.IMatcher;
import org.eclipse.jgit.ignore.internal.PathMatcher; import org.eclipse.jgit.ignore.internal.PathMatcher;


/** /**

+ 1
- 2
org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java ファイルの表示

*/ */
package org.eclipse.jgit.ignore; package org.eclipse.jgit.ignore;


import static org.eclipse.jgit.ignore.internal.IMatcher.NO_MATCH;
import static org.eclipse.jgit.ignore.IMatcher.NO_MATCH;
import static org.eclipse.jgit.ignore.internal.Strings.isDirectoryPattern; import static org.eclipse.jgit.ignore.internal.Strings.isDirectoryPattern;
import static org.eclipse.jgit.ignore.internal.Strings.stripTrailing; import static org.eclipse.jgit.ignore.internal.Strings.stripTrailing;
import static org.eclipse.jgit.ignore.internal.Strings.stripTrailingWhitespace; import static org.eclipse.jgit.ignore.internal.Strings.stripTrailingWhitespace;


import org.eclipse.jgit.errors.InvalidPatternException; import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.ignore.internal.IMatcher;
import org.eclipse.jgit.ignore.internal.PathMatcher; import org.eclipse.jgit.ignore.internal.PathMatcher;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/IMatcher.java → org.eclipse.jgit/src/org/eclipse/jgit/ignore/IMatcher.java ファイルの表示

/* /*
* Copyright (C) 2014, 2017 Andrey Loskutov <loskutov@gmx.de> and others
* Copyright (C) 2014, 2020 Andrey Loskutov <loskutov@gmx.de> and others
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at * terms of the Eclipse Distribution License v. 1.0 which is available at
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
package org.eclipse.jgit.ignore.internal;
package org.eclipse.jgit.ignore;

import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.ignore.internal.PathMatcher;


/** /**
* Generic string matcher
* Generic path matcher.
*
* @since 5.7
*/ */
public interface IMatcher { public interface IMatcher {


* Matcher that does not match any pattern. * Matcher that does not match any pattern.
*/ */
public static final IMatcher NO_MATCH = new IMatcher() { public static final IMatcher NO_MATCH = new IMatcher() {

@Override @Override
public boolean matches(String path, boolean assumeDirectory, public boolean matches(String path, boolean assumeDirectory,
boolean pathMatch) { boolean pathMatch) {
} }
}; };


/**
* Creates a path matcher for the given pattern. A pattern may contain the
* wildcards "?", "*", and "**". The directory separator is '/'.
*
* @param pattern
* to match
* @param dirOnly
* whether to match only directories
* @return a matcher for the given pattern
* @throws InvalidPatternException
* if the pattern is invalid
*/
@NonNull
public static IMatcher createPathMatcher(@NonNull String pattern,
boolean dirOnly) throws InvalidPatternException {
return PathMatcher.createPathMatcher(pattern,
Character.valueOf(FastIgnoreRule.PATH_SEPARATOR), dirOnly);
}

/** /**
* Matches entire given string * Matches entire given string
* *
* with a slash) * with a slash)
* @param pathMatch * @param pathMatch
* {@code true} if the match is for the full path: prefix-only * {@code true} if the match is for the full path: prefix-only
* matches are not allowed, and
* {@link org.eclipse.jgit.ignore.internal.NameMatcher}s must
* match only the last component (if they can -- they may not, if
* they are anchored at the beginning)
* matches are not allowed
* @return true if this matcher pattern matches given string * @return true if this matcher pattern matches given string
*/ */
boolean matches(String path, boolean assumeDirectory, boolean pathMatch); boolean matches(String path, boolean assumeDirectory, boolean pathMatch);

+ 2
- 0
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/AbstractMatcher.java ファイルの表示

*/ */
package org.eclipse.jgit.ignore.internal; package org.eclipse.jgit.ignore.internal;


import org.eclipse.jgit.ignore.IMatcher;

/** /**
* Base class for default methods as {@link #toString()} and such. * Base class for default methods as {@link #toString()} and such.
* <p> * <p>

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java ファイルの表示

import java.util.List; import java.util.List;


import org.eclipse.jgit.errors.InvalidPatternException; import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.ignore.IMatcher;
import org.eclipse.jgit.ignore.internal.Strings.PatternState; import org.eclipse.jgit.ignore.internal.Strings.PatternState;


/** /**

読み込み中…
キャンセル
保存