List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:com.us.reflect.ClassFinder.java
/** * ??//w w w . j a v a 2 s. c o m * * @param path * @return */ private static String[] findParameters(String path) { int methodStart = path.indexOf("("); if (methodStart == -1) { return ArrayHelper.make(); } int methodEnd = path.indexOf(")"); String list = path.substring(methodStart + 1, methodEnd); if (list.trim().equals("")) { return ArrayHelper.make(); } List<String> plist = new LinkedList<String>(); for (String param : list.split(",")) { if (param.trim().equals("")) throw new IllegalArgumentException("Parameters error"); plist.add(param.trim()); } return plist.toArray(new String[] {}); }
From source file:com.netflix.genie.core.jpa.specifications.JpaClusterSpecs.java
/** * Get all the clusters given the specified parameters. * * @param commandId The id of the command that is registered with this cluster * @param statuses The status of the cluster * @return The specification//from www .java 2 s . c o m */ public static Specification<ClusterEntity> findClustersForCommand(final String commandId, final Set<ClusterStatus> statuses) { return (final Root<ClusterEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); final Join<ClusterEntity, CommandEntity> commands = root.join(ClusterEntity_.commands); predicates.add(cb.equal(commands.get(CommandEntity_.id), commandId)); if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = statuses.stream() .map(status -> cb.equal(root.get(ClusterEntity_.status), status)) .collect(Collectors.toList()); predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }
From source file:com.stratuscom.harvester.Utils.java
public static String[] splitOnWhitespace(String input) { List<String> strings = new ArrayList<String>(); StringTokenizer tok = new StringTokenizer(Strings.WHITESPACE_SEPARATORS); while (tok.hasMoreTokens()) { strings.add(tok.nextToken());/* w w w . j a v a 2 s . c o m*/ } return (String[]) strings.toArray(new String[0]); }
From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java
private static Predicate buildSearchSpec(Root<Vocabulary> root, CriteriaBuilder cb, Set<String> matches, Set<String> nots) { List<Predicate> predicates = new ArrayList<>(0); if (!isEmpty(matches)) { predicates.addAll(inNameOrDescription(root, cb, matches)); }//w ww. j a va 2 s . c om if (!isEmpty(nots)) { predicates.addAll(notInNameOrDescription(root, cb, nots)); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.DbObjects.java
public static String[] getRenderableTypes() { List<String> renderables = new ArrayList<String>(); for (DbEntryHandler o : objs) { if (o instanceof FeedRenderer) { renderables.add(o.getType()); }//w w w .ja va2 s .c o m } return renderables.toArray(new String[renderables.size()]); }
From source file:io.fabric8.camel.tooling.util.CamelNamespaces.java
protected static Element findOrCreateDescriptionOnNextElement(Element element, int commentIndex, Parent root) { // lets find the next peer element node and if it can contain a description lets use that List<Node> nodes = element.getNodes(); Node[] array = nodes.toArray(new Node[nodes.size()]); for (int i = commentIndex + 1; i < array.length; i++) { if (array[i] instanceof Element) { if (elementsWithDescription().contains(element.getName())) { return findOrCreateDescrptionElement((Element) array[i], root); }/*from ww w .j av a 2 s. c om*/ } } return findOrCreateDescrptionElement(element, root); }
From source file:org.mstc.zmq.json.Decoder.java
static <T> T[] toArray(List<T> list) { Class clazz = list.get(0).getClass(); // check for size and null before T[] array = (T[]) java.lang.reflect.Array.newInstance(clazz, list.size()); return list.toArray(array); }
From source file:Main.java
/** * @param sibling/* w w w .java2s .com*/ * @param uri * @param nodeName * @return nodes with the constrain */ public static Element[] selectNodes(Node sibling, String uri, String nodeName) { List<Element> list = new ArrayList<Element>(); while (sibling != null) { if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri) && sibling.getLocalName().equals(nodeName)) { list.add((Element) sibling); } sibling = sibling.getNextSibling(); } return list.toArray(new Element[list.size()]); }
From source file:org.apache.sling.replication.transport.impl.HttpTransportHandler.java
public static String[] getCustomizedHeaders(String[] additionalHeaders, String action, String[] paths) { List<String> headers = new ArrayList<String>(); for (String additionalHeader : additionalHeaders) { int idx = additionalHeader.indexOf("->"); if (idx < 0) { headers.add(additionalHeader); } else {/*w ww . jav a 2 s. co m*/ String actionSelector = additionalHeader.substring(0, idx).trim(); String header = additionalHeader.substring(idx + 2).trim(); if (actionSelector.equalsIgnoreCase(action) || actionSelector.equals("*")) { headers.add(header); } } } StringBuilder sb = new StringBuilder(); if (paths != null && paths.length > 0) { sb.append(paths[0]); for (int i = 1; i < paths.length; i++) { sb.append(", ").append(paths[i]); } } String path = sb.toString(); List<String> boundHeaders = new ArrayList<String>(); for (String header : headers) { boundHeaders.add(header.replace(PATH_VARIABLE_NAME, path)); } return boundHeaders.toArray(new String[boundHeaders.size()]); }
From source file:Main.java
public static JComponent[] getAllSubComponents(Container root) { List<JComponent> comps = new LinkedList<JComponent>(); for (Component c : root.getComponents()) { try {/*w w w. j a va2 s. c o m*/ comps.add((JComponent) c); comps.addAll(Arrays.asList(getAllSubComponents((JComponent) c))); } catch (final ClassCastException e) { continue; } } return comps.toArray(new JComponent[comps.size()]); }