List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:org.eclipse.lyo.testsuite.oslcv2.FetchResourceTests.java
@Parameters public static Collection<Object[]> getAllDescriptionUrls() throws IOException { staticSetup();/*from w w w. j a v a2 s . com*/ //Checks the ServiceProviderCatalog at the specified baseUrl of the REST service in order to grab all urls //to other ServiceProvidersCatalogs contained within it, recursively, in order to find the URLs of all //query capability of the REST service, then fetch the resource using the query service. ArrayList<String> capabilityURLsUsingRdfXml = null; String useThisQuery = setupProps.getProperty("useThisQuery"); if (useThisQuery != null) { capabilityURLsUsingRdfXml = new ArrayList<String>(); capabilityURLsUsingRdfXml.add(useThisQuery); } else { ArrayList<String> serviceUrls = getServiceProviderURLsUsingRdfXml(setupProps.getProperty("baseUri"), onlyOnce); capabilityURLsUsingRdfXml = TestsBase.getCapabilityURLsUsingRdfXml(OSLCConstants.QUERY_BASE_PROP, serviceUrls, true); } String where = setupProps.getProperty("changeRequestWhere"); if (where == null) { String queryProperty = setupProps.getProperty("queryEqualityProperty"); String queryPropertyValue = setupProps.getProperty("queryEqualityValue"); where = queryProperty + "=\"" + queryPropertyValue + "\""; } String additionalParameters = setupProps.getProperty("queryAdditionalParameters", ""); String query = (additionalParameters.length() == 0) ? "?" : "?" + additionalParameters + "&"; query = query + "oslc.where=" + URLEncoder.encode(where, "UTF-8") + "&oslc.pageSize=1"; ArrayList<String> results = new ArrayList<String>(); for (String queryBaseUri : capabilityURLsUsingRdfXml) { String queryUrl = OSLCUtils.addQueryStringToURL(queryBaseUri, query); HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, queryUrl, creds, OSLCConstants.CT_RDF, headers); Model queryModel = ModelFactory.createDefaultModel(); queryModel.read(resp.getEntity().getContent(), queryBaseUri, OSLCConstants.JENA_RDF_XML); RDFUtils.validateModel(queryModel); Property member = queryModel.createProperty(OSLCConstants.RDFS_MEMBER); Resource queryBase = queryModel.getResource(queryBaseUri); Selector select = new SimpleSelector(queryBase, member, (RDFNode) null); StmtIterator statements = queryModel.listStatements(select); while (statements.hasNext()) { results.add(statements.nextStatement().getObject().toString()); if (onlyOnce) return toCollection(results); } if (!results.isEmpty() && onlyOnce) break; } return toCollection(results); }
From source file:edu.temple.cis3238.wiki.vo.TopicVO.java
/** * @param tagsCollection the tagsCollection to set *//*w ww.j a va 2 s .c om*/ public void setTagsCollection(ArrayList<TagsVO> tagsCollection) { if (tagsCollection != null && !tagsCollection.isEmpty()) { this.tagsCollection = new CopyOnWriteArrayList<TagsVO>(); Collections.sort(tagsCollection); this.tagsCollection.addAll(tagsCollection); } }
From source file:coolmap.canvas.action.PasteColumnNodesAction.java
@Override public void actionPerformed(ActionEvent e) { try {//from w w w . j a va2 s.c om CoolMapObject obj = CoolMapMaster.getActiveCoolMapObject(); Transferable content = (Transferable) Toolkit.getDefaultToolkit().getSystemClipboard() .getContents(null); String data = (String) content.getTransferData(DataFlavor.stringFlavor); JSONObject json = new JSONObject(data); System.out.println(json); //System.out.println(((JMenuItem)(e.getSource())).getParent()); ArrayList<Range<Integer>> selectedColumns = obj.getCoolMapView().getSelectedColumns(); // System.out.println(selectedColumns); //if there are selections int insertionIndex = 0; if (selectedColumns != null && !selectedColumns.isEmpty()) { insertionIndex = selectedColumns.get(0).lowerEndpoint(); } //else System.out.println(insertionIndex); JSONArray terms = json.getJSONArray("Terms"); String ontologyID = json.getString("OntologyID"); COntology ontology = CoolMapMaster.getCOntologyByID(ontologyID); System.out.println("Ontology:" + ontology); if (ontology == null) { return; } ArrayList<VNode> newNodes = new ArrayList<VNode>(); for (int i = 0; i < terms.length(); i++) { VNode node = new VNode(terms.getString(i), ontology); newNodes.add(node); System.out.println(node); } Rectangle centerTo = new Rectangle(insertionIndex, 0, 1, 1); if (obj.getCoolMapView().getSelectedRows() != null && !obj.getCoolMapView().getSelectedRows().isEmpty()) { centerTo.y = ((Range<Integer>) (obj.getCoolMapView().getSelectedRows().get(0))).lowerEndpoint(); } CoolMapState state = CoolMapState.createStateColumns("Insert Column Nodes", obj, null); obj.insertColumnNodes(insertionIndex, newNodes, true); //need to center to inserted obj.getCoolMapView().centerToRegion(centerTo); StateStorageMaster.addState(state); } catch (Exception ex) { //Return System.err.println("Exception in pasting columns:" + ex); } }
From source file:com.pinterest.deployservice.scm.PhabricatorManager.java
@Override public Queue<CommitBean> getCommits(String repo, String startSha, boolean keepHead) throws Exception { String input = String.format(QUERY_COMMITS_HISTORY_PARAMETER, startSha, DEFAULT_SIZE, repo); Map<String, Object> json = queryCLI(input); @SuppressWarnings("unchecked") Map<String, Object> commitsJson = (Map<String, Object>) json.get("response"); @SuppressWarnings("unchecked") ArrayList<Map<String, Object>> commitsArray = (ArrayList<Map<String, Object>>) commitsJson .get("pathChanges"); if (!commitsArray.isEmpty()) { Queue<CommitBean> CommitBeans = new LinkedList<>(); for (Map<String, Object> commitMap : commitsArray) { if (!keepHead) { keepHead = true;/*w w w . j a v a2 s .c o m*/ continue; } CommitBeans.offer(toCommitBean(commitMap, repo)); } return CommitBeans; } else { throw new DeployInternalException("Invalid SHA or branch name passed to Phabricator getCommitBeans!"); } }
From source file:fr.inria.atlanmod.neoemf.map.datastore.MapPersistenceBackendFactory.java
@Override protected SearcheableResourceEStore internalCreatePersistentEStore(PersistentResource resource, PersistenceBackend backend, Map<?, ?> options) throws InvalidDataStoreException { assert backend instanceof DB : "Trying to create a Map-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(MapResourceOptions.EStoreMapOption.DIRECT_WRITE)) { // Default store return new DirectWriteMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend); } else {//from ww w . j a va2s . co m if (storeOptions.contains(MapResourceOptions.EStoreMapOption.AUTOCOMMIT)) { return new AutocommitMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend); } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.CACHED_MANY)) { return new CachedManyDirectWriteMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend); } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.DIRECT_WRITE_WITH_LISTS)) { return new DirectWriteMapResourceWithListsEStoreImpl(resource, (MapPersistenceBackend) backend); } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.DIRECT_WRITE_WITH_INDEXES)) { return new DirectWriteMapWithIndexesResourceEStoreImpl(resource, (MapPersistenceBackend) backend); } else { throw new InvalidDataStoreException(); } } }
From source file:PlotsBuilding.PlotPanel.java
private JFreeChart fillCollection(ArrayList<PlotsData> plotscollection) { XYSeriesCollection col = new XYSeriesCollection(); ArrayList<Integer> seriesCount = new ArrayList<>(); int SeriesCount = 0; PlotsData plotdata = new PlotsData(); if (plotscollection.isEmpty()) { XYSeries series = new XYSeries("1. "); series.add(0, 0);// w ww. j ava2 s . c o m plotdata.y1 = -10; plotdata.y2 = 10; col.addSeries(series); } for (int i = 0; i < plotscollection.size(); i++) { plotdata = (PlotsData) plotscollection.get(i); col = plotdata.createPlotdataset(i, col); seriesCount.add(col.getSeriesCount() - SeriesCount); SeriesCount = col.getSeriesCount(); } double y1 = plotdata.y1; double y2 = plotdata.y2; JFreeChart chart = createChart(col, seriesCount, y1, y2); return chart; }
From source file:gov.wa.wsdot.android.wsdot.ui.BlogFragment.java
public void onLoadFinished(Loader<ArrayList<BlogItem>> loader, ArrayList<BlogItem> data) { if (!data.isEmpty()) { mAdapter.setData(data);/*w w w. j a v a 2 s. c o m*/ } else { TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); getListView().setEmptyView(mEmptyView); } swipeRefreshLayout.setRefreshing(false); }
From source file:biblivre3.cataloging.vocabulary.VocabularyBO.java
public DTOCollection<VocabularyDTO> autoComplete(String query) { DTOCollection<VocabularyDTO> dto = new DTOCollection<VocabularyDTO>(); try {/*from w w w . ja v a 2 s. c om*/ String[] searchArray = null; if (query != null) { searchArray = TextUtils.removeDiacriticals(query).toLowerCase().split("\\s+"); } if (searchArray == null) { return dto; } ArrayList<VocabularyDTO> terms = dao.search(searchArray, "150", 0, 1000); if (!terms.isEmpty()) { for (VocabularyDTO term : terms) { Record record = MarcUtils.iso2709ToRecord(term.getIso2709()); Subfield subfield = MarcUtils.getSubfield(record, "150", 'a'); if (subfield != null) { term.setTerm(subfield.getData()); term.setIso2709(null); dto.add(term); } } return dto; } } catch (Exception e) { System.out.println("[VOCABULARYBO.autoComplete(..)] Exception: " + e); } return dto; }
From source file:com.miserablemind.butter.domain.model.user.user.impl.UserManagerImpl.java
@Override public void updateUser(AppUser updatedUser) throws UserTakenException { boolean emailAvailable = this.userDao.isEmailAvailableForChange(updatedUser.getEmail(), updatedUser.getId());//from ww w. j a va 2 s . com boolean userNameAvailable = this.userDao.isUserNameAvailableForChange(updatedUser.getUsername(), updatedUser.getId()); ArrayList<String> errors = new ArrayList<String>(); if (!userNameAvailable) errors.add(UserTakenException.USERNAME_TAKEN); if (!emailAvailable) errors.add(UserTakenException.EMAIL_TAKEN); if (!errors.isEmpty()) throw new UserTakenException(errors); this.userDao.updateUser(updatedUser); }
From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java
private void exportSecretCodes() { ArrayList<SecretCode> secretCodes = Utils.getSecretCodes(this); Collections.sort(secretCodes); if (secretCodes.isEmpty()) { Toast.makeText(MainActivity.this, getString(R.string.no_secret_code), Toast.LENGTH_SHORT).show(); return;//from www. jav a 2s . c om } sendEmail(secretCodes); }