List of usage examples for java.util List toArray
Object[] toArray();
From source file:com.tr8n.core.Utils.java
/** * /*from ww w . j a v a 2s .c o m*/ * @param objects * @param joiner * @return */ @SuppressWarnings("rawtypes") public static String join(List objects, String joiner) { return join(objects.toArray(), joiner); }
From source file:de.tudarmstadt.ukp.dkpro.core.testing.IOTestRunner.java
public static void testOneWay2(Class<? extends CollectionReader> aReader, Class<? extends AnalysisComponent> aWriter, String aExpectedFile, String aOutputFile, String aFile, Object... aExtraParams) throws Exception { String outputFolder = aReader.getSimpleName() + "-" + FilenameUtils.getBaseName(aFile); if (DkproTestContext.get() != null) { outputFolder = DkproTestContext.get().getTestOutputFolderName(); }//from ww w. j a v a 2 s . c om File reference = new File("src/test/resources/" + aExpectedFile); File input = new File("src/test/resources/" + aFile); File output = new File("target/test-output/" + outputFolder); List<Object> extraReaderParams = new ArrayList<>(); extraReaderParams.add(ComponentParameters.PARAM_SOURCE_LOCATION); extraReaderParams.add(input); extraReaderParams.addAll(asList(aExtraParams)); CollectionReaderDescription reader = createReaderDescription(aReader, extraReaderParams.toArray()); List<Object> extraWriterParams = new ArrayList<>(); if (!ArrayUtils.contains(aExtraParams, ComponentParameters.PARAM_TARGET_LOCATION)) { extraWriterParams.add(ComponentParameters.PARAM_TARGET_LOCATION); extraWriterParams.add(output); } extraWriterParams.add(ComponentParameters.PARAM_STRIP_EXTENSION); extraWriterParams.add(true); extraWriterParams.addAll(asList(aExtraParams)); AnalysisEngineDescription writer = createEngineDescription(aWriter, extraWriterParams.toArray()); runPipeline(reader, writer); String expected = FileUtils.readFileToString(reference, "UTF-8"); String actual = FileUtils.readFileToString(new File(output, aOutputFile), "UTF-8"); assertEquals(expected.trim(), actual.trim()); }
From source file:Main.java
/** * Transform a multidimensional array into a one-dimensional list. * * @param array Array (possibly multidimensional). * @return a list of all the {@code Object} instances contained in * {@code array}.// ww w. ja v a2 s . com */ public static Object[] flatten(Object[] array) { final List<Object> list = new ArrayList<Object>(); if (array != null) { for (Object o : array) { if (o instanceof Object[]) { for (Object oR : flatten((Object[]) o)) { list.add(oR); } } else { list.add(o); } } } return list.toArray(); }
From source file:com.zb.app.external.lucene.solr.utils.BaseSolrQueryConvert.java
protected static SolrQuery createSearchQuery(List<String> params, List<String> fiters, SearchQuery searchQuery) {/*from w w w . j a va2s .c o m*/ SolrQuery solrQuery = new SolrQuery(); String query = null; if (Argument.isEmpty(params)) { query = ("*:*"); } else { query = StringUtils.join(params, " AND "); if (!StringUtils.join(params.toArray()).contains("*")) { solrQuery.setRequestHandler("/browse"); } } if (Argument.isNotEmpty(fiters)) { solrQuery.setFilterQueries(StringUtils.join(fiters, " AND ")); } solrQuery.setQuery(query); solrQuery.setStart(searchQuery.getStart()); solrQuery.setRows(searchQuery.getRows()); if (StringUtils.isNotBlank(searchQuery.getSortFiled())) { solrQuery.addSort(searchQuery.getSortFiled(), searchQuery.getOrderBy()); } return solrQuery; }
From source file:com.mmj.app.lucene.solr.utils.BaseSolrQueryConvert.java
protected static SolrQuery createSearchQuery(List<String> params, List<String> fiters, SearchQuery searchQuery, String... searchHandler) { SolrQuery solrQuery = new SolrQuery(); String query = null;/*from w w w .jav a 2 s.com*/ if (Argument.isEmpty(params)) { query = ("*:*"); } else { query = StringUtils.join(params, " AND "); if (!StringUtils.join(params.toArray()).contains("*")) { if (Argument.isNotEmptyArray(searchHandler)) { solrQuery.setRequestHandler( StringUtils.isEmpty(searchHandler[0]) ? "/select" : searchHandler[0]); } } } if (Argument.isNotEmpty(fiters)) { solrQuery.setFilterQueries(StringUtils.join(fiters, " AND ")); } solrQuery.setQuery(query); solrQuery.setStart(searchQuery.getStart()); solrQuery.setRows(searchQuery.getRows()); if (StringUtils.isNotBlank(searchQuery.getSortFiled())) { solrQuery.addSort(searchQuery.getSortFiled(), searchQuery.getOrderBy()); } return solrQuery; }
From source file:com.gst.infrastructure.reportmailingjob.data.ReportMailingJobEmailAttachmentFileFormat.java
/** * @return list of valid ReportMailingJobEmailAttachmentFileFormat values **//*from ww w .ja v a 2 s . com*/ public static Object[] validIds() { List<Object> validValues = new ArrayList<>(); for (ReportMailingJobEmailAttachmentFileFormat constant : ReportMailingJobEmailAttachmentFileFormat .values()) { if (constant.isValid()) { validValues.add(constant.id); } } return validValues.toArray(); }
From source file:com.gst.infrastructure.reportmailingjob.data.ReportMailingJobStretchyReportParamDateOption.java
/** * @return list of valid ReportMailingJobStretchyReportParamDateOption values **///from w ww. j a v a 2 s. c o m public static Object[] validValues() { List<Object> validValues = new ArrayList<>(); for (ReportMailingJobStretchyReportParamDateOption constant : ReportMailingJobStretchyReportParamDateOption .values()) { if (constant.isValid()) { validValues.add(constant.value); } } return validValues.toArray(); }
From source file:com.gst.infrastructure.reportmailingjob.data.ReportMailingJobEmailAttachmentFileFormat.java
/** * @return list of valid ReportMailingJobEmailAttachmentFileFormat values **///from www . j ava 2 s . com public static Object[] validValues() { List<Object> validValues = new ArrayList<>(); for (ReportMailingJobEmailAttachmentFileFormat constant : ReportMailingJobEmailAttachmentFileFormat .values()) { if (constant.isValid()) { validValues.add(constant.value); } } return validValues.toArray(); }
From source file:me.neatmonster.spacertk.PanelListener.java
/** * Interprets a raw command from the panel * @param string input from panel/* www . j ava2 s. co m*/ * @return result of the action * @throws InvalidArgumentsException Thrown when the wrong arguments are used by the panel * @throws UnhandledActionException Thrown when there is no handler for the action */ @SuppressWarnings("unchecked") private static Object interpret(final String string) throws InvalidArgumentsException, UnhandledActionException { final int indexOfMethod = string.indexOf("?method="); final int indexOfArguments = string.indexOf("&args="); final int indexOfKey = string.indexOf("&key="); final String method = string.substring(indexOfMethod + 8, indexOfArguments); final String argumentsString = string.substring(indexOfArguments + 6, indexOfKey); final List<Object> arguments = (List<Object>) JSONValue.parse(argumentsString); try { if (SpaceRTK.getInstance().actionsManager.contains(method)) return SpaceRTK.getInstance().actionsManager.execute(method, arguments.toArray()); } catch (final InvalidArgumentsException e) { e.printStackTrace(); } catch (final UnhandledActionException e) { e.printStackTrace(); } return null; }
From source file:me.neatmonster.spacertk.PanelListener.java
/** * Interprets a raw command from the panel (multiple) * @param string input from panel/*from w ww .j a v a2s . co m*/ * @return result of the action * @throws InvalidArgumentsException Thrown when the wrong arguments are used by the panel * @throws UnhandledActionException Thrown when there is no handler for the action */ @SuppressWarnings("unchecked") private static Object interpretm(final String string) throws InvalidArgumentsException, UnhandledActionException { final int indexOfMethod = string.indexOf("?method="); final int indexOfArguments = string.indexOf("&args="); final int indexOfKey = string.indexOf("&key="); final String methodString = string.substring(indexOfMethod + 8, indexOfArguments); final String argumentsString = string.substring(indexOfArguments + 6, indexOfKey); final List<Object> methods = (List<Object>) JSONValue.parse(methodString); final List<Object> arguments = (List<Object>) JSONValue.parse(argumentsString); final List<Object> result = (List<Object>) JSONValue.parse("[]"); for (int i = 0; i < methods.size(); i++) { String argsString = arguments.toArray()[i].toString(); List<Object> args = (List<Object>) JSONValue.parse(argsString); try { if (SpaceRTK.getInstance().actionsManager.contains(methods.toArray()[i].toString())) result.add(SpaceRTK.getInstance().actionsManager.execute(methods.toArray()[i].toString(), args.toArray())); } catch (final InvalidArgumentsException e) { result.add(null); e.printStackTrace(); } catch (final UnhandledActionException e) { result.add(null); e.printStackTrace(); } } return result; }