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:hudson.gridmaven.MavenModuleSetBuild.java
private static String normalizePath(String relPath) { relPath = StringUtils.trimToEmpty(relPath); if (StringUtils.isEmpty(relPath)) { LOGGER.config("No need to normalize an empty path."); } else {//from w w w.j av a2s. c o m if (FilenameUtils.indexOfLastSeparator(relPath) == -1) { LOGGER.config("No need to normalize " + relPath); } else { String tmp = FilenameUtils.normalize(relPath); if (tmp == null) { LOGGER.config( "Path " + relPath + " can not be normalized (parent dir is unknown). Keeping as is."); } else { LOGGER.config("Normalized path " + relPath + " to " + tmp); relPath = tmp; } relPath = FilenameUtils.separatorsToUnix(relPath); } } LOGGER.fine("Returning path " + relPath); return relPath; }
From source file:com.egt.core.db.util.Reporter.java
public static ReporterMessage report(String informe, long funcion, String destino, EnumFormatoInforme tipo, String select, Object[] args, Map parametros) { Bitacora.trace(Reporter.class, "report", informe, String.valueOf(funcion), destino, String.valueOf(tipo)); Long rastro = null;//ww w . java 2s. c o m try { informe = StringUtils.trimToEmpty(informe); if (STP.esIdentificadorArchivoValido(informe)) { if (TLC.getControlador().esFuncionAutorizada(funcion)) { rastro = TLC.getControlador().ponerInformePendiente(funcion); return report(informe, rastro, TLC.getControlador().getUsuario().getIdUsuario(), TLC.getControlador().getUsuario().getCodigoUsuario(), TLC.getControlador().getUsuario().getNombreUsuario(), destino, tipo, select, args, parametros, false); } 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 null; }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.SQLiteLoginComposite.java
/** * ? ? .//w w w. jav a 2 s. c o m * * @return */ @Override public boolean isValidateInput(boolean isTest) { // ??? ?. File fileRootResource = new File(ROOT_RESOURCE_DIR); if (!fileRootResource.isDirectory()) { fileRootResource.mkdirs(); } if (!ValidChecker.checkTextCtl(preDBInfo.getComboGroup(), Messages.get().GroupName)) return false; if (!ValidChecker.checkTextCtl(preDBInfo.getTextDisplayName(), Messages.get().DisplayName)) return false; if (oldUserDB != null) return true; if (chkBtnFileUpload.getSelection()) { File[] arryFiles = receiver.getTargetFiles(); if (arryFiles.length == 0) { MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().SQLiteLoginComposite_23); return false; } File userDBFile = arryFiles[arryFiles.length - 1]; File targetFile = new File(ROOT_RESOURCE_DIR + userDBFile.getName()); if (targetFile.exists()) { boolean isUpload = MessageDialog.openConfirm(null, Messages.get().Confirm, Messages.get().SQLiteLoginComposite_24); if (!isUpload) { chkBtnFileUpload.setFocus(); return false; } } } else if (chkBtnFileLocationDb.getSelection()) { File targetFile = new File(textFileLocationDB.getText()); if (!targetFile.exists()) { MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().SQLiteLoginComposite_25); textFileLocationDB.setFocus(); return false; } // ?. } else { String strFile = StringUtils.trimToEmpty(textCreationDB.getText()); if ("".equals(strFile)) { //$NON-NLS-1$ MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().SQLiteLoginComposite_7); textCreationDB.setFocus(); return false; } if (new File(ROOT_RESOURCE_DIR + textCreationDB.getText()).exists()) { MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().SQLiteLoginComposite_24); textCreationDB.setFocus(); return false; } } return true; }
From source file:com.hangum.tadpole.rdb.core.editors.table.TableViewerEditPart.java
/** * Create contents of the editor part./*ww w . j a v a2s . c o m*/ * @param parent */ @Override public void createPartControl(Composite parent) { GridLayout gl_parent = new GridLayout(1, false); gl_parent.marginHeight = 0; parent.setLayout(gl_parent); composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite.setLayout(new GridLayout(1, false)); toolBar = new ToolBar(composite, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tltmSave = new ToolItem(toolBar, SWT.NONE); tltmSave.setEnabled(false); tltmSave.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // save ? . java.sql.Connection javaConn = null; Statement stmt = null; String lastExeQuery = ""; //$NON-NLS-1$ try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); // sqlite? forward cursor ? stmt = javaConn.createStatement();//ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); javaConn.setAutoCommit(false); String[] querys = SQLTextUtil.delLineChar(getChangeQuery()).split(";"); //$NON-NLS-1$ for (int i = 0; i < querys.length; i++) { // logger.info("exe query [" + querys[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ lastExeQuery = querys[i]; stmt.execute(querys[i]); } javaConn.commit(); // ?? . tltmSave.setEnabled(false); initBusiness(textWhere.getText()); isDirty = false; } catch (Exception ee) { try { if (javaConn != null) javaConn.rollback(); } catch (SQLException roE) { } ; logger.error(Messages.TableViewerEditPart_7, ee); // ? . MessageDialog.openError(null, Messages.TableViewerEditPart_3, "Query [ " + lastExeQuery + Messages.TableViewerEditPart_10 + ee.getMessage() + Messages.TableViewerEditPart_11); //$NON-NLS-2$ } finally { // connection? ? ? . try { javaConn.setAutoCommit(true); } catch (Exception ee) { } try { if (stmt != null) stmt.close(); } catch (Exception ee) { } try { if (javaConn != null) javaConn.close(); } catch (Exception ee) { } } } }); tltmSave.setText(Messages.TableEditPart_0); tltmInsert = new ToolItem(toolBar, SWT.NONE); tltmInsert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (modifyType == TABLE_MOD_TYPE.EDITOR) insertRow(); } }); tltmInsert.setText(Messages.TableEditPart_tltmInsert_text); tltmInsert.setEnabled(false); tltmDelete = new ToolItem(toolBar, SWT.NONE); tltmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) sqlResultTableViewer.getSelection(); if (!is.isEmpty()) { deleteRow(is.getFirstElement()); } } }); tltmDelete.setEnabled(false); tltmDelete.setText(Messages.TableEditPart_1); tltmTablecomment = new ToolItem(toolBar, SWT.NONE); tltmTablecomment.setText(TbUtils.NONE_MSG); Composite compositeBody = new Composite(parent, SWT.NONE); compositeBody.setLayout(new GridLayout(2, false)); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Label lblWhere = new Label(compositeBody, SWT.NONE); lblWhere.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblWhere.setText(Messages.TableEditPart_lblWhere_text); textWhere = new Text(compositeBody, SWT.BORDER); textWhere.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) changeWhere(textWhere.getText()); } }); textWhere.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel = new Label(compositeBody, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText(Messages.TableEditPart_3); textFilter = new Text(compositeBody, SWT.BORDER); textFilter.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.Selection) setFilter(); } }); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); sqlResultTableViewer = new TableViewer(compositeBody, SWT.VIRTUAL | SWT.BORDER | SWT.FULL_SELECTION); sqlResultTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (primaryKeyListIndex.size() >= 1) tltmDelete.setEnabled(true); } }); tableResult = sqlResultTableViewer.getTable(); tableResult.setHeaderVisible(true); tableResult.setLinesVisible(true); tableResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); // table markup-enable tableResult.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); sqlFilter.setTable(tableResult); initBusiness(StringUtils.trimToEmpty(textWhere.getText())); }
From source file:ips1ap101.lib.base.util.StrUtils.java
public static String getStringAscii(String string) { if (string == null) { return null; }/*from w w w . j a v a 2s .c o m*/ String s = StringUtils.trimToEmpty(string); s = s.replace("", "a"); s = s.replace("", "e"); s = s.replace("", "i"); s = s.replace("", "o"); s = s.replace("", "u"); s = s.replace("", "u"); s = s.replace("", "n"); s = s.replace("?", "A"); s = s.replace("", "E"); s = s.replace("?", "I"); s = s.replace("", "O"); s = s.replace("", "U"); s = s.replace("", "U"); s = s.replace("", "N"); try { byte[] bytes = s.getBytes(); return new String(bytes, "US-ASCII"); } catch (UnsupportedEncodingException ex) { logger.fatal(ThrowableUtils.getString(ex), ex); } return s; }
From source file:com.hangum.tadpole.rdb.core.editors.table.TableViewerEditPart.java
/** * ?? ? ?? . */ public void refreshEditor() { initBusiness(StringUtils.trimToEmpty(textWhere.getText())); initButtonCtrl(); }
From source file:com.egt.core.util.Utils.java
public static String getQuotedParameterString(Object[] args) { String str = StringUtils.EMPTY; String dlm = " "; if (args != null && args.length > 0) { for (int i = 0; i < args.length; i++) { str += dlm + getQuotedParameterString(STP.getString(args[i])); }//www .j a v a 2s . c o m str = str.substring(dlm.length()); } return StringUtils.trimToEmpty(str); }
From source file:com.egt.core.util.Utils.java
public static String getQuotedParameterString(String str) { String quote = getQuote(); return quote + StringUtils.trimToEmpty(str) + quote; }
From source file:com.hangum.tadpole.application.start.dialog.login.LoginDialog.java
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEMail.getText()); String strPass = StringUtils.trimToEmpty(textPasswd.getText()); if (!validation(strEmail, strPass)) return;/* w ww . j a v a 2 s . c om*/ try { UserDAO userDao = TadpoleSystem_UserQuery.login(strEmail, strPass); // firsttime email confirm if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getIs_email_certification())) { InputDialog inputDialog = new InputDialog(getShell(), Messages.get().LoginDialog_10, Messages.get().LoginDialog_17, "", null); //$NON-NLS-3$ //$NON-NLS-1$ if (inputDialog.open() == Window.OK) { if (!userDao.getEmail_key().equals(inputDialog.getValue())) { throw new Exception(Messages.get().LoginDialog_19); } else { TadpoleSystem_UserQuery.updateEmailConfirm(strEmail); } } else { throw new Exception(Messages.get().LoginDialog_20); } } if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getApproval_yn())) { MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().LoginDialog_27); return; } // Check the allow ip String strAllowIP = userDao.getAllow_ip(); boolean isAllow = IPFilterUtil.ifFilterString(strAllowIP, RequestInfoUtils.getRequestIP()); if (logger.isDebugEnabled()) logger.debug(Messages.get().LoginDialog_21 + userDao.getEmail() + Messages.get().LoginDialog_22 + strAllowIP + Messages.get().LoginDialog_23 + RequestInfoUtils.getRequestIP()); if (!isAllow) { logger.error(Messages.get().LoginDialog_21 + userDao.getEmail() + Messages.get().LoginDialog_22 + strAllowIP + Messages.get().LoginDialog_26 + RequestInfoUtils.getRequestIP()); MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().LoginDialog_28); return; } if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDao.getUse_otp())) { OTPLoginDialog otpDialog = new OTPLoginDialog(getShell()); otpDialog.open(); if (!GoogleAuthManager.getInstance().isValidate(userDao.getOtp_secret(), otpDialog.getIntOTPCode())) { throw new Exception(Messages.get().LoginDialog_2); } } // ? . registLoginID(userDao.getEmail(), strPass); SessionManager.addSession(userDao); // save login_history TadpoleSystem_UserQuery.saveLoginHistory(userDao.getSeq()); } catch (TadpoleAuthorityException e) { logger.error( String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), Messages.get().Warning, e.getMessage()); textPasswd.setText(""); textPasswd.setFocus(); return; } catch (Exception e) { logger.error( String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), Messages.get().Warning, e.getMessage()); textPasswd.setFocus(); return; } super.okPressed(); }
From source file:com.egt.core.util.Utils.java
public static String trimPrefix(String message, String prefix) { String mensaje = StringUtils.trimToEmpty(message); int i = mensaje.indexOf(prefix); if (i >= 0) { mensaje = mensaje.substring(i + prefix.length()); }/*from w ww.j a v a 2 s . c o m*/ return mensaje; }