List of usage examples for java.util.regex Pattern CASE_INSENSITIVE
int CASE_INSENSITIVE
To view the source code for java.util.regex Pattern CASE_INSENSITIVE.
Click Source Link
From source file:org.sonatype.nexus.repository.httpclient.HttpClientFactoryImpl.java
@VisibleForTesting public void applyProxyConfig(final Builder builder, final HttpClientConfig config) { if (config.getProxy() != null && config.getProxy().getHttp() != null) { Map<String, HttpHost> proxies = Maps.newHashMap(); HttpProxyConfig httpProxyConfig = config.getProxy().getHttp(); HttpHost httpProxy = new HttpHost(httpProxyConfig.getHostname(), httpProxyConfig.getPort()); applyAuthenticationConfig(builder, httpProxyConfig.getAuthentication(), httpProxy); log.debug("http proxy setup with host '{}'", httpProxyConfig.getHostname()); proxies.put("http", httpProxy); proxies.put("https", httpProxy); if (config.getProxy().getHttps() != null) { HttpProxyConfig httpsProxyConfig = config.getProxy().getHttps(); HttpHost httpsProxy = new HttpHost(httpsProxyConfig.getHostname(), httpsProxyConfig.getPort()); applyAuthenticationConfig(builder, httpsProxyConfig.getAuthentication(), httpsProxy); log.debug("https proxy setup with host '{}'", httpsProxy.getHostName()); proxies.put("https", httpsProxy); }//w ww .j ava 2 s . c om final Set<Pattern> nonProxyHostPatterns = Sets.newHashSet(); if (config.getProxy().getNonProxyHosts() != null) { for (String nonProxyHostRegex : config.getProxy().getNonProxyHosts()) { try { nonProxyHostPatterns.add(Pattern.compile(nonProxyHostRegex, Pattern.CASE_INSENSITIVE)); } catch (PatternSyntaxException e) { log.warn("Invalid non proxy host regex: {}", nonProxyHostRegex, e); } } } builder.getHttpClientBuilder().setRoutePlanner( new NexusHttpRoutePlanner(proxies, nonProxyHostPatterns, DefaultSchemePortResolver.INSTANCE)); } }
From source file:net.jimj.automaton.commands.QuoteCommand.java
protected BasicDBObject buildQuoteSearch(String arg) { //todo: replace w/ real Network concept. BasicDBObject query = new BasicDBObject(QUOTE_NETWORK, "slashnet"); if (arg != null) { //Regex search int searchStart = arg.indexOf("/"); int searchEnd = arg.lastIndexOf("/"); if (searchStart != -1 && searchStart < searchEnd) { //cut out the included / characters. String quoteSearch = arg.substring(searchStart + 1, searchEnd); if (quoteSearch.length() > 0) { query.append(QUOTE_QUOTE, Pattern.compile(quoteSearch, Pattern.CASE_INSENSITIVE)); }/* w w w . ja v a 2 s. c o m*/ } String nick = arg; if (searchStart != -1) { nick = arg.substring(0, searchStart).trim(); } if (!StringUtils.isBlank(nick)) { query.append(QUOTE_NICK, nick); } } LOGGER.debug(query.toString()); return query; }
From source file:net.padlocksoftware.padlock.DefaultMacAddressProvider.java
private Set<String> useShellToFindAddresses() { logger.fine("Platform: " + PLATFORM); if (PLATFORM == Platform.Unknown) { logger.fine("Could not determine host platform, no Network Interfaces found."); return null; }//from w ww .ja v a 2s . c om BufferedReader reader = null; try { Process conf = Runtime.getRuntime().exec(PLATFORM.command); reader = new BufferedReader(new InputStreamReader(conf.getInputStream())); Set<String> macs = new HashSet<String>(4); String regex = "[a-f0-9]{2}([:-][a-f0-9]{2}){5}"; Pattern pattern = Pattern.compile(regex.toString(), Pattern.CASE_INSENSITIVE); String line = reader.readLine(); do { logger.finer("Found line: " + line); Matcher matcher = pattern.matcher(line); while (matcher.find()) { String address = matcher.group(0); address = address.trim().replaceAll("[:-]", ""); logger.fine("Found address: " + address); if (address.length() == 11) address = "0" + address; if (address.length() == 12) { byte[] hex = Hex.decodeHex(address.toCharArray()); if (permitVMAddresses || !isVirtualAddress(hex)) { macs.add(address); } else logger.fine("Found blacklisted address: " + address); } else logger.fine("Found bogus address: " + address); } line = reader.readLine(); } while (line != null); return Collections.unmodifiableSet(macs); } catch (Throwable t) { logger.log(Level.FINE, null, t); return Collections.emptySet(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { logger.log(Level.FINE, null, e); } } } }
From source file:es.juntadeandalucia.panelGestion.negocio.vo.TaskVO.java
public void preareFileColumns() throws PanelException { fileColumns = new LinkedList<ColumnVO>(); if (taskEntity.isUpdate()) { for (ColumnVO column : tableColumns) { if ((column.getFilePosition() >= 0) || column.isFromCoordinates()) { fileColumns.add(column); }/*from ww w .ja va 2s .c o m*/ } } else { for (ColumnVO column : columns) { if (column.isInTable()) { // checks valid column name String columnNameOnTable = column.getNameOnTable(); if (StringUtils.isEmpty(columnNameOnTable)) { columnNameOnTable = column.getText(); } if (StringUtils.isEmpty(columnNameOnTable)) { throw new PanelException("nombre de columna vaco"); } else if (!Utils.isValidName(columnNameOnTable)) { throw new PanelException("nombre de columna invlido: " + columnNameOnTable); } String dbType = column.getType(); Integer sqlType = PanelSettings.dataBaseTypes.get(dbType); if (sqlType == Types.OTHER) { // geometry type if (Pattern.compile(".*\\s*(X|lat)\\s*.*", Pattern.CASE_INSENSITIVE).matcher(dbType) .matches()) { column.setCoordinateX(true); } else if (!Pattern.matches("geometry", dbType.toLowerCase()) && Pattern.compile(".*\\s*(Y|lon)\\s*.*", Pattern.CASE_INSENSITIVE).matcher(dbType) .matches()) { column.setCoordinateY(true); } else { getTaskEntity().getTable().setGeomField(column.getNameOnTable()); } } column.setSqlType(sqlType); fileColumns.add(column); } } } }
From source file:com.g3net.tool.StringUtils.java
/** * // w w w . j av a 2s. c o m * @param srcStr * @param regexp * @param ignoreCase * @return */ public static int indexOf(String srcStr, String regexp, boolean ignoreCase) { Pattern p = null; if (ignoreCase) { p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); } else { p = Pattern.compile(regexp); } Matcher m = p.matcher(srcStr); while (m.find()) { // log.info(m.group()+":"+m.start()+":"+m.end()); return m.start(); } return -1; // sql3.regionMatches(ignoreCase, toffset, other, ooffset, len) // log.info(m.matches()); }
From source file:com.ms.commons.standalone.service.StandaloneServiceImpl.java
private String grepLogFile(String logFilePath, String pattern, int lenth) { String content = getHeadLogFile(logFilePath, false, lenth); String[] lines = content.split("\n"); int[] marks = new int[lines.length]; Pattern p = Pattern.compile(String.format(".*%s.*", pattern), Pattern.CASE_INSENSITIVE); for (int i = 0; i < lines.length; i++) { String line = lines[i];/*from w w w . j a v a 2s .com*/ if (p.matcher(line).matches()) { for (int j = i - 5; j <= i + 5; j++) { if (j >= 0 && j < marks.length) { marks[j] = 1; } } } } String matchLings = ""; for (int i = 0; i < marks.length; i++) { if (marks[i] == 1) { matchLings += lines[i]; } } return matchLings; }
From source file:it.ventuland.ytd.ui.GUIClient.java
/** * @param string//from w w w .j a v a 2 s . c om * @param regex * @param replaceWith * @return changed String */ String replaceAll(String string, String regex, String replaceWith) { Pattern myPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); return (myPattern.matcher(string).replaceAll(replaceWith)); }
From source file:esg.node.filters.UrlResolvingFilter.java
public void init(FilterConfig filterConfig) throws ServletException { System.out.println("Initializing filter: " + this.getClass().getName()); this.filterConfig = filterConfig; dbProperties = new Properties(); System.out.println("FilterConfig is : " + filterConfig); System.out.println("db.protocol is : " + filterConfig.getInitParameter("db.protocol")); dbProperties.put("db.protocol", filterConfig.getInitParameter("db.protocol")); dbProperties.put("db.host", filterConfig.getInitParameter("db.host")); dbProperties.put("db.port", filterConfig.getInitParameter("db.port")); dbProperties.put("db.database", filterConfig.getInitParameter("db.database")); dbProperties.put("db.user", filterConfig.getInitParameter("db.user")); dbProperties.put("db.password", filterConfig.getInitParameter("db.password")); log.trace("Database parameters: " + dbProperties); DatabaseResource.init(filterConfig.getInitParameter("db.driver")).setupDataSource(dbProperties); DatabaseResource.getInstance().showDriverStats(); urlResolvingDAO = new UrlResolvingDAO(DatabaseResource.getInstance().getDataSource()); String extensionsParam = filterConfig.getInitParameter("extensions"); if (extensionsParam == null) { extensionsParam = ""; } //defensive program against null for this param String[] extensions = (".nc," + extensionsParam.toString()).split(","); StringBuffer sb = new StringBuffer(); for (int i = 0; i < extensions.length; i++) { sb.append(extensions[i].trim()); if (i < extensions.length - 1) sb.append("|"); }//from www . j a v a 2s . c om System.out.println("looking for extensions: " + sb.toString()); String regex = "http.*(?:" + sb.toString() + ")$"; System.out.println("Regex = " + regex); urlPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); log.trace(urlResolvingDAO.toString()); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.exporter.ExportWorkbook.java
/** * Creates the instance of the export workbook with the specified {@code locale} and * using the specified {@code templateType} and {@code templateFileName}. * /*from www .j av a2 s . c om*/ * @param locale the locale for generating excel * @param templateType the TemplateType * @param templateFileName the name of the excel template file that should be used */ public ExportWorkbook(Locale locale, TemplateType templateType, String templateFileName) { super(); this.setLocale(locale); String regex = "\\[(http://\\S*|https://\\S*|ftp://\\S*|file:///\\S*)\\s?([^]]*)?\\]"; this.urlPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); loadWorkbookFromTemplateFileName(templateType, templateFileName); initStyles(); }
From source file:com.bazaarvoice.seo.sdk.BVUIContentServiceProvider.java
public boolean showUserAgentSEOContent() { if (_bvParameters == null || _bvParameters.getUserAgent() == null) { return false; }/*from w ww .j a v a 2 s . co m*/ String crawlerAgentPattern = _bvConfiguration .getProperty(BVClientConfig.CRAWLER_AGENT_PATTERN.getPropertyName()); if (!StringUtils.isBlank(crawlerAgentPattern)) { crawlerAgentPattern = ".*(" + crawlerAgentPattern + ").*"; } Pattern pattern = Pattern.compile(crawlerAgentPattern, Pattern.CASE_INSENSITIVE); _logger.debug("userAgent is : " + _bvParameters.getUserAgent()); return (pattern.matcher(_bvParameters.getUserAgent()).matches() || _bvParameters.getUserAgent().toLowerCase().contains("google")); }