Java Code Examples for org.apache.commons.io.FilenameUtils#wildcardMatch()
The following examples show how to use
org.apache.commons.io.FilenameUtils#wildcardMatch() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectStoreFlatGlobFilter.java From stocator with Apache License 2.0 | 6 votes |
@Override public boolean accept(Path path) { String name = path.getName(); String pathStr = path.toString(); boolean match = true; for (String pathPattern : parsedPatterns) { LOG.trace("accept on {}, path pattern {}, name {}", pathStr, pathPattern, name); if (name != null && name.startsWith("part-")) { LOG.trace("accept on parent {}, path pattern {}", path.getParent().toString(), pathPattern); match = FilenameUtils.wildcardMatch(path.getParent().toString() + "/", pathPattern); } else { match = FilenameUtils.wildcardMatch(pathStr, pathPattern); } if (match) { return match; } } return match; }
Example 2
Source File: ClassFilterSpec.java From DroidAssist with Apache License 2.0 | 5 votes |
private boolean isExcludeClass(String className) { if (excludes.isEmpty()) { return false; } for (String fi : excludes) { if (FilenameUtils.wildcardMatch(className, fi)) { return true; } } return false; }
Example 3
Source File: AbstractFileWriter.java From walkmod-core with GNU Lesser General Public License v3.0 | 5 votes |
protected boolean isValid(File out) throws IOException { boolean write = true; if (out != null) { String aux = FilenameUtils.normalize(out.getCanonicalPath(), true); if (excludes != null) { for (int i = 0; i < excludes.length && write; i++) { if (!excludes[i].startsWith(normalizedOutputDirectory)) { excludes[i] = normalizedOutputDirectory + "/" + excludes[i]; if (excludes[i].endsWith("\\*\\*")) { excludes[i] = excludes[i].substring(0, excludes[i].length() - 2); } } write = !(excludes[i].startsWith(aux) || FilenameUtils.wildcardMatch(aux, excludes[i])); } } if (includes != null && write) { write = false; for (int i = 0; i < includes.length && !write; i++) { if (!includes[i].startsWith(normalizedOutputDirectory)) { includes[i] = normalizedOutputDirectory + "/" + includes[i]; if (includes[i].endsWith("\\*\\*")) { includes[i] = includes[i].substring(0, includes[i].length() - 2); } } write = includes[i].startsWith(aux) || FilenameUtils.wildcardMatch(aux, includes[i]); } } } return write; }
Example 4
Source File: RangerPolicyConditionSampleSimpleMatcher.java From ranger with Apache License 2.0 | 5 votes |
@Override public boolean isMatched(RangerAccessRequest request) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerPolicyConditionSampleSimpleMatcher.isMatched(" + request + ")"); } boolean matched = false; if (_allowAny) { matched = true; } else { String requestValue = extractValue(request, _contextName); if (StringUtils.isNotBlank(requestValue)) { for (String policyValue : _values) { if (FilenameUtils.wildcardMatch(requestValue, policyValue)) { matched = true; break; } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerPolicyConditionSampleSimpleMatcher.isMatched(" + request+ "): " + matched); } return matched; }
Example 5
Source File: AbstractDirective.java From gocd with Apache License 2.0 | 5 votes |
protected boolean matchesResource(String resource) { if (equalsIgnoreCase("*", this.resource)) { return true; } return FilenameUtils.wildcardMatch(resource, this.resource, IOCase.INSENSITIVE); }
Example 6
Source File: WildcardFileFilter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory (ignored) * @param name the filename * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File dir, final String name) { for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { return true; } } return false; }
Example 7
Source File: WildcardFilter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Checks to see if the filename matches one of the wildcards. * * @param file the file to check * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File file) { if (file.isDirectory()) { return false; } for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(file.getName(), wildcard)) { return true; } } return false; }
Example 8
Source File: RangerPathResourceMatcher.java From ranger with Apache License 2.0 | 5 votes |
static boolean isRecursiveWildCardMatch(String pathToCheck, String wildcardPath, char pathSeparatorChar, IOCase caseSensitivity) { boolean ret = false; if (! StringUtils.isEmpty(pathToCheck)) { String[] pathElements = StringUtils.split(pathToCheck, pathSeparatorChar); if(! ArrayUtils.isEmpty(pathElements)) { StringBuilder sb = new StringBuilder(); if(pathToCheck.charAt(0) == pathSeparatorChar) { sb.append(pathSeparatorChar); // preserve the initial pathSeparatorChar } for(String p : pathElements) { sb.append(p); ret = FilenameUtils.wildcardMatch(sb.toString(), wildcardPath, caseSensitivity); if (ret) { break; } sb.append(pathSeparatorChar); } sb = null; } else { // pathToCheck consists of only pathSeparatorChar ret = FilenameUtils.wildcardMatch(pathToCheck, wildcardPath, caseSensitivity); } } return ret; }
Example 9
Source File: WildcardFileFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory (ignored) * @param name the filename * @return true if the filename matches one of the wildcards */ @Override public boolean accept(File dir, String name) { for (String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { return true; } } return false; }
Example 10
Source File: ElasticAgentProfilesAbstractDirective.java From gocd with Apache License 2.0 | 5 votes |
protected boolean matchesResourceToOperateWithin(String resource) { if (equalsIgnoreCase("*", this.resourceToOperateWithin)) { return true; } return FilenameUtils.wildcardMatch(resource, this.resourceToOperateWithin, IOCase.INSENSITIVE); }
Example 11
Source File: TestRandomFlRTGCloud.java From lucene-solr with Apache License 2.0 | 5 votes |
private boolean matchesGlob(final String fieldName) { if ( FilenameUtils.wildcardMatch(fieldName, glob) ) { matchingFieldsCache.add(fieldName); // Don't calculate it again return true; } return false; }
Example 12
Source File: RangerURLResourceMatcher.java From ranger with Apache License 2.0 | 4 votes |
static boolean isRecursiveWildCardMatch(String pathToCheck, String wildcardPath, char pathSeparatorChar, IOCase caseSensitivity) { boolean ret = false; String url = StringUtils.trim(pathToCheck); if (!StringUtils.isEmpty(url) && isPathURLType(url)) { String scheme = getScheme(url); if (StringUtils.isEmpty(scheme)) { return ret; } String path = getPathWithOutScheme(url); String[] pathElements = StringUtils.split(path, pathSeparatorChar); if (!ArrayUtils.isEmpty(pathElements)) { StringBuilder sb = new StringBuilder(); sb.append(scheme); if (pathToCheck.charAt(0) == pathSeparatorChar) { sb.append(pathSeparatorChar); // preserve the initial pathSeparatorChar } for (String p : pathElements) { sb.append(p); ret = FilenameUtils.wildcardMatch(sb.toString(), wildcardPath, caseSensitivity); if (ret) { break; } sb.append(pathSeparatorChar); } sb = null; } else { // pathToCheck consists of only pathSeparatorChar ret = FilenameUtils.wildcardMatch(pathToCheck, wildcardPath, caseSensitivity); } } return ret; }
Example 13
Source File: WildcardClassNameMatcher.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public boolean matches(String className) { return FilenameUtils.wildcardMatch(className, pattern); }
Example 14
Source File: RangerServiceTag.java From ranger with Apache License 2.0 | 4 votes |
@Override public List<String> lookupResource(ResourceLookupContext context) throws Exception { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceTag.lookupResource(" + context + ")"); } List<String> ret = new ArrayList<>(); if (context != null && StringUtils.equals(context.getResourceName(), TAG_RESOURCE_NAME)) { try { List<String> tags = tagStore != null ? tagStore.getTagTypes() : null; if(CollectionUtils.isNotEmpty(tags)) { List<String> valuesToExclude = MapUtils.isNotEmpty(context.getResources()) ? context.getResources().get(TAG_RESOURCE_NAME) : null; if(CollectionUtils.isNotEmpty(valuesToExclude)) { tags.removeAll(valuesToExclude); } String valueToMatch = context.getUserInput(); if(StringUtils.isNotEmpty(valueToMatch)) { if(! valueToMatch.endsWith("*")) { valueToMatch += "*"; } for (String tag : tags) { if(FilenameUtils.wildcardMatch(tag, valueToMatch)) { ret.add(tag); } } } } } catch (Exception excp) { LOG.error("RangerServiceTag.lookupResource()", excp); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceTag.lookupResource(): tag count=" + ret.size()); } return ret; }
Example 15
Source File: HiveClient.java From ranger with Apache License 2.0 | 4 votes |
private List<String> getClmListFromHM(String columnNameMatching,List<String> dbList, List<String> tblList, List<String> colList) throws HadoopException { if (LOG.isDebugEnabled()) { LOG.debug("==> HiveClient.getClmListFromHM() columnNameMatching: " + columnNameMatching + " dbList :" + dbList + " tblList: " + tblList + " colList: " + colList); } List<String> ret = new ArrayList<String>(); String columnNameMatchingRegEx = null; if (columnNameMatching != null && !columnNameMatching.isEmpty()) { columnNameMatchingRegEx = columnNameMatching; } if (hiveClient != null && dbList != null && !dbList.isEmpty() && tblList != null && !tblList.isEmpty()) { for (String db : dbList) { for (String tbl : tblList) { try { List<FieldSchema> hiveSch = hiveClient.getFields(db, tbl); if (hiveSch != null) { for (FieldSchema sch : hiveSch) { String columnName = sch.getName(); if (colList != null && colList.contains(columnName)) { continue; } if (columnNameMatchingRegEx == null) { ret.add(columnName); } else if (FilenameUtils.wildcardMatch(columnName, columnNameMatchingRegEx)) { ret.add(columnName); } } } } catch (TException e) { String msgDesc = "Unable to get Columns."; HadoopException hdpException = new HadoopException(msgDesc, e); hdpException.generateResponseDataMap(false, getMessage(e), msgDesc + ERR_MSG, null, null); if (LOG.isDebugEnabled()) { LOG.debug("<== HiveClient.getClmListFromHM() Error : " ,e); } throw hdpException; } } } } if (LOG.isDebugEnabled()) { LOG.debug("<== HiveClient.getClmListFromHM() " + ret ); } return ret; }
Example 16
Source File: CommandClaimReserve.java From GriefDefender with MIT License | 4 votes |
@CommandAlias("claimreserve") @Syntax("[<name>]") @Description("Reserves a claim name for administrator use.") @Subcommand("claim reserve") public void execute(CommandSource src, @Optional String name) { GriefDefenderConfig<?> activeConfig = null; if (src instanceof Player) { final Player player = (Player) src; activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()); } else { activeConfig = GriefDefenderPlugin.getGlobalConfig(); } if (name == null) { List<Component> nameList = new ArrayList<>(); for (String reserved : activeConfig.getConfig().claim.reservedClaimNames) { nameList.add(TextComponent.builder("") .append(reserved, TextColor.GREEN) .append(" ") .append("[", TextColor.WHITE) .append(TextComponent.builder() .append("x", TextColor.RED) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createRemoveConsumer(activeConfig, name)))) .build()) .append("]", TextColor.WHITE) .build()); } final int fillSize = 20 - (nameList.size() + 2); for (int i = 0; i < fillSize; i++) { nameList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() .title(TextComponent.of("Reserved Claim Names", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(nameList); paginationBuilder.sendTo(src); return; } for (String str : activeConfig.getConfig().claim.reservedClaimNames) { if (FilenameUtils.wildcardMatch(name, str)) { GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESERVE_EXISTS); return; } } activeConfig.getConfig().claim.reservedClaimNames.add(name); activeConfig.save(); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_RESERVE_ADD, ImmutableMap.of( "name", name)); GriefDefenderPlugin.sendMessage(src, message); }
Example 17
Source File: RangerAbstractResourceMatcher.java From ranger with Apache License 2.0 | 4 votes |
@Override boolean isMatch(String resourceValue, Map<String, Object> evalContext) { return FilenameUtils.wildcardMatch(resourceValue, getExpandedValue(evalContext), IOCase.SENSITIVE); }
Example 18
Source File: CommandClaimReserve.java From GriefDefender with MIT License | 4 votes |
@CommandAlias("claimreserve") @Syntax("[<name>]") @Description("Reserves a claim name for administrator use.") @Subcommand("claim reserve") public void execute(CommandSender src, @Optional String name) { GriefDefenderConfig<?> activeConfig = null; if (src instanceof Player) { final Player player = (Player) src; activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()); } else { activeConfig = GriefDefenderPlugin.getGlobalConfig(); } if (name == null) { List<Component> nameList = new ArrayList<>(); for (String reserved : activeConfig.getConfig().claim.reservedClaimNames) { nameList.add(TextComponent.builder("") .append(reserved, TextColor.GREEN) .append(" ") .append("[", TextColor.WHITE) .append(TextComponent.builder() .append("x", TextColor.RED) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_REMOVE)) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createRemoveConsumer(activeConfig, name)))) .build()) .append("]", TextColor.WHITE) .build()); } final int fillSize = 20 - (nameList.size() + 2); for (int i = 0; i < fillSize; i++) { nameList.add(TextComponent.of(" ")); } PaginationList.Builder paginationBuilder = PaginationList.builder() .title(TextComponent.of("Reserved Claim Names", TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(nameList); paginationBuilder.sendTo(src); return; } for (String str : activeConfig.getConfig().claim.reservedClaimNames) { if (FilenameUtils.wildcardMatch(name, str)) { GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().CLAIM_RESERVE_EXISTS); return; } } activeConfig.getConfig().claim.reservedClaimNames.add(name); activeConfig.save(); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_RESERVE_ADD, ImmutableMap.of( "name", name)); GriefDefenderPlugin.sendMessage(src, message); }
Example 19
Source File: FileResource.java From walkmod-core with GNU Lesser General Public License v3.0 | 2 votes |
private boolean matches(String fileName, String filter) { return filter.startsWith(fileName) || FilenameUtils.wildcardMatch(fileName, filter) || fileName.startsWith(filter); }
Example 20
Source File: FileResource.java From walkmod-core with GNU Lesser General Public License v3.0 | 2 votes |
private boolean matches(String fileName, String filter) { return filter.startsWith(fileName) || FilenameUtils.wildcardMatch(fileName, filter) || fileName.startsWith(filter); }