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:com.smi.travel.monitor.BookingFlightComparator.java
@Override public int compare(BookingFlight f1, BookingFlight f2) { int compareDate = f1.getDepartureDate().compareTo(f2.getDepartureDate()); if (compareDate != 0) { return compareDate; } else {//from w w w .ja v a 2s . co m int departTime1; int departTime2; if (StringUtils.isEmpty(f1.getDepartTime())) { departTime1 = 0; } else { departTime1 = Integer.valueOf(f1.getDepartTime().trim()); } if (StringUtils.isEmpty(f2.getDepartTime())) { departTime2 = 0; } else { departTime2 = Integer.valueOf(f2.getDepartTime().trim()); } return Integer.compare(departTime1, departTime2); } }
From source file:com.glaf.mail.MailFactory.java
public synchronized static ClassPathXmlApplicationContext reload() { if (ctx != null) { ctx.close();//w ww . j a v a 2 s . co m ctx = null; } String configLocation = CustomProperties.getString("mail.context"); if (StringUtils.isEmpty(configLocation)) { configLocation = SystemProperties.getString("mail.context"); } if (StringUtils.isEmpty(configLocation)) { configLocation = DEFAULT_CONFIG; } ctx = new ClassPathXmlApplicationContext(configLocation); logger.debug("start spring ioc from: " + configLocation); return ctx; }
From source file:de.bmarwell.j9kwsolver.util.ResponseUtils.java
/** * @param response The response sent by the server. * @return null if response is null or empty, else a HashMap. *///from ww w . j av a 2 s . c o m public static Map<String, Integer> stringResponseToIntMap(final String response) { Map<String, Integer> result = new HashMap<String, Integer>(); if (StringUtils.isEmpty(response)) { /* * Response should be like so: * worker=15|avg24h=12s|avg1h=12s|avg15m=13s|avg5m=13s|inwork=8| * queue=0|queue1=0|queue2=0|workermouse=13| * workerconfirm=14|workertext=13 */ return null; } List<String> serverstatelist = Arrays.asList(StringUtils.split(response, '|')); /* Iterate each item in response */ for (String item : serverstatelist) { String[] keyValue = StringUtils.split(item, '='); int value = 0; if (keyValue.length != 2) { LOG.warn("Key-Value splitting on '=' doesn't return 2 items: {}.", item); continue; } String key = keyValue[0]; String textvalue = keyValue[1]; textvalue = StringUtils.removeEnd(textvalue, "s"); if (!NumberUtils.isDigits(textvalue)) { LOG.warn("Key-Value where value is non-numeric: {}", item); continue; } else { value = NumberUtils.toInt(textvalue); } result.put(key, value); } return result; }
From source file:com.jaeksoft.searchlib.renderer.field.RendererWidgetType.java
public static RendererWidgetType find(String name) { if (StringUtils.isEmpty(name)) return TEXT; return valueOf(name); }
From source file:cn.vlabs.clb.server.ui.frameservice.URLBuilder.java
public static String getPdfURL(String storageKey) { if (StringUtils.isEmpty(storageKey)) return null; return NGX_DOMAIN + "/" + PDF_CTX + "/" + storageKey + ".pdf"; }
From source file:com.eryansky.common.utils.encode.MD5Util.java
/** * ?MD5 32??// w w w . j a va 2 s . co m * @param str * @return * @date 2012-1-9?3:16:04 */ public static String getStringMD5(String str) { if (StringUtils.isEmpty(str)) { return ""; } byte[] buffer = str.getBytes(); messagedigest.update(buffer); return bufferToHex(messagedigest.digest()); }
From source file:com.assignmentone.handler.EchoHandler.java
@RequestHandler public void echo(String value) { if (StringUtils.isEmpty(value)) { value = "hello!"; }/* w w w . jav a 2 s .c om*/ System.out.println("[EchoHandler:echo]" + value); }
From source file:AIR.Common.Configuration.AppSettingsHelper.java
private static int getInt32(String key, Integer defaultValue) { String rawValue = get(key);//from w w w .j a v a2 s . c o m if (!StringUtils.isEmpty(rawValue)) { int value = Integer.parseInt(rawValue); return value; } return defaultValue != null ? defaultValue.intValue() : 0; }
From source file:com.htmlhifive.pitalium.it.util.ItUtils.java
/** * ?JSON???????// w ww .ja v a 2 s .c o m * * @param results * @param capabilities */ public static JsonNode getCurrentScreenshotResultJson(String methodName, JsonNode results, PtlCapabilities capabilities) { for (JsonNode jn : results.get("screenshotResults")) { JsonNode capabilitiesNode = jn.get("capabilities"); String platform = capabilities.getPlatform() != null ? capabilities.getPlatform().toString() : ""; if (methodName.equals(jn.get("testMethod").asText()) && capabilities.getBrowserName().equals(capabilitiesNode.get("browserName").asText())) { if (platform.equals("") || platform.endsWith(capabilitiesNode.get("platform").asText())) { JsonNode version = capabilitiesNode.get("version"); if (version == null) { if (StringUtils.isEmpty(capabilities.getVersion())) { return jn; } } else { if (version.asText().equals(capabilities.getVersion())) { return jn; } } } } } return null; }
From source file:com.glaf.template.engine.TemplateEngineFactory.java
public static ApplicationContext reload() { if (ctx != null) { ctx = null;/*from w w w .ja v a 2 s . co m*/ } String configLocation = CustomProperties.getString("template.engines.context"); if (StringUtils.isEmpty(configLocation)) { configLocation = SystemProperties.getString("template.engines.context"); } if (StringUtils.isEmpty(configLocation)) { configLocation = DEFAULT_CONFIG; } ctx = new ClassPathXmlApplicationContext(configLocation); logger.debug("start spring ioc from: " + configLocation); return ctx; }