List of usage examples for org.apache.commons.lang3 StringUtils substring
public static String substring(final String str, int start)
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start n characters from the end of the String.
A null String will return null .
From source file:org.asqatasun.rules.test.AbstractRuleImplementationTestCase.java
@Override public String getName() { int lastPointIndex = StringUtils.lastIndexOf(ruleImplementationClassName, ".") + 1; String className = StringUtils.substring(ruleImplementationClassName, lastPointIndex); return StringUtils.replace(className, "Rule", "-"); }
From source file:org.goko.core.gcode.bean.GCodeWord.java
/** * @return the value */ public BigDecimal getValue() { return new BigDecimal(StringUtils.substring(stringValue, 1)); }
From source file:org.goko.core.rs274ngcv3.RS274.java
public static String getTokenValue(GCodeToken token) { return StringUtils.substring(token.getValue(), 1); }
From source file:org.goko.serial.bindings.SerialConsoleController.java
protected void appendTextToConsoleWidget(final String text, final int color) { if (consoleWidget != null) { Display.getDefault().asyncExec(new Runnable() { @Override/*from w w w .jav a 2 s. c om*/ public void run() { int initialCharCount = consoleWidget.getCharCount(); consoleWidget.append(text); StyleRange[] ranges = new StyleRange[1]; ranges[0] = new StyleRange(); ranges[0].start = initialCharCount; ranges[0].length = StringUtils.length(text); ranges[0].foreground = SWTResourceManager.getColor(color); consoleWidget.replaceStyleRanges(ranges[0].start, ranges[0].length, ranges); if (SerialActivator.getPreferenceStore() .getBoolean(SerialConsolePreferences.SERIAL_CONSOLE_LIMIT_CHARACTER)) { int maxChar = SerialActivator.getPreferenceStore() .getInt(SerialConsolePreferences.SERIAL_CONSOLE_MAX_CHARACTER); if (consoleWidget.getCharCount() > maxChar) { int delta = consoleWidget.getCharCount() - maxChar; //consoleWidget.setText( StringUtils.substring(consoleWidget.getText(), delta)); getDataModel().setConsole(StringUtils.substring(consoleWidget.getText(), delta)); updateCarretPosition(); } } else { getDataModel().setConsole(consoleWidget.getText()); } } }); } }
From source file:org.javabeanstack.util.Strings.java
/** * Extrae carecteres de un string// w w w . j a va2 s . c om * @param str variable string * @param start posicin a partir de la cual extraera los caracteres hasta el final de la variable. * @return caracteres extraidos a partir de una posicin hasta el final de la variable. */ public static String substring(String str, int start) { return StringUtils.substring(str, start); }
From source file:org.javabeanstack.util.Strings.java
/** * Extrae caracteres de un string//from www. j a va 2 s .c o m * @param str variable string * @param start posicin a partir de la cual extraera los caracteres hasta el final de la variable. * @return caracteres extraidos a partir de una posicin hasta el final de la variable. */ public static String substr(String str, int start) { return StringUtils.substring(str, start); }
From source file:org.kuali.coeus.sys.framework.controller.ParameterAwareCommonsMultipartResolver.java
private Long getMaxUploadSizeParameter() { long maxUploadSize = 0; String maxString = getParameterService().getParameterValueAsString(KRADConstants.KNS_NAMESPACE, ParameterConstants.ALL_COMPONENT, KRADConstants.MAX_UPLOAD_SIZE_PARM_NM); String suffix = StringUtils.substring(maxString, maxString.length() - 1); Long multiplier = Long.parseLong(StringUtils.stripEnd(maxString, suffix)); if (StringUtils.equals(suffix, "K")) { maxUploadSize = multiplier * 1000L; } else if (StringUtils.equals(suffix, "M")) { maxUploadSize = multiplier * 1000000L; } else if (StringUtils.equals(suffix, "G")) { maxUploadSize = multiplier * 1000000000L; } else {/*w w w . j a va 2 s. co m*/ maxUploadSize = Long.parseLong(maxString); } return maxUploadSize; }
From source file:org.kuali.coeus.sys.impl.controller.KcFileServiceImpl.java
public Long getMaxUploadSizeParameter() { long maxUploadSize = 0; String maxString = getParameterService().getParameterValueAsString(KRADConstants.KNS_NAMESPACE, ParameterConstants.ALL_COMPONENT, KRADConstants.MAX_UPLOAD_SIZE_PARM_NM); String suffix = StringUtils.substring(maxString, maxString.length() - 1); Long multiplier = Long.parseLong(StringUtils.stripEnd(maxString, suffix)); if (StringUtils.equals(suffix, "K")) { maxUploadSize = multiplier * 1000L; } else if (StringUtils.equals(suffix, "M")) { maxUploadSize = multiplier * 1000000L; } else if (StringUtils.equals(suffix, "G")) { maxUploadSize = multiplier * 1000000000L; } else {/* w w w . j ava 2s .co m*/ maxUploadSize = Long.parseLong(maxString); } return maxUploadSize; }
From source file:org.kuali.kra.award.web.struts.action.AwardAction.java
/** * This method sets up a sponsor template synchronization loop. * It is called by the ui when a specific set of scopes need to by synchronized. * If no scopes are in the request, then a full synchronization to the scopes: * /*from ww w . j a va2 s . c o m*/ * AWARD_PAGE * SPONSOR_CONTACTS_TAB * PAYMENTS_AND_INVOICES_TAB * TERMS_TAB * REPORTS_TAB * COMMENTS_TAB * * is performed. This method generates and stores the list of scopes to sync * and the map to indicate if confirmation is necessary from the user before * a particular scope is synchronized and then forwards to the method the handles * the request loop. * */ public ActionForward syncAwardTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AwardForm awardForm = (AwardForm) form; AwardDocument awardDocument = awardForm.getAwardDocument(); AwardTemplateSyncScope[] scopes; String syncScopes = getSyncScopesString(request); if (awardDocument.getAward().getTemplateCode() == null || awardDocument.getAward().getAwardTemplate() == null) { GlobalVariables.getMessageMap().clearErrorMessages(); GlobalVariables.getMessageMap().putError( StringUtils.isBlank(syncScopes) ? "document.award.awardTemplate" : String.format("document.award.awardTemplate.%s", StringUtils.substring(syncScopes, 1)), KeyConstants.ERROR_NO_SPONSOR_TEMPLATE_FOUND, new String[] {}); awardForm.setOldTemplateCode(null); awardForm.setTemplateLookup(false); return mapping.findForward(Constants.MAPPING_AWARD_BASIC); } Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME); if (question != null) return processSyncAward(mapping, awardForm, request, response); awardForm.setCurrentSyncScopes(null); awardForm.setSyncRequiresConfirmationMap(null); /* * The format for the action string is: * methodToCall.syncAwardTemplate:SCOPE1:...:SCOPEN].anchor... * Where: * [PropertyName|MethodName] means to sync by a property name or a method name. * SCOPE1...SCOPEN : A ':' delimited list of scope names that should be synced. If none are specified then the sync is done for every field and method. * */ if (StringUtils.isNotBlank(syncScopes) && syncScopes.length() > 1 && syncScopes.indexOf(":") > -1) { String[] scopeStrings = StringUtils.split(StringUtils.substringAfter(syncScopes, ":")); scopes = new AwardTemplateSyncScope[scopeStrings.length]; for (int i = 0; i < scopeStrings.length; i++) { scopes[i] = Enum.valueOf(AwardTemplateSyncScope.class, scopeStrings[i]); } awardForm.setSyncRequiresConfirmationMap( generateScopeRequiresConfirmationMap(scopes, awardDocument, false, false)); awardForm.setCurrentSyncScopes(scopes); } else { awardForm.setSyncRequiresConfirmationMap(generateScopeRequiresConfirmationMap( DEFAULT_AWARD_TEMPLATE_SYNC_SCOPES, awardDocument, false, false)); awardForm.setCurrentSyncScopes(DEFAULT_AWARD_TEMPLATE_SYNC_SCOPES); } return processSyncAward(mapping, form, request, response); }
From source file:org.massyframework.assembly.base.web.HttpResourceProcessorManagement.java
protected String parseExtensionName(String path) { int index = StringUtils.lastIndexOf(path, AbstractHttpService.PATH_SEPARATOR); int index_ext = StringUtils.lastIndexOf(path, EXTENSION_SEPARATOR); if (index_ext > index) { return StringUtils.substring(path, index_ext); }/*from w w w. j a va2 s . com*/ return null; }