List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:se.inera.axel.shs.broker.routing.internal.DefaultShsRouter.java
@Override synchronized public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent) { ListableBeanFactory beanFactory = (ListableBeanFactory) event.getSource(); Map pluginMap = BeanFactoryUtils.beansOfTypeIncludingAncestors(beanFactory, ShsPluginRegistration.class); ArrayList<ShsPluginRegistration> pluginRegistrations = new ArrayList<ShsPluginRegistration>(); pluginRegistrations.addAll(pluginMap.values()); for (ShsPluginRegistration reg : pluginRegistrations) { log.info("Registered plugin '" + reg.getName() + "' from the application context"); }//from w w w . j av a 2s . c om if (!pluginRegistrations.isEmpty()) { setPluginRegistrations(pluginRegistrations); } } }
From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBDelegate.java
public static boolean areGSIsSameConfiguration(List<GlobalSecondaryIndexDescription> g1, List<GlobalSecondaryIndexDescription> g2) { if (g1 == null) { if (g2 == null) { return true; }// w w w . j a v a 2 s. c o m return false; } if (g1.size() != g2.size()) { return false; } // make copy of the lists because we don't want to mutate the lists ArrayList<GlobalSecondaryIndexDescription> g1clone = new ArrayList<>(g1.size()); g1clone.addAll(g1); ArrayList<GlobalSecondaryIndexDescription> g2clone = new ArrayList<>(g2.size()); g1clone.addAll(g2); for (GlobalSecondaryIndexDescription gi1 : g1) { for (GlobalSecondaryIndexDescription gi2 : g2) { if (areGSIsSameConfiguration(gi1, gi2)) { g1clone.remove(gi1); g2clone.remove(gi2); break; } } } return g1clone.isEmpty() || g2clone.isEmpty(); }
From source file:com.atinternet.tracker.Builder.java
private Param getRefOrRefstoreParam(String key, ArrayList<Param> completeBuffer) { Param ref = null;//from w w w . j av a2 s . com ArrayList<int[]> refParamPositions = Tool.findParameterPosition(key, completeBuffer); int indexRef = refParamPositions.isEmpty() ? -1 : refParamPositions.get(refParamPositions.size() - 1)[1]; if (indexRef != -1) { ref = completeBuffer.remove(indexRef); if (ref.getOptions() != null && ref.getOptions().getRelativePosition() != last && ref.getOptions().getRelativePosition() != none) { Tool.executeCallback(tracker.getListener(), CallbackType.warning, key + "= parameter will be put in last position"); } } return ref; }
From source file:edu.temple.cis3238.wiki.vo.TopicVO.java
/** * * @param _topicID//from ww w. j av a 2 s. co m * @param _topicName * @param _topicContent * @param _topicCreated * @param _topicModified * @param _revisions * @param _tagsCollection * @param _topicHistoryCollection */ public TopicVO(int _topicID, String _topicName, String _topicContent, String _topicCreated, String _topicModified, int _revisions, ArrayList<TagsVO> _tagsCollection, ArrayList<TopicHistoryVO> _topicHistoryCollection) { this.topicID = _topicID; this.topicName = _topicName; this.topicContent = _topicContent; this.topicCreated = _topicCreated; this.topicModified = _topicModified; this.revisions = _revisions; if (_tagsCollection != null && !_tagsCollection.isEmpty()) { try { this.tagsCollection = new CopyOnWriteArrayList<TagsVO>(_tagsCollection); } catch (Exception e) { } } this.topicHistoryCollection = _topicHistoryCollection; }
From source file:clipboardplugin.ClipboardPlugin.java
public ProgramReceiveTarget[] getProgramReceiveTargets() { ArrayList<ProgramReceiveTarget> list = new ArrayList<ProgramReceiveTarget>(); for (AbstractPluginProgramFormating config : mConfigs) { if (config != null && config.isValid()) { list.add(new ProgramReceiveTarget(this, config.getName(), config.getId())); }/*from ww w . j a va 2 s . c o m*/ } if (list.isEmpty()) { list.add(new ProgramReceiveTarget(this, DEFAULT_CONFIG.getName(), DEFAULT_CONFIG.getId())); } return list.toArray(new ProgramReceiveTarget[list.size()]); }
From source file:com.infinity.controller.ElasticController.java
@RequestMapping(value = { "/elastic/get/{id}" }) public ModelAndView getCandidat(@PathVariable String id) throws IOException { ModelAndView mv = new ModelAndView("elastic"); CandidatEnum candidatEnum = new CandidatEnum(); Candidat byId = candidatService.getById(id); if (byId == null) { mv.addObject("noCandidat", true); } else {/*www. j a v a2 s . co m*/ byId.setId(id); float nbYearExp = 0; ArrayList<Experiences> byId1 = expService.getByIdSearhText(id); for (Experiences byId11 : byId1) { float duration = byId11.getDuration(); nbYearExp += duration; } byId.setNbYearExp(nbYearExp); ArrayList<Comments> commentsList = commentsService.getByCandidatId(id); ArrayList<School> schoolList = schoolService.getByIdSearhText(id); if (!byId1.isEmpty()) { mv.addObject("exp", byId1); } else { LOG.debug("no exp found for {}", id); } mv.addObject("candidat", byId); mv.addObject("status", candidatEnum.getStatusList()); mv.addObject("comments", commentsList); mv.addObject("school", schoolList); } return mv; }
From source file:gr.iit.demokritos.cru.cps.ai.ComputationalCreativityMetrics.java
public double Surprise(String new_frag, ArrayList<String> frags) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { //split the story in fragments (sentences) if (frags.isEmpty()) { return 0.0; }//from www . j av a 2 s . c o m double dist = 0; //calculate AvgSemDist for the first fragment HashMap<ArrayList<String>, Double> top = inf.TopTerms(frags.get(0), false); double older = 0.0; Set<String> terms = new HashSet<String>(); if (!top.isEmpty()) { //cumpute the average semantic distance of this fragment for (ArrayList<String> stems : top.keySet()) { //if it is in compact form , there is only one term for each stem for (int j = 0; j < stems.size(); j++) { terms.add(stems.get(j)); } } older = AvgSemDist(terms); } double newer = 0.0; //put the new story as the last fragment if (new_frag.length() > 0) { frags.add(new_frag); } //frags.remove(0);//fragment 0 is already calculated for (int i = 1; i < frags.size(); i++) { //calculate AvgSemDist for every fragment top = inf.TopTerms(frags.get(i), false); if (top.isEmpty()) { //if the framgent has only stopwords, it has 0.0 avg sem distance //newer = 0.0; //if the fragment had only stopoff words, step it continue; } else { terms = new HashSet<String>(); //cumpute the average semantic distance of this story for (ArrayList<String> stems : top.keySet()) { //if it is in compact form , there is only one term for each stem for (int j = 0; j < stems.size(); j++) { terms.add(stems.get(j)); } } newer = AvgSemDist(terms); //System.out.println(newer); } //and abstract it with the previous dist += abs(older - newer);// / top.size(); //the new becomes the older to be abstracted with the next fragment older = newer; } //calculate the final formula double sur = 0.0; if (dist != 0) { sur = dist * 2 / (frags.size() - 1); } return sur; }
From source file:com.phicomm.account.network.NetworkConnectionImpl.java
/** * Call the webservice using the given parameters to construct the request and return the * result.// ww w .j a v a 2s.c o m * * @param context The context to use for this operation. Used to generate the user agent if * needed. * @param urlValue The webservice URL. * @param method The request method to use. * @param parameterList The parameters to add to the request. * @param headerMap The headers to add to the request. * @param isGzipEnabled Whether the request will use gzip compression if available on the * server. * @param userAgent The user agent to set in the request. If null, a default Android one will be * created. * @param postText The POSTDATA text to add in the request. * @param credentials The credentials to use for authentication. * @param isSslValidationEnabled Whether the request will validate the SSL certificates. * @return The result of the webservice call. */ public static ConnectionResult execute(Context context, String urlValue, Method method, ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled, String userAgent, String postText, UsernamePasswordCredentials credentials, boolean isSslValidationEnabled) throws ConnectionException { Thread.dumpStack(); Log.i("ss", "NetworkConnectionImpl_____________________________________execute__urlValue:" + urlValue); HttpURLConnection connection = null; try { // Prepare the request information if (userAgent == null) { userAgent = UserAgentUtils.get(context); } if (headerMap == null) { headerMap = new HashMap<String, String>(); } headerMap.put(HTTP.USER_AGENT, userAgent); if (isGzipEnabled) { headerMap.put(ACCEPT_ENCODING_HEADER, "gzip"); } headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET); if (credentials != null) { headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials)); } StringBuilder paramBuilder = new StringBuilder(); if (parameterList != null && !parameterList.isEmpty()) { for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String name = parameter.getName(); String value = parameter.getValue(); if (TextUtils.isEmpty(name)) { // Empty parameter name. Check the next one. continue; } if (value == null) { value = ""; } paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET)); paramBuilder.append("="); paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET)); paramBuilder.append("&"); } } // Log the request if (true) { Log.d(TAG, "Request url: " + urlValue); Log.d(TAG, "Method: " + method.toString()); if (parameterList != null && !parameterList.isEmpty()) { Log.d(TAG, "Parameters:"); for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\""; Log.d(TAG, message); } Log.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\""); } if (postText != null) { Log.d(TAG, "Post data: " + postText); } if (headerMap != null && !headerMap.isEmpty()) { Log.d(TAG, "Headers:"); for (Entry<String, String> header : headerMap.entrySet()) { Log.d(TAG, "- " + header.getKey() + " = " + header.getValue()); } } } // Create the connection object URL url = null; String outputText = null; switch (method) { case GET: case DELETE: String fullUrlValue = urlValue; if (paramBuilder.length() > 0) { fullUrlValue += "?" + paramBuilder.toString(); } url = new URL(fullUrlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); break; case PUT: case POST: url = new URL(urlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); connection.setDoOutput(true); if (paramBuilder.length() > 0) { outputText = paramBuilder.toString(); headerMap.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length)); } else if (postText != null) { outputText = postText; } break; } // Set the request method connection.setRequestMethod(method.toString()); // If it's an HTTPS request and the SSL Validation is disabled if (url.getProtocol().equals("https") && !isSslValidationEnabled) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory()); httpsConnection.setHostnameVerifier(getAllHostsValidVerifier()); } // Add the headers if (!headerMap.isEmpty()) { for (Entry<String, String> header : headerMap.entrySet()) { connection.addRequestProperty(header.getKey(), header.getValue()); } } // Set the connection and read timeout connection.setConnectTimeout(OPERATION_TIMEOUT); connection.setReadTimeout(OPERATION_TIMEOUT); // Set the outputStream content for POST and PUT requests if ((method == Method.POST || method == Method.PUT) && outputText != null) { OutputStream output = null; try { output = connection.getOutputStream(); output.write(outputText.getBytes()); } finally { if (output != null) { try { output.close(); } catch (IOException e) { // Already catching the first IOException so nothing to do here. } } } } String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING); int responseCode = connection.getResponseCode(); boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip"); Log.d(TAG, "Response code: " + responseCode); if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) { String redirectionUrl = connection.getHeaderField(LOCATION_HEADER); throw new ConnectionException("New location : " + redirectionUrl, redirectionUrl); } InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String error = convertStreamToString(errorStream, isGzip); throw new ConnectionException(error, responseCode); } String body = convertStreamToString(connection.getInputStream(), isGzip); if (true) { Log.v(TAG, "Response body: "); int pos = 0; int bodyLength = body.length(); while (pos < bodyLength) { Log.v(TAG, body.substring(pos, Math.min(bodyLength - 1, pos + 200))); pos = pos + 200; } } return new ConnectionResult(connection.getHeaderFields(), body); } catch (IOException e) { Log.e(TAG, "IOException", e); throw new ConnectionException(e); } catch (KeyManagementException e) { Log.e(TAG, "KeyManagementException", e); throw new ConnectionException(e); } catch (NoSuchAlgorithmException e) { Log.e(TAG, "NoSuchAlgorithmException", e); throw new ConnectionException(e); } finally { if (connection != null) { connection.disconnect(); } } }
From source file:org.restheart.test.performance.LoadGetPT.java
/** * */// w w w . j a va 2 s. c o m public void dbdirect() { final Database dbsDAO = new DbsDAO(); DBCollection dbcoll = dbsDAO.getCollection(db, coll); Deque<String> _filter; if (filter == null) { _filter = null; } else { _filter = new ArrayDeque<>(); _filter.add(filter); } ArrayList<DBObject> data; try { data = new DbsDAO().getCollectionData(dbcoll, page, pagesize, null, _filter, DBCursorPool.EAGER_CURSOR_ALLOCATION_POLICY.NONE); } catch (Exception e) { System.out.println("error: " + e.getMessage()); return; } assertNotNull(data); assertFalse(data.isEmpty()); if (printData) { System.out.println(data); } }
From source file:eionet.cr.dao.virtuoso.VirtuosoHarvestScriptDAO.java
@Override public List<HarvestScriptDTO> getScriptsByIds(List<Integer> ids) throws DAOException { ArrayList<HarvestScriptDTO> result = new ArrayList<HarvestScriptDTO>(); for (int id : ids) { result.add(fetch(id));//from w ww .jav a2 s . co m } return result.isEmpty() ? null : result; }