Example usage for java.util List toArray

List of usage examples for java.util List toArray

Introduction

In this page you can find the example usage for java.util List toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Usage

From source file:com.aliyun.odps.ship.common.Util.java

public static File[] sortFiles(File[] fs) {

    if (fs == null) {
        return null;
    }/*from w w w  .  j  a  va2 s.c  o m*/
    //sort files
    List<File> files = Arrays.asList(fs);
    Collections.sort(files, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    return files.toArray(new File[files.size()]);
}

From source file:ddf.catalog.source.solr.provider.SolrProviderTestUtil.java

public static void deleteAll(int methodNameIndex, SolrCatalogProvider provider)
        throws IngestException, UnsupportedQueryException {
    messageBreak(Thread.currentThread().getStackTrace()[methodNameIndex].getMethodName() + "()");

    QueryImpl query;/*from w  ww .  j  av  a 2 s  .  c o  m*/
    SourceResponse sourceResponse;
    query = new QueryImpl(filterBuilder.attribute(Metacard.ID).is().like().text("*"));
    query.setPageSize(ALL_RESULTS);
    sourceResponse = provider.query(new QueryRequestImpl(query));

    List<String> ids = new ArrayList<>();
    for (Result r : sourceResponse.getResults()) {
        ids.add(r.getMetacard().getId());
    }

    LOGGER.info("Records found for deletion: {}", ids);

    provider.delete(new DeleteRequestImpl(ids.toArray(new String[ids.size()])));

    LOGGER.info("Deletion complete. -----------");
}

From source file:Main.java

public static Double[] getDataList(Node sampleNode) {
    if (sampleNode == null)
        return new Double[0];
    List<Double> measureValues = new ArrayList<Double>();
    Node n = sampleNode.getFirstChild();
    while (n != null) {
        if (n.getNodeName().equalsIgnoreCase("data")) {
            String ms = n.getFirstChild().getNodeValue();
            double mesVal = Double.parseDouble(ms);
            measureValues.add(new Double(mesVal));
        }/*  w ww  . j  a v a 2  s .  co  m*/
        n = n.getNextSibling();
    }
    return measureValues.toArray(new Double[0]);
}

From source file:org.wallride.repository.PageSpecifications.java

public static Specification<Page> siblings(Page page, boolean includeUnpublished) {
    return (root, query, cb) -> {
        query.distinct(true);//from w  w  w.  ja va 2 s.c  om
        List<Predicate> predicates = new ArrayList<>();
        predicates.add(cb.equal(root.get(Page_.parent), page.getParent()));
        if (!includeUnpublished) {
            predicates.add(cb.equal(root.get(Page_.status), Page.Status.PUBLISHED));
        }
        query.orderBy(cb.asc(root.get(Page_.lft)));
        return cb.and(predicates.toArray(new Predicate[0]));
    };
}

From source file:com.dianping.squirrel.client.util.ClassUtils.java

public static Field[] getDeclaredFields(Class<?> clazz) {
    Assert.notNull(clazz);//w  ww .  j av  a 2  s  . c o m
    List<Field> fields = new ArrayList<Field>();
    for (Class<?> currentClazz = clazz; currentClazz != Object.class; currentClazz = currentClazz
            .getSuperclass()) {
        fields.addAll(Arrays.asList(currentClazz.getDeclaredFields()));
    }
    return fields.toArray(new Field[fields.size()]);
}

From source file:edu.byu.nlp.crowdsourcing.SerializableCrowdsourcingState.java

public static int[][] yChains(List<SerializableCrowdsourcingState> chains, String[] docSourceOrder) {
    List<int[]> yChains = Lists.newArrayList();
    for (SerializableCrowdsourcingState chain : chains) {
        yChains.add(orderedY(chain, docSourceOrder));
    }/*from  www.j  a v  a 2 s  .c o m*/
    return yChains.toArray(new int[][] {});
}

From source file:edu.byu.nlp.crowdsourcing.SerializableCrowdsourcingState.java

public static int[][] mChains(List<SerializableCrowdsourcingState> chains, String[] docSourceOrder) {
    List<int[]> mChains = Lists.newArrayList();
    for (SerializableCrowdsourcingState chain : chains) {
        mChains.add(orderedM(chain, docSourceOrder));
    }/*w w w  .  j av  a 2s . c  o  m*/
    return mChains.toArray(new int[][] {});
}

From source file:com.smartbear.swagger.ValidationSupport.java

static void validateMessage(JsonSchema jsonSchema, JsonNode contentObject) throws AssertionException {
    ProcessingReport report = null;//from   ww w.  j a  v a 2 s. c om
    try {
        report = jsonSchema.validate(contentObject);
    } catch (ProcessingException e) {
        throw new AssertionException(new AssertionError(e.getProcessingMessage().getMessage()));
    }

    if (!report.isSuccess()) {
        List<AssertionError> errors = Lists.newArrayList();
        for (ProcessingMessage message : report) {
            if (message.getLogLevel() == LogLevel.ERROR || message.getLogLevel() == LogLevel.FATAL) {
                errors.add(new AssertionError(message.getMessage()));
            }
        }

        if (!errors.isEmpty()) {
            throw new AssertionException(errors.toArray(new AssertionError[errors.size()]));
        }
    }
}

From source file:com.liferay.blade.samples.test.BladeCLIUtil.java

public static String execute(File workingDir, String... bladeArgs) throws Exception {

    String bladeCLIJarPath = getLatestBladeCLIJar();

    List<String> command = new ArrayList<>();

    command.add("java");
    command.add("-jar");
    command.add(bladeCLIJarPath);//from  ww w .ja v  a 2s  . c  om

    for (String arg : bladeArgs) {
        command.add(arg);
    }

    Process process = new ProcessBuilder(command.toArray(new String[0])).directory(workingDir).start();

    process.waitFor();

    InputStream stream = process.getInputStream();

    String output = new String(IO.read(stream));

    InputStream errorStream = process.getErrorStream();

    List<String> errorList = new ArrayList<>();

    if (errorStream != null) {
        errorList.add(new String(IO.read(errorStream)));
    }

    List<String> filteredErrorList = new ArrayList<>();

    for (String string : errorList) {
        if (!string.isEmpty() && !string.contains("Picked up JAVA_TOOL_OPTIONS:")) {

            filteredErrorList.add(string);
        }
    }

    assertTrue(filteredErrorList.toString(), filteredErrorList.isEmpty());

    output = StringUtil.toLowerCase(output);

    return output;
}

From source file:edu.byu.nlp.crowdsourcing.SerializableCrowdsourcingState.java

public static int[][][] zChains(List<SerializableCrowdsourcingState> chains, String[] docSourceOrder) {
    List<int[][]> mChains = Lists.newArrayList();
    for (SerializableCrowdsourcingState chain : chains) {
        mChains.add(orderedZ(chain, docSourceOrder));
    }// w  w  w  . j  a v a2 s .c  o  m
    return mChains.toArray(new int[][][] {});
}