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:org.apache.zeppelin.interpreter.InterpreterResult.java
private int getIndexOfType(String msg, Type t) { if (msg == null) { return 0; }//w w w .j ava 2 s.c o m String typeString = "%" + t.name().toLowerCase(); return StringUtils.indexOf(msg, typeString); }
From source file:org.asqatasun.rules.elementchecker.contrast.helper.ContrastHelper.java
/** * /* ww w . ja v a 2 s. co m*/ * @param color * @return */ public static Color getColorFromString(final String color) { if (StringUtils.equalsIgnoreCase(color, TRANSPARENT_KEY)) { return Color.WHITE; } String[] comps = StringUtils.substring(color, StringUtils.indexOf(color, OPEN_PARENTHESE) + 1, StringUtils.indexOf(color, CLOSE_PARENTHESE)).split(COMPOSANT_SEPARATOR); return new Color(Integer.valueOf(comps[0].trim()), Integer.valueOf(comps[1].trim()), Integer.valueOf(comps[2].trim())); }
From source file:org.asqatasun.rules.elementchecker.lang.LangChecker.java
/** * //from w ww.j a v a2s. co m * @param langDefinition * @return the language code (truncate language definition when option is * defined) */ protected String extractEffectiveLang(String langDefinition) { int separatorIndex = StringUtils.indexOf(langDefinition, '-'); if (separatorIndex != -1) { return StringUtils.substring(langDefinition, 0, separatorIndex); } return langDefinition; }
From source file:org.corpus_tools.pepper.cli.ConvertWizardConsole.java
/** * Reads a property from the given inpu and returns true, if the input was * not empty and false otherwise.//from w w w . j a va 2s .com * * @param input * the user input * @param stepDesc * the {@link StepDesc} object to which the property should be * added * @return true if input was not empty */ private boolean readProp(Map<Integer, String> number2propName, String input, StepDesc stepDesc) { if ((input != null) && (!input.isEmpty())) { int eqPosition = StringUtils.indexOf(input, "="); if (eqPosition > 0) { String qualifier = input.substring(0, eqPosition); try { Integer num = Integer.valueOf(qualifier); qualifier = number2propName.get(num); } catch (NumberFormatException e) { // do nothing } String value = input.substring(eqPosition + 1, input.length()); if (stepDesc.getProps() == null) { stepDesc.setProps(new Properties()); } stepDesc.getProps().put(qualifier, value); out.println("\tAdded property: " + qualifier + " = " + value); } else { out.println(MSG_NO_VALID_PROP); } return (true); } else { return (false); } }
From source file:org.eclipse.ebr.maven.LicenseProcessingUtility.java
protected boolean isPotentialWebUrl(final String url) { return (url != null) && (StringUtils.startsWithAny(url.toLowerCase(), HTTP_PREFIX, HTTPS_PREFIX) || (StringUtils.indexOf(url, ':') == -1)); }
From source file:org.goko.controller.grbl.v08.GrblCommunicator.java
/** * Create a status report from the given string * @param strStatusReport the String representing the status report * @return {@link StatusReport}/* www . ja v a 2 s .c o m*/ * @throws GkException */ private StatusReport parseStatusReport(String strStatusReport) throws GkException { StatusReport result = new StatusReport(); int comma = StringUtils.indexOf(strStatusReport, ","); String state = StringUtils.substring(strStatusReport, 1, comma); GrblMachineState grblState = grbl.getGrblStateFromString(state); result.setState(grblState); // Looking for MPosition String mpos = StringUtils.substringBetween(strStatusReport, "MPos:", ",WPos"); String wpos = StringUtils.substringBetween(strStatusReport, "WPos:", ">"); Tuple6b machinePosition = new Tuple6b().setNull(); Tuple6b workPosition = new Tuple6b().setNull(); String[] machineCoordinates = StringUtils.split(mpos, ","); parseTuple(machineCoordinates, machinePosition); result.setMachinePosition(machinePosition); String[] workCoordinates = StringUtils.split(wpos, ","); parseTuple(workCoordinates, workPosition); result.setWorkPosition(workPosition); return result; }
From source file:org.goko.controller.grbl.v09.GrblCommunicator.java
/** * Create a status report from the given string * @param strStatusReport the String representing the status report * @return {@link StatusReport}//from w w w. jav a 2 s .c o m * @throws GkException */ private StatusReport parseStatusReport(String strStatusReport) throws GkException { StatusReport result = new StatusReport(); int comma = StringUtils.indexOf(strStatusReport, ","); String state = StringUtils.substring(strStatusReport, 1, comma); GrblMachineState grblState = grbl.getGrblStateFromString(state); result.setState(grblState); Tuple6b machinePosition = new Tuple6b().setNull(); Tuple6b workPosition = new Tuple6b().setNull(); // Looking for MPosition Matcher mposMatcher = PATTERN_MPOS.matcher(strStatusReport); if (mposMatcher.matches()) { String mposX = mposMatcher.group(1); String mposY = mposMatcher.group(2); String mposZ = mposMatcher.group(3); parseTuple(machinePosition, mposX, mposY, mposZ); result.setMachinePosition(machinePosition); } // Looking for WPosition Matcher wposMatcher = PATTERN_WPOS.matcher(strStatusReport); if (wposMatcher.matches()) { int t = wposMatcher.groupCount(); String wposX = wposMatcher.group(1); String wposY = wposMatcher.group(2); String wposZ = wposMatcher.group(3); parseTuple(workPosition, wposX, wposY, wposZ); result.setWorkPosition(workPosition); } // Looking for buffer planner occupation Matcher bufMatcher = PATTERN_BUF.matcher(strStatusReport); if (bufMatcher.matches()) { Integer plannerBuffer = Integer.valueOf(bufMatcher.group(1)); result.setPlannerBuffer(plannerBuffer); } return result; }
From source file:org.kuali.coeus.propdev.impl.questionnaire.ProposalDevelopmentQuestionsAction.java
/** * This is specifically for 'lookup' return a value. * @see org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase#refresh(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w ww. jav a 2 s. co m @Override public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward forward = super.refresh(mapping, form, request, response); if (request.getParameter("refreshCaller") != null && request.getParameter("refreshCaller").toString().equals("kualiLookupable")) { // Lookup field 'onchange' is not working if it is return a value from 'lookup', so do it on server side for (Object obj : request.getParameterMap().keySet()) { if (StringUtils.indexOf((String) obj, "questionnaireHelper.answerHeaders[") == 0) { ((ProposalDevelopmentForm) form).getQuestionnaireHelper() .updateChildIndicator(Integer.parseInt(StringUtils.substringBetween((String) obj, "questionnaireHelper.answerHeaders[", "].answers["))); } else if (StringUtils.indexOf((String) obj, "s2sQuestionnaireHelper.answerHeaders[") == 0) { ((ProposalDevelopmentForm) form).getS2sQuestionnaireHelper() .updateChildIndicator(Integer.parseInt(StringUtils.substringBetween((String) obj, "s2sQuestionnaireHelper.answerHeaders[", "].answers["))); } } } return forward; }
From source file:org.kuali.kra.award.notification.AwardReportTrackingNotificationRenderer.java
@Override public String render(String text) { int startIndex = StringUtils.indexOf(text, START_REPEAT_SECTION); int endIndex = StringUtils.indexOf(text, END_REPEAT_SECTION) + END_REPEAT_SECTION.length(); String startStr = text.substring(0, startIndex); String repeatedStr = text.substring(startIndex, endIndex); String endStr = text.substring(endIndex); StringBuffer buffer = new StringBuffer(); buffer.append(startStr);// w w w .ja v a 2s . c o m for (ReportTracking report : reports) { buffer.append(this.render(repeatedStr, getReportReplacementParameters(report))); } buffer.append(endStr); return buffer.toString(); }
From source file:org.kuali.kra.award.web.struts.action.AwardPaymentReportsAndTermsAction.java
private int getAwardReportTermItemsIndex(HttpServletRequest request) { final String awardReportTermItemsIndexBase = "AwardReportTermItemsIndex"; Map paramMap = request.getParameterMap(); Iterator keys = paramMap.keySet().iterator(); while (keys.hasNext()) { String key = keys.next().toString(); if (StringUtils.contains(key, awardReportTermItemsIndexBase)) { int startingSubStringIndex = StringUtils.indexOf(key, awardReportTermItemsIndexBase) + awardReportTermItemsIndexBase.length(); int endingSubStringIndex = key.length() - 2; String intValSubstring = key.substring(startingSubStringIndex, endingSubStringIndex); return Integer.valueOf(intValSubstring); }//from w ww.j a v a 2 s . c o m } throw new IllegalArgumentException( awardReportTermItemsIndexBase + " was not found in the request, can't find the index."); }