List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:com.github.geequery.codegen.ast.JavaMethod.java
static String toMethodKey(String name, List<IClass> inputArgs) { return toMethodKey(name, inputArgs.toArray(new IClass[inputArgs.size()])); }
From source file:net.sourceforge.vulcan.spring.jdbc.JdbcSchemaMigratorTest.java
@SuppressWarnings("unchecked") static Resource[] getMigrationScripts() { File dir = TestUtils.resolveRelativeFile("source/main/sql/hsql"); List<Resource> scripts = new ArrayList<Resource>(); for (File file : (Collection<File>) FileUtils.listFiles(dir, new WildcardFilter("S*.sql"), FalseFileFilter.INSTANCE)) { scripts.add(new FileSystemResource(file)); }// www. jav a 2 s. c o m return scripts.toArray(new Resource[scripts.size()]); }
From source file:gov.nih.nci.protexpress.ui.actions.registration.EmailUtil.java
private static MimeMessage constructMessage(List<String> mailRecipients, String from, String mailSubject) throws MessagingException { Validate.notEmpty(mailRecipients, "No email recipients are specified"); if (StringUtils.isEmpty(mailSubject)) { LOG.info("No email subject specified"); }/*from w ww. j a v a 2 s. c om*/ List<Address> addresses = new ArrayList<Address>(); for (String recipient : mailRecipients) { addresses.add(new InternetAddress(recipient)); } MimeMessage message = new MimeMessage(mailSession); message.setRecipients(Message.RecipientType.TO, addresses.toArray(new Address[addresses.size()])); message.setFrom(new InternetAddress(from)); message.setSubject(mailSubject); return message; }
From source file:net.sf.jabref.bibtex.DuplicateCheck.java
/** * Checks if the two entries represent the same publication. * * @param one BibEntry/*w w w .jav a 2s . c o m*/ * @param two BibEntry * @return boolean */ public static boolean isDuplicate(BibEntry one, BibEntry two) { // First check if they are of the same type - a necessary condition: if (one.getType() != two.getType()) { return false; } // The check if they have the same required fields: java.util.List<String> var = one.getType().getRequiredFieldsFlat(); String[] fields = var.toArray(new String[var.size()]); double[] req; if (fields == null) { req = new double[] { 0., 0. }; } else { req = DuplicateCheck.compareFieldSet(fields, one, two); } if (Math.abs(req[0] - DuplicateCheck.duplicateThreshold) > DuplicateCheck.DOUBT_RANGE) { // Far from the threshold value, so we base our decision on the req. fields only return req[0] >= DuplicateCheck.duplicateThreshold; } // Close to the threshold value, so we take a look at the optional fields, if any: java.util.List<String> optionalFields = one.getType().getOptionalFields(); fields = optionalFields.toArray(new String[optionalFields.size()]); if (fields != null) { double[] opt = DuplicateCheck.compareFieldSet(fields, one, two); double totValue = ((DuplicateCheck.REQUIRED_WEIGHT * req[0] * req[1]) + (opt[0] * opt[1])) / ((req[1] * DuplicateCheck.REQUIRED_WEIGHT) + opt[1]); return totValue >= DuplicateCheck.duplicateThreshold; } return req[0] >= DuplicateCheck.duplicateThreshold; }
From source file:com.netflix.genie.server.repository.jpa.CommandSpecs.java
/** * Get a specification using the specified parameters. * * @param name The name of the command * @param userName The name of the user who created the command * @param statuses The status of the command * @param tags The set of tags to search the command for * @return A specification object used for querying *//*ww w . j a v a2 s . c o m*/ public static Specification<Command> find(final String name, final String userName, final Set<CommandStatus> statuses, final Set<String> tags) { return new Specification<Command>() { @Override public Predicate toPredicate(final Root<Command> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(cb.equal(root.get(Command_.name), name)); } if (StringUtils.isNotBlank(userName)) { predicates.add(cb.equal(root.get(Command_.user), userName)); } if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = new ArrayList<>(); for (final CommandStatus status : statuses) { orPredicates.add(cb.equal(root.get(Command_.status), status)); } predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } if (tags != null) { for (final String tag : tags) { if (StringUtils.isNotBlank(tag)) { predicates.add(cb.isMember(tag, root.get(Command_.tags))); } } } return cb.and(predicates.toArray(new Predicate[predicates.size()])); } }; }
From source file:com.google.api.ads.dfp.lib.utils.v201208.PqlUtils.java
/** * Gets the column labels for the result set. * * @param resultSet the result set to get the column labels for * @return the string array of column labels */// w w w . ja va2s . co m public static String[] getColumnLabels(ResultSet resultSet) { List<String> columnLabels = new ArrayList<String>(); for (ColumnType column : resultSet.getColumnTypes()) { columnLabels.add(column.getLabelName()); } return columnLabels.toArray(new String[] {}); }
From source file:io.fabric8.camel.tooling.util.CamelNamespaces.java
public static void moveCommentsIntoDescriptionElements(Element e, Element root) { // lets iterate through finding all comments which are then added to a description node int idx = 0;/*from w w w.ja va 2 s. c o m*/ List<Node> nodes = e.getNodes(); for (Node node : nodes.toArray(new Node[nodes.size()])) { if (node instanceof Comment) { Comment c = (Comment) node; Token token = c.getToken(); if (token != null) { String text = token.getText().trim().replace("<!--", "").replace("-->", "").trim(); Element descr = findOrCreateDescriptionOnNextElement(e, idx, root); if (descr == null) { // lets move the comment node to before the root element... LOG.warn("No description node found"); e.removeNode(c); Parent grandParent = root.getParent(); if (grandParent != null) { grandParent.addNode(grandParent.nodeIndexOf(root), c); } else { LOG.warn("Cannot save the comment '{}' as there's no parent in the DOM", text); } } else { if (descr.getNodes().size() > 0) { text = "\n" + text; } descr.addNode(new Text(text)); } } } else if (node instanceof Element) { moveCommentsIntoDescriptionElements((Element) node, root); } idx++; } }
From source file:org.jvnet.hudson.plugins.backup.utils.BackupTask.java
public static IOFileFilter createFileFilter(List<String> exclusions, IOFileFilter jobsExclusionFileFilter) { if (jobsExclusionFileFilter == null) { return FileFilterUtils.notFileFilter(new NameFileFilter(exclusions.toArray(new String[] {}))); } else {/* w w w . j a v a 2 s. c om*/ return FileFilterUtils.andFileFilter( FileFilterUtils.notFileFilter(new NameFileFilter(exclusions.toArray(new String[] {}))), jobsExclusionFileFilter); } }
From source file:com.codebutler.farebot.key.ClassicCardKeys.java
public static ClassicCardKeys fromDump(String keyType, byte[] keyData) { List<ClassicSectorKey> keys = new ArrayList<>(); int numSectors = keyData.length / KEY_LEN; for (int i = 0; i < numSectors; i++) { int start = i * KEY_LEN; keys.add(new ClassicSectorKey(keyType, Arrays.copyOfRange(keyData, start, start + KEY_LEN))); }/*from w w w . j a v a2s .c om*/ return new ClassicCardKeys(keys.toArray(new ClassicSectorKey[keys.size()])); }
From source file:com.ms.commons.test.common.ReflectUtil.java
public static Field[] getDeclaredFields(Class<?> clazz) { List<Field> fieldList = new ArrayList<Field>(); getDeclaredFields(clazz, fieldList); return fieldList.toArray(new Field[] {}); }