List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:de.mirkosertic.easydav.index.QueryParser.java
private void addSubQuery(BooleanQuery aQuery, String aTerm, boolean aNegated, String aSearchField) { if (!StringUtils.isEmpty(aTerm)) { if (!aTerm.contains("*")) { if (aTerm.contains(" ")) { PhraseQuery thePhraseQuery = new PhraseQuery(); for (StringTokenizer theTokenizer = new StringTokenizer(aTerm, " "); theTokenizer .hasMoreTokens();) { String theToken = theTokenizer.nextToken(); thePhraseQuery.add(new Term(aSearchField, theToken)); }//from w w w . ja v a 2s .c o m thePhraseQuery.setSlop(1); if (aNegated) { aQuery.add(thePhraseQuery, BooleanClause.Occur.MUST_NOT); } else { aQuery.add(thePhraseQuery, BooleanClause.Occur.MUST); } } else { Query theQuery; if (!aTerm.endsWith("~")) { theQuery = new TermQuery(new Term(aSearchField, aTerm)); } else { theQuery = new FuzzyQuery(new Term(aSearchField, aTerm.substring(0, aTerm.length() - 1))); } if (aNegated) { aQuery.add(theQuery, BooleanClause.Occur.MUST_NOT); } else { aQuery.add(theQuery, BooleanClause.Occur.MUST); } } } else { WildcardQuery theWildcardQuery = new WildcardQuery(new Term(aSearchField, aTerm)); if (aNegated) { aQuery.add(theWildcardQuery, BooleanClause.Occur.MUST_NOT); } else { aQuery.add(theWildcardQuery, BooleanClause.Occur.MUST); } } } }
From source file:io.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate.java
@JsonCreator public BasicAuthenticatorCredentialUpdate(@JsonProperty("password") String password, @JsonProperty("iterations") Integer iterations) { Preconditions.checkNotNull(password, "Cannot assign null password."); Preconditions.checkArgument(!StringUtils.isEmpty(password), "Cannot assign empty password."); this.password = password; this.iterations = iterations == null ? -1 : iterations; }
From source file:com.envisioncn.it.super_sonic.showcase.support.LoginInterceptor.java
@Override public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object handler) throws Exception { String uri = req.getRequestURI(); if (!uri.startsWith("/resources/") && !uri.startsWith("/icon/") && !uri.startsWith("/pre_login") && !uri.startsWith("/login")) { HttpSession session = req.getSession(); String user = SessionUtil.getUser(session); if (StringUtils.isEmpty(user)) { res.sendRedirect("/pre_login"); return false; }/*w w w. j a v a 2 s . co m*/ } return true; }
From source file:com.opendesign.vo.AlarmVO.java
/** * ? ? * * @return */ public boolean isNew() { return StringUtils.isEmpty(confirmTime); }
From source file:io.apiman.gateway.engine.ispn.AbstractInfinispanComponent.java
/** * Constructor./* w w w . java 2 s .com*/ * @param config the config */ public AbstractInfinispanComponent(Map<String, String> config, String defaultCacheContainer, String defaultCache) { cacheContainer = config.get("cache.container"); //$NON-NLS-1$ cacheName = config.get("cache.name"); //$NON-NLS-1$ if (StringUtils.isEmpty(cacheContainer)) { cacheContainer = defaultCacheContainer; } if (StringUtils.isEmpty(cacheName)) { cacheName = defaultCache; } }
From source file:com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.java
/** * Common logic in processAndExport* methods. *///www.j a v a 2 s . c o m private static void write(GcodeParser gcp, GcodeStreamWriter gsw, String original, String command, String comment, int idx) throws GcodeParserException { if (idx % 100000 == 0) { logger.log(Level.FINE, "gcode processing line: " + idx); } if (StringUtils.isEmpty(command)) { gsw.addLine(original, command, comment, idx); } else { // Parse the gcode for the buffer. Collection<String> lines = gcp.preprocessCommand(command, gcp.getCurrentState()); for (String processedLine : lines) { gsw.addLine(original, processedLine, comment, idx); } gcp.addCommand(command); } }
From source file:com.newtranx.util.mysql.fabric.SpringMybatisSetShardKeyUtilImpl.java
@Override public void setShardKey(String shardKey, boolean force) throws SQLException { FabricMySQLConnection connection = (FabricMySQLConnection) sqlSession.getConnection(); if (StringUtils.isEmpty(connection.getShardKey()) || force) { connection.setShardKey(shardKey); log.debug("New shardKey set"); log.debug("ShardKey=" + shardKey); log.debug("CurrentServerGroup=" + connection.getCurrentServerGroup()); } else {/* www . jav a 2 s . co m*/ log.debug("Keep original shardKey"); log.debug("ShardKey=" + connection.getShardKey()); } }
From source file:com.navercorp.pinpoint.web.dao.ibatis.DefaultBindingLogFormatter.java
public String format(String query, List<String> parameters) { if (StringUtils.isEmpty(query)) { return query; }/* w ww . j a v a2s . c o m*/ if (removeWhitespace) { query = SqlUtils.removeBreakingWhitespace(query); } StringBuilder builder = new StringBuilder(query.length() << 1); int index = 0; int queryPrev = 0; for (int i = 0; i < query.length();) { if (parameters != null && query.charAt(i) == '?') { builder.append(query.substring(queryPrev, i)); builder.append(parameters.size() > index ? convert(parameters.get(index)) : null); queryPrev = ++i; index++; continue; } i++; } if (queryPrev < query.length()) { builder.append(query.substring(queryPrev)); } return builder.toString(); }
From source file:com.qcadoo.mes.basic.constants.GlobalTypeOfMaterial.java
public static GlobalTypeOfMaterial parseString(final String globalTypeOfMaterial) { if (StringUtils.isEmpty(globalTypeOfMaterial)) { return NONE; } else if ("01component".equals(globalTypeOfMaterial)) { return COMPONENT; } else if ("02intermediate".equals(globalTypeOfMaterial)) { return INTERMEDIATE; } else if ("03finalProduct".equals(globalTypeOfMaterial)) { return FINAL_PRODUCT; } else if ("04waste".equals(globalTypeOfMaterial)) { return WASTE; }// w w w .j av a 2 s.c o m throw new IllegalStateException("Unsupported GlobalTypeOfMaterial: " + globalTypeOfMaterial); }
From source file:net.sfr.tv.mom.mgt.handlers.InvocationHandler.java
public InvocationHandler(final String expression, final Operation operation, final Formatter formatter, final String help) { if (StringUtils.isEmpty(expression)) throw new IllegalArgumentException("Expression must be not null or empty"); if (null == operation) throw new IllegalArgumentException("Operation must be not null"); if (null == formatter) throw new IllegalArgumentException("Formatter must be not null"); this.expression = expression; this.operation = operation; this.formatter = formatter; this.help = help; }