/** * Accepts if a file is going to be watched. */ protected boolean acceptFile(File file) { if (!file.isFile()) { return false; // ignore non-files } String fileName = file.getName(); if (ignoreDotFiles) { if (fileName.startsWith(StringPool.DOT)) { return false; // ignore hidden files } } if (patterns == null) { return true; } return Wildcard.matchOne(fileName, patterns) != -1; }
/** * Accepts if a file is going to be watched. */ protected boolean acceptFile(final File file) { if (!file.isFile()) { return false; // ignore non-files } String fileName = file.getName(); if (ignoreDotFiles) { if (fileName.startsWith(StringPool.DOT)) { return false; // ignore hidden files } } if (patterns == null) { return true; } return Wildcard.matchOne(fileName, patterns) != -1; }
Wildcard.matchOne(entryMimeType, mimeTypes) : StringUtil.equalsOne(entryMimeType, mimeTypes);
@SuppressWarnings("unchecked") protected void extractMap( final Map target, final Map<String, PropsEntry> map, final String[] profiles, final String[] wildcardPatterns, final String prefix ) { for (Map.Entry<String, PropsEntry> entry : map.entrySet()) { String key = entry.getKey(); if (wildcardPatterns != null) { if (Wildcard.matchOne(key, wildcardPatterns) == -1) { continue; } } // shorten the key if (prefix != null) { if (!key.startsWith(prefix)) { continue; } key = key.substring(prefix.length()); } // only append if target DOES NOT contain the key if (!target.containsKey(key)) { target.put(key, entry.getValue().getValue(profiles)); } } }
/** * Finds all extensions that belong to given mime type(s). * If wildcard mode is on, provided mime type is wildcard pattern. * @param mimeType list of mime types, separated by comma * @param useWildcard if set, mime types are wildcard patterns */ public static String[] findExtensionsByMimeTypes(String mimeType, final boolean useWildcard) { final ArrayList<String> extensions = new ArrayList<>(); mimeType = mimeType.toLowerCase(); final String[] mimeTypes = StringUtil.splitc(mimeType, ", "); for (final Map.Entry<String, String> entry : MIME_TYPE_MAP.entrySet()) { final String entryExtension = entry.getKey(); final String entryMimeType = entry.getValue().toLowerCase(); final int matchResult = useWildcard ? Wildcard.matchOne(entryMimeType, mimeTypes) : StringUtil.equalsOne(entryMimeType, mimeTypes); if (matchResult != -1) { extensions.add(entryExtension); } } if (extensions.isEmpty()) { return StringPool.EMPTY_ARRAY; } return extensions.toArray(new String[0]); }
/** * Accepts if a file is going to be watched. */ protected boolean acceptFile(final File file) { if (!file.isFile()) { return false; // ignore non-files } String fileName = file.getName(); if (ignoreDotFiles) { if (fileName.startsWith(StringPool.DOT)) { return false; // ignore hidden files } } if (patterns == null) { return true; } return Wildcard.matchOne(fileName, patterns) != -1; }
@SuppressWarnings("unchecked") protected void extractMap( final Map target, final Map<String, PropsEntry> map, final String[] profiles, final String[] wildcardPatterns, final String prefix ) { for (Map.Entry<String, PropsEntry> entry : map.entrySet()) { String key = entry.getKey(); if (wildcardPatterns != null) { if (Wildcard.matchOne(key, wildcardPatterns) == -1) { continue; } } // shorten the key if (prefix != null) { if (!key.startsWith(prefix)) { continue; } key = key.substring(prefix.length()); } // only append if target DOES NOT contain the key if (!target.containsKey(key)) { target.put(key, entry.getValue().getValue(profiles)); } } }
/** * Finds all extensions that belong to given mime type(s). * If wildcard mode is on, provided mime type is wildcard pattern. * @param mimeType list of mime types, separated by comma * @param useWildcard if set, mime types are wildcard patterns */ public static String[] findExtensionsByMimeTypes(String mimeType, final boolean useWildcard) { final ArrayList<String> extensions = new ArrayList<>(); mimeType = mimeType.toLowerCase(); final String[] mimeTypes = StringUtil.splitc(mimeType, ", "); for (final Map.Entry<String, String> entry : MIME_TYPE_MAP.entrySet()) { final String entryExtension = entry.getKey(); final String entryMimeType = entry.getValue().toLowerCase(); final int matchResult = useWildcard ? Wildcard.matchOne(entryMimeType, mimeTypes) : StringUtil.equalsOne(entryMimeType, mimeTypes); if (matchResult != -1) { extensions.add(entryExtension); } } if (extensions.isEmpty()) { return StringPool.EMPTY_ARRAY; } return extensions.toArray(new String[0]); }