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:ips1ap101.web.fragments.FragmentoFiltro1.java
public void setValorTextoFiltro2(String valor) { getRecursoDataProvider().setNombreFuncionSelect(StringUtils.trimToNull(valor)); }
From source file:ips1ap101.lib.core.web.app.GestorPaginaActualizacion.java
protected boolean isConsultaValida() { if (designing) { return true; }// w w w . ja v a2 s . c o m track("isConsultaValida"); boolean ok = !isRestauracion() && getPaginaActualizacion().getRecursoDataProvider().isFuncionSelectAutorizada(); if (ok) { long f1 = getPaginaActualizacion().getRecursoDataProvider().getFuncionSelect(); long f2 = getPaginaActualizacion().getFuncionConsultarRecurso(); trace("funcion-actual=" + f1 + ", funcion-anterior=" + f2); ok = f1 == f2; } if (ok) { long v1 = getPaginaActualizacion().getRecursoDataProvider().getVersionComandoSelect(); long v2 = getPaginaActualizacion().getContextoSesion().getVersionComandoSelectPagina(); trace("version-actual=" + v1 + ", version-anterior=" + v2); ok = v1 == v2; } if (ok && isReinicio()) { String c1 = StringUtils .trimToNull(getPaginaActualizacion().getRecursoDataProvider().getConsultaBusqueda()); String c2 = StringUtils .trimToNull(getPaginaActualizacion().getContextoPeticion().getConsultaBusqueda()); trace("consulta-actual=" + c1 + ", consulta-anterior=" + c2); ok = c1 == null ? c2 == null : c1.equals(c2); } if (ok && isReinicio()) { String c1 = StringUtils .trimToNull(getPaginaActualizacion().getRecursoDataProvider().getCriteriosBusqueda()); String c2 = StringUtils .trimToNull(getPaginaActualizacion().getContextoPeticion().getCriteriosBusqueda()); trace("criterio-actual=" + c1 + ", criterio-anterior=" + c2); ok = c1 == null ? c2 == null : c1.equals(c2); } if (ok) { // String c1 = getColumnaIdentificacionRecursoMaestro(); String c1 = getPaginaActualizacion().getRecursoDataProvider().getColumnaMaestro(); String c2 = getPaginaActualizacion().getContextoSesion().getColumnaIdentificacionRecursoMaestroPagina(); trace("maestro-actual=" + c1 + ", maestro-anterior=" + c2); ok = c1 == null ? c2 == null : c1.equals(c2); } if (ok) { // Long i1 = getIdentificacionRecursoMaestro(); Long i1 = getPaginaActualizacion().getRecursoDataProvider().getIdentificacionMaestro(); Long i2 = getPaginaActualizacion().getContextoSesion().getIdentificacionRecursoMaestroPagina(); trace("maestro-actual=" + i1 + ", maestro-anterior=" + i2); ok = i1 == null ? i2 == null : i1.equals(i2); } return ok; }
From source file:ips1ap101.web.fragments.FragmentoFiltro1.java
public String getUrlImagenTextoFiltro2() { String nx = getRecursoDataProvider().getNombreFuncionSelect(); nx = StringUtils.trimToNull(nx); return getRecursoDataProvider().isNombreFuncionSelectModificado() ? URL_IMAGEN_WARNING : nx == null ? URL_IMAGEN_OK_DIMMED : URL_IMAGEN_OK; }
From source file:mitm.common.postfix.PostfixLogParser.java
public int getRawLogCount(Reader log) throws IOException { LineNumberReader lineReader = new LineNumberReader(log); int count = 0; String line;//ww w. j av a 2 s. c o m while ((line = lineReader.readLine()) != null) { line = StringUtils.trimToNull(line); if (line == null) { continue; } if (searchPattern != null) { Matcher matcher = searchPattern.matcher(line); if (matcher.find()) { count++; } } else { count++; } } return count; }
From source file:com.bluexml.side.form.utils.DOMUtil.java
/** * Gets the node value by tag name./*from w ww . j av a 2s . c o m*/ * * @param node * the node * @param name * the name * @param recursive * the recursive * * @return the node value by tag name */ public static String getNodeValueByTagName(Node node, String name, boolean recursive) { if (node instanceof Document) { return getNodeValueByTagName(((Document) node).getDocumentElement(), name, recursive); } if (node instanceof Element) { Element element = (Element) node; if (StringUtils.equals(element.getTagName(), name)) { return StringUtils.trimToNull(element.getTextContent()); } } NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item instanceof Element) { Element element = (Element) item; if (StringUtils.equals(element.getTagName(), name)) { return StringUtils.trimToNull(element.getTextContent()); } if (recursive) { String nodeValueByTagName = getNodeValueByTagName(item, name, true); if (nodeValueByTagName != null) { return nodeValueByTagName; } } } } return null; }
From source file:de.willuhn.jameica.hbci.passports.pintan.ChipTANDialog.java
/** * Uebernimmt das Passwort./*from www . jav a 2 s .c om*/ * @param password das Passwort. * @param controls die Controls. * @return true, wenn es uebernommen wurde. */ private boolean applyPassword(String password, Control[] controls) { if (controls == null || controls.length == 0) return false; for (Control c : controls) { if (c instanceof Text) { Text t = (Text) c; if (!t.isDisposed()) { // Das kann nur das Passwort-Feld sein. String value = StringUtils.trimToNull(t.getText()); if (value == null) { t.setText(password); return true; } } } // Rekursion if (c instanceof Composite) { Composite comp = (Composite) c; boolean b = applyPassword(password, comp.getChildren()); if (b) return true; // gefunden } } return false; }
From source file:de.willuhn.jameica.hbci.passports.pintan.server.PassportHandleImpl.java
/** * @see de.willuhn.jameica.hbci.passport.PassportHandle#callback(org.kapott.hbci.passport.HBCIPassport, int, java.lang.String, int, java.lang.StringBuffer) *//* www .ja v a 2 s . c om*/ public boolean callback(HBCIPassport passport, int reason, String msg, int datatype, StringBuffer retData) throws Exception { switch (reason) { case HBCICallback.NEED_PT_PIN: { retData.replace(0, retData.length(), DialogFactory.getPIN(passport)); return true; } case HBCICallback.NEED_PT_PHOTOTAN: { Logger.debug("got phototan code, using phototan dialog"); TANDialog dialog = new PhotoTANDialog(config, retData.toString()); dialog.setContext(this.getContext(passport)); dialog.setText(msg); retData.replace(0, retData.length(), (String) dialog.open()); return true; } case HBCICallback.NEED_PT_TAN: { TANDialog dialog = null; String flicker = retData.toString(); if (flicker != null && flicker.length() > 0) { Logger.debug("got flicker code " + flicker); // Wir haben einen Flicker-Code. Also zeigen wir den Flicker-Dialog statt // dem normalen TAN-Dialog an Logger.info("using chiptan OPTIC/USB"); dialog = new ChipTANDialog(config, flicker); } // regulaerer TAN-Dialog if (dialog == null) { Logger.info("using chiptan MANUAL"); Logger.debug("using regular tan dialog"); dialog = new TANDialog(config); } dialog.setContext(this.getContext(passport)); dialog.setText(msg); retData.replace(0, retData.length(), (String) dialog.open()); return true; } // BUGZILLA 200 case HBCICallback.NEED_PT_SECMECH: { if (config != null) { PtSecMech mech = config.getStoredSecMech(); String type = mech != null ? StringUtils.trimToNull(mech.getId()) : null; if (type != null) { // Wir checken vorher noch, ob es das TAN-Verfahren ueberhaupt noch gibt PtSecMech m = PtSecMech.contains(retData.toString(), type); if (m != null) { // Jepp, gibts noch retData.replace(0, retData.length(), type); return true; } } } PtSecMechDialog ptd = new PtSecMechDialog(config, retData.toString()); retData.replace(0, retData.length(), (String) ptd.open()); return true; } // BUGZILLA 827 case HBCICallback.NEED_PT_TANMEDIA: { // Wenn wir eine Medienbezeichnung von HBCI4Java gekriegt haben und das genau // eine einzige ist. Dann uebernehmen wir diese ohne Rueckfrage. Der User // hat hier sonst eh keine andere Wahl. String media = retData.toString(); if (media.length() > 0 && !media.contains("|")) { Logger.info("having exactly one TAN media name (provided by institute) - automatically using this: " + media); retData.replace(0, retData.length(), media); return true; } // Falls wir eine PIN/TAN-Config haben, in der die Medienbezeichnung // hinterlegt ist, dann nehmen wir die. if (config != null) { media = config.getTanMedia(); if (media != null && media.length() > 0) { Logger.info("having a stored TAN media name (provided by user) - automatically using this: " + media); retData.replace(0, retData.length(), media); return true; } } Logger.info("asking user for TAN media (options provided by institute: " + media + ")"); TanMediaDialog tmd = new TanMediaDialog(config, retData.toString()); retData.replace(0, retData.length(), (String) tmd.open()); return true; } } return false; }
From source file:com.egt.core.aplicacion.Bitacora.java
public static String getTextoMensaje(String clave, Object arg0, Object arg1, Object arg2, Object arg3) { String texto = StringUtils.trimToNull(clave); if (texto != null) { String patron = getPatron(clave, arg0, arg1, arg2, arg3); if (patron != null) { texto = Utils.getMessageFormat(patron, getArgumentos(arg0, arg1, arg2, arg3)); }//from w ww . j a va2 s .com } return texto; }
From source file:com.opengamma.integration.coppclark.CoppClarkExchangeFileReader.java
private ManageableExchangeDetail readDetailLine(String[] rawFields, int[] indices) { ManageableExchangeDetail detail = new ManageableExchangeDetail(); detail.setProductGroup(optionalStringField(rawFields[indices[INDEX_PRODUCT_GROUP]])); detail.setProductName(requiredStringField(rawFields[indices[INDEX_PRODUCT_NAME]])); detail.setProductType(optionalStringField(rawFields[indices[INDEX_PRODUCT_TYPE]])); // should be required, but isn't there on one entry. detail.setProductCode(optionalStringField(rawFields[indices[INDEX_PRODUCT_CODE]])); detail.setCalendarStart(parseDate(rawFields[indices[INDEX_CALENDAR_START]])); detail.setCalendarEnd(parseDate(rawFields[indices[INDEX_CALENDAR_END]])); detail.setDayStart(requiredStringField(rawFields[indices[INDEX_DAY_START]])); detail.setDayRangeType(StringUtils.trimToNull(rawFields[indices[INDEX_DAY_RANGE_TYPE]])); detail.setDayEnd(StringUtils.trimToNull(rawFields[indices[INDEX_DAY_END]])); detail.setPhaseName(optionalStringField(rawFields[indices[INDEX_PHASE_NAME]])); // nearly required, but a couple aren't detail.setPhaseType(optionalStringField(rawFields[indices[INDEX_PHASE_TYPE]])); detail.setPhaseStart(parseTime(rawFields[indices[INDEX_PHASE_START]])); detail.setPhaseEnd(parseTime(rawFields[indices[INDEX_PHASE_END]])); detail.setRandomStartMin(parseTime(rawFields[indices[INDEX_RANDOM_START_MIN]])); detail.setRandomStartMax(parseTime(rawFields[indices[INDEX_RANDOM_START_MAX]])); detail.setRandomEndMin(parseTime(rawFields[indices[INDEX_RANDOM_END_MIN]])); detail.setRandomEndMax(parseTime(rawFields[indices[INDEX_RANDOM_END_MAX]])); detail.setLastConfirmed(parseDate(rawFields[indices[INDEX_LAST_CONFIRMED]])); detail.setNotes(optionalStringField(rawFields[indices[INDEX_NOTES]])); return detail; }
From source file:com.bluexml.side.portal.alfresco.reverse.reverser.EclipseReverser.java
public Component getComponent(Region region, Components fromInstance, Components fromPage) throws Exception { Component com = null;//from w ww . j a v a 2 s .c o m // maybe in page components or template-instances components or finally in SIDE-DATA/component directory com = searchComponent(region, fromInstance); if (com == null) { com = searchComponent(region, fromPage); } if (com == null) { String regionId = region.getRegionId(); String scope = region.getScope(); String fileName = ""; if (scope.equals("global")) { fileName = scope + "." + regionId + ".xml"; } else { fileName = scope + "." + this.pageName + "." + regionId + ".xml"; } // need to search in site-data/components File componentFile = null; File[] listFiles = components.listFiles(); for (File file : listFiles) { if (file.getName().equals(fileName)) { componentFile = file; } } if (componentFile != null && componentFile.exists()) { // read component configuration Unmarshaller createUnmarshaller = jaxbContext.createUnmarshaller(); com = (Component) createUnmarshaller.unmarshal(componentFile); } } // fill scope if not provided if (com != null && StringUtils.trimToNull(com.getScope()) == null) { com.setScope(region.getScope()); } return com; }