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.siberhus.ngai.core.CrudHelper.java
public final static Number count(EntityManager em, QTO qto) { String queryString = StringUtils.trim(qto.getQueryString()); if (StringUtils.startsWithIgnoreCase(queryString, "select")) { throw new UnsupportedOperationException( "Query string cannot begin with \"select\"." + "It should start with \"from\""); }// www . j av a2 s . c o m return ((Number) CrudHelper.createQueryObject(em, "select count(*) " + queryString, qto.getParameterList()) .getSingleResult()).intValue(); }
From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.PersonDAO.java
public final void createPerson(final PersonPE person) throws DataAccessException { assert person != null : "Given person can not be null."; if (person.getDatabaseInstance() == null) { person.setDatabaseInstance(getDatabaseInstance()); }//from w w w . j a v a 2 s. c o m person.setEmail(StringUtils.trim(person.getEmail())); validatePE(person); final HibernateTemplate template = getHibernateTemplate(); template.save(person); template.flush(); if (operationLog.isInfoEnabled()) { operationLog.info(String.format("ADD: person '%s'.", person)); } }
From source file:com.microfocus.application.automation.tools.model.OctaneServerSettingsModel.java
@DataBoundConstructor public OctaneServerSettingsModel(String uiLocation, String username, Secret password, String impersonatedUser, String sscBaseToken) {/*from www . j a v a 2 s . c o m*/ this.uiLocation = StringUtils.trim(uiLocation); this.username = username; this.password = password; this.impersonatedUser = impersonatedUser; this.sscBaseToken = sscBaseToken; }
From source file:gov.nih.nci.caintegrator.external.caarray.GenericMultiSamplePerFileParser.java
/** * @param dataMap the data mapping//from w ww . ja va 2 s. c om * @throws DataRetrievalException read data exception */ public void loadData(Map<String, Map<String, float[]>> dataMap) throws DataRetrievalException { String[] fields; try { while ((fields = Cai2Util.readDataLine(dataFileReader)) != null) { String probeName = fields[0]; for (String sampleName : sampleToIndexMap.keySet()) { String valueField = StringUtils.trim(fields[sampleToIndexMap.get(sampleName)]); if (NumberUtils.isNumber(valueField)) { setReporterMap(dataMap, sampleName, probeName, NumberUtils.toFloat(valueField)); } } } } catch (IOException e) { throw new DataRetrievalException("Couldn't read supplemental file.", e); } }
From source file:hudson.plugins.copyartifact.DownstreamBuildSelector.java
/** * @param upstreamProjectName//from w ww. ja va2 s . c om * @param upstreamBuildNumber */ @DataBoundConstructor public DownstreamBuildSelector(String upstreamProjectName, String upstreamBuildNumber) { this.upstreamProjectName = StringUtils.trim(upstreamProjectName); this.upstreamBuildNumber = StringUtils.trim(upstreamBuildNumber); }
From source file:mitm.common.util.DomainUtils.java
/** * Checks if the domain is valid for the domain type. If not valid null will be returned * if valid, leading white space will be removed. *///from w w w. j a v a 2 s. c o m public static String validate(String domain, DomainType domainType) { if (domain == null) { return null; } Pattern pattern = null; switch (domainType) { case FULLY_QUALIFIED: pattern = fullyQualifiedPattern; break; case WILD_CARD: pattern = wildcardPattern; break; case FRAGMENT: pattern = fragmentPattern; break; default: throw new IllegalArgumentException("Unknown domainType."); } Matcher matcher = pattern.matcher(domain); String validated = null; if (matcher.matches()) { validated = matcher.group(1); String trimmed = StringUtils.trim(validated); /* * A domain should not start or end with - */ if (StringUtils.startsWith(trimmed, "-") || StringUtils.endsWith(trimmed, "-")) { validated = null; } } return validated; }
From source file:com.qcadoo.localization.api.utils.DateUtils.java
/** * Parse string into date, with autocomplete missing month, day, hour, minute and second. * //from w ww. j a v a 2 s . c o m * Examples with up-complete: * * <ul> * <li>2010: 2010-12-31 23:59:59</li> * <li>2010-03: 2010-03-31 23:59:59</li> * <li>2010-03-06: 2010-03-06 23:59:59</li> * <li>2010-03-06 19: 2010-03-06 19:59:59</li> * <li>2010-03-06 19:30: 2010-03-06 19:30:59</li> * <li>2010-03-06 19:30:20: 2010-03-06 19:30:20</li> * </ul> * * Examples with down-complete: * * <ul> * <li>2010: 2010-01-01 00:00:00</li> * <li>2010-03: 2010-03-01 00:00:00</li> * <li>2010-03-06: 2010-03-06 00:00:00</li> * <li>2010-03-06 19: 2010-03-06 19:00:00</li> * <li>2010-03-06 19:30: 2010-03-06 19:30:00</li> * <li>2010-03-06 19:30:20: 2010-03-06 19:30:20</li> * </ul> * * @param dateExpression * string with date expression * @param upComplete * true if up-complete, otherwise down-complete * @return parsed date * @throws ParseException * if year, month, day, hour, minute or second is invalid or when year is < 1500 or > 2500 */ public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang.time.DateUtils .parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); }
From source file:com.intuit.tank.common.ScriptUtil.java
public static List<ScriptAssignment> getAssignments(ScriptStep step) { List<ScriptAssignment> ret = new ArrayList<ScriptAssignment>(); if (step.getType().equals("request")) { for (RequestData rd : step.getResponseData()) { if (StringUtils.isNotBlank(rd.getKey())) { if (StringUtils.containsIgnoreCase(rd.getType(), "assignment")) { ret.add(new ScriptAssignment(rd.getKey().trim(), StringUtils.removeStart(StringUtils.trim(rd.getValue()), "="), step.getStepIndex())); }// ww w .j av a 2s .c om } } } return ret; }
From source file:com.junly.service.helper.TicketHelper.java
/** <p class="detail"> * ???ticket//from w w w. j a v a2 s . c om * </p> * @author junly * @date 2017324 * @param request * @param httpChannelType * @return */ public String getTicket(HttpServletRequest request, HttpChannelType httpChannelType) { Cookie cookies[] = request.getCookies(); String ticket = null; if (null != cookies) { for (Cookie cookie : cookies) { if (StringUtils.equals(ViewContants.LOGIN_TICKET_KEY, cookie.getName())) { ticket = StringUtils.trim(cookie.getValue()); StringBuilder builder = new StringBuilder(httpChannelType.name()); builder.append("?cookieticket=").append(ticket); builder.append("?=").append(request.getServerName()).append("===="); builder.append(cookie.getDomain()); logger.info(builder.toString()); break; } } } // java??cookieheader???, // ???cookie? ?? if (StringUtils.isBlank(ticket)) { ticket = customHeadTicket(request, httpChannelType); } if (StringUtils.isBlank(ticket)) { ticket = StringUtils.trim(request.getParameter(ViewContants.LOGIN_TICKET_KEY)); } return ticket; }
From source file:com.nridge.connector.common.con_com.transform.TContentClean.java
private String cleanControl(String aValue) { String cleanValue;/*from ww w . ja v a 2 s . c om*/ if (StringUtils.isNotEmpty(aValue)) { String[] nlReplace = new String[] { " ", " ", " " }; String[] nlPattern = new String[] { "\r", "\n", "\t" }; String replaceValue = StringUtils.replaceEach(aValue, nlPattern, nlReplace); replaceValue = StringUtils.trim(replaceValue); cleanValue = replaceValue.replaceAll("\\p{Cntrl}", ""); StringBuilder asciiValue = new StringBuilder(cleanValue.length()); int strLength = cleanValue.length(); for (int i = 0; i < strLength; i++) { if (isASCII(cleanValue.charAt(i))) asciiValue.append(cleanValue.charAt(i)); } cleanValue = asciiValue.toString(); } else cleanValue = StringUtils.EMPTY; return cleanValue; }