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:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.BlueprintsPersistenceBackendFactory.java

@Override
protected SearcheableResourceEStore internalCreatePersistentEStore(PersistentResource resource,
        PersistenceBackend backend, Map<?, ?> options) throws InvalidDataStoreException {
    assert backend instanceof BlueprintsPersistenceBackend : "Trying to create a Graph-based EStore with an invalid backend";
    @SuppressWarnings("unchecked")
    ArrayList<PersistentResourceOptions.StoreOption> storeOptions = (ArrayList<PersistentResourceOptions.StoreOption>) options
            .get(PersistentResourceOptions.STORE_OPTIONS);
    if (storeOptions == null || storeOptions.isEmpty()
            || storeOptions.contains(BlueprintsResourceOptions.EStoreGraphOption.DIRECT_WRITE)) {
        // Default store
        return new DirectWriteBlueprintsResourceEStoreImpl(resource, (BlueprintsPersistenceBackend) backend);
    } else {//from www .  jav a  2s. com
        if (storeOptions.contains(BlueprintsResourceOptions.EStoreGraphOption.AUTOCOMMIT)) {
            return new AutocommitBlueprintsResourceEStoreImpl(resource, (BlueprintsPersistenceBackend) backend);
        } else {
            throw new InvalidDataStoreException();
        }
    }
}

From source file:fr.acxio.tools.agia.google.GoogleDriveServiceImpl.java

@Override
public File getFileByPath(String sPath) throws IOException {
    File aResult = null;//from   w  w  w  . jav a2 s  .com
    if (drive != null) {
        String[] aSubPaths = sPath.split(PATH_SPLIT_REGEX);
        String aParentID = getRootFolderID();
        if (aSubPaths.length > 0) {
            for (int i = 0; i < (aSubPaths.length - 1); i++) {
                String aSubPath = aSubPaths[i];
                if (!aSubPath.isEmpty()) {
                    ArrayList<File> aFiles = getChildrenFolders(aParentID, aSubPath);
                    if (aFiles.isEmpty()) {
                        throw new IOException("Folder '" + aSubPath + "' not found");
                    } else {
                        aResult = aFiles.get(0);
                    }
                    aParentID = aResult.getId();
                }
            }
            String aSubPath = aSubPaths[aSubPaths.length - 1];
            if (!aSubPath.isEmpty()) {
                ArrayList<File> aFiles = getChildren(aParentID, aSubPath);
                if (aFiles.isEmpty()) {
                    throw new IOException("File '" + aSubPath + "' not found");
                } else {
                    aResult = aFiles.get(0);
                }
            }
        }
    }
    return aResult;
}

From source file:by.stub.yaml.stubs.StubRequest.java

@VisibleForTesting
boolean arraysIntersect(final ArrayList<String> dataStoreArray, final ArrayList<String> thisAssertingArray) {
    if (dataStoreArray.isEmpty()) {
        return true;
    } else if (!thisAssertingArray.isEmpty()) {
        for (final String entry : thisAssertingArray) {
            if (dataStoreArray.contains(entry)) {
                return true;
            }//from ww w.j  a v  a 2s. c o m
        }
    }
    return false;
}

From source file:hd3gtv.mydmam.useraction.fileoperation.CopyMove.java

private static void dirListing(File source, ArrayList<File> list_to_copy) throws IOException {
    ArrayList<File> bucket = new ArrayList<File>();
    ArrayList<File> next_bucket = new ArrayList<File>();
    bucket.add(source);/*from w w w. ja  va  2  s  .  c o  m*/

    File bucket_item;
    File[] list_content;

    while (true) {
        for (int pos_b = 0; pos_b < bucket.size(); pos_b++) {
            bucket_item = bucket.get(pos_b).getCanonicalFile();

            if (FileUtils.isSymlink(bucket_item)) {
                continue;
            }

            if (list_to_copy.contains(bucket_item)) {
                continue;
            }
            if (bucket_item.isDirectory()) {
                list_content = bucket_item.listFiles();
                for (int pos_lc = 0; pos_lc < list_content.length; pos_lc++) {
                    next_bucket.add(list_content[pos_lc]);
                }
            }
            list_to_copy.add(bucket_item);
        }
        if (next_bucket.isEmpty()) {
            return;
        }
        bucket.clear();
        bucket.addAll(next_bucket);
        next_bucket.clear();
    }
}

From source file:com.squid.kraken.v4.core.analysis.engine.index.DimensionStore.java

@Override
public String indexCorrelations(List<DimensionIndex> types, List<DimensionMember> values) {
    ArrayList<DimensionMember> accu = new ArrayList<>();
    for (int i = 0; i < values.size(); i++) {
        DimensionMember value = values.get(i);
        if (!accu.isEmpty()) {
            addCorrelations(value, accu);
        }//from   w w w  . j  av  a 2s  .c om
        accu.add(value);
    }
    return "";
}

From source file:gov.wa.wsdot.android.wsdot.ui.TwitterFragment.java

public void onLoadFinished(Loader<ArrayList<TwitterItem>> loader, ArrayList<TwitterItem> data) {

    if (!data.isEmpty()) {
        mAdapter.setData(data);// www.  j  a v a2 s  .c o m
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java

public static void _deleteChattingMessage(long sessionId) {
    ArrayList<ECMessage> iMessageList = IMessageSqlManager.queryIMessageList(sessionId, 0, null);
    if (iMessageList != null && !iMessageList.isEmpty()) {
        ArrayList<String> fileList = new ArrayList<String>();
        for (ECMessage detail : iMessageList) {
            if (detail.getType() != ECMessage.Type.TXT) {
                ECFileMessageBody body = (ECFileMessageBody) detail.getBody();
                if (!TextUtils.isEmpty(body.getLocalUrl())) {
                    if (body.getLocalUrl().startsWith("THUMBNAIL://")) {
                        ImgInfo imgInfo = ImgInfoSqlManager.getInstance().getImgInfo(detail.getMsgId());
                        if (imgInfo != null) {
                            ImgInfoSqlManager.getInstance().delImgInfo(imgInfo.getMsglocalid());
                            if (TextUtils.isEmpty(
                                    FileAccessor.getImagePathName() + "/" + imgInfo.getThumbImgPath())) {
                                continue;
                            }/*from   w  ww .ja va2s .  c  o  m*/
                            if (!new File(FileAccessor.getImagePathName() + "/" + imgInfo.getThumbImgPath())
                                    .exists()) {
                                continue;
                            }
                            fileList.add(FileAccessor.getImagePathName() + "/" + imgInfo.getBigImgPath());
                            fileList.add(FileAccessor.getImagePathName() + "/" + imgInfo.getThumbImgPath());
                        }
                    } else if (detail.getUserData() != null
                            && detail.getUserData().indexOf("THUMBNAIL://") != -1) {
                        String userData = detail.getUserData();
                        int start = userData.indexOf("THUMBNAIL://");
                        if (start != -1) {
                            String thumbnail = userData.substring(start);
                            fileList.add(ImgInfoSqlManager.getInstance().getThumbUrlAndDel(thumbnail));
                        }
                    } else {
                        fileList.add(body.getLocalUrl());
                    }
                }
            }
        }
        int rows = IMessageSqlManager.deleteMulitMsgs(iMessageList);
        if (rows > 0 && !fileList.isEmpty()) {
            FileAccessor.delFiles(fileList);
        }
    }
}

From source file:deprecate.compare.TokenizerJava_old.java

/**
 * Given a source code, this method will split the code into methods and
 * will call the processLine method for each line
 * @param sourceCode //from w w w.  ja v a2  s .c om
 */
TokenSource tokenize(final String sourceCode) {
    // the variable to store the output
    TokenSource tokenSource = new TokenSource();
    // get the array of methods
    InterfaceToGrabJavaMethods grabber = new GrabJavaMethodsUsingRawInterpretation();
    ArrayList<SourceCodeSnippet> methods = grabber.grab(sourceCode);
    // test if we got a meaninful result
    if (methods.isEmpty()) {
        // uncomment the lines below for debugging purposes
        //            System.out.println(sourceCode);
        //            System.out.println("---------------------");
        return null;
    }
    // keep the stored methods in memory
    tokenSource.setMethodsOriginal(methods);

    // now process each method
    for (final SourceCodeSnippet method : methods) {
        // the variable where we store the results
        String result = "";
        // the lines for this method            
        String[] lines = method.getText().split("\n");

        // now iterate each line
        for (final String line : lines) {
            // get the source code line converted to tokens
            final String tokenizedLine = processLine(line);
            // if the result was null, continue to the next line
            if (tokenizedLine == null) {
                continue;
            }
            // get the lines together
            result = result.concat(tokenizedLine);
        }
        // avoid empty results
        if (result.isEmpty()) {
            continue;
        }

        // remove the empty spaces
        result = result.replaceAll(" ", "");
        // create the tokenized method
        SourceCodeSnippet tokenMethod = new SourceCodeSnippet();
        // get the line where the method starts
        tokenMethod.setLineStart(method.getLineStart());
        // get the line where the method ends
        tokenMethod.setLineEnd(method.getLineEnd());
        // add the tokenized method to the object
        tokenMethod.setText(result);
        // add the method to the source code
        tokenSource.add(tokenMethod);
    }
    // all done
    return tokenSource;
}

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

@RequestMapping(value = "/get-new-auctions", method = RequestMethod.GET, produces = "application/json")
@ResponseBody/*ww  w .  j  a va  2 s. co  m*/
public ResponseEntity<Map<String, Object>> getNewAuctions() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Auction_Detail> auction = auc_service.getNewAuction();
        if (!auction.isEmpty()) {
            map.put("DATA", auction);
            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:at.rocworks.oa4j.logger.dbs.NoSQLJDBC.java

@Override
public boolean dpGetPeriod(Date t1, Date t2, Dp dp, Set<String> configs, DpGetPeriodResult result) {
    JDebug.out.log(Level.INFO, "dpGetPeriod: {0}-{1} {2} {3}",
            new Object[] { t1, t2, dp.toString(), configs.toString() });
    try {//from w ww.  java2s  . co m
        Connection conn = dataSourceQuery.getConnection();
        if (conn != null) {
            // select columns                
            ArrayList<Dp> dps = createDpConfigAttrList(dp, configs);
            if (dps.isEmpty()) {
                JDebug.out.warning("dpGetPeriod without any valid config.");
                return false;
            }

            StringBuilder columns = new StringBuilder();
            dps.forEach((Dp x) -> {
                String c = attrMap.get(x.getAttribute());
                if (c != null)
                    columns.append(c).append(",");
            });

            // add the timestamp
            columns.append("ts AS TS");

            // datapoint element_id
            Object tag = this.getTagOfDp(dp);
            if (tag == null) {
                JDebug.out.log(Level.SEVERE, "dpGetPeriod with invalid datapoint {0}",
                        new Object[] { dp.toString() });
                return false;
            }

            // build sql statement
            String sql = String.format(this.sqlSelectStmt, columns);

            // query data
            int records = 0;
            JDebug.out.log(Level.FINE, "dpGetPeriod SQL={0}", sql);
            try (PreparedStatement stmt = conn.prepareStatement(sql)) {
                // tag
                if (tag instanceof Long)
                    stmt.setLong(1, (Long) tag);
                else if (tag instanceof String) {
                    stmt.setString(1, (String) tag);
                }

                // timerange
                stmt.setTimestamp(2, new java.sql.Timestamp(t1.getTime()), cal);
                stmt.setTimestamp(3, new java.sql.Timestamp(t2.getTime()), cal);

                // execute
                //stmt.setFetchSize(1000);
                ResultSet rs = stmt.executeQuery();
                //ResultSetMetaData md = rs.getMetaData();

                Date ts;
                Object value;
                while (rs.next()) {
                    records++;
                    int c = 0;
                    ts = rs.getTimestamp("TS", cal);
                    for (int i = 0; i < dps.size(); i++) {
                        switch (dps.get(i).getAttribute()) {
                        case Value:
                            // value_number
                            value = rs.getObject(++c);
                            if (value != null)
                                result.addValue(dps.get(i), ts, value);
                            // value_string
                            value = rs.getObject(++c);
                            if (value != null)
                                result.addValue(dps.get(i), ts, value);
                            // value_timestamp
                            value = rs.getObject(++c);
                            if (value != null)
                                result.addValue(dps.get(i), ts, value);
                            break;
                        case Status:
                            value = rs.getObject(++c);
                            result.addVariable(dps.get(i), ts, new Bit32Var(value));
                            break;
                        case Status64:
                            value = rs.getObject(++c);
                            result.addVariable(dps.get(i), ts, new Bit64Var(value));
                            break;
                        case Manager:
                        case User:
                            value = rs.getObject(++c);
                            result.addValue(dps.get(i), ts, value);
                            break;
                        case Stime:
                            value = ts;
                            result.addValue(dps.get(i), ts, value);
                            break;
                        default:
                            c++;
                            JDebug.out.log(Level.SEVERE, "unhandeled config {0}", dps.get(i).getAttribute());
                        }
                    }
                }
            }
            JDebug.out.log(Level.FINE, "dpGetPeriod: {0} records", records);
            conn.close();
            return true;
        } else {
            JDebug.StackTrace(Level.SEVERE, "no connection!");
        }
    } catch (Exception ex) {
        JDebug.StackTrace(Level.SEVERE, ex);
    }
    return false;
}