List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:net.orfjackal.sbt.plugin.IO.java
public static String absolutePath(String path) { if (StringUtils.isEmpty(path)) { return ""; }// w w w. j av a 2 s . co m return new File(path).getAbsolutePath(); }
From source file:com.clican.pluto.cms.tag.enumeration.TemplateVariable.java
public static TemplateVariable convert(String name) { if (StringUtils.isEmpty(name)) { return null; }//from ww w .java 2 s.com for (TemplateVariable tv : values()) { if (tv.variable.equals(name)) { return tv; } } return null; }
From source file:com.zb.app.external.wechat.cons.WeixinEventType.java
public static WeixinEventType getEventType(String event) { if (StringUtils.isEmpty(event)) { return null; }/* w w w .jav a2 s. c om*/ for (WeixinEventType eventType : values()) { if (eventType.name().equals(event)) { return eventType; } } return null; }
From source file:com.att.pirates.util.DBUtility.java
public static Connection getDBConnection() throws SQLException, Exception { Connection conn = null;//from ww w .jav a 2 s .com PropertyReader reader = new PropertyReader(); String forName = reader.readPropertyByName(PiratesConstants.CLASSFORNAME); if (StringUtils.isBlank(forName) || StringUtils.isEmpty(forName)) { throw new Exception("forName is empty from property file"); } String serverName = reader.readPropertyByName(PiratesConstants.SERVERNAME); String databaseName = reader.readPropertyByName(PiratesConstants.DATABASENAME); String user = reader.readPropertyByName(PiratesConstants.USER); String password = reader.readPropertyByName(PiratesConstants.PASSWORD); if (StringUtils.isBlank(serverName) || StringUtils.isEmpty(databaseName) || StringUtils.isBlank(user) || StringUtils.isEmpty(password)) { throw new Exception("connection string is empty from property file"); } String url = serverName + ";" + "databaseName=" + databaseName; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); conn = DriverManager.getConnection(url, user, password); return conn; }
From source file:com.bstek.dorado.web.ConsoleUtils.java
public static void outputConfigureItem(String item) { String value = Configure.getString(item); if (StringUtils.isEmpty(value)) { value = "<empty>"; }/*from ww w . j a v a 2s . co m*/ outputLoadingInfo("[" + item + "=" + value + "]"); }
From source file:com.cy.common.util.ValidateUtil.java
/** * ? ???0571-88175786057188175786//from ww w . j av a 2 s .c om * @return false:?; true: * */ public static boolean validatePhone(String telephone) { if (StringUtils.isEmpty(telephone)) { return false; } Pattern pattern = Pattern.compile("^((0\\d{2,3}))(-{0,})(\\d{7,8})(-(\\d{3,}))?$"); Matcher macher = pattern.matcher(telephone); return macher.matches(); }
From source file:kirchnerei.glatteis.page.ui.MenuDivider.java
public static MenuDivider fromString(String name) { if (StringUtils.isEmpty(name)) { return NONE; }/*from w w w. ja v a2s.co m*/ try { return valueOf(name.toUpperCase()); } catch (Exception e) { return NONE; } }
From source file:controllers.BIProxy.java
public static F.Promise<Result> index(String query) { if (StringUtils.isEmpty(query)) { F.Promise.promise(new F.Function0<Object>() { @Override/*w w w . j a v a 2 s . c o m*/ public Object apply() throws Throwable { return ok(Json.toJson("Query parameter (q) not provided ")); } }); } F.Promise<WSResponse> wsResponsePromise = WS.url("http://www.businessinsider.com/s") .setQueryParameter("q", query).get(); return wsResponsePromise.map(new F.Function<WSResponse, Result>() { @Override public Result apply(WSResponse wsResponse) throws Throwable { String body = wsResponse.getBody(); List<Map<String, String>> results = new ArrayList<Map<String, String>>(); try { // Insert into map org.jsoup.nodes.Document doc = Jsoup.parse(body); Elements items = doc.select("div.search-result"); // Iterate through results for (Element item : items) { Map<String, String> keyValue = new LinkedHashMap<String, String>(); keyValue.put("image", item.select("img").attr("src")); keyValue.put("title", item.select("h3").text()); keyValue.put("content", item.select("div.excerpt").first().text()); keyValue.put("date", item.select("li.date").text()); keyValue.put("url", item.select("a").attr("href")); results.add(keyValue); } } catch (DOMException e) { e.printStackTrace(); } return ok(Json.toJson(results)); } }); }
From source file:controllers.KWProxy.java
public static F.Promise<Result> index(String query) { if (StringUtils.isEmpty(query)) { F.Promise.promise(new F.Function0<Object>() { @Override//from www . j a va2 s. c om public Object apply() throws Throwable { return ok(Json.toJson("Query parameter (q) not provided ")); } }); } F.Promise<WSResponse> wsResponsePromise = WS.url("http://knowledge.wharton.upenn.edu/") .setQueryParameter("s", query).get(); return wsResponsePromise.map(new F.Function<WSResponse, Result>() { @Override public Result apply(WSResponse wsResponse) throws Throwable { String body = wsResponse.getBody(); List<Map<String, String>> results = new ArrayList<Map<String, String>>(); try { // Insert into map org.jsoup.nodes.Document doc = Jsoup.parse(body); Elements items = doc.select("div.article.type-article.status-publish"); // All articles belong to this classes for (Element item : items) { Map<String, String> keyValue = new LinkedHashMap<String, String>(); // Check if specific article belongs to "has-post-thumbnail" class (therefore it contains an image) if (item.hasClass("has-post-thumbnail")) { // Add image key and value to map keyValue.put("image", item.select("img").attr("src")); } // Add the rest of keys and values keyValue.put("title", item.select("h2").select("a").text()); keyValue.put("content", item.select("div.attribute.categorythumbs").first().text()); keyValue.put("date", item.select("ul.datestamp").select("li").first().text()); keyValue.put("url", item.select("h2").select("a").attr("href")); results.add(keyValue); } } catch (DOMException e) { e.printStackTrace(); } return ok(Json.toJson(results)); } }); }
From source file:controllers.FRBProxy.java
public static F.Promise<Result> index(String query) { if (StringUtils.isEmpty(query)) { F.Promise.promise(new F.Function0<Object>() { @Override/*ww w . j a v a2 s .c om*/ public Object apply() throws Throwable { return ok(Json.toJson("Query parameter (q) not provided ")); } }); } F.Promise<WSResponse> wsResponsePromise = WS.url("http://www.forbes.com/search/") .setQueryParameter("q", query).get(); return wsResponsePromise.map(new F.Function<WSResponse, Result>() { @Override public Result apply(WSResponse wsResponse) throws Throwable { String body = wsResponse.getBody(); List<Map<String, String>> results = new ArrayList<Map<String, String>>(); try { // Insert into map org.jsoup.nodes.Document doc = Jsoup.parse(body); Elements items = doc.select("li.edittools-contentitem"); // All articles belong to this class for (Element item : items) { Map<String, String> keyValue = new LinkedHashMap<String, String>(); // Check if specific article belongs to gallery class (therefore it contains an image) if (item.hasClass("gallery")) { // Add image key and value to map keyValue.put("image", item.select("img").attr("src")); } // Add the rest of keys and values keyValue.put("title", item.select("h2").select("a").text()); keyValue.put("content", item.select("p").first().ownText()); keyValue.put("date", item.select("time").text()); keyValue.put("url", item.select("h2").select("a").attr("href")); results.add(keyValue); } } catch (DOMException e) { e.printStackTrace(); } return ok(Json.toJson(results)); } }); }