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:com.abssh.util.GenericDao.java
private boolean matchOrderClause(String hql) { String regEx = "(?i)\\s+order(\\s+)by\\s+"; Pattern p = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(hql);//from ww w . java2 s . co m return m.find(); }
From source file:com.mycompany.myproject.xemailservice.tests.XEmailIntegrationIT.java
@Test public void testgetLists() { RequestExecutor exec = null;// w w w.j a va2s .c o m try { String path = "/_jcr_content.emailservice.json?operation=getlist&cfgpath=" + XConfigPath; exec = authorAdmin.http.doGet(path, SC_OK); String content = exec.getContent(); assertNotNull(content); final Pattern p = Pattern.compile("\"name\":\"samplelist\"", Pattern.CASE_INSENSITIVE); if (!p.matcher(content).find()) fail("Couldnot retreive sample mail list"); } catch (Exception e) { Assert.fail("Could not retreive default attribute email from XMailService" + e.getMessage()); } }
From source file:ru.efo.security.ADUserDetailsService.java
/** * Set the base DN to search users accounts. * For example: <code>dc=example,dc=com</code> * * @param userSearchBase the DN/*from ww w . java 2s. c om*/ */ public void setUserSearchBase(String userSearchBase) { this.userSearchBase = userSearchBase; if (userSuffix == null && userSearchBase != null) { // If userSuffix is not set then determine it from searchBase final Pattern pattern = Pattern.compile("dc\\s*=\\s*([^,]+)", Pattern.CASE_INSENSITIVE); userSuffix = ""; final Matcher matcher = pattern.matcher(userSearchBase); while (matcher.find()) { userSuffix += (userSuffix.isEmpty() ? "@" : ".") + matcher.group(1); } } }
From source file:com.hp.alm.ali.idea.entity.tree.EntityNode.java
public String toString() { String name = entity.getPropertyValue("name"); if (loading) { name += "..."; // TODO: show as icon }/* w w w . j ava 2s.c o m*/ String filter = model.getFilter(); if (!filter.isEmpty()) { Matcher matcher = Pattern.compile(wildcardToRegex(filter), Pattern.CASE_INSENSITIVE).matcher(name); List<Pair<Integer, Integer>> list = new LinkedList<Pair<Integer, Integer>>(); while (matcher.find()) { list.add(new Pair<Integer, Integer>(matcher.start(), matcher.end())); } if (!list.isEmpty()) { Collections.reverse(list); for (Pair<Integer, Integer> match : list) { name = name.substring(0, match.first) + "<b>" + name.substring(match.first, match.second) + "</b>" + name.substring(match.second); } return "<html>" + name + "</html>"; } } return name; }
From source file:com.thoughtworks.go.server.newsecurity.filters.AccessTokenAuthenticationFilter.java
private AccessTokenCredential extractAuthTokenCredential(String authorizationHeader) { final Pattern BEARER_AUTH_EXTRACTOR_PATTERN = Pattern.compile("bearer (.*)", Pattern.CASE_INSENSITIVE); if (isBlank(authorizationHeader)) { return null; }// ww w. j a va2 s . com final Matcher matcher = BEARER_AUTH_EXTRACTOR_PATTERN.matcher(authorizationHeader); if (matcher.matches()) { String token = matcher.group(1); AccessToken accessToken = accessTokenService.findByAccessToken(token); return new AccessTokenCredential(accessToken); } return null; }
From source file:com.asual.summer.core.faces.FacesResourceProcessor.java
public static byte[] execute(URL url, InputStream input, String encoding) throws IOException { byte[] bytes; try {/*from w ww. j a v a2 s .co m*/ StringBuilder sb = new StringBuilder(); UnicodeReader reader = new UnicodeReader(input, encoding); try { char[] cbuf = new char[32]; int r; while ((r = reader.read(cbuf, 0, 32)) != -1) { sb.append(cbuf, 0, r); } String str = sb.toString(); if (!str.contains("ui:component")) { try { String fileEncoding = reader.getEncoding(); InputSource is = new InputSource(new StringReader(str)); is.setEncoding(fileEncoding); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLDocumentFilter[] filters = { new Writer(baos, fileEncoding) { protected void printStartElement(QName element, XMLAttributes attributes) { fPrinter.print('<'); fPrinter.print(element.rawname); int attrCount = attributes != null ? attributes.getLength() : 0; for (int i = 0; i < attrCount; i++) { String aname = attributes.getQName(i); String avalue = attributes.getValue(i); fPrinter.print(' '); fPrinter.print(aname); fPrinter.print("=\""); printAttributeValue(avalue); fPrinter.print('"'); } if (HTMLElements.getElement(element.rawname).isEmpty()) { fPrinter.print(' '); fPrinter.print('/'); } fPrinter.print('>'); fPrinter.flush(); } protected void printAttributeValue(String text) { fPrinter.print(StringEscapeUtils.escapeHtml(text)); fPrinter.flush(); } protected void printEntity(String name) { fPrinter.print('&'); fPrinter.print('#'); fPrinter.print(HTMLEntities.get(name)); fPrinter.print(';'); fPrinter.flush(); } } }; DOMParser parser = new DOMParser(); parser.setFeature("http://cyberneko.org/html/features/balance-tags", false); parser.setFeature("http://cyberneko.org/html/features/scanner/notify-builtin-refs", true); parser.setProperty("http://cyberneko.org/html/properties/default-encoding", fileEncoding); parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower"); parser.setProperty("http://cyberneko.org/html/properties/filters", filters); parser.parse(is); str = "<!DOCTYPE html>" + baos.toString(fileEncoding); } catch (Exception e) { logger.error(e.getMessage(), e); } if (url.getFile().contains("META-INF/templates")) { str = "<ui:component xmlns:ui=\"http://java.sun.com/jsf/facelets\">" + Pattern .compile("(<\\!DOCTYPE html>)|(</?html[^>]*>)|(<title>[^<]*</title>)", Pattern.CASE_INSENSITIVE) .matcher(str).replaceAll("").replaceAll("\\$\\{template\\.body\\}", "<ui:insert />") + "</ui:component>"; } } bytes = str.getBytes(reader.getEncoding()); } finally { reader.close(); } } catch (IOException e) { throw e; } return bytes; }
From source file:com.github.koraktor.steamcondenser.community.GameStats.java
/** * Creates a <code>GameStats</code> object and fetches data from the Steam * Community for the given user and game * * @param steamId The custom URL or the 64bit Steam ID of the user * @param gameId The app ID or friendly name of the game * @throws SteamCondenserException if the stats cannot be fetched *//*from w w w. j av a 2s . c om*/ protected GameStats(Object steamId, Object gameId) throws SteamCondenserException { if (steamId instanceof String) { this.user = SteamId.create((String) steamId, false); } else if (steamId instanceof Long) { this.user = SteamId.create((Long) steamId, false); } try { this.xmlData = new XMLData(getBaseUrl(steamId, gameId) + "?xml=all"); if (this.xmlData.hasElement("error")) { throw new SteamCondenserException(this.xmlData.getString("error")); } this.privacyState = this.xmlData.getString("privacyState"); if (this.isPublic()) { Pattern appIdPattern = Pattern.compile("http://steamcommunity\\.com/+app/+([1-9][0-9]*)", Pattern.CASE_INSENSITIVE); Matcher appIdMatcher = appIdPattern.matcher(this.xmlData.getString("game", "gameLink")); appIdMatcher.find(); int appId = Integer.parseInt(appIdMatcher.group(1)); this.game = SteamGame.create(appId, this.xmlData.getElement("game")); this.hoursPlayed = this.xmlData.getString("stats", "hoursPlayed"); } } catch (Exception e) { throw new SteamCondenserException("XML data could not be parsed.", e); } }
From source file:com.adguard.filter.rules.ContentFilterRule.java
/** * Creates an instance of the ContentFilterRule from its text format * * @param ruleText Rule text//ww w . j a v a 2 s.c om */ protected ContentFilterRule(String ruleText) { super(ruleText); parentSearchLevel = DEFAULT_PARENT_SEARCH_LEVEL; int contentRuleMarkIndex = StringUtils.indexOf(ruleText, MASK_CONTENT_RULE); int ruleStartIndex = StringUtils.indexOf(ruleText, ATTRIBUTE_START_MARK); // Cutting tag name from string if (ruleStartIndex == -1) { tagName = ruleText.substring(contentRuleMarkIndex + MASK_CONTENT_RULE.length()); } else { tagName = ruleText.substring(contentRuleMarkIndex + MASK_CONTENT_RULE.length(), ruleStartIndex); } // Loading domains (if any)) if (contentRuleMarkIndex > 0) { String domains = ruleText.substring(0, contentRuleMarkIndex); loadDomains(domains); } // Loading attributes filter while (ruleStartIndex != -1) { int equalityIndex = ruleText.indexOf(EQUAL, ruleStartIndex + 1); int quoteStartIndex = ruleText.indexOf(QUOTES, equalityIndex + 1); int quoteEndIndex = getQuoteIndex(ruleText, quoteStartIndex + 1); if (quoteStartIndex == -1 || quoteEndIndex == -1) { break; } int ruleEndIndex = ruleText.indexOf(ATTRIBUTE_END_MARK, quoteEndIndex + 1); String attributeName = ruleText.substring(ruleStartIndex + 1, equalityIndex); String attributeValue = ruleText.substring(quoteStartIndex + 1, quoteEndIndex); attributeValue = StringUtils.replace(attributeValue, "\"\"", "\""); switch (attributeName) { case TAG_CONTENT_MASK: tagContentFilter = attributeValue; break; case WILDCARD_MASK: wildcard = new Wildcard(attributeValue, Pattern.DOTALL | Pattern.CASE_INSENSITIVE); break; case TAG_CONTENT_MAX_LENGTH: maxLength = NumberUtils.toInt(attributeValue); break; case TAG_CONTENT_MIN_LENGTH: minLength = NumberUtils.toInt(attributeValue); break; case PARENT_ELEMENTS: parentElements = Arrays.asList(StringUtils.split(attributeValue, ',')); break; case PARENT_SEARCH_LEVEL: parentSearchLevel = NumberUtils.toInt(attributeValue); break; default: attributesFilter.put(attributeName, attributeValue); break; } if (ruleEndIndex == -1) break; ruleStartIndex = ruleText.indexOf(ATTRIBUTE_START_MARK, ruleEndIndex + 1); } }
From source file:GIST.IzbirkomExtractor.Russian.OrdinalFactory.java
/** * Default constructor//w w w . j a v a 2 s. co m */ public OrdinalFactory() { /* creating varions maps and hash tables */ stems0_10_lookup = new HashMap<String, Integer>(stems0_10.length); for (int i = 0; i < stems0_10.length; i++) stems0_10_lookup.put(stems0_10[i], i); stems11_19_lookup = new HashMap<String, Integer>(stems11_19.length); for (int i = 0; i < stems11_19.length; i++) stems11_19_lookup.put(stems11_19[i], i); /* create matching patterns for parsing */ /* pattern for 1-, 2-, ... */ digits_numeral_pat = Pattern.compile("\\b(\\d{1,2})(?:(-)?([-?]{1,2}))?\\b", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); /* pattern for , , ... */ StringBuilder sb0_10_pat = new StringBuilder(); sb0_10_pat.append("\\b("); sb0_10_pat.append(StringUtils.join(stems0_10, '|')); sb0_10_pat.append(")([-?]{1,3})\\b"); stem0_10_numeral_pat = Pattern.compile(sb0_10_pat.toString(), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); /* pattern for , , ... */ StringBuilder sb11_19_pat = new StringBuilder(); sb11_19_pat.append("\\b("); sb11_19_pat.append(StringUtils.join(stems11_19, '|')); sb11_19_pat.append(")([-?]{1,2})\\b"); stem11_19_numeral_pat = Pattern.compile(sb11_19_pat.toString(), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); // TODO: patterns for 20+ }
From source file:es.juntadeandalucia.panelGestion.negocio.utiles.Utils.java
public static FileType getTypeFromName(String fileName) { FileType type = null;/*w ww. j av a 2 s . c o m*/ if (!StringUtils.isEmpty(fileName)) { Pattern csvPattern = Pattern.compile("^.*\\.(csv|txt)$", Pattern.CASE_INSENSITIVE); Pattern shapePattern = Pattern.compile("^.*\\.(shp|shape|zip|rar|tar|gz|xz)$", Pattern.CASE_INSENSITIVE); if (csvPattern.matcher(fileName).matches()) { type = FileType.CSV; } else if (shapePattern.matcher(fileName).matches()) { type = FileType.SHAPEFILE; } } return type; }