Example usage for java.util ArrayList isEmpty

List of usage examples for java.util ArrayList isEmpty

Introduction

In this page you can find the example usage for java.util ArrayList isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:gdsc.smlm.ij.plugins.ResultsManager.java

/**
 * Add a list of input sources to the generic dialog. The choice field will be named inputName. If a file input option
 * is selected then a field will be added name 'Input_file'.
 * <p>/*from  w  w w .j  av  a  2  s.  c o  m*/
 * If the source is a memory source then it will not be added if it is empty. If not empty then a summary of the
 * number of localisation is added as a message to the dialog.
 * 
 * @param gd
 * @param inputName
 * @param inputOption
 * @param inputs
 */
public static void addInput(GenericDialog gd, String inputName, String inputOption, InputSource... inputs) {
    ArrayList<String> source = new ArrayList<String>(3);
    boolean fileInput = false;
    for (InputSource input : inputs) {
        ResultsManager.addInputSource(source, input);
        if (input == InputSource.FILE)
            fileInput = true;
    }
    if (source.isEmpty())
        addInputSource(source, InputSource.NONE);

    addInputSourceToDialog(gd, inputName, inputOption, source, fileInput);
}

From source file:com.ibuildapp.romanblack.FanWallPlugin.data.Statics.java

public static ArrayList<FanWallMessage> getFbLikesForUrls(ArrayList<FanWallMessage> messagesList) {
    String token = FacebookAuthorizationActivity.getFbToken(com.appbuilder.sdk.android.Statics.FACEBOOK_APP_ID,
            com.appbuilder.sdk.android.Statics.FACEBOOK_APP_SECRET);
    if (TextUtils.isEmpty(token))
        return messagesList;

    if (messagesList == null || messagesList.isEmpty())
        return messagesList;

    // collect urls list
    List<String> urlList = new ArrayList<String>();
    for (int i = 0; i < messagesList.size(); i++) {
        if (!TextUtils.isEmpty(messagesList.get(i).getImageUrl()))
            urlList.add(messagesList.get(i).getImageUrl());
    }//from w w w  .  jav  a2s  . c o m

    Map<String, String> tempResultMap = FacebookAuthorizationActivity.getLikesForUrls(urlList, token);

    if (tempResultMap.size() != 0) {
        Set<String> keySet = tempResultMap.keySet();
        for (String key : keySet) {
            for (FanWallMessage msg : messagesList) {
                if (!TextUtils.isEmpty(msg.getImageUrl()) && msg.getImageUrl().compareTo(key) == 0) {
                    String likeCountStr = tempResultMap.get(key);
                    msg.setLikeCount(Long.parseLong(likeCountStr));
                    break;
                }
            }
        }
    }

    return messagesList;
}

From source file:bookChapter.theoretical.AnalyzeTheoreticalMSMSCalculation.java

private static String result(MSnSpectrum msms, double precursorTolerance, HashSet<DBEntry> peptideAndMass,
        double fragmentTolerance, int correctionFactor, boolean hasAllPossCharge)
        throws IllegalArgumentException, IOException, MzMLUnmarshallerException {
    String res = "";
    HashMap<Peptide, Boolean> allSelectedPeps = getSelectedTheoPeps(msms, precursorTolerance, peptideAndMass); // select peptides within a given precursor tolerance
    int scoredPeps = allSelectedPeps.size();
    ArrayList<Identify> sequestResults = new ArrayList<Identify>(),
            andromedaResults = new ArrayList<Identify>();
    // for every peptide... calculate each score...
    for (Peptide selectedPep : allSelectedPeps.keySet()) {
        Identify toCalculateSequest = new Identify(msms, selectedPep, fragmentTolerance, true,
                allSelectedPeps.get(selectedPep), scoredPeps, correctionFactor, hasAllPossCharge),
                toCalculateAndromeda = new Identify(msms, selectedPep, fragmentTolerance, false,
                        allSelectedPeps.get(selectedPep), scoredPeps, correctionFactor, hasAllPossCharge);
        if (toCalculateSequest.getScore() != Double.NEGATIVE_INFINITY) {
            sequestResults.add(toCalculateSequest);
            andromedaResults.add(toCalculateAndromeda);
        }/* w w  w.j a  v a2 s  . com*/
    }
    if (!sequestResults.isEmpty()) {
        HashSet<Identify> theBestSEQUESTResults = getBestResult(sequestResults),
                theBestAndromedaResults = getBestResult(andromedaResults);
        res = printInfo(theBestAndromedaResults, theBestSEQUESTResults);
    }
    return res;
}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static ArrayList getAllTypes(ArrayList _searchDomainList, ArrayList _allTypesList) {
    for (int i = 0; i < _searchDomainList.size(); i++) {
        Class searchClass = (Class) _searchDomainList.get(i);
        _searchDomainList.remove(searchClass);

        Class superClass = searchClass.getSuperclass();

        if (superClass != null && (_allTypesList.contains(superClass) == false)) {
            _searchDomainList.add(superClass);
            _allTypesList.add(superClass);
        }/*  w w  w  . j  a v  a 2s.  c  o m*/

        Class[] interfaceArray = searchClass.getInterfaces();

        if (interfaceArray != null) {
            for (int j = 0; j < interfaceArray.length; j++) {
                if (interfaceArray[j] != null && (_allTypesList.contains(interfaceArray[j]) == false)) {
                    _searchDomainList.add(interfaceArray[j]);
                    _allTypesList.add(interfaceArray[j]);
                }
            }
        }
    }

    if (_searchDomainList.isEmpty() == false) {
        _allTypesList = getAllTypes(_searchDomainList, _allTypesList);
    }

    return _allTypesList;
}

From source file:com.intel.cosbench.driver.generator.HistogramIntGenerator.java

private static HistogramIntGenerator tryParse(String pattern) {
    pattern = StringUtils.substringBetween(pattern, "(", ")");
    String[] args = StringUtils.split(pattern, ',');
    ArrayList<Bucket> bucketsList = new ArrayList<Bucket>();
    for (String arg : args) {
        int v1 = StringUtils.indexOf(arg, '|');
        int v2 = StringUtils.lastIndexOf(arg, '|');
        boolean isOpenRange = ((v2 - v1) == 1) ? true : false;
        String[] values = StringUtils.split(arg, '|');
        int lower, upper, weight;
        if (isOpenRange) {
            lower = Integer.parseInt(values[0]);
            upper = UniformIntGenerator.getMAXupper();
            weight = Integer.parseInt(values[1]);
        } else if (values.length != 3) {
            throw new IllegalArgumentException();
        } else {/*w  w  w  . java 2s  .c  om*/
            lower = Integer.parseInt(values[0]);
            upper = Integer.parseInt(values[1]);
            weight = Integer.parseInt(values[2]);
        }
        bucketsList.add(new Bucket(lower, upper, weight));
    }
    if (bucketsList.isEmpty()) {
        throw new IllegalArgumentException();
    }
    Collections.sort(bucketsList, new LowerComparator());
    final Bucket[] buckets = bucketsList.toArray(new Bucket[0]);
    int cumulativeWeight = 0;
    for (Bucket bucket : buckets) {
        cumulativeWeight += bucket.weight;
        bucket.cumulativeWeight = cumulativeWeight;
    }
    return new HistogramIntGenerator(buckets);
}

From source file:com.fluidops.iwb.wiki.Wikimedia.java

/**
 * We replace special variables like $this.Host/cpuUsage$ by the value
 * that we obtain a for property Host/cpuUsage w.r.t to val. If
 * a variable has no value w.r.t. val, the value <i>(undefined)</i> is
 * replaced instead. There's a special handling for thumbnail vocabulary:
 * there, we try to embed the picture.// w w  w  .ja v a2s.co  m
 * 
 * @param content The String which includes the variables
 * @param val The variable value
 * @return Returns the finished String
 */
private static String replaceTemplateVariables(String content, Value val, Repository repository) {
    String ret = content.replaceAll("\\$this\\$", StringEscapeUtils.escapeHtml(val.stringValue()));

    // Support for variables like this: $this[IMAGE]$
    Pattern pat = Pattern.compile("\\$this(\\[([a-zA-Z_0-9]+)\\])\\$");
    Matcher matcher = pat.matcher(content);
    while (matcher.find()) {
        String rt = matcher.group(2) == null ? ValueResolver.DEFAULT : matcher.group(2);
        String valueStr = ValueResolver.resolveValue(rt, val);
        ret = ret.replace(matcher.group(0), valueStr);
    }

    ArrayList<LookupConfig> properties = new ArrayList<LookupConfig>();

    // collect outgoing special variables
    extractProperties(properties, ret, "\\$this\\.([^\\[\\$]+)(\\[([a-zA-Z_0-9]+)\\])?\\$", true);

    // collect incoming special variables
    extractProperties(properties, ret, "\\$(\\S+)\\.this(\\[([a-zA-Z_0-9]+)\\])?\\$", false);

    // if no replacement necessary, we're done
    if (properties.isEmpty())
        return ret;

    // Build the query
    String query = buildQueryUnion(properties);

    // execute the SPARQL query and replace the content
    ReadWriteDataManager dm = null;
    TupleQueryResult res = null;
    try {
        dm = ReadWriteDataManagerImpl.openDataManager(repository);
        res = dm.sparqlSelect(query, true, val, false);

        while (res.hasNext()) {
            BindingSet bs = res.next();

            Iterator<Binding> iter = bs.iterator();
            while (iter.hasNext()) {

                // name is v0, v1, .. => add into corresponding properties results
                Binding b = iter.next();
                int index = Integer.parseInt(b.getName().substring(1));
                // implicit indexing using array list, add to properties result list
                properties.get(index).results.add(b.getValue());
            }
        }

        for (LookupConfig cfg : properties)
            ret = replaceVariables(ret, cfg);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        ReadWriteDataManagerImpl.closeQuietly(res);
        ReadWriteDataManagerImpl.closeQuietly(dm);
    }

    return ret;
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Top_Bidder_controller.java

@RequestMapping(value = "/get-top-bidder", method = RequestMethod.GET, produces = "application/json")
@ResponseBody//  w  ww  .j a va2s.c  om
public ResponseEntity<Map<String, Object>> getTopBidder() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Top_Bidder> top_bidder = top_bidder_service.getTop_Bidder();

        if (!top_bidder.isEmpty()) {
            map.put("DATA", top_bidder);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:net.opentsdb.meta.TSMeta.java

/**
 * Determines if an entry exists in storage or not. 
 * This is used by the UID Manager tool to determine if we need to write a 
 * new TSUID entry or not. It will not attempt to verify if the stored data is 
 * valid, just checks to see if something is stored in the proper column.
 * @param tsdb  The TSDB to use for storage access
 * @param tsuid The UID of the meta to verify
 * @return True if data was found, false if not
 * @throws HBaseException if there was an issue fetching
 */// w  w  w . j  a  va2s.com
public static Deferred<Boolean> metaExistsInStorage(final TSDB tsdb, final String tsuid) {
    final GetRequest get = new GetRequest(tsdb.metaTable(), UniqueId.stringToUid(tsuid));
    get.family(FAMILY);
    get.qualifier(META_QUALIFIER);

    /**
     * Callback from the GetRequest that simply determines if the row is empty
     * or not
     */
    final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {

        @Override
        public Boolean call(ArrayList<KeyValue> row) throws Exception {
            if (row == null || row.isEmpty() || row.get(0).value() == null) {
                return false;
            }
            return true;
        }

    }

    return tsdb.getClient().get(get).addCallback(new ExistsCB());
}

From source file:net.opentsdb.meta.TSMeta.java

/**
 * Determines if the counter column exists for the TSUID. 
 * This is used by the UID Manager tool to determine if we need to write a 
 * new TSUID entry or not. It will not attempt to verify if the stored data is 
 * valid, just checks to see if something is stored in the proper column.
 * @param tsdb The TSDB to use for storage access
 * @param tsuid The UID of the meta to verify
 * @return True if data was found, false if not
 * @throws HBaseException if there was an issue fetching
 *//*from  ww w. ja  v  a2s  .c om*/
public static Deferred<Boolean> counterExistsInStorage(final TSDB tsdb, final byte[] tsuid) {
    final GetRequest get = new GetRequest(tsdb.metaTable(), tsuid);
    get.family(FAMILY);
    get.qualifier(COUNTER_QUALIFIER);

    /**
     * Callback from the GetRequest that simply determines if the row is empty
     * or not
     */
    final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {

        @Override
        public Boolean call(ArrayList<KeyValue> row) throws Exception {
            if (row == null || row.isEmpty() || row.get(0).value() == null) {
                return false;
            }
            return true;
        }

    }

    return tsdb.getClient().get(get).addCallback(new ExistsCB());
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Bid_log_controller.java

@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json")
@ResponseBody//w  w  w.ja  v a 2  s  .  c  o  m
public ResponseEntity<Map<String, Object>> getNumberOfBid() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Bid_log> bids = bid_log_service.getNumberOfBid();
        if (!bids.isEmpty()) {
            map.put("DATA", bids);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}