List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:coral.utils.Matching.java
/** * Shuffle the array for N==2 will produce alternating behaviour * // ww w .ja v a2 s. com * @param in * @param seed * @return */ public static Integer[] shuffle(Integer[] in, long seed) { int n = in.length; Integer[] out; List<Integer> l = Arrays.asList(in); Collections.shuffle(l, new Random((seed * 48271) % 2147483647)); out = l.toArray(new Integer[n]); return out; }
From source file:Main.java
public static String[] defaultLabelerTemplates() { List<String> templates = new ArrayList<String>(); // templates.scaffolding.LabelerTemplate templates.add(dot(DEFAULT_APPLICATION_TEMPLATE_PATH, KEY_LABELER_TEMPLATE)); // griffon.plugins.scaffolding.LabelerTemplate templates.add(dot(DEFAULT_TEMPLATE_PATH, KEY_LABELER_TEMPLATE)); return templates.toArray(new String[templates.size()]); }
From source file:Main.java
/** * Get the elements with the given name. * @param element// ww w . j av a 2 s.c o m * @param name * @return array, never <code>null</code> */ public static Element[] getChildElementsNamed(Element element, String name) { if (element == null) return new Element[0]; NodeList nodeList = element.getChildNodes(); List<Element> elements = new ArrayList<Element>(); Node node = nodeList.item(0); while (node != null) { if (node instanceof Element && name.equals(node.getNodeName())) { elements.add((Element) node); } node = node.getNextSibling(); } return (Element[]) elements.toArray(new Element[elements.size()]); }
From source file:com.intuit.tank.vm.common.util.ReportUtil.java
public static final String[] getSummaryHeaders() { List<String> l = new ArrayList<String>(SUMMARY_HEADERS.length + PERCENTILES.length); l.addAll(Arrays.asList(SUMMARY_HEADERS)); for (int n = 0; n < PERCENTILES.length; n++) { l.add((String) PERCENTILES[n][0]); }/* w ww . ja v a2s. c om*/ return l.toArray(new String[l.size()]); }
From source file:com.xpfriend.fixture.cast.temp.TempDynaClass.java
private static DynaProperty[] createDynaProperties(Table table) throws ClassNotFoundException { List<Column> columns = table.getColumns(); List<DynaProperty> list = new ArrayList<DynaProperty>(columns.size()); for (Column column : columns) { if (column != null) { list.add(new TempDynaProperty(column)); }//from www .j a v a2s. c om } DynaProperty[] properties = new DynaProperty[list.size()]; return list.toArray(properties); }
From source file:fr.ippon.pamelaChu.test.support.LdapTestServer.java
private static void injectEntry(LdifEntry entry, DirectoryService service) throws Exception { if (entry.isChangeAdd()) { ServerEntry serverEntry = service.newEntry(entry.getDn()); for (EntryAttribute entryAttribute : entry.getEntry()) { List<Value<?>> allValue = new ArrayList<Value<?>>(); for (Value<?> value : entryAttribute) { allValue.add(value);/*from w ww. j a v a 2 s .c o m*/ } serverEntry.add(entryAttribute.getId(), allValue.toArray(new Value[0])); } service.getAdminSession().add(serverEntry); // service.getAdminSession().add( new DefaultServerEntry( service.getSchemaManager(), entry.getEntry() ) ); } else if (entry.isChangeModify()) { // not used, not tested ... service.getAdminSession().modify(entry.getDn(), entry.getModificationItems()); } else { throw new IllegalArgumentException("bug"); } }
From source file:com.cloudera.oryx.common.text.TextUtils.java
/** * @param delimited PMML-style space-delimited value string * @return delimited values, parsed according to PMML rules *//*from ww w . j av a2 s . c o m*/ public static String[] parsePMMLDelimited(String delimited) { // Although you'd think ignoreSurroundingSpaces helps here, won't work with space // delimiter. So manually trim below. String[] rawResult = doParseDelimited(delimited, formatForDelimiter(' ')); List<String> resultList = new ArrayList<>(); for (String raw : rawResult) { if (!raw.isEmpty()) { resultList.add(raw); } } return resultList.toArray(new String[resultList.size()]); }
From source file:jp.co.nemuzuka.utils.ConvertUtils.java
/** * Long?String??./*from ww w .j a v a 2s. c om*/ * @param targets ?? * @return ?String?(???null???0??) */ public static String[] convert(Long[] targets) { if (targets == null) { return new String[0]; } List<String> list = new ArrayList<String>(); for (Long target : targets) { list.add(target.toString()); } return list.toArray(new String[0]); }
From source file:jp.co.nemuzuka.utils.ConvertUtils.java
/** * String?Long??./*from w w w . j a v a2 s . c om*/ * @param targets ?? * @return ?Long?(???null???0??) */ public static Long[] convert(String[] targets) { if (targets == null) { return new Long[0]; } List<Long> list = new ArrayList<Long>(); for (String target : targets) { list.add(Long.valueOf(target)); } return list.toArray(new Long[0]); }
From source file:de.se_rwth.langeditor.util.Misc.java
public static boolean removeFromClasspath(IJavaProject javaProject, Predicate<IClasspathEntry> predicate) { try {/*www .j a v a 2s . c o m*/ IClasspathEntry[] oldClasspath = javaProject.getRawClasspath(); List<IClasspathEntry> filteredClasspath = Arrays.stream(oldClasspath).filter(predicate.negate()) .collect(Collectors.toList()); IClasspathEntry[] newClasspath = filteredClasspath .toArray(new IClasspathEntry[filteredClasspath.size()]); javaProject.setRawClasspath(newClasspath, null); return oldClasspath.length > newClasspath.length; } catch (JavaModelException e) { throw new RuntimeException(e); } }