blob: 69220c17a6910dcf6b9e3f11978e9d0c29d265eb [file] [log] [blame]
/*
* 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.sling.i18n.impl;
import org.apache.sling.api.resource.path.PathSet;
public class PathFilter {
/**
* Included paths
*/
private final PathSet includedPaths;
/**
* Excluded paths
*/
private final PathSet excludedPaths;
public PathFilter() {
this(null, null);
}
public PathFilter(final String[] includes, final String[] excludes) {
this.includedPaths = includes == null ? null : PathSet.fromStrings(includes);
this.excludedPaths = excludes == null ? null : PathSet.fromStrings(excludes);
}
/**
* Check whether the path is in the included but not in the excluded paths
* @param path The path to check
* @return {@code true} if the path can be included
*/
public boolean includePath(final String path) {
boolean included = this.includedPaths == null || this.includedPaths.matches(path) != null;
if (included) {
included = this.excludedPaths == null || this.excludedPaths.matches(path) == null;
}
return included;
}
}