List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:com.egt.ejb.core.exporter.ExporterBrokerBean.java
@Override public ObjectMessage executeExport(String informe, long funcion, String destino, EnumFormatoArchivo tipo, String select, Object[] args) { Bitacora.trace(this.getClass(), "executeExport", informe, String.valueOf(funcion), destino, String.valueOf(tipo)); Bitacora.trace(select);/*from w ww .j av a 2s .c o m*/ Utils.traceObjectArray(args); Long rastro = null; ObjectMessage reply = null; try { informe = StringUtils.trimToEmpty(informe); if (STP.esIdentificadorArchivoValido(informe)) { if (TLC.getControlador().esFuncionAutorizada(funcion)) { TLC.getConnection(ds); rastro = TLC.getControlador().ponerInformePendiente(funcion); ExporterMessage message = new ExporterMessage(informe, funcion); TLC.getControlador().ponerUsuarioEnMensaje(message); message.setRastro(rastro); message.setMensaje(Bitacora.getTextoMensaje(CBM2.EXPORT_EXECUTION_REQUEST, informe)); message.setDestino(destino); message.setTipo(tipo); message.setSelect(select); message.setArgs(args); reply = messenger.send(message); TLC.getBitacora().info(message.getMensaje()); } else { throw new ExcepcionAplicacion(Bitacora.getTextoMensaje(CBM2.FUNCION_NO_AUTORIZADA, informe)); } } else { throw new ExcepcionAplicacion( Bitacora.getTextoMensaje(CBM2.IDENTIFICADOR_ARCHIVO_INVALIDO, informe)); } } catch (Exception ex) { EnumCondicionEjeFun condicion = EnumCondicionEjeFun.EJECUCION_CANCELADA; String mensaje = ThrowableUtils.getString(ex); Auditor.grabarRastroInforme(rastro, condicion, null, mensaje); TLC.getBitacora().error(mensaje); } return reply; }
From source file:com.ning.maven.plugins.dependencyversionscheck.version.Version.java
public Version(final String rawVersion, final String selectedVersion) { if (StringUtils.isBlank(rawVersion) || StringUtils.isBlank(selectedVersion)) { throw new NullPointerException("Version cannot be null"); }//from w w w . ja va 2 s. c o m this.selectedVersion = selectedVersion; this.rawVersion = rawVersion; rawElements = StringUtils.splitPreserveAllTokens(selectedVersion, "-._"); versionElements = new VersionElement[rawElements.length]; // Position of the next splitter to look at. int charPos = 0; // Position to store the result in. int resultPos = 0; for (int i = 0; i < rawElements.length; i++) { final String rawElement = rawElements[i]; long divider = 0L; final char dividerChar; charPos += rawElement.length(); if (charPos < selectedVersion.length()) { dividerChar = selectedVersion.charAt(charPos); charPos++; if (dividerChar == '.') { divider |= DOT_DIVIDER; } else if (dividerChar == '-') { divider |= MINUS_DIVIDER; } else if (dividerChar == '_') { divider |= UNDERSCORE_DIVIDER; } else { divider |= OTHER_DIVIDER; } } else { dividerChar = 0; divider |= END_OF_VERSION; } final String element = StringUtils.trimToEmpty(rawElement); if (!StringUtils.isBlank(element)) { long flags = ALL_NUMBERS | ALL_LETTERS | ALL_OTHER; final char firstChar = element.charAt(0); final char lastChar = element.charAt(element.length() - 1); if (Character.isDigit(firstChar)) { flags |= STARTS_WITH_NUMBERS; } else if (Character.isLetter(firstChar)) { flags |= STARTS_WITH_LETTERS; } else { flags |= STARTS_WITH_OTHER; } if (Character.isDigit(lastChar)) { flags |= ENDS_WITH_NUMBERS; } else if (Character.isLetter(lastChar)) { flags |= ENDS_WITH_LETTERS; } else { flags |= ENDS_WITH_OTHER; } for (int j = 0; j < element.length(); j++) { if (Character.isDigit(element.charAt(j))) { flags &= ~(ALL_LETTERS | ALL_OTHER); flags |= NUMBERS; } else if (Character.isLetter(element.charAt(j))) { flags &= ~(ALL_NUMBERS | ALL_OTHER); flags |= LETTERS; } else { flags &= ~(ALL_LETTERS | ALL_NUMBERS); flags |= OTHER; } } versionElements[resultPos++] = new VersionElement(element, flags, divider, dividerChar); } } this.elementCount = resultPos; }
From source file:eu.uqasar.web.pages.auth.login.LoginPage.java
private void doSubmit(final String login, final String password) { final String cred = StringUtils.trimToEmpty(login); try {// w ww .j a va 2 s. c om User user = authService.authenticate(cred, password); if (user != null) { UQSession.get().setLoggedInUser(user, UQSession.get().getLocale()); // Initialize the dashboard for the user initDashboard(); continueToOriginalDestination(); // if we get here there was no previous request and we can continue // to home page setResponsePage(getApplication().getHomePage()); } } catch (UnknownUserException ex) { error(new StringResourceModel("error.user.unknown", this, null, new Object[] { cred }).getString()); } catch (WrongUserCredentialsException ex) { error(new StringResourceModel("error.user.wrong.credentials", this, null, new Object[] { cred }) .getString()); } catch (RegistrationCancelledException ex) { error(new StringResourceModel("error.user.register.cancelled", this, null, new Object[] { cred }) .getString()); } catch (RegistrationNotYetConfirmedException ex) { error(new StringResourceModel("error.user.register.notconfirmed", this, null, new Object[] { cred }) .getString()); } }
From source file:com.edgenius.wiki.render.impl.LinkRenderHelperImpl.java
public ObjectPosition appendLink(StringBuffer buffer, String link, String view) { link = StringUtils.trimToEmpty(link); view = StringUtils.trimToEmpty(view); ObjectPosition pos = new ObjectPosition("[" + view + "]"); pos.serverHandler = LinkHandler.HANDLER; pos.uuid = context.createUniqueKey(false); pos.values.put(NameConstants.TYPE, String.valueOf(LinkModel.LINK_TO_VIEW_FLAG)); pos.values.put(NameConstants.NAME, link); pos.values.put(NameConstants.VIEW, view); pos.values.put(NameConstants.SPACE, spaceUname); context.getObjectList().add(pos);// w w w . j a v a 2 s . c o m buffer.append(pos.uuid); return pos; }
From source file:ml.shifu.shifu.core.binning.AbstractBinning.java
/** * Constructor with expected bin number and expected missing values * /*from www . ja va 2s. com*/ * @param binningNum * the binningNum * @param missingValList * the missing value list * @param maxCategorySize * max size of category list */ public AbstractBinning(int binningNum, List<String> missingValList, int maxCategorySize) { this.expectedBinningNum = binningNum; this.missingValSet = new HashSet<String>(); this.missingValSet.add(""); if (CollectionUtils.isNotEmpty(missingValList)) { for (String missingVal : missingValList) { missingValSet.add(StringUtils.trimToEmpty(missingVal)); } } this.maxCategorySize = maxCategorySize; }
From source file:hello.service.GreetingServiceImpl.java
/** * Creates a new instance./* w ww.j a v a2 s . c om*/ * * @param myNodeId */ public GreetingServiceImpl(final String myNodeId) { this.myNodeId = StringUtils.trimToEmpty(myNodeId); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.CubridLoginComposite.java
@Override public boolean makeUserDBDao(boolean isTest) { if (!isValidateInput(isTest)) return false; String dbUrl = ""; String selectLocale = StringUtils.trimToEmpty(comboLocale.getText()); if (selectLocale.equals("") || DBLocaleUtils.NONE_TXT.equals(selectLocale)) { dbUrl = String.format(getSelectDB().getDB_URL_INFO(), StringUtils.trimToEmpty(textHost.getText()), StringUtils.trimToEmpty(textPort.getText()), StringUtils.trimToEmpty(textDatabase.getText())); if (!"".equals(textJDBCOptions.getText())) { dbUrl += "?" + textJDBCOptions.getText(); }/*from w w w . j a va2 s . c om*/ } else { dbUrl = String.format(getSelectDB().getDB_URL_INFO(), StringUtils.trimToEmpty(textHost.getText()), StringUtils.trimToEmpty(textPort.getText()), StringUtils.trimToEmpty(textDatabase.getText())) + "?charset=" + selectLocale; if (!"".equals(textJDBCOptions.getText())) { dbUrl += "&" + textJDBCOptions.getText(); } } userDB = new UserDBDAO(); userDB.setDbms_type(getSelectDB().getDBToString()); userDB.setUrl(dbUrl); userDB.setUrl_user_parameter(textJDBCOptions.getText()); userDB.setDb(StringUtils.trimToEmpty(textDatabase.getText())); userDB.setGroup_name(StringUtils.trimToEmpty(preDBInfo.getComboGroup().getText())); userDB.setDisplay_name(StringUtils.trimToEmpty(preDBInfo.getTextDisplayName().getText())); String dbOpType = PublicTadpoleDefine.DBOperationType .getNameToType(preDBInfo.getComboOperationType().getText()).name(); userDB.setOperation_type(dbOpType); if (dbOpType.equals(PublicTadpoleDefine.DBOperationType.PRODUCTION.name()) || dbOpType.equals(PublicTadpoleDefine.DBOperationType.BACKUP.name())) { userDB.setIs_lock(PublicTadpoleDefine.YES_NO.YES.name()); } userDB.setHost(StringUtils.trimToEmpty(textHost.getText())); userDB.setPort(StringUtils.trimToEmpty(textPort.getText())); userDB.setUsers(StringUtils.trimToEmpty(textUser.getText())); userDB.setPasswd(StringUtils.trimToEmpty(textPassword.getText())); userDB.setLocale(StringUtils.trimToEmpty(comboLocale.getText())); // ? ?? ? . userDB.setRole_id(PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString()); // others connection . setOtherConnectionInfo(); return true; }
From source file:com.egt.core.aplicacion.Bitacora.java
public static void stamp(String str) { logTrace(DASHES); logTrace(StringUtils.trimToEmpty(str)); logTrace(DASHES); }
From source file:com.groupon.jenkins.SetupConfig.java
public String getLabel() { return StringUtils.trimToEmpty(this.label); }
From source file:com.mothsoft.alexis.engine.textual.WebContentParserImpl.java
private String parse(org.apache.tika.parser.Parser parser, InputStream is, ContentHandler handler, StringBuffer buffer) throws IOException { final Metadata metadata = new Metadata(); final ParseContext context = new ParseContext(); try {/* w ww .j a va 2 s . c o m*/ parser.parse(is, handler, metadata, context); return StringUtils.trimToEmpty(buffer.toString()); } catch (SAXException e) { throw new IOException(e.getLocalizedMessage()); } catch (TikaException e) { throw new IOException(e.getLocalizedMessage()); } }