List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:com.hangum.tadpole.engine.sql.parser.ddl.ParserDDL.java
/** * ddl parser/*from ww w . ja v a2 s. com*/ * * @param sql * @param queryInfoDTO * @return */ public QueryInfoDTO parseQuery(String sql, QueryInfoDTO queryInfoDTO) { sql = StringUtils.upperCase(StringUtils.trim(sql)); for (DefineDDL ddl : DefineDDL.values()) { // if(logger.isDebugEnabled()) logger.debug(ddl.getRegExp()); Matcher matcher = Pattern.compile(ddl.getRegExp(), ParserDefine.PATTERN_FLAG).matcher(sql); if (matcher.find()) { // if(logger.isDebugEnabled()) logger.debug("=> finding: " + ddl.getRegExp()); queryInfoDTO.setQueryDDLType(ddl.getDdlType()); queryInfoDTO.setQueryStatus(ddl.getDdlStatus()); queryInfoDTO.setObjectName(getObjectName(matcher, sql)); break; } } return queryInfoDTO; }
From source file:com.github.dbourdette.otto.web.form.SourceForm.java
public void setName(String name) { this.name = StringUtils.trim(name); }
From source file:com.hangum.tadpole.rdb.core.util.GenerateDDLScriptUtils.java
/** * get table script//from ww w . j a v a2 s . c o m * * @param userDB * @param tableDAO * @param showTableColumns * @return */ public static String genTableScript(UserDBDAO userDB, TableDAO tableDAO, List<TableColumnDAO> showTableColumns) { if (showTableColumns == null) return ""; if (showTableColumns.isEmpty()) return ""; StringBuffer sbSQL = new StringBuffer(); try { sbSQL.append("SELECT "); //$NON-NLS-1$ for (int i = 0; i < showTableColumns.size(); i++) { TableColumnDAO dao = showTableColumns.get(i); sbSQL.append(StringUtils.trim(dao.getSysName())); // ? , if (i < (showTableColumns.size() - 1)) sbSQL.append(", "); //$NON-NLS-1$ else sbSQL.append(" "); //$NON-NLS-1$ } sbSQL.append(PublicTadpoleDefine.LINE_SEPARATOR + "FROM "); //$NON-NLS-1$ sbSQL.append(SQLUtil.getTableName(userDB, tableDAO)); sbSQL.append(PublicTadpoleDefine.SQL_DELIMITER); } catch (Exception e) { logger.error("Generate select statement", e); Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$ ExceptionDetailsErrorDialog.openError(null, Messages.get().Error, Messages.get().GenerateSQLSelectAction_0, errStatus); //$NON-NLS-1$ } return sbSQL.toString(); }
From source file:de.snertlab.xdccBee.irc.DccMessageParser.java
public static DccPacket buildDccPacket(String sender, String dccMessage) { DccPacket dccPacket = new DccPacket(); dccPacket.setSender(sender);/* w w w . j a v a2 s.com*/ String s = cleanMessage(dccMessage); Matcher m = DCC_MESSAGE_PATTER.matcher(s); if (m.find()) { dccPacket.setPacketNr(Integer.parseInt(StringUtils.trim(m.group(1)))); dccPacket.setSize(StringUtils.trim(m.group(2))); String packetName = m.group(3); packetName = StringUtils.trim(packetName); dccPacket.setName(packetName); } return dccPacket; }
From source file:com.qualitesys.sonarqcr4pblplugin.pbl.PblPackage.java
public PblPackage(String key) { super(); setKey(StringUtils.defaultIfEmpty(StringUtils.trim(key), DEFAULT_PACKAGE_NAME)); }
From source file:ei.ne.ke.cassandra.cql3.template.Term.java
/** * * * @param value// w w w . ja va2 s.c o m */ public Term(String value) { String trimmedValue = StringUtils.trim(value); Preconditions.checkArgument(PATTERN.matcher(trimmedValue).matches(), "Value must match pattern " + PATTERN); this.value = trimmedValue; }
From source file:com.hangum.tadpole.engine.sql.parser.UpdateDeleteParser.java
/** * ddl parser/* ww w .j a v a 2 s. co m*/ * * @param sql * @param queryInfoDTO * @return */ public QueryDMLInfoDTO parseQuery(String sql, QueryDMLInfoDTO queryInfoDTO) { sql = StringUtils.upperCase(StringUtils.trim(sql)); for (TABLE_PARSER ddl : TABLE_PARSER.values()) { // if(logger.isDebugEnabled()) logger.debug(ddl.getRegExp()); Matcher matcher = Pattern.compile(ddl.getRegExp(), ParserDefine.PATTERN_FLAG).matcher(sql); if (matcher.find()) { // if(logger.isDebugEnabled()) logger.debug("=> finding: " + ddl.getRegExp()); queryInfoDTO.setDmlType(ddl.getDmlType()); queryInfoDTO.setObjectName(getObjectName(matcher, sql)); break; } } return queryInfoDTO; }
From source file:com.alibaba.cobar.client.router.rules.AbstractEntityTypeRule.java
public AbstractEntityTypeRule(String pattern, String action) { Validate.notEmpty(StringUtils.trim(pattern)); Validate.notEmpty(StringUtils.trim(action)); this.typePatten = pattern; this.action = action; }
From source file:com.taobao.tdhs.jdbc.util.StringUtil.java
public static String escapeField(String field) { field = StringUtils.trim(field); if (StringUtils.startsWith(field, VALUE_ESCAPE_QUOTATION_1) || StringUtils.endsWith(field, VALUE_ESCAPE_QUOTATION_1) || StringUtils.startsWith(field, VALUE_ESCAPE_QUOTATION_2) || StringUtils.endsWith(field, VALUE_ESCAPE_QUOTATION_2)) { return null; }//from www. j a va 2 s . com if (StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && !StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { return null; } if (!StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { return null; } if (StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { if (field.length() > 1) return field.substring(1, field.length() - 1); else return null; } return field; }
From source file:ei.ne.ke.cassandra.cql3.template.Identifier.java
/** * * * @param value/*from w ww.ja v a2 s . c om*/ */ public Identifier(String value) { String trimmedValue = StringUtils.trim(value); Preconditions.checkArgument(PATTERN.matcher(trimmedValue).matches(), "Value must match pattern " + PATTERN); this.value = trimmedValue; }