List of usage examples for java.util HashMap isEmpty
public boolean isEmpty()
From source file:ai.api.sample.MainActivity.java
@Override public void onResult(final AIResponse response) { runOnUiThread(new Runnable() { @Override//from w w w.ja va2s .c om public void run() { Log.d(TAG, "onResult"); //resultTextView.setText(gson.toJson(response.getResult())); Log.i(TAG, "Received success response"); // this is example how to get different parts of result object final Status status = response.getStatus(); Log.i(TAG, "Status code: " + status.getCode()); Log.i(TAG, "Status type: " + status.getErrorType()); final Result result = response.getResult(); Log.i(TAG, "Resolved query: " + result.getResolvedQuery()); //resultTextView.setBackgroundResource(R.drawable.background_border); //resultTextView.setText("You said: " + result.getResolvedQuery()); Log.i(TAG, "Action: " + result.getAction()); final String speech = result.getFulfillment().getSpeech(); Log.i(TAG, "Speech: " + speech); TTS.speak(speech, aiButton); if (speech.contains("remind") || speech.contains("schedule a meeting") || speech.contains("set up a meeting") || speech.contains("meeting") || speech.contains("appointment")) { //createCalendarEvent(); CalendarBuilderObject calendarObj = null; try { calendarObj = buildCalendarEvent(result.getParameters()); } catch (ParseException e) { e.printStackTrace(); } createCalendar(calendarObj); //setAlarm(); } //aiButton.onClick(); final Metadata metadata = result.getMetadata(); if (metadata != null) { Log.i(TAG, "Intent id: " + metadata.getIntentId()); Log.i(TAG, "Intent name: " + metadata.getIntentName()); } final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); } } } }); // aiButton.onClick(); // startActivity(AIButtonSampleActivity.class); }
From source file:org.cloudata.core.common.testhelper.FaultManager.java
private void internalClear(Class<?> c, String methodName) { synchronized (classFaultMap) { HashMap<String, Fault> faultMap = findFaultMap(c); if (faultMap != null) { faultMap.remove(methodName); if (faultMap.isEmpty()) { classFaultMap.remove(c); }//from w w w . j ava 2 s . c o m } classFaultMap.notifyAll(); } }
From source file:ru.apertum.qsystem.reports.model.AGenerator.java
/** * ? - ?? . ? ? ? IFormirovator ? ? . * * @param request ? (html, pdf, rtf) * @return ./*w ww . j a v a 2 s .c om*/ */ @Override public Response process(HttpRequest request) { QLog.l().logRep().debug(" : \"" + href + "\""); /* * . * ? ? ? ? ? . * ? ? . */ /* * ??: * * ? , ? ? * ? ? null, ??. ? ? ?? * , ? . * * ? ? ? null, * ? null ? ? getParameters(...) . * ? ??, - ? ? * ?? . */ //? ? final HashMap<String, String> params = NetUtil.getParameters(request); if (params.isEmpty()) { final Response dialog = getDialog(request, null); if (dialog != null) { return dialog; } } else { String err = validate(request, params); if (err != null) { final Response dialog = getDialog(request, err); if (dialog != null) { return dialog; } } } // ? ? final Response before = preparationReport(request); if (before != null) { return before; } // ?? , ?, ? //InputStream is = getClass().getResourceAsStream(template); //JasperReport jasperReport = JasperCompileManager.compileReport(is); // ?? //JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hm, xmlDataSource); - ? ? ? // ? , http String dataType = null; try { // , ?? final File f_temp = new File(template); final InputStream inStr; if (f_temp.exists()) { inStr = new FileInputStream(f_temp); } else { inStr = getClass().getResourceAsStream(template); } if (inStr == null) { throw new ReportException(" . \"" + template + "\" ?? , ? ? ."); } // ?, ? //? ? , ? , . final Connection conn = getConnection(request); final Map paramsForFilling = getParameters(request); paramsForFilling.put(JRParameter.REPORT_LOCALE, Locales.getInstance().getLangCurrent()); final JasperPrint jasperPrint; if (conn == null) { jasperPrint = JasperFillManager.fillReport(inStr, paramsForFilling, getDataSource(request));//? ?? } else { jasperPrint = JasperFillManager.fillReport(inStr, paramsForFilling, conn);//? ?? } byte[] result = null; final String subject = NetUtil.getUrl(request); int dot = subject.lastIndexOf("."); final String format = subject.substring(dot + 1); final File ff = new File(Uses.TEMP_FOLDER); if (!ff.exists()) { ff.mkdir(); } if (Uses.REPORT_FORMAT_HTML.equalsIgnoreCase(format)) { final JRHtmlExporter exporter = new JRHtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); // ? // ? ? , ? ?? ? html ??? , , // ?? ? ? ? ? . // ? ? ? ? ? . final JRHtmlExporter exporterToTempFile = new JRHtmlExporter(); exporterToTempFile.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporterToTempFile.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, Uses.TEMP_FOLDER + File.separator + "temphtml.html"); exporterToTempFile.exportReport(); final StringBuffer buf = new StringBuffer("UTF-8"); exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, buf); exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8"); exporter.exportReport(); result = buf.toString().replaceAll("nullpx", "resources/px") .replaceFirst("<body text=\"#000000\"", "<body text=\"#000000\" background=\"resources/fp.png\" bgproperties=\"fixed\"") .replaceAll("bgcolor=\"white\"", "bgcolor=\"CCDDEE\"").replaceAll("nullimg_", "img_") .getBytes("UTF-8"); dataType = "text/html"; } else if (Uses.REPORT_FORMAT_RTF.equalsIgnoreCase(format)) { final JRRtfExporter exporter = new JRRtfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); result = baos.toByteArray(); dataType = "application/rtf"; } else if (Uses.REPORT_FORMAT_XLSX.equalsIgnoreCase(format)) { //final JROdsExporter exporter = new JROdsExporter(); final JRXlsxExporter exporter = new JRXlsxExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); result = baos.toByteArray(); //dataType = "application/ods"; dataType = "application/xlsx"; } else if (Uses.REPORT_FORMAT_PDF.equalsIgnoreCase(format)) { // ? ? ? final File f = new File("tahoma.ttf"); if (!f.exists()) { try (FileOutputStream fo = new FileOutputStream(f)) { final InputStream inStream = getClass() .getResourceAsStream("/ru/apertum/qsystem/reports/fonts/tahoma.ttf"); final byte[] b = Uses.readInputStream(inStream); fo.write(b); fo.flush(); } } result = genPDF(jasperPrint); dataType = "application/pdf"; } return new Response(result, dataType); } catch (FileNotFoundException ex) { throw new ReportException( "? ? PDF. " + ex); } catch (IOException ex) { throw new ReportException( " ? /. " + ex); } catch (JRException ex) { throw new ReportException(" . " + ex); } }
From source file:com.example.android.tvleanback2.ui.MainFragment.java
@Override public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0, HashMap<String, List<Movie>> data) { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); CardPresenter cardPresenter = new CardPresenter(); int index = 0; if (null != data && !data.isEmpty()) { for (Map.Entry<String, List<Movie>> entry : data.entrySet()) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); List<Movie> list = entry.getValue(); for (int j = 0; j < list.size(); j++) { listRowAdapter.add(list.get(j)); }// ww w .j a v a 2 s.c o m HeaderItem header = new HeaderItem(index, entry.getKey()); index++; mRowsAdapter.add(new ListRow(header, listRowAdapter)); } } else { Log.e(TAG, "An error occurred fetching videos"); Toast.makeText(getActivity(), R.string.videos_loading_error, Toast.LENGTH_LONG).show(); } HeaderItem gridHeader = new HeaderItem(index, getString(R.string.more_samples)); GridItemPresenter gridPresenter = new GridItemPresenter(this); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter); gridRowAdapter.add(getString(R.string.grid_view)); gridRowAdapter.add(getString(R.string.guidedstep_first_title)); gridRowAdapter.add(getString(R.string.error_fragment)); gridRowAdapter.add(getString(R.string.personal_settings)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); updateRecommendations(); startEntranceTransition(); }
From source file:org.goobi.api.display.helper.ConfigDisplayRules.java
/** * Get items by name and type./*from w w w . j a v a 2 s.co m*/ * * @param myproject * name of project as String * @param mybind * create or edit * @param myelementName * name of the element * @param mydisplayType * type of the element * @return ArrayList with all values of given element */ public List<Item> getItemsByNameAndType(String myproject, String mybind, String myelementName, DisplayType mydisplayType) { List<Item> values = new ArrayList<>(); synchronized (this.allValues) { if (this.allValues.isEmpty() && config != null) { getDisplayItems(); } else if (config == null) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, HashMap<String, HashMap<String, ArrayList<Item>>>> bind = this.allValues.get(myproject); if (bind.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, HashMap<String, ArrayList<Item>>> itemsByType = bind.get(mybind); if (itemsByType.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, ArrayList<Item>> typeList = itemsByType.get(mydisplayType.getTitle()); if (typeList.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } values = typeList.get(myelementName); if (values.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } } return values; }
From source file:org.apache.hadoop.hive.ql.parse.spark.SparkCompiler.java
@Override protected void setInputFormat(Task<? extends Serializable> task) { if (task instanceof SparkTask) { SparkWork work = ((SparkTask) task).getWork(); List<BaseWork> all = work.getAllWork(); for (BaseWork w : all) { if (w instanceof MapWork) { MapWork mapWork = (MapWork) w; HashMap<String, Operator<? extends OperatorDesc>> opMap = mapWork.getAliasToWork(); if (!opMap.isEmpty()) { for (Operator<? extends OperatorDesc> op : opMap.values()) { setInputFormat(mapWork, op); }//from w ww .j av a 2 s .com } } } } else if (task instanceof ConditionalTask) { List<Task<? extends Serializable>> listTasks = ((ConditionalTask) task).getListTasks(); for (Task<? extends Serializable> tsk : listTasks) { setInputFormat(tsk); } } if (task.getChildTasks() != null) { for (Task<? extends Serializable> childTask : task.getChildTasks()) { setInputFormat(childTask); } } }
From source file:org.mskcc.cbio.portal.dao.DaoGeneticAlteration.java
/** * Gets a HashMap of Values, keyed by Sample ID. * @param geneticProfileId Genetic Profile ID. * @param entrezGeneId Entrez Gene ID. * @return HashMap of values, keyed by Sample ID. * @throws DaoException Database Error.//from w w w.java 2 s.c om */ public HashMap<Integer, String> getGeneticAlterationMap(int geneticProfileId, long entrezGeneId) throws DaoException { HashMap<Long, HashMap<Integer, String>> map = getGeneticAlterationMap(geneticProfileId, Collections.singleton(entrezGeneId)); if (map.isEmpty()) { return new HashMap<Integer, String>(); } return map.get(entrezGeneId); }
From source file:org.goobi.api.display.helper.ConfigDispayRules.java
/** * Get items by name and type.//from w w w .j av a 2 s . c o m * * @param myproject * name of project as String * @param mybind * create or edit * @param myelementName * name of the element * @param mydisplayType * type of the element * @return ArrayList with all values of given element */ public ArrayList<Item> getItemsByNameAndType(String myproject, String mybind, String myelementName, DisplayType mydisplayType) { ArrayList<Item> values = new ArrayList<>(); synchronized (this.allValues) { if (this.allValues.isEmpty() && config != null) { getDisplayItems(); } else if (config == null) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, HashMap<String, HashMap<String, ArrayList<Item>>>> bind = this.allValues.get(myproject); if (bind.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, HashMap<String, ArrayList<Item>>> itemsByType = bind.get(mybind); if (itemsByType.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } HashMap<String, ArrayList<Item>> typeList = itemsByType.get(mydisplayType.getTitle()); if (typeList.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } values = typeList.get(myelementName); if (values.isEmpty()) { values.add(new Item(myelementName, "", false)); return values; } } return values; }
From source file:org.pentaho.platform.plugin.services.webservices.content.HtmlAxisServiceLister.java
/** * Writes the HTML page title area//from w w w . j ava2 s . co m * * @param serviceMap * Map of current web services * @param sb * StringBuilder to write content to */ @SuppressWarnings("unchecked") protected void getPageTitle(HashMap serviceMap, StringBuilder sb) { // write out the page title sb.append("<div id=\"webservicediv\">"); //$NON-NLS-1$ sb.append("<h1>").append(Messages.getInstance().getString("ListServices.USER_WEB_SERVICES")) .append("</h1>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (serviceMap.isEmpty()) { // there are no services defined sb.append(Messages.getInstance().getString("ListServices.USER_NO_SERVICES")); //$NON-NLS-1$ } }
From source file:org.akaza.openclinica.control.submit.VerifyImportedCRFDataServlet.java
private List<String> extractRuleActionWarnings(HashMap<String, ArrayList<String>> summaryMap) { List<String> messages = new ArrayList<String>(); if (summaryMap != null && !summaryMap.isEmpty()) { for (String key : summaryMap.keySet()) { StringBuilder mesg = new StringBuilder(key + " : "); for (String s : summaryMap.get(key)) { mesg.append(s + ", "); }//from w ww. j a v a 2 s . co m messages.add(mesg.toString()); } } return messages; }