List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:com.huateng.struts.system.action.AuthoriseAction.java
public String authorise() { try {/*from www.j a v a 2s .c o m*/ if (StringUtil.isNull(username)) { return returnService("???"); } if (StringUtil.isNull(pass)) { return returnService("????"); } if (StringUtil.isNull(txnCode)) { return returnService("??"); } //??? TblOprInfoDAO tblOprInfoDAO = (TblOprInfoDAO) ContextUtil.getBean("OprInfoDAO"); TblOprInfo user = tblOprInfoDAO.get(username); /*if (getOperator().getOprId().equals(username)) { return returnService("???????"); }*/ //20120906?????? if (!getOperator().getOprId().equals(username)) { return returnService("??????"); } // Step 1 :?? if (user == null) { return returnService("???"); } // ??? if ("1".equals(user.getOprSta().trim())) { return returnService("??????"); } // ??? if (Integer.parseInt(user.getPwdOutDate().trim()) <= Integer .parseInt(CommonFunction.getCurrentDate())) { return returnService("??????"); } // Step 2 :?? if (!getOperator().getOprBrhId().equals(user.getBrhId())) { return returnService( "????????"); } // Step 3 :?????? String txn = "select KEY_ID from TBL_ROLE_FUNC_MAP " + "where KEY_ID = '" + user.getOprDegree().trim() + "' and VALUE_ID = '" + txnCode.trim() + "'"; List list = commQueryDAO.findBySQLQuery(txn); if (list != null && !list.isEmpty()) { // ??? String oprPassword = StringUtils.trim(user.getOprPwd()); pass = StringUtils.trim(Encryption.encrypt(pass)); if (pass.equals(oprPassword)) { return returnService(Constants.SUCCESS_CODE); } else { return returnService("?????"); } } else { return returnService("?????"); } } catch (Exception e) { e.printStackTrace(); return returnService(rspCode, e); } }
From source file:com.incapture.apigen.SampleCodeFactory.java
private String createForTemplate(String apiName, com.incapture.apigen.slate.function.Function function, String templatePath) {// w w w .jav a 2 s .c om String template = getResource(templatePath); CompiledTemplate compiled = TemplateCompiler.compileTemplate(template); Map<String, Object> vars = new HashMap<>(); vars.put("apiUpper", upperFirst(apiName)); vars.put("apiLower", apiName.toLowerCase()); String functionName = function.getName(); vars.put("functionUpper", upperFirst(functionName)); vars.put("functionName", functionName); vars.put("retType", function.getReturnType()); List<String> paramNames = Lists .newArrayList(Iterables.transform(function.getParameters(), new Function<Parameter, String>() { @Override public String apply(Parameter input) { return input.getName(); } })); vars.put("parameters", StringUtils.join(paramNames, ", ")); return StringUtils.trim(TemplateRuntime.execute(compiled, vars).toString()); }
From source file:com.taobao.adfs.database.tdhsocket.client.response.TDHSResutSet.java
public String getString(int columnIndex) throws SQLException { this.checkRow(columnIndex); String str = currentRow.get(columnIndex - 1); this.lastWasNull = (str == null); return StringUtils.trim(str); }
From source file:com.huateng.struts.system.action.LoginAction.java
@Override protected String subExecute() throws Exception { TblOprInfoDAO tblOprInfoDAO = (TblOprInfoDAO) ContextUtil.getBean("OprInfoDAO"); //ID?ID/* ww w . j a v a2 s . c om*/ boolean authUser = false; try { String ids = SysParamUtil.getParam("AUTH_USER"); if (StringUtil.isNull(ids)) { writeErrorMsg("?ID"); return SUCCESS; } else { String[] id = ids.split(","); for (String tmp : id) { if (!StringUtil.isNull(tmp) && tmp.equals(oprid)) { authUser = true; break; } } } } catch (Exception e) { log("??"); e.printStackTrace(); } // if (!authUser) { // log("[" + oprid + "]??ID"); // writeErrorMsg("[" + oprid + "]??ID??"); // return SUCCESS; // } TblOprInfo tblOprInfo = tblOprInfoDAO.get(oprid); //?? if (tblOprInfo == null) { log("???[ " + oprid + " ]"); writeErrorMsg("??"); return SUCCESS; } // ?? if ("1".equals(tblOprInfo.getOprSta().trim())) { log("??[ " + oprid + " ]"); writeErrorMsg("????"); return SUCCESS; } // ??? if (Integer.parseInt(tblOprInfo.getPwdOutDate().trim()) <= Integer .parseInt(CommonFunction.getCurrentDate())) { log("????[ " + oprid + " ]"); writeAlertMsg("???", SysParamUtil.getParam(SysParamConstants.RESET_PWD)); return SUCCESS; } //??? String oprPassword = StringUtils.trim(tblOprInfo.getOprPwd()); password = StringUtils.trim(Encryption.encrypt(password)); if (!oprPassword.equals(password)) { // if(!CommonFunction.getCurrentDate().equals(tblOprInfo.getPwdWrLastDt())) { // tblOprInfo.setPwdWrLastDt(CommonFunction.getCurrentDate()); // tblOprInfo.setPwdWrTm("1"); // } else { // tblOprInfo.setPwdWrTm(String.valueOf(Integer.parseInt(tblOprInfo.getPwdWrTm().trim()) + 1)); // } // tblOprInfo.setPwdWrTmTotal(String.valueOf(Integer.parseInt(tblOprInfo.getPwdWrTmTotal().trim()) + 1)); // // // 53? // if(Integer.parseInt(tblOprInfo.getPwdWrTmTotal().trim()) >= 5 || // (Integer.parseInt(tblOprInfo.getPwdWrTm().trim()) >= 3 && // CommonFunction.getCurrentDate().equals(tblOprInfo.getPwdWrLastDt().trim()))) { // tblOprInfo.setOprSta("1"); // } // tblOprInfoDAO.update(tblOprInfo); log("???[ " + oprid + " ]"); writeErrorMsg("??"); return SUCCESS; } setSessionAttribute("oprId", oprid); writeSuccessMsg("?"); return SUCCESS; }
From source file:ml.shifu.shifu.udf.stats.NumericalVarStats.java
/** * @param databag/*from w w w. j a v a2 s. c om*/ * @param columnConfig * @throws ExecException */ private void statsNumericalColumnInfo(DataBag databag, ColumnConfig columnConfig) throws ExecException { // The last bin is for missingOrInvalid values Integer[] binCountPos = new Integer[columnConfig.getBinBoundary().size() + 1]; Integer[] binCountNeg = new Integer[columnConfig.getBinBoundary().size() + 1]; Double[] binWeightCountPos = new Double[columnConfig.getBinBoundary().size() + 1]; Double[] binWeightCountNeg = new Double[columnConfig.getBinBoundary().size() + 1]; int lastBinIndex = columnConfig.getBinBoundary().size(); initializeZeroArr(binCountPos); initializeZeroArr(binCountNeg); initializeZeroArr(binWeightCountPos); initializeZeroArr(binWeightCountNeg); boolean isMissingValue = false; boolean isInvalidValue = false; Iterator<Tuple> iterator = databag.iterator(); while (iterator.hasNext()) { isMissingValue = false; isInvalidValue = false; Tuple element = iterator.next(); if (element.size() < 4) { continue; } Object value = element.get(1); String tag = CommonUtils.trimTag((String) element.get(2)); Double weight = (Double) element.get(3); double colVal = 0.0; String str = null; if (value == null || StringUtils.isBlank(value.toString())) { // TODO check missing value list in ModelConfig?? missingValueCnt++; isMissingValue = true; } else { str = StringUtils.trim(value.toString()); try { colVal = Double.parseDouble(str); } catch (Exception e) { invalidValueCnt++; isInvalidValue = true; } } if (isInvalidValue || isMissingValue) { if (modelConfig.getPosTags().contains(tag)) { increaseInstCnt(binCountPos, lastBinIndex); increaseInstCnt(binWeightCountPos, lastBinIndex, weight); } else if (modelConfig.getNegTags().contains(tag)) { increaseInstCnt(binCountNeg, lastBinIndex); increaseInstCnt(binWeightCountNeg, lastBinIndex, weight); } } else { streamStatsCalculator.addData(colVal); // binning.addData(colVal); int binNum = BinUtils.getBinNum(columnConfig, str); if (binNum == -1) { throw new RuntimeException("binNum should not be -1 to this step."); } if (modelConfig.getPosTags().contains(tag)) { increaseInstCnt(binCountPos, binNum); increaseInstCnt(binWeightCountPos, binNum, weight); } else if (modelConfig.getNegTags().contains(tag)) { increaseInstCnt(binCountNeg, binNum); increaseInstCnt(binWeightCountNeg, binNum, weight); } } } columnConfig.setBinCountPos(Arrays.asList(binCountPos)); columnConfig.setBinCountNeg(Arrays.asList(binCountNeg)); columnConfig.setBinWeightedPos(Arrays.asList(binWeightCountPos)); columnConfig.setBinWeightedNeg(Arrays.asList(binWeightCountNeg)); columnConfig.setMax(streamStatsCalculator.getMax()); columnConfig.setMean(streamStatsCalculator.getMean()); columnConfig.setMin(streamStatsCalculator.getMin()); columnConfig.setMedian(streamStatsCalculator.getMedian()); columnConfig.setStdDev(streamStatsCalculator.getStdDev()); // Currently, invalid value will be regarded as missing columnConfig.setMissingCnt(missingValueCnt + invalidValueCnt); columnConfig.setTotalCount(databag.size()); columnConfig.setMissingPercentage(((double) columnConfig.getMissingCount()) / columnConfig.getTotalCount()); columnConfig.getColumnStats().setSkewness(streamStatsCalculator.getSkewness()); columnConfig.getColumnStats().setKurtosis(streamStatsCalculator.getKurtosis()); calculateBinPosRateAndAvgScore(); }
From source file:com.zb.app.web.controller.BaseController.java
protected JsonResult doLonginWithCheck(String account, String password, CompanyTypeEnum type) { account = StringUtils.trim(account); password = StringUtils.trim(password); password = EncryptBuilder.getInstance().encrypt(password); if (StringUtils.isEmpty(account) || StringUtils.isEmpty(password)) { return JsonResultUtils.error("!???!"); }//w w w. j a va2s. c o m // Query the database, check the user authentication information TravelMemberDO tm = memberService .getByName(new TravelMemberQuery(StringUtils.lowerCase(account), type.getValue())); if (tm == null) { return JsonResultUtils.error("!?!"); } if (!StringUtils.equals(password, tm.getmPassword())) { return JsonResultUtils.error("!???!"); } if (tm.getmState() == MemberStateEnum.STOP.getValue()) { return JsonResultUtils.error("!?!"); } // ?? TravelCompanyDO tc = companyService.getById(tm.getcId()); if (tc == null) { return JsonResultUtils.error("!?!"); } if (tc.getcType() != type.getValue()) { return JsonResultUtils.error("!?" + type.getDesc() + "!"); } if (tc.getcState() != CompanyStateEnum.NORMAL.getValue()) { return JsonResultUtils.error("!??!"); } // Verified, writing cookie tm.setmType(tc.getcType()); String url = CompanyTypeEnum.getEnum(tc.getcType()).getIndexUrl(); doLoginSuccess(tm); return JsonResultUtils.success(url, "?!"); }
From source file:jp.ikedam.jenkins.plugins.jobcopy_builder.AdditionalFileset.java
/** * Constructor to instantiate from parameters in the job configuration page. * /*w w w .j a v a2s . com*/ * When instantiating from the saved configuration, * the object is directly serialized with XStream, * and no constructor is used. * * @param includeFile a pattern of files to copy. * @param excludeFile a pattern of files not to copy. * @param overwrite whether to overwrite if the file if it is already existing. * @param jobcopyOperationList * the list of operations to be performed when copying. */ @DataBoundConstructor public AdditionalFileset(String includeFile, String excludeFile, boolean overwrite, List<JobcopyOperation> jobcopyOperationList) { this.includeFile = StringUtils.trim(includeFile); this.excludeFile = StringUtils.trim(excludeFile); this.overwrite = overwrite; this.jobcopyOperationList = jobcopyOperationList; }
From source file:com.qccr.livtrip.web.template.BaseDirective.java
/** * ??/*from www .j a v a 2 s . co m*/ * * @param params * ? * @param ignoreProperties * * @return ? */ protected List<Order> getOrders(Map<String, TemplateModel> params, String... ignoreProperties) throws TemplateModelException { String orderBy = StringUtils .trim(FreeMarkerUtils.getParameter(ORDER_BY_PARAMETER_NAME, String.class, params)); List<Order> orders = new ArrayList<Order>(); if (StringUtils.isNotEmpty(orderBy)) { String[] orderByItems = orderBy.split(ORDER_BY_ITEM_SEPARATOR); for (String orderByItem : orderByItems) { if (StringUtils.isNotEmpty(orderByItem)) { String property = null; Order.Direction direction = null; String[] orderBys = orderByItem.split(ORDER_BY_FIELD_SEPARATOR); if (orderBys.length == 1) { property = orderBys[0]; } else if (orderBys.length >= 2) { property = orderBys[0]; try { direction = Order.Direction.valueOf(orderBys[1]); } catch (IllegalArgumentException e) { continue; } } else { continue; } if (!ArrayUtils.contains(ignoreProperties, property)) { orders.add(new Order(property, direction)); } } } } return orders; }
From source file:hydrograph.ui.expression.editor.pages.AddExternalJarPage.java
public boolean createPropertyFileForSavingData() { IProject iProject = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject(); IFolder iFolder = iProject.getFolder(PathConstant.PROJECT_RESOURCES_FOLDER); Properties properties = new Properties(); FileOutputStream file = null; boolean isFileCreated = false; try {/* w ww . j av a 2 s . c o m*/ if (!iFolder.exists()) { iFolder.create(true, true, new NullProgressMonitor()); } for (String items : categoriesDialogTargetComposite.getTargetList().getItems()) { String jarFileName = StringUtils.trim(StringUtils.substringAfter(items, Constants.DASH)); String packageName = StringUtils.trim(StringUtils.substringBefore(items, Constants.DASH)); properties.setProperty(packageName, jarFileName); } file = new FileOutputStream(iFolder.getLocation().toString() + File.separator + PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES); properties.store(file, ""); ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); isFileCreated = true; } catch (IOException | CoreException exception) { LOGGER.error("Exception occurred while saving jar file path at projects setting folder", exception); } finally { if (file != null) try { file.close(); } catch (IOException e) { LOGGER.warn("IOException occurred while closing output-stream of file", e); } } return isFileCreated; }
From source file:com.hangum.tadpole.engine.security.DBPasswordAndOTPDialog.java
@Override protected void okPressed() { String strOTPCode = textOTP.getText(); if ("".equals(strOTPCode)) { MessageDialog.openError(getShell(), CommonMessages.get().Error, Messages.get().OTPEmpty); textOTP.setFocus();/* w w w . j ava 2s. c om*/ return; } try { GetOTPCode.isValidate(SessionManager.getEMAIL(), SessionManager.getOTPSecretKey(), strOTPCode); } catch (Exception e) { logger.error("OTP check", e); MessageDialog.openError(getShell(), CommonMessages.get().Error, e.getMessage()); textOTP.setFocus(); return; } // ? ? . try { userDB.setPasswd(StringUtils.trim(textPassword.getText())); TadpoleSQLManager.getInstance(userDB); } catch (Exception e) { logger.error("Test Passwd+opt Connection error "); String msg = e.getMessage(); if (StringUtils.contains(msg, "No more data to read from socket")) { MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg + CommonMessages.get().Check_DBAccessSystem); } else { MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg); } textPassword.setFocus(); return; } super.okPressed(); }