List of usage examples for org.apache.commons.lang StringUtils trimToNull
public static String trimToNull(String str)
Removes control characters (char <= 32) from both ends of this String returning null
if the String is empty ("") after the trim or if it is null
.
From source file:com.hmsinc.epicenter.integrator.service.event.AbstractHL7EventHandler.java
/** * @param complaint/* ww w . j av a 2 s .com*/ * @return */ protected static boolean isValidComplaint(final String complaint) { boolean ret = false; if (complaint != null && StringUtils.trimToNull(complaint.replaceAll("[^a-zA-Z\\s]", "")) != null) { ret = true; } return ret; }
From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSTaskTemplate.java
@DataBoundSetter public void setJvmArgs(String jvmArgs) { this.jvmArgs = StringUtils.trimToNull(jvmArgs); }
From source file:com.egt.core.util.JS.java
private static String merge(String name, VelocityContext context) { String script = null;//from w w w . jav a2 s.c o m if (VelocityEngineer.init()) { try { Template template = Velocity.getTemplate(name + "." + "vm"); if (context == null) { context = new VelocityContext(); } StringWriter writer = new StringWriter(); template.merge(context, writer); script = StringUtils.trimToNull(writer.toString()); } catch (Exception ex) { // ex.printStackTrace(); } } return script; }
From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSTaskTemplate.java
@DataBoundSetter public void setLogDriver(String logDriver) { this.logDriver = StringUtils.trimToNull(logDriver); }
From source file:mitm.common.security.smime.SMIMESigningAlgorithm.java
public static SMIMESigningAlgorithm fromName(String name) { name = StringUtils.trimToNull(name); if (name != null) { for (SMIMESigningAlgorithm algorithm : SMIMESigningAlgorithm.values()) { if (algorithm.getName().equalsIgnoreCase(name)) { return algorithm; }//w w w . j a va2 s . c o m } } return null; }
From source file:hudson.plugins.simpleupdatesite.SimpleUpdateSitePlugIn.java
@Override public void configure(StaplerRequest req, JSONObject json) throws IOException, ServletException, FormException { super.configure(req, json); String newsRssUrl = req.getParameter("simpleupdatesite.newsRssUrl"); newsRssUrl = StringUtils.trim(newsRssUrl); if (!StringUtils.equals(newsRssUrl, getNewsRssUrl())) { diagnoseNewsRssSiteUrl(newsRssUrl); setNewsRssUrl(newsRssUrl);//ww w . j av a 2 s .co m this.rssEntryReference.invalidate(); } String updateSiteUrl = req.getParameter("simpleupdatesite.updateSiteUrl"); updateSiteUrl = StringUtils.trim(updateSiteUrl); if (!StringUtils.equals(updateSiteUrl, getUpdateSiteUrl())) { diagnoseUpdateSiteUrl(updateSiteUrl); setUpdateSiteUrl(updateSiteUrl); downloadUpdateSiteJSON(); this.pluginEntryReference.invalidate(); } supportUrl = StringUtils.trimToNull(req.getParameter("simpleupdatesite.supportUrl")); save(); }
From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSTaskTemplate.java
@DataBoundSetter public void setDnsSearchDomains(String dnsSearchDomains) { this.dnsSearchDomains = StringUtils.trimToNull(dnsSearchDomains); }
From source file:fsl.ta.toms.roms.dao.impl.RoadCompliancyDAOImpl.java
@SuppressWarnings("unchecked") @Override/*from ww w.j a v a2 s.c om*/ public List<PersonDO> findPersonByCriteria(PersonCriteriaBO criteria) { StringBuffer queryString = new StringBuffer(); queryString.append(" from PersonDO p where 1=1 "); //Person ID if (StringUtils.trimToNull(criteria.getPersonId()) != null) { queryString.append(" and upper(p.personId) = '").append(criteria.getPersonId().toUpperCase()) .append("'"); } //TRN if (StringUtils.trimToNull(criteria.getTrnNbr()) != null) { queryString.append(" and upper(p.trnNbr) = '").append(criteria.getTrnNbr().toUpperCase()).append("'"); } //First Name if (StringUtils.trimToNull(criteria.getFirstName()) != null) { queryString.append(" and upper(p.firstName) like '%").append(criteria.getFirstName().toUpperCase()) .append("%'"); } //Last Name if (StringUtils.trimToNull(criteria.getLastName()) != null) { queryString.append(" and upper(p.lastName) like '%").append(criteria.getLastName().toUpperCase()) .append("%'"); } //Middle Name if (StringUtils.trimToNull(criteria.getMiddleName()) != null) { queryString.append(" and upper(p.middleName) like '%").append(criteria.getMiddleName().toUpperCase()) .append("%'"); } return hibernateTemplate.find(queryString.toString()); }
From source file:net.sf.eclipsecs.ui.config.configtypes.RemoteConfigurationEditor.java
/** * {@inheritDoc}//from w w w.j a va 2 s . c om */ public CheckConfigurationWorkingCopy getEditedWorkingCopy() throws CheckstylePluginException { // set the cachefile name if (mChkCacheConfig.getSelection() && mWorkingCopy.getAdditionalData().get(RemoteConfigurationType.KEY_CACHE_FILE_LOCATION) == null) { long currentTime = System.currentTimeMillis(); mWorkingCopy.getAdditionalData().put(RemoteConfigurationType.KEY_CACHE_FILE_LOCATION, mWorkingCopy.getName() + "_" + currentTime + "_cache.xml"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$ mWorkingCopy.getAdditionalData().put(RemoteConfigurationType.KEY_CACHE_PROPS_FILE_LOCATION, mWorkingCopy.getName() + "_" + currentTime + "_cache.properties"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$ } // store credentials if necessary try { if (StringUtils.trimToNull(mUserName.getText()) != null || StringUtils.trimToNull(mPassword.getText()) != null) { RemoteConfigurationType.RemoteConfigAuthenticator.storeCredentials(new URL(mLocation.getText()), mUserName.getText(), mPassword.getText()); } else { RemoteConfigurationType.RemoteConfigAuthenticator .removeCachedAuthInfo(new URL(mLocation.getText())); } } catch (MalformedURLException e) { CheckstylePluginException.rethrow(e); } mWorkingCopy.setName(mConfigName.getText()); mWorkingCopy.setLocation(mLocation.getText()); mWorkingCopy.setDescription(mDescription.getText()); mWorkingCopy.getAdditionalData().put(RemoteConfigurationType.KEY_CACHE_CONFIG, "" + mChkCacheConfig.getSelection()); //$NON-NLS-1$ return mWorkingCopy; }
From source file:de.willuhn.jameica.hbci.passports.pintan.ChipTANDialog.java
/** * @see de.willuhn.jameica.gui.dialogs.PasswordDialog#paint(org.eclipse.swt.widgets.Composite) */// w ww . ja v a2s. c om protected void paint(final Composite parent) throws Exception { Container container = new SimpleContainer(parent); if (this.usb) { Application.getMessagingFactory().sendMessage(new StatusBarMessage( i18n.tr("Legen Sie die bitte Chipkarte ein."), StatusBarMessage.TYPE_INFO)); this.setShowPassword(true); // Bei ChipTAN USB immer die TAN anzeigen, damit der User vergleichen kann. container.addHeadline(i18n.tr("ChipTAN USB")); container.addText(i18n.tr( "Legen Sie die Chipkarte ein und folgen Sie den Anweisungen des Kartenlesers. Klicken Sie auf \"OK\", wenn die TAN korrekt bertragen wurde."), true); ProgressBar progress = new ProgressBar(container.getComposite(), SWT.INDETERMINATE); final GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; progress.setLayoutData(gd); final AtomicBoolean cancelled = new AtomicBoolean(false); final Thread usbThread = new Thread() { public void run() { try { Logger.info("trying to get TAN using USB cardreader"); String s = StringUtils.trimToNull(service.getTan(code)); if (s != null && !cancelled.get()) { setPassword(s, parent); } else { throw new Exception(i18n.tr("Keine TAN bertragen")); } } catch (Exception e) { if (!cancelled.get()) { Logger.error("unable to get tan from chipcard", e); setErrorText(i18n.tr("Fehler bei TAN-Ermittlung: {0}", e.getMessage())); } } } }; usbThread.start(); parent.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { cancelled.set(true); // Nur fuer den Fall, dass der Thread noch laeuft. try { if (usbThread != null) usbThread.interrupt(); } catch (Throwable th) { Logger.error("unable to interrupt USB thread", th); } } }); } else { container.addHeadline(i18n.tr(this.usb ? "ChipTAN USB" : "Flicker-Grafik")); container.addText(i18n.tr("Klicken Sie \"-\" bzw. \"+\", um die Breite anzupassen."), true); FlickerPart flicker = new FlickerPart(this.code); flicker.paint(parent); } // Hier stehen dann noch die Anweisungen von der Bank drin super.paint(parent); if (!this.usb) { // Wir muessen das Fenster wenigstens gross genug machen, damit der Flickercode reinpasst, falls // der User den recht verbreitert hat int width = settings.getInt("width", -1); if (width > 0) width += 10; // Wenigstens noch 10 Pixel Rand hinzufuegen. // Wir nehmen den groesseren von beiden Werten getShell().setMinimumSize(getShell().computeSize(width > WINDOW_WIDTH ? width : WINDOW_WIDTH, smallDisplay ? 520 : SWT.DEFAULT)); } }