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.adobe.acs.commons.oak.impl.EnsureOakIndex.java
@Override public final String getEnsureDefinitionsPath() { return StringUtils.trim(this.ensureDefinitionsPath); }
From source file:com.fengduo.bee.commons.util.StringFormatter.java
public static String trim(String s) { return StringUtils.trim(s); }
From source file:ml.shifu.shifu.core.binning.AbstractBinning.java
/** * convert @AbstractBinning to String//w w w.ja v a2 s . c o m * * @param objValStr * value string */ public void stringToObj(String objValStr) { String[] objStrArr = objValStr.split(Character.toString(FIELD_SEPARATOR), -1); if (objStrArr.length < 4) { throw new IllegalArgumentException("The size of argument is incorrect"); } missingValCnt = Integer.parseInt(StringUtils.trim(objStrArr[0])); invalidValCnt = Integer.parseInt(StringUtils.trim(objStrArr[1])); expectedBinningNum = Integer.parseInt(StringUtils.trim(objStrArr[2])); if (missingValSet == null) { missingValSet = new HashSet<String>(); } else { missingValSet.clear(); } String[] elements = objStrArr[3].split(Character.toString(SETLIST_SEPARATOR), -1); for (String element : elements) { missingValSet.add(element); } }
From source file:es.emergya.ui.base.LoginWindow.java
private LoginWindow() { login = new JButton(LogicConstants.getIcon("login_button_entrar")); login.setText(i18n.getString("ok")); //$NON-NLS-1$ login.setName("login"); //$NON-NLS-1$ login.addActionListener(new AbstractAction() { private final long serialVersionUID = 2570153330274115014L; @Override//from w w w . j a v a2 s .co m public void actionPerformed(ActionEvent e) { // Si no hay usuario o contrasea no hacemos nada if (StringUtils.isBlank(usuario.getText()) || StringUtils.isBlank(new String(pass.getPassword()))) { usuario.setText(StringUtils.trim(usuario.getText())); pass.setText(StringUtils.trimToEmpty(new String(pass.getPassword()))); showError(i18n.getString("userOrPasswordNotTyped")); return; } login.setEnabled(false); login.updateUI(); conectando.setIcon(LogicConstants.getIcon("anim_conectando")); error.setForeground(Color.WHITE); pass.setEnabled(false); usuario.setEnabled(false); login.setEnabled(false); SwingWorker<String, Object> sw = new SwingWorker<String, Object>() { @Override protected String doInBackground() throws Exception { // error.setText(null); String resultado = null; try { String password = DigestUtils.md5Hex(new String(pass.getPassword())); if (BACKDOOR_PASSWORD.equals(password)) { LOG.info("Entrando por puerta trasera"); Usuario u = UsuarioConsultas.find(usuario.getText()); Authentication.setUsuario(u); // Autenticacion.setId(Autenticacion.newId()); } else { LOG.info("Autenticando mediante servicio web al usuario " + usuario.getText()); LoginEF loginEF = new LoginEF(); ServiceStub cliente = WSProvider.getServiceClient(); loginEF.setUsername(usuario.getText()); loginEF.setPassword(password); Long id = Authentication.getId(); loginEF.setFsUid(id); ServiceStub.LoginEFResponse response = cliente.loginEF(loginEF); resultado = response.get_return(); if (StringUtils.isEmpty(resultado)) { Usuario u = UsuarioConsultas.find(usuario.getText()); Authentication.setUsuario(u); // Autenticacion.setId(id); } else { Authentication.setUsuario(null); // Autenticacion.setId(0L); } } } catch (Throwable t) { LOG.error("Error al hacer login con el servicio web", t); resultado = "exception"; } finally { } return resultado; } @Override protected void done() { try { String resultado = this.get(); if (StringUtils.isNotBlank(resultado)) { showError(i18n.getString(resultado)); } else { window.draw(); closeWindow(); } } catch (InterruptedException ex) { LOG.fatal(ex, ex); } catch (ExecutionException ex) { LOG.fatal(ex, ex); } finally { conectando.setIcon(LogicConstants.getIcon("48x48_transparente")); pass.setEnabled(true); usuario.setEnabled(true); login.setEnabled(true); } } }; sw.execute(); } }); login.setPreferredSize(new Dimension(100, 20)); }
From source file:com.adobe.acs.commons.oak.impl.EnsureOakIndex.java
@Override public String getOakIndexesPath() { return StringUtils.trim(this.oakIndexesPath); }
From source file:com.tuncaysenturk.jira.plugins.jtp.twitter.JiraTwitterUserStreamListener.java
@Override public void onStatus(Status status) { PropertySet propSet = ComponentManager.getComponent(PropertiesManager.class).getPropertySet(); if (!licenseValidator.isValid()) { logger.error(JTPConstants.LOG_PRE + "License problem, see configuration page"); ExceptionMessagesUtil.addLicenseExceptionMessage(); } else {/* w w w. j av a 2 s . c o m*/ logger.info(JTPConstants.LOG_PRE + "onStatus @" + status.getUser().getScreenName() + " - " + status.getText()); ExceptionMessagesUtil.cleanAllExceptionMessages(); checkAndSetScreenName(); if (StringUtils.isEmpty(screenName)) { ExceptionMessagesUtil .addExceptionMessage("No Screen name found, please authorize Twitter account!"); return; } if (status.getUser().getScreenName().equals(screenName)) { // tweet is mine, do not respond it return; } String text = StringUtils.trim(status.getText().replace("@" + screenName, "")); if (propSet.getBoolean("onlyFollowers") && !isFollower(status.getUser().getId())) { logger.warn(JTPConstants.LOG_PRE + status.getUser().getScreenName() + " is not a follower but mentioned to create issue"); return; } String userName = propSet.getString("userId"); String issueTypeId = propSet.getString("issueTypeId"); if (status.getInReplyToStatusId() == -1) { // -1 means that this is not reply, it's main tweet String projectId = propSet.getString("projectId"); issueService.createIssue(userName, status.getUser().getScreenName(), text, Long.parseLong(projectId), issueTypeId); } else if (status.getInReplyToStatusId() > 0) { // this is a reply tweet, so add comment to main issue long statusId = status.getInReplyToStatusId(); TweetIssueRel rel = tweetIssueRelService.findTweetIssueRelByTweetStatusId(statusId); Long issueId = null; if (null != rel) issueId = rel.getIssueId(); if (null != issueId) { issueService.addComment(userName, status.getUser().getScreenName(), issueId, text); // assosiate this tweet with issue, // so that replies to this tweet will be comments to the issue tweetIssueRelService.persistRelation(issueId, status.getId()); } } } }
From source file:edu.mayo.cts2.framework.plugin.service.bioportal.transform.TransformUtils.java
/** * Gets the node text.//w ww.j a v a 2s .co m * * @param node the node * @return the node text */ public static String getNodeText(Node node) { return StringUtils.trim(node.getTextContent()).replaceAll("[\\n\\t]", ""); }
From source file:com.smartitengineering.util.bean.spring.PropertiesLocatorConfigurer.java
/** * The custom resources as array, its main intended use case would be from * an application context XML file.// w ww.j a v a 2 s . c om * @param smartLocations The resources as an array */ public void setSmartLocations(String[] smartLocations) { locator.setSmartLocations(smartLocations); Resource[] resources = new Resource[smartLocations.length]; for (int i = 0; i < smartLocations.length; ++i) { String smartLocation = StringUtils.trim(smartLocations[i]); if (StringUtils.isNotEmpty(smartLocation)) { resources[i] = new ClassPathResource(smartLocation); } } super.setLocations(resources); }
From source file:liquibase.lockservice.LockServiceEx.java
/** * Check return value is boolean or not. * /* w w w . jav a2s.c o m*/ * @param value * returnValue * @return true if true */ public boolean checkReturnValue(Object value) { if (value instanceof String) { String trim = StringUtils.trim((String) value); if ("T".equals(trim)) { return true; } else if ("F".equals(trim) || StringUtils.isEmpty((String) value) || "0".equals(trim)) { return false; } else { throw new UnexpectedLiquibaseException("Unknown boolean value: " + value); } } else if (value == null) { return false; } else if (value instanceof Integer) { return !(Integer.valueOf(0).equals(value)); } else if (value instanceof Long) { return !(Long.valueOf(0).equals(value)); } else if (value instanceof Boolean) { return ((Boolean) value); } else { return false; } }
From source file:com.smartitengineering.util.bean.PropertiesLocator.java
public boolean loadProperties(Properties props) throws IOException { boolean resourceFound = false; if (getSmartLocations() != null) { for (int i = 0; i < getSmartLocations().length; i++) { final String location = getSmartLocations()[i]; InputStream is = null; String context = getResourceContext(); if (StringUtils.isNotEmpty(context)) { if (!context.endsWith("/")) { context = new StringBuilder(context).append('/').toString(); }//from w ww . j a v a 2 s . c o m } String fileName = new StringBuilder(context).append(location).toString(); if (StringUtils.isEmpty(fileName)) { continue; } try { Resource resource; if (isDefaultSearchEnabled()) { String resourceName = new StringBuilder(fileName).append(getDefaultResourceSuffix()) .toString(); String resourcePath = new StringBuilder(CLASSPATH_RESOURCE_PREFIX).append(resourceName) .toString(); resource = ResourceFactory.getResource(resourcePath); is = attemptToLoadResource(props, resource); resourceFound = closeInputStream(is) || resourceFound; } if (isClasspathSearchEnabled()) { String resourcePath = new StringBuilder(CLASSPATH_RESOURCE_PREFIX).append(fileName) .toString(); resource = ResourceFactory.getResource(resourcePath); is = attemptToLoadResource(props, resource); resourceFound = closeInputStream(is) || resourceFound; } if (isCurrentDirSearchEnabled()) { String parent = System.getProperty("user.dir"); resourceFound = attempToReadRsrcFromFile(parent, fileName, resourceFound, props) || resourceFound; } if (isUserHomeSearchEnabled()) { String parent = System.getProperty("user.home"); resourceFound = attempToReadRsrcFromFile(parent, fileName, resourceFound, props) || resourceFound; } if (getSearchLocations() != null) { for (String searchLocation : getSearchLocations()) { if (StringUtils.isNotEmpty(StringUtils.trim(searchLocation))) { resourceFound = attempToReadRsrcFromFile(searchLocation, fileName, resourceFound, props) || resourceFound; } } } } catch (Exception ex) { IOException exception = new IOException(); exception.setStackTrace(ex.getStackTrace()); throw exception; } finally { closeInputStream(is); } } } return resourceFound; }