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.shenit.commons.utils.Formatter.java
/** * @param notifyDateStr/*from ww w . j a v a 2 s . c o m*/ * @return */ public static Date parseDate(String notifyDateStr, DateFormat formatter) { if (StringUtils.isEmpty(notifyDateStr)) return null; try { return (formatter == null ? DATETIME_FORMATTER : formatter).parse(notifyDateStr); } catch (ParseException e) { LOG.warn("[parseDate] illegal date string: {}", notifyDateStr); } return null; }
From source file:ActionClasses.LoginAction.java
@Override public void validate() { if (StringUtils.isEmpty(this.username)) addFieldError("username", "User Name can not be blank"); if (StringUtils.isEmpty(this.password)) addFieldError("password", "Password con not be blank"); }
From source file:glluch.com.ontotaxoseeker.FreelingTagger.java
/** * Analizes a doc and return only the terms that are nouns. * @param doc The text to be analized.//w ww .j a va2 s. c o m * @return Terms, all the nouns terms in doc. * @throws IOException Reading files. */ public static Terms nouns(String doc) throws IOException { if (StringUtils.isEmpty(doc)) { Out.p("FreelingTagger, nouns: doc is null"); //throw new IllegalArgumentException("The argument cannot be null"); Terms ts = new Terms(); return ts; } System.loadLibrary("freeling_javaAPI"); Util.initLocale("default"); // Create options set for maco analyzer. // Default values are Ok, except for data files. if (null == op) { op = new MacoOptions(LANG); op.setDataFiles("", DATA + "common/punct.dat", DATA + LANG + "/dicc.src", DATA + LANG + "/afixos.dat", "", "resources/testLocucionsEn.dat", DATA + LANG + "/np.dat", DATA + LANG + "/quantities.dat", DATA + LANG + "/probabilitats.dat"); } if (tk == null) { tk = new Tokenizer(DATA + LANG + "/tokenizer.dat"); } if (sp == null) sp = new Splitter(DATA + LANG + "/splitter.dat"); SWIGTYPE_p_splitter_status sid = sp.openSession(); Maco mf = new Maco(op); mf.setActiveOptions(false, true, true, true, // select which among created true, true, false, true, // submodules are to be used. true, true, true, true); // default: all created submodules // are used if (tg == null) tg = new HmmTagger(DATA + LANG + "/tagger.dat", true, 2); if (parser == null) parser = new ChartParser(DATA + LANG + "/chunker/grammar-chunk.dat"); if (dep == null) dep = new DepTxala(DATA + LANG + "/dep_txala/dependences.dat", parser.getStartSymbol()); if (neclass == null) neclass = new Nec(DATA + LANG + "/nerc/nec/nec-ab-poor1.dat"); if (sen == null) sen = new Senses(DATA + LANG + "/senses.dat"); // sense dictionary if (dis == null) dis = new Ukb(DATA + LANG + "/ukb.dat"); // sense disambiguator // Extract the tokens from the line of text. ListWord l = tk.tokenize(doc); // Split the tokens into distinct sentences. ListSentence ls = sp.split(sid, l, false); // Perform morphological analysis mf.analyze(ls); // Perform part-of-speech tagging. tg.analyze(ls); // Perform named entity (NE) classificiation. neclass.analyze(ls); //sen.analyze( ls ); //dis.analyze( ls ); Terms tagOnlyNouns = FreelingTagger.tagOnlyNouns(ls); //debug("DOC"); //debug(doc); //debug("Result"); //debug(tagOnlyNouns.pretyPrint()); return tagOnlyNouns; }
From source file:com.xxd.web.controller.usercenter.CompanyController.java
/** * /*from w ww.j a v a 2 s . co m*/ * ??CompanyInterceptor * @return View */ @GetMapping("/login.html") public String companyLogin(Model model) { String username = request.getParameter("username"); model.addAttribute("username", StringUtils.isEmpty(username) ? "" : username); return "usercenter/company/login"; }
From source file:io.cloudslang.content.httpclient.build.RequestConfigBuilder.java
public RequestConfigBuilder setFollowRedirects(String followRedirects) { if (!StringUtils.isEmpty(followRedirects)) { this.followRedirects = followRedirects; }/* w w w . j a v a 2 s. co m*/ return this; }
From source file:com.reversemind.glia.other.TTT.java
private boolean something(String s1, String s2) { return StringUtils.isEmpty(s1); }
From source file:com.findcomputerstuff.nips.DefaultSecurityModule.java
@Override public String decryptMessage(String message) throws SsmEncryptionException { if (StringUtils.isEmpty(message)) throw new SsmEncryptionException("Cipher to be decrypted cannot be null or empty"); if (StringUtils.isEmpty(privateKeyPassword)) throw new SsmEncryptionException("Private key password specified is blank"); return processMessage(message, MessageAction.DECRYPT); }
From source file:candr.yoclip.OptionUtils.java
/** * Combines an array of strings into a single string. Multiple strings are joined together separated by a space * character unless proceeded by an {@link Options#LINE_BREAK Options} line break.<p/> * As an example the string array <code>String[] example = { "Hello", "World!" }</code> will result * in the string <code>"Hello World!"</code>. The string array <code>String[] example = { "Hello\n", * "World!" }</code> will result in the string <code>"Hello${nl}World!"</code> (where ${nl} is the OS * dependent new line character string). * * @param descriptions The strings that will be combined. * @return a string created from the array of strings. */// ww w. j av a 2 s .co m public static String combine(final String[] descriptions) { if (ArrayUtils.isEmpty(descriptions)) { return StringUtils.EMPTY; } if (descriptions.length == 1) { return descriptions[0]; } final StrBuilder descriptionBuilder = new StrBuilder(descriptions[0]); for (int i = 1; i < descriptions.length; i++) { if (!descriptions[i].startsWith(Options.LINE_BREAK)) { final String prior = StringUtils.isEmpty(descriptions[i - 1]) ? StringUtils.EMPTY : descriptions[i - 1]; if (!prior.endsWith(Options.LINE_BREAK)) { descriptionBuilder.append(' '); } } descriptionBuilder.append(descriptions[i]); } return descriptionBuilder.toString(); }
From source file:forge.util.FileSection.java
public static Map<String, String> parseToMap(final String line, final String kvSeparator, final String pairSeparator) { Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); if (!StringUtils.isEmpty(line)) { final String[] pairs = line.split(Pattern.quote(pairSeparator)); final Pattern splitter = Pattern.compile(Pattern.quote(kvSeparator)); for (final String dd : pairs) { final String[] v = splitter.split(dd, 2); result.put(v[0].trim(), v.length > 1 ? v[1].trim() : ""); }//from w ww .j a v a2 s .c o m } return result; }
From source file:minor.register.RegisterAction.java
@Override public void validate() { if (StringUtils.isEmpty(getUname())) { addFieldError("uname", "Username cannot be blank."); }/*from w ww . j a v a 2s . co m*/ if (StringUtils.isEmpty(getUname())) { addFieldError("name", "Name cannot be blank."); } if (StringUtils.isEmpty(getUname())) { addFieldError("password", "Password cannot be blank."); } if (StringUtils.isEmpty(getCpassword())) { addFieldError("cpassword", "Confirm Password cannot be blank."); } if (StringUtils.isEmpty(getEmail())) { addFieldError("email", "Email cannot be blank"); } if (!StringUtils.equals(getPassword(), getCpassword())) { addFieldError("cpassword", "Passwords don't match."); } try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Minor", "root", ""); PreparedStatement ps = con.prepareStatement("select * from userinfo where username=?"); ps.setString(1, uname); ResultSet rs = ps.executeQuery(); if (rs.next()) { addFieldError("uname", "Username already taken."); } con.close(); } catch (ClassNotFoundException e) { System.out.println(e); } catch (SQLException e) { System.out.println(e); } }