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:de.willuhn.jameica.hbci.passports.pintan.ChipTANDialog.java
/** * Findet heraus, ob alle Vorbedingungen fuer die Nutzung von ChipTAN USB erfuellt sind. * @throws RemoteException// w w w . ja v a 2 s . co m */ private void checkUSB() throws RemoteException { // Checken, ob wir chipTAN USB ausgewaehlt haben PtSecMech mech = config != null ? config.getCurrentSecMech() : null; if (mech == null || !mech.useUSB()) return; // brauchen wir gar nicht weiter ueberlegen // Checken, ob der User schon entschieden hatte, dass er chipTAN USB NICHT nutzen moechte Boolean use = config != null ? config.isChipTANUSB() : null; if (use != null && !use.booleanValue()) return; // User hat explizit entschieden, chipTAN USB NICHT zu nutzen // Versuchen, die Verbindung zum Kartenleser herzustellen try { Logger.info("searching for smartcards, please wait..."); Application.getMessagingFactory().sendMessage(new StatusBarMessage( i18n.tr("Legen Sie die bitte Chipkarte ein."), StatusBarMessage.TYPE_INFO)); this.service = SmartCardService.createInstance(ChipTanCardService.class, this.config != null ? StringUtils.trimToNull(this.config.getCardReader()) : null); // Wir haben grundsaetzlich einen Kartenleser. if (this.service != null && this.config != null) { Logger.info("found smartcard, to be used: " + (use != null ? use : "<asking user>")); // User hat explizit entschieden, den Kartenleser per USB zu nutzen. if (use != null && use.booleanValue()) { this.usb = this.config.isChipTANUSB(); return; } // User fragen, ob er ihn auch nutzen moechte, wenn wir das noch nicht getan haben // Das Speichern der Antwort koennen wir nicht Jameica selbst ueberlassen, weil // die Entscheidung ja pro PIN/TAN-Config gelten soll und nicht global. this.usb = Application.getCallback().askUser(i18n.tr( "Es wurde ein USB-Kartenleser gefunden.\nMchten Sie diesen zur Erzeugung der TAN verwenden?"), false); this.config.setChipTANUSB(this.usb); } } catch (Throwable t) { Logger.info("no chipcard reader found, chipTAN USB not available: " + t.getMessage()); Logger.write(Level.DEBUG, "stacktrace for debugging purpose", t); } }
From source file:com.novartis.pcs.ontology.rest.servlet.OntologiesServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mediaType = getExpectedMediaType(request); String pathInfo = StringUtils.trimToNull(request.getPathInfo()); boolean includeNonPublicXrefs = Boolean .parseBoolean(StringUtils.trimToNull(request.getParameter("nonpublic-xrefs"))); if (mediaType == null) { response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); response.setContentLength(0);// w ww .j av a 2 s.c o m } else if (pathInfo != null && pathInfo.length() > 1) { String ontologyName = pathInfo.substring(1); if (mediaType.equals(MEDIA_TYPE_JSON)) { serialize(ontologyName, response); } else { export(ontologyName, includeNonPublicXrefs, mediaType, response); } } else { mediaType = getExpectedMediaType(request, Collections.singletonList(MEDIA_TYPE_JSON)); if (mediaType.equals(MEDIA_TYPE_JSON)) { serializeAll(response); } else { response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); response.setContentLength(0); } } }
From source file:mitm.application.djigzo.james.mailets.MailAttributes.java
private void initSetAttributes() { setAttributes = new HashMap<String, String>(); String[] sets = getValues(getConfiguration().getChildren(Parameter.SET.name)); if (sets != null) { for (String set : sets) { set = StringUtils.trimToNull(set); if (set == null) { continue; }/*from ww w . j a v a 2 s .c om*/ String[] nameValue = parseNameValue(set); if (nameValue == null) { throw new IllegalArgumentException(set + " is not a valid name value pair."); } setAttributes.put(nameValue[0], nameValue[1]); } } }
From source file:com.enonic.cms.core.security.userstore.connector.config.UserStoreConnectorConfigLoader.java
private String getProperty(final String key) { final String systemProperty = StringUtils.trimToNull(System.getProperty(key)); if (systemProperty != null) { return systemProperty; }/*from w ww .j a va2 s .c o m*/ return StringUtils.trimToNull(properties.getProperty(key)); }
From source file:com.siberhus.tdfl.transform.DefaultFieldSet.java
protected String readAndTrim(int index) { if (index == -1) return null; if (index < values.length) return StringUtils.trimToNull(values[index]); else// www. ja v a 2 s.c o m return null; }
From source file:com.hmsinc.epicenter.classifier.util.ClassifierUtils.java
public static CharSequence filter(final CharSequence complaint, final Set<String> stopwords) { String ret = ""; if (complaint != null) { // Lowercase, alphabetic only, remove extra spaces.. final String cleaned = StringUtils.trimToNull(complaint.toString().toLowerCase(Locale.getDefault()) .replaceAll("h/a", "headache").replaceAll("n/v", "nausea vomiting").replaceAll("[/,]", " ") .replaceAll("[^a-z\\s]", " ")); if (cleaned != null) { final StringBuilder buf = new StringBuilder(); final String[] sp = cleaned.split("\\s"); for (int i = 0; i < sp.length; i++) { if (sp[i] != null && sp[i].length() > 1 && !stopwords.contains(sp[i])) { if (buf.length() > 0) { buf.append(" "); }// w w w . j a v a 2s . c o m buf.append(sp[i]); } } if (buf.length() > 0) { ret = buf.toString(); } } } return ret; }
From source file:com.bluexml.xforms.actions.SubmitAction.java
/** * Submit node./*from w ww .j a v a2s. c o m*/ * * @return the string * * @throws ServletException * the alfresco controller exception * @throws ServletException */ private String submitNode() throws ServletException { currentPage = navigationPath.peekCurrentPage(); FormTypeEnum type = currentPage.getFormType(); String formName = currentPage.getFormName(); initParams = currentPage.getInitParams(); String result = null; String propStr = StringUtils.trimToNull(initParams.get(MsgId.PARAM_SEARCH_USE_SHORT_NAMES.getText())); boolean shortNames = StringUtils.equals(propStr, "true"); // persist instance if (type == FormTypeEnum.CLASS) { PersistFormResultBean resultBean = controller.persistClass(transaction, node, false, initParams); result = resultBean.getResultStr(); } else if (type == FormTypeEnum.SEARCH) { result = controller.persistSearch(formName, node, shortNames, initParams); setSearching(true); } else if (type == FormTypeEnum.FORM) { PersistFormResultBean resultBean; boolean isMassTagging = currentPage.isMassTagging(); // #1421 resultBean = controller.persistForm(transaction, formName, node, initParams, isMassTagging); result = resultBean.getResultStr(); } else { String datatype = controller.getUnderlyingDataFormForWorkflow(formName); String searchStr = StringUtils.trimToNull(initParams.get(MsgId.PARAM_SEARCH_MODE.getText())); setSearching(StringUtils.equals(searchStr, "true")); if (isSearching()) { result = controller.persistFormJSON(transaction, datatype, node, shortNames, initParams); } else { PersistFormResultBean resultBean = controller.persistForm(transaction, datatype, node, initParams, false); result = resultBean.getResultStr(); } } return result; }
From source file:ips1ap101.lib.core.util.JS.java
public static String getOpenWindowJavaScript(String url, String rpl, String window, String session) { if (url == null) { return null; }/*from w w w. j av a 2 s . c om*/ if (StringUtils.isNotBlank(rpl)) { AbstractPageBean paginaActual = ThreadContext.getPaginaActual(); if (paginaActual instanceof PaginaBasica) { String opcionCampoRetorno = null; String dominioRetorno = null; String[] tokens = StringUtils.split(rpl, "?&"); for (String token : tokens) { if (token != null) { if (token.startsWith(CPP.ID_OPCION_CAMPO_RETORNO + "=")) { opcionCampoRetorno = StringUtils.substringAfter(token, "="); } if (token.startsWith(CPP.ID_DOMINIO_RETORNO + "=")) { dominioRetorno = StringUtils.substringAfter(token, "="); } } } if (opcionCampoRetorno != null) { PaginaBasica paginaBasica = (PaginaBasica) paginaActual; paginaBasica.getContextoSesion().setValorRetorno(opcionCampoRetorno, dominioRetorno, null); } } } String ventana = StringUtils.isBlank(window) ? Global.DEFAULT_WINDOW_NAME : window; VelocityContext context = new VelocityContext(); context.put("url", StringUtils.trimToNull(url)); context.put("rpl", StringUtils.trimToNull(rpl)); context.put("window", StringUtils.trimToNull(ventana)); context.put("sesion", StringUtils.trimToNull(session)); return merge("js-open-window", context); }
From source file:ch.entwine.weblounge.common.impl.security.WebloungeUserImpl.java
/** * Returns the name of this user. If possible, the value returned consists of * type <first name><last name>. * /* w w w . j ava2s . com*/ * @returns the full user name */ public String getName() { if (name != null) return name; if (cachedName != null) return cachedName; String first = getFirstName(); String last = getLastName(); if (StringUtils.trimToNull(first) == null && StringUtils.trimToNull(last) == null) return null; // Create the name StringBuffer name = new StringBuffer(); if (StringUtils.trimToNull(first) != null) { name.append(first); } if (StringUtils.trimToNull(last) != null) { if (name.length() > 0) name.append(" "); name.append(last); } // Cache for further reference cachedName = name.toString(); return cachedName; }
From source file:com.bluexml.xforms.generator.forms.renderable.forms.field.RenderableSimpleInputMultipleActions.java
/** * Adds the button for removing the currently selected item from the list of values. * /*from w w w . ja v a 2 s .com*/ * @param rootPath * @return */ private Element getTriggerRemove(String rootPath) { Element trigger = XFormsGenerator.createTriggerWithLabelImage(XFormsGenerator.IMG_REMOVE, "Remove item"); Element action = XFormsGenerator.createElement("action", XFormsGenerator.NAMESPACE_XFORMS); String repeaterId = parent.getRepeaterId(); ModelElementBindSimple inputBind = parent.getInputBind(); ModelElementBindSimple storeBind = parent.getStoreBind(); String inputNodeset = inputBind.getNodeset(); String storeNodeset = storeBind.getNodeset(); if ((StringUtils.trimToNull(rootPath) == null) && (rootPath.startsWith("instance('minstance')/") == false)) { storeNodeset = "instance('minstance')/" + storeNodeset; } action.setAttribute("event", "DOMActivate", XFormsGenerator.NAMESPACE_EVENTS); String iftest = "(" + storeNodeset + "[1]/value ne '')"; action.setAttribute("if", iftest); // copy the currently selected value back to the input field Element copy = XFormsGenerator.createElement("setvalue", XFormsGenerator.NAMESPACE_XFORMS); copy.setAttribute("ref", inputNodeset); String valueStr = storeNodeset + "[index('" + repeaterId + "')]/value"; copy.setAttribute("value", valueStr); action.addContent(copy); // delete the value from the list of values Element delete = XFormsGenerator.createElement("delete", XFormsGenerator.NAMESPACE_XFORMS); delete.setAttribute("at", "index('" + repeaterId + "')"); action.addContent(delete); trigger.addContent(action); storeBind.addLinkedElement(delete); return trigger; }