List of usage examples for org.apache.commons.lang3 StringUtils indexOf
public static int indexOf(final CharSequence seq, final CharSequence searchSeq)
Finds the first index within a CharSequence, handling null .
From source file:SampleLang.java
/** * Check if the key is valid//w w w . j a v a 2 s . c om * @param key license key value * @return true if key is valid, false otherwise. */ public static boolean checkLicenseKey(String key) { //checks if empty or null if (StringUtils.isBlank(key)) { return false; } //delete all white space key = StringUtils.deleteWhitespace(key); //Split String using the - separator String[] keySplit = StringUtils.split(key, "-"); //check lengths of whole and parts if (keySplit.length != 2 || keySplit[0].length() != 4 || keySplit[1].length() != 4) { return false; } //Check if first part is numeric if (!StringUtils.isNumeric(keySplit[0])) { return false; } //Check if second part contains only //the four characters 'J', 'A', 'V' and 'A' if (!StringUtils.containsOnly(keySplit[1], new char[] { 'J', 'A', 'V', 'A' })) { return false; } //Check if the fourth character //in the first part is a '0' if (StringUtils.indexOf(keySplit[0], '0') != 3) { return false; } //If all conditions are fulfilled, key is valid. return true; }
From source file:com.adguard.filter.rules.ScriptFilterRule.java
/** * Creates FilterRule text/*from w w w . java 2 s .c o m*/ * * @param ruleText Rule text */ protected ScriptFilterRule(String ruleText) { super(ruleText); int indexOfMask = StringUtils.indexOf(ruleText, MASK_SCRIPT_RULE); // Loading domains (if any)) if (indexOfMask > 0) { String domains = ruleText.substring(0, indexOfMask); loadDomains(domains); } scriptText = ruleText.substring(indexOfMask + MASK_SCRIPT_RULE.length()); }
From source file:de.blizzy.documentr.markdown.macro.impl.PanelMacro.java
@Override public String getHtml(IMacroContext macroContext) { String params = macroContext.getParameters(); String width = StringUtils.substringBefore(params, " ").trim(); //$NON-NLS-1$ boolean border = StringUtils.indexOf(params, " border") >= 0; //$NON-NLS-1$ return "<div class=\"span" + StringEscapeUtils.escapeHtml4(width) + "\">" + //$NON-NLS-1$ //$NON-NLS-2$ (border ? "<div class=\"span12 panel-border\">" : StringUtils.EMPTY) + //$NON-NLS-1$ macroContext.getBody() + (border ? "</div>" : StringUtils.EMPTY) + //$NON-NLS-1$ "</div>"; //$NON-NLS-1$ }
From source file:kenh.expl.functions.IndexOf.java
public int process(String seq, String searchSeq, boolean ignoreCase) { if (ignoreCase) return StringUtils.indexOfIgnoreCase(seq, searchSeq); else// w ww . ja v a 2 s. c o m return StringUtils.indexOf(seq, searchSeq); }
From source file:io.wcm.devops.conga.generator.plugins.fileheader.UnixShellScriptFileHeader.java
@Override protected int getInsertPosition(String content) { // keep shebang on first line if present if (StringUtils.startsWith(content, "#!")) { return StringUtils.indexOf(content, "\n") + 1; }/*from w ww . j av a2 s .c o m*/ return 0; }
From source file:com.sonicle.webtop.contacts.bol.OCategory.java
public String getHexColor() { String color = getColor(); return (StringUtils.indexOf(color, "#") == 0) ? StringUtils.substring(color, 1) : color; }
From source file:com.zergiu.tvman.init.SQLFileImporter.java
/** * @param statements//from ww w.ja v a 2s. co m * @param line * @param statementBuilder */ private void buildStatement(List<String> statements, String line, StrBuilder statementBuilder) { int indexOfSemicolon = StringUtils.indexOf(line, ";"); if (indexOfSemicolon >= 0) { statementBuilder.append(line.substring(0, indexOfSemicolon));//add contents of the line up to ; statements.add(statementBuilder.toString()); //add the statement to the list statementBuilder.clear();//clear whatever we had before statementBuilder.append(line.substring(indexOfSemicolon + 1));//add whatever is left on that line after ; } else { //we're not done yet //always prepend a space before adding a new line statementBuilder.append(" " + line); } }
From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java
private static List<Object> evalAttributes(JspTag tag, List<Object> attributes, ChildPageContext ctx) throws JspException { if (ctx.isEvaluateTagAttributes() == false) return attributes; List<Object> nattr = new ArrayList<Object>(attributes.size()); for (int i = 0; i < attributes.size() - 1; i = i + 2) { String key = (String) attributes.get(i); nattr.add(key);/*from w w w. j a v a 2s . com*/ Object value = attributes.get(i + 1); if ((value instanceof String) == false) { nattr.add(value); continue; } String sv = (String) value; if (StringUtils.indexOf(sv, "${") == -1) { nattr.add(value); continue; } Object r = jspTagEvaluator.evaluate(key, sv, Object.class, tag, ctx); nattr.add(r); } return nattr; }
From source file:jenkins.plugins.asqatasun.ProjectAsqatasunAction.java
private String doBuildAuditResultUrl(String line, String webappUrl) { String auditId = StringUtils.substring(line, StringUtils.indexOf(line, ":") + 1).trim(); if (StringUtils.endsWith(webappUrl, "/")) { return webappUrl + URL_PREFIX_RESULT + auditId; } else {/*from w w w.ja va2 s .com*/ return webappUrl + "/" + URL_PREFIX_RESULT + auditId; } }
From source file:com.adguard.filter.rules.ContentFilterRule.java
/** * Creates an instance of the ContentFilterRule from its text format * * @param ruleText Rule text/* w ww.j av a2 s . co m*/ */ 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); } }