List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:com.saltedge.sdk.utils.SEJSONTools.java
private static boolean validation(JSONObject jsonObject, String key) { return jsonObject == null || key == null || key.isEmpty() || jsonObject.isNull(key); }
From source file:edu.lternet.pasta.common.HTMLUtility.java
/** * This method helps to ensure that the output String has only valid HTML * characters by stripping out invalid control characters. * * @param in The String whose non-valid characters we want to remove. * @return The input String, stripped of non-valid characters. *//* w w w. j a v a 2 s . c om*/ public static String stripNonValidHTMLCharacters(String in) { char[] charBuf = null; if (in != null && !in.isEmpty()) { charBuf = in.toCharArray(); int charBufSize = charBuf.length; for (int i = 0; i < charBufSize; i++) { if (isInvalidHTMLCharacter(charBuf[i])) { charBuf[i] = '\uFFFD'; // Replace illegal character with replacement character } } } return new String(charBuf); }
From source file:Main.java
public static String basename(String path) { if (path == null) return ""; path = path.replaceAll("/+$", ""); int i = path.lastIndexOf('/'); return (path.isEmpty()) ? "/" : (i == -1) ? path : path.substring(i + 1); }
From source file:com.modcrafting.ultrabans.util.Formatting.java
public static boolean validIP(String ip) { if (ip == null || ip.isEmpty()) return false; ip = ip.trim();/* w w w .j av a2s. co m*/ if ((ip.length() < 6) & (ip.length() > 15)) return false; try { Pattern pattern = Pattern.compile( "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); Matcher matcher = pattern.matcher(ip); return matcher.matches(); } catch (PatternSyntaxException ex) { return false; } }
From source file:com.hoiio.sdk.util.StringUtil.java
/** * Checks for the {@code String} is empty or not. It checks both nullability and emptiness * @param str {@code String} to check//from w ww . j a va 2s . c om * @return whether this string is empty or not */ public static boolean isEmpty(String str) { return (str == null || str.isEmpty()); }
From source file:adalid.util.i18n.Merger.java
private static boolean noTranslationRequired(String string) { return string.isEmpty() || isMessageKey(string); }
From source file:net.landora.video.preferences.PreferenceObject.java
private static List<String> convertToStringList(String value) { if (value.isEmpty()) { return Collections.EMPTY_LIST; }//w ww. ja v a2 s . com List<String> result = new ArrayList<String>(); int lastIndex = -1; int index; while ((index = value.indexOf('\t', lastIndex + 1)) != -1) { result.add(StringEscapeUtils.unescapeJava(value.substring(lastIndex + 1, index))); lastIndex = index; } return result; }
From source file:Main.java
public static Component getChild(Component parent, String name) { parent = getContainer(parent);/*from w ww . ja v a 2s . c o m*/ if (parent instanceof JSplitPane) { JSplitPane split = (JSplitPane) parent; if (JSplitPane.TOP.equals(name)) { return split.getTopComponent(); } else if (JSplitPane.LEFT.equals(name)) { return split.getLeftComponent(); } else if (JSplitPane.RIGHT.equals(name)) { return split.getRightComponent(); } else if (JSplitPane.BOTTOM.equals(name)) { return split.getBottomComponent(); } } Container cont = (Container) parent; for (int i = 0; i < cont.getComponentCount(); i++) { Component comp = cont.getComponent(i); if (name.equals(comp.getName())) { return comp; } } if (name.endsWith(VIEW_SUFFIX)) { String subName = name.substring(0, name.length() - VIEW_SUFFIX.length()); if (subName.isEmpty()) { return parent; } return getContainer(getChild(parent, subName)); } throw new IllegalArgumentException("No component named " + name); }
From source file:com.fjn.helper.common.util.StringUtil.java
public static boolean isBlank(String str) { return str == null || str.isEmpty() || str.trim().isEmpty(); }
From source file:com.kstenschke.shifter.models.shiftertypes.JsVariablesDeclarations.java
/** * @param str text selection to be shifted * @return String//w w w . j a v a 2 s.c o m */ public static String getShifted(String str) { String[] lines = str.split("\n"); String shiftedLines = ""; int lineNumber = 0; String shiftedLine; for (String line : lines) { line = line.trim(); if (line.isEmpty() || line.startsWith("//")) { // do not change empty or comment-lines shiftedLine = line; } else { // remove "var " from beginning line = line.substring(4); // replace ";" from ending by ",\n" if (StringUtils.countMatches(line, "//") == 1) { // handle line ending with comment intact String[] parts = line.split("//"); parts[0] = parts[0].trim(); shiftedLine = parts[0].substring(0, parts[0].length() - 1) + ", //" + parts[1]; } else { shiftedLine = line.substring(0, line.length() - 1) + ","; } } shiftedLines += (lineNumber == 0 ? "" : "\t") + shiftedLine + "\n"; lineNumber++; } return "var " + shiftedLines.substring(0, shiftedLines.length() - 2) + ";"; }