List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:de.mpg.mpdl.inge.reporting.ReportFHI.java
/** * Generate month report files (formats are specified in properties) * /*from w w w .j a v a2 s . c om*/ * @throws JRException * @return list of paths to the generated reports */ public static String[] generateReport() throws JRException { String[] formats = rprops.getProperty("FHI.report.formats").split(","); // GET REPORT FROM JRXMLs // compile subreports // JasperCompileManager.compileReportToFile("src/main/resources/subreport_creators.jrxml"); // get main report JasperReport jr = null; JasperDesign jd; jd = JRXmlLoader.load(JRLoader.getLocationInputStream("FHI_Bibilothek_report.jrxml")); jr = JasperCompileManager.compileReport(jd); if (jr == null) { throw new RuntimeException("Compiled report is null: " + "FHI_Bibilothek_report.jrxml"); } Document doc = getXmlDataSource(); Map<String, Object> params = new HashMap<String, Object>(); params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, doc); // fill report in memory JasperPrint jasperPrint; jasperPrint = JasperFillManager.fillReport(jr, params, new JRXmlDataSource(doc, jr.getQuery().getText())); ArrayList<String> atts = new ArrayList<String>(); String fn; // save in files in formats for (String f : formats) { if ("pdf".equalsIgnoreCase(f)) { JRPdfExporter pdfExp = new JRPdfExporter(); pdfExp.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); fn = "FHI_Bibilothek_report.pdf"; pdfExp.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, fn); pdfExp.exportReport(); atts.add(fn); } else if ("rtf".equalsIgnoreCase(f)) { JRRtfExporter rtfExp = new JRRtfExporter(); rtfExp.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); fn = "FHI_Bibilothek_report.rtf"; rtfExp.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, fn); rtfExp.exportReport(); atts.add(fn); } } return atts.toArray(new String[atts.size()]); }
From source file:com.digitalpebble.storm.crawler.Metadata.java
public void addValues(String key, Collection<String> values) { if (values == null || values.size() == 0) return;/*from www .j av a 2 s .com*/ String[] existingvals = md.get(key); if (existingvals == null) { md.put(key, values.toArray(new String[values.size()])); return; } ArrayList<String> existing = new ArrayList<String>(existingvals.length + values.size()); for (String v : existingvals) existing.add(v); existing.addAll(values); md.put(key, existing.toArray(new String[existing.size()])); }
From source file:de.topicmapslab.tmcledit.model.psiprovider.internal.Subj3ctPSIProvider.java
public Set<PSIProviderResult> getSubjectIdentifier() { if (getName().length() == 0) return Collections.emptySet(); HttpMethod method = null;/*from www .jav a 2s .c o m*/ try { String url = "http://api.subj3ct.com/subjects/search"; HttpClient client = new HttpClient(); method = new GetMethod(url); ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(2); params.add(new NameValuePair("format", "xml")); params.add(new NameValuePair("query", getName())); method.setQueryString(params.toArray(new NameValuePair[params.size()])); client.getParams().setSoTimeout(5000); client.executeMethod(method); String result = method.getResponseBodyAsString(); SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); Subj3ctXmlHandler handler = new Subj3ctXmlHandler(); parser.parse(new InputSource(new StringReader(result)), handler); List<Subje3ctResult> resultList = handler.getResultList(); if (resultList.size() == 0) { return Collections.emptySet(); } Set<PSIProviderResult> resultSet = new HashSet<PSIProviderResult>(resultList.size()); for (Subje3ctResult r : resultList) { String description = ""; if (r.name != null) description = "Name: " + r.name + "\n"; if (r.description != null) description += "Description: " + r.description + "\n"; description += "\n\nThis service is provided by http://www.subj3ct.com"; resultSet.add(new PSIProviderResult(r.identifier, description)); } return Collections.unmodifiableSet(resultSet); } catch (UnknownHostException e) { // no http connection -> no results TmcleditEditPlugin.logInfo(e); return Collections.emptySet(); } catch (SocketTimeoutException e) { // timeout -> no results TmcleditEditPlugin.logInfo(e); return Collections.emptySet(); } catch (Exception e) { throw new RuntimeException(e); } finally { if (method != null) method.releaseConnection(); } }
From source file:com.tealeaf.AppFinder.java
private void createAdapter(final TestAppActivity activity, final ArrayList<AppInfo> appInfos, final String host, final int port) { handler.post(new Runnable() { public void run() { AppInfo[] appArr = appInfos.toArray(new AppInfo[appInfos.size()]); adapter = new AppAdapter(activity, R.layout.appview, appArr, host, port); activity.appListView.setAdapter(adapter); apps = appInfos;//w w w. j a v a2 s. c o m } }); }
From source file:gdt.data.entity.facet.ExtensionHandler.java
private static FacetHandler[] listExtensionHandlers(Entigrator entigrator, String extension$) { try {/*ww w .j a v a 2 s .c om*/ System.out.println("ExtesionHandler:listExtensionHandlers:extension=" + extension$); Sack extension = entigrator.getEntityAtKey(extension$); String lib$ = extension.getElementItemAt("field", "lib"); String[] sa = extension.elementList("content.fhandler"); if (sa == null) return null; ArrayList<FacetHandler> fl = new ArrayList<FacetHandler>(); FacetHandler fh; Class<?> cls; String jar$ = "jar:file:" + entigrator.getEntihome() + "/" + extension$ + "/" + lib$ + "!/"; URL[] urls = { new URL(jar$) }; URLClassLoader cl = URLClassLoader.newInstance(urls); for (String aSa : sa) { try { // System.out.println("ExtesionHandler:listExtensionHandlers:jar="+jar$); cls = cl.loadClass(aSa); fh = (FacetHandler) cls.newInstance(); fl.add(fh); } catch (Exception ee) { Logger.getLogger(ExtensionHandler.class.getName()).severe("load class: " + ee.toString()); } } return fl.toArray(new FacetHandler[0]); } catch (Exception e) { Logger.getLogger(ExtensionHandler.class.getName()).severe(e.toString()); return null; } }
From source file:com.jgeppert.struts2.bootstrap.showcase.Languages.java
@Action(value = "/languages", results = { @Result(type = "json", name = "success", params = { "root", "languages" }) }) public String execute() throws Exception { if (term != null && term.length() > 1) { ArrayList<String> tmp = new ArrayList<String>(); for (String staticLanguage : staticLanguages) { if (StringUtils.contains(staticLanguage.toLowerCase(), term.toLowerCase())) { tmp.add(staticLanguage); }/*from w ww .j a v a2 s . c o m*/ } languages = tmp.toArray(new String[tmp.size()]); } return SUCCESS; }
From source file:edu.emory.library.tast.submission.SubmissionAttributes.java
private SubmissionAttributes() { System.out.println("***************************************************"); attributes = loadConfig();/*from ww w .j av a2s . c om*/ ArrayList tmp = new ArrayList(); for (int i = 0; i < attributes.length; i++) { if (attributes[i].isPublic()) { tmp.add(attributes[i]); } } attributesPublic = (SubmissionAttribute[]) tmp.toArray(new SubmissionAttribute[] {}); // attributes = new SubmissionAttribute[10]; // // attributes[0] = new SubmissionAttribute("shipname", Voyage.getAttribute("shipname"), "Name of ship", null, TextboxAdapter.TYPE); // attributes[1] = new SubmissionAttribute("datedep", Voyage.getAttribute("datedep"), "Departure date", null, DateAdapter.TYPE); // attributes[2] = new SubmissionAttribute("captaina", Voyage.getAttribute("captaina"), "First captain", null, TextboxAdapter.TYPE); // attributes[3] = new SubmissionAttribute("captainb", Voyage.getAttribute("captainb"), "Second captain", null, TextboxAdapter.TYPE); // attributes[4] = new SubmissionAttribute("portdep", Voyage.getAttribute("portdep"), "Port of departure", null, TextboxAdapter.TYPE); // attributes[5] = new SubmissionAttribute("arrport", Voyage.getAttribute("arrport"), "Port of arrival", null, TextboxAdapter.TYPE); // attributes[6] = new SubmissionAttribute("crew1", Voyage.getAttribute("crew1"), "Crew 1", null, TextboxIntegerAdapter.TYPE); // attributes[7] = new SubmissionAttribute("crew3", Voyage.getAttribute("crew3"), "Crew 2", null, TextboxIntegerAdapter.TYPE); // attributes[8] = new SubmissionAttribute("tonnage", Voyage.getAttribute("tonnage"), "Tonnage of vessel", null, TextboxFloatAdapter.TYPE); // attributes[9] = new SubmissionAttribute("guns", Voyage.getAttribute("guns"), "Guns", null, TextboxIntegerAdapter.TYPE); }
From source file:com.opengamma.util.test.DbTest.java
protected static Object[][] getParametersForSeparateMasters(int prevVersionCount) { String databaseType = System.getProperty("test.database.type"); if (databaseType == null) { databaseType = "all"; }/*from ww w.j a v a 2 s . c o m*/ Collection<String> databaseTypes = TestProperties.getDatabaseTypes(databaseType); ArrayList<Object[]> parameters = new ArrayList<Object[]>(); for (String dbType : databaseTypes) { DbTool dbtool = TestProperties.getDbTool(dbType); dbtool.setJdbcUrl(dbtool.getTestDatabaseUrl()); if (isScriptPublished()) { dbtool.addDbScriptDirectory(SCRIPT_INSTALL_DIR.getAbsolutePath()); } else { dbtool.addDbScriptDirectory(DbTool.getWorkingDirectory()); } for (String masterDB : dbtool.getScriptDirs().keySet()) { Set<Integer> versions = dbtool.getScriptDirs().get(masterDB).keySet(); int max = Collections.max(versions); int min = Collections.min(versions); for (int v = max; v >= Math.max(max - prevVersionCount, min); v--) { parameters.add(new Object[] { dbType, masterDB, "" + max /*target_version*/, "" + v /*migrate_from_version*/ }); } } } Object[][] array = new Object[parameters.size()][]; parameters.toArray(array); return array; }
From source file:com.espertech.esper.epl.view.OutputProcessViewConditionSnapshot.java
/** * Called once the output condition has been met. * Invokes the result set processor.//from ww w . j a v a 2 s . c om * Used for non-join event data. * @param doOutput - true if the batched events should actually be output as well as processed, false if they should just be processed * @param forceUpdate - true if output should be made even when no updating events have arrived * */ protected void continueOutputProcessingView(boolean doOutput, boolean forceUpdate) { if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) { log.debug(".continueOutputProcessingView"); } EventBean[] newEvents = null; EventBean[] oldEvents = null; Iterator<EventBean> it = this.iterator(); if (it.hasNext()) { ArrayList<EventBean> snapshot = new ArrayList<EventBean>(); for (EventBean bean : this) { snapshot.add(bean); } newEvents = snapshot.toArray(new EventBean[snapshot.size()]); oldEvents = null; } UniformPair<EventBean[]> newOldEvents = new UniformPair<EventBean[]>(newEvents, oldEvents); if (doOutput) { output(forceUpdate, newOldEvents); } }
From source file:de.fhg.iais.asc.oai.retriever.MetadataFormatsAndSetNamesRetriever.java
public String[] listMetadataFormats() { try {/*from w ww . jav a2 s .c o m*/ MetadataFormatsList metadataformatlist = this.server.listMetadataFormats(); if (metadataformatlist == null) { return new String[0]; } List<MetadataFormat> list = metadataformatlist.asList(); ArrayList<String> mda = new ArrayList<String>(); for (MetadataFormat mdf : list) { mda.add(mdf.getPrefix()); } LOG.debug("Metadataformats are " + mda); return mda.toArray(new String[mda.size()]); } catch (OAIException e) { throw new DbcException(e); } }