Example usage for java.lang String isEmpty

List of usage examples for java.lang String isEmpty

Introduction

In this page you can find the example usage for java.lang String isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if, and only if, #length() is 0 .

Usage

From source file:com.nts.alphamale.shell.AdbShellCommand.java

/**
 * 1. adbcommand.properties? ? adb command list  ?  ResourceBudle? ?  ??? .
 * 2.  adb  ?  ??? . //from   w  ww  .  ja  v  a 2  s.  com
 * @param serial ?? 
 * @param adbCmd adb 
 * @return adb command line
 */
public static CommandLine cmd(String serial, String adbCmd) {
    CommandLine cmd = new CommandLine(Utils.adb());
    if (!serial.isEmpty()) {
        cmd.addArgument("-s");
        cmd.addArgument(serial);
    }
    if (ADB_COMMAND_BUNDLE.getString(adbCmd).isEmpty()) {
        cmd.addArguments(adbCmd.split(" "));
    } else {
        cmd.addArguments(ADB_COMMAND_BUNDLE.getString(adbCmd).split(" "));
    }
    return cmd;
}

From source file:Main.java

/**
 * compares textual content of two elements which are get with
 * element.getChildText() content of a non-existing element is equal to
 * content of an element without text/*w w  w  . j  a v a  2s .com*/
 * 
 * @param t1
 * @param t2
 * @return
 */
public static boolean isEqualXMLText(String t1, String t2) {
    if (t1 == null && t2 == null) {
        return true;
    } else if (t1 == null) {
        return t2.isEmpty();
    } else if (t2 == null) {
        return t1.isEmpty();
    } else {
        return t1.equals(t2);
    }
}

From source file:Main.java

/**
 *
 * @param content/*from  w  w w .  j  av  a 2 s. com*/
 * @param charset
 * @return
 */
public static String parseHexBinary(String content, Charset charset) {

    String converted = content;

    if (content != null && !content.isEmpty()) {
        converted = new String(DatatypeConverter.parseHexBinary(content), charset);
    }

    return converted;
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.course.WayPointQueryService.java

public static List<IWayPoint> getWayPointList(String pilotUrl) throws IOException, ParseException {

    String jsonString = HttpQueryUtils.simpleQuery(pilotUrl + "/json/waypoints");
    if (jsonString == null || jsonString.isEmpty())
        return null;

    JSONParser parser = new JSONParser();
    JSONArray array = (JSONArray) parser.parse(jsonString);
    List<IWayPoint> wayPointList = new ArrayList<IWayPoint>();

    for (Object entry : array) {
        WayPoint wayPoint = new WayPoint((JSONObject) entry);
        wayPointList.add(wayPoint);//w  ww  . j a  v  a  2 s.  co  m
    }

    return wayPointList;
}

From source file:graph.module.NLPToSyntaxModule.java

/**
 * Replaces special characters from the latin-1 table with the nearest
 * characters from the ascii table:// w ww  .ja  v a  2s  .c om
 * 
 * For example: ,,, will become a,  becomes ss, ,
 * become c, C...
 */
public static String convertToAscii(String str) {
    if (str == null || str.isEmpty())
        return str;
    // Pre-normalisation
    String temp = Normalizer.normalize(str, Normalizer.Form.NFD);
    Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
    str = pattern.matcher(temp).replaceAll("");

    StringBuilder buffer = new StringBuilder();
    char[] strArray = str.toCharArray();
    for (int i = 0; i < strArray.length; i++) {
        char c = strArray[i];

        if (c < 128)
            buffer.append(c);
        else if (c == 176)
            buffer.append(" degrees ");
        else if (c == 198)
            buffer.append("AE");
        else if (c == 230)
            buffer.append("ae");
        else if (c == 338)
            buffer.append("OE");
        else if (c == 339)
            buffer.append("oe");
        else if (c == 223)
            buffer.append("ss");
        else if (c == 8211 || c == 8212)
            buffer.append("-");
        else if (c == 8217)
            buffer.append("'");
        else {
            // System.out.println("Unknown character: " + c + " (" + ((int)
            // c)
            // + ")" + ((c + "") == "?"));
            buffer.append("?");
        }
    }
    return buffer.toString();
}

From source file:jackrabbit.query.Querier.java

public static RowIterator queryBySQLRow(Session session, String query, String queryType)
        throws RepositoryException {
    if (queryType == null || queryType.isEmpty())
        queryType = Query.JCR_SQL2;
    QueryManager qm = session.getWorkspace().getQueryManager();
    Query q = qm.createQuery(query, queryType);
    QueryResult result = q.execute();//from   w ww .j  a  va 2s .c om
    RowIterator it = result.getRows();
    return it;
}

From source file:net.minecraftforge.common.command.SelectorHandlerManager.java

/**
 * Returns the best matching handler for the given string. Defaults to the vanilla handler if no prefix applies
 *///from  w  ww. j a  v  a2s  .  com
public static SelectorHandler getHandler(final String selectorStr) {
    if (!selectorStr.isEmpty()) {
        for (final Entry<String, SelectorHandler> handler : selectorHandlers
                .subMap(selectorStr, true, selectorStr.substring(0, 1), true).entrySet()) {
            if (selectorStr.startsWith(handler.getKey())) {
                return handler.getValue();
            }
        }
    }

    return vanillaHandler;
}

From source file:net.myrrix.online.eval.ReconstructionEvaluator.java

private static Multimap<Long, RecommendedItem> readAndCopyDataFiles(File dataDir, File tempDir)
        throws IOException {
    Multimap<Long, RecommendedItem> data = ArrayListMultimap.create();
    for (File dataFile : dataDir.listFiles(new PatternFilenameFilter(".+\\.csv(\\.(zip|gz))?"))) {
        log.info("Reading {}", dataFile);
        int count = 0;
        for (CharSequence line : new FileLineIterable(dataFile)) {
            Iterator<String> parts = COMMA_TAB_SPLIT.split(line).iterator();
            long userID = Long.parseLong(parts.next());
            long itemID = Long.parseLong(parts.next());
            if (parts.hasNext()) {
                String token = parts.next().trim();
                if (!token.isEmpty()) {
                    data.put(userID, new GenericRecommendedItem(itemID, LangUtils.parseFloat(token)));
                }/*from  w w  w .ja va 2s . c om*/
                // Ignore remove lines
            } else {
                data.put(userID, new GenericRecommendedItem(itemID, 1.0f));
            }
            if (++count % 1000000 == 0) {
                log.info("Finished {} lines", count);
            }
        }

        Files.copy(dataFile, new File(tempDir, dataFile.getName()));
    }
    return data;
}

From source file:name.martingeisse.common.util.string.StringUtil.java

/**
 * Converts an underscored name to an lower-camel-case name like
 * this: "my_foo_bar" -> "myFooBar"./*from  w w  w. jav a 2s  . c o m*/
 * @param s the string to convert
 * @return the lower camel case string
 */
public static String convertUnderscoresToLowerCamelCase(String s) {
    if (s.isEmpty()) {
        return s;
    }
    char firstCharacterLowerCase = Character.toLowerCase(s.charAt(0));
    return firstCharacterLowerCase
            + StringUtils.remove(WordUtils.capitalizeFully(s, UNDERSCORE_ARRAY), '_').substring(1);
}

From source file:biospectra.ServerConfiguration.java

public static ServerConfiguration createInstance(String json) throws IOException {
    if (json == null || json.isEmpty()) {
        throw new IllegalArgumentException("json is empty or null");
    }/*  w  w w  .  j  a  va2s  .c  o  m*/

    JsonSerializer serializer = new JsonSerializer();
    return (ServerConfiguration) serializer.fromJson(json, ServerConfiguration.class);
}