Here you can find the source of isIndexable(String key, List
public static boolean isIndexable(String key, List<String> includes, List<String> excludes)
//package com.java2s; /*//from w w w . j a v a2 s . c om * Licensed to Laurent Broudoux (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author 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. */ import java.util.List; public class Main { /** * Tells if an Aamzon S3 file is indexable from its key (file name), based on includes * and excludes rules. * @return true if file should be indexed, false otherwise */ public static boolean isIndexable(String key, List<String> includes, List<String> excludes) { // If no rules specified, we index everything ! if ((includes == null && excludes == null) || (includes.isEmpty() && excludes.isEmpty())) { return true; } // Exclude rules : we know that whatever includes rules are, we should exclude matching files. if (excludes != null) { for (String exclude : excludes) { String regex = exclude.replace("?", ".?").replace("*", ".*"); if (key.matches(regex)) { return false; } } } // Include rules : we should add document if it match include rules. if (includes == null || includes.isEmpty()) { return true; } if (includes != null) { for (String include : includes) { String regex = include.replace("?", ".?").replace("*", ".*"); if (key.matches(regex)) { return true; } } } return false; } }