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:de.unisb.cs.st.javalanche.mutation.javaagent.MutationsForRun.java

/**
 * Reads a list of mutation ids from a file and fetches the corresponding
 * mutations from the database./*from   w  w w . j  a  v  a  2s.co m*/
 * 
 * @param file
 *            the file to read from
 * @return a list of mutations read from the db.
 */
public static List<Mutation> getMutationsByFile(File file) {
    List<Long> idList = Io.getIDsFromFile(file);
    List<Mutation> returnList = null;
    if (idList.size() > 0) {
        returnList = QueryManager.getMutationsByIds(idList.toArray(new Long[0]));
    } else {
        returnList = new ArrayList<Mutation>();
    }
    return returnList;

}

From source file:net.cheney.webdav.resource.api.Elements.java

public static PROP prop(List<Element> elements) {
    return new PROP(elements.toArray(new Element[0]));
}

From source file:at.ac.tuwien.dsg.comot.m.common.Utils.java

public static String asXmlString(Object obj, Class<?>... clazz) throws JAXBException {

    List<Object> list = new ArrayList<Object>(Arrays.asList(clazz));
    list.add(obj.getClass());//from w  ww  . j a v a  2 s .  c o  m

    StringWriter w = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(list.toArray(new Class[list.size()]));

    Marshaller m = context.createMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    m.marshal(obj, w);

    return w.toString();
}

From source file:com.tlabs.eve.api.EveRequest.java

protected static final String[] filter(String[] names) {
    List<String> l = new ArrayList<String>(names.length);
    for (String s : names) {
        if (!l.contains(s)) {
            l.add(s);/*  w w w.j  a  va  2s .c  om*/
        }
    }
    return l.toArray(new String[l.size()]);
}

From source file:com.titankingdoms.dev.titanchat.format.Censor.java

/**
 * Filters the text for phrases and censors the phrases with the censor
 * /*w ww  .  j ava  2  s .co  m*/
 * @param text The text to filter
 * 
 * @param phrases The phrases to censor
 * 
 * @param censor The censor to use
 * 
 * @return The filtered text
 */
public static String filter(String text, List<String> phrases, String censor) {
    if (text == null)
        return "";

    if (phrases == null)
        return text;

    if (censor == null)
        censor = "";

    StringBuffer filtered = new StringBuffer();

    String regex = "(" + StringUtils.join(phrases.toArray(new String[0])) + ")";

    Pattern phrasePattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
    Matcher match = phrasePattern.matcher(text);

    while (match.find())
        match.appendReplacement(filtered, Pattern.compile(".").matcher(match.group()).replaceAll(censor));

    return match.appendTail(filtered).toString();
}

From source file:Main.java

public static Intent createTakePictureIntent(@NonNull Context context, @NonNull Uri outputFileUri) {
    List<Intent> cameraIntents = createTakePictureIntentList(context, outputFileUri);

    if (cameraIntents.isEmpty())
        return null;

    Intent chooserIntent = new Intent(cameraIntents.get(0));

    cameraIntents.remove(0);//from  w ww. j  ava  2  s . c o m

    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            cameraIntents.toArray(new Parcelable[cameraIntents.size()]));

    return chooserIntent;
}

From source file:com.googlecode.jtiger.modules.ecside.table.calc.CalcUtils.java

public static CalcResult[] getCalcResults(TableModel model, Column column) {
    List values = new ArrayList();

    String calcs[] = column.getCalc();
    for (int i = 0; i < calcs.length; i++) {
        values.add(getCalcResultsByPosition(model, column, i));
    }/*from   ww  w  .j  a  v a2s.c o  m*/

    return (CalcResult[]) values.toArray(new CalcResult[values.size()]);
}

From source file:com.tlabs.eve.api.EveRequest.java

protected static final long[] filter(long[] ids) {
    List<Long> l = new ArrayList<Long>(ids.length);
    for (Long id : ids) {
        if (!l.contains(id)) {
            l.add(id);//from w  w  w  . j  a va 2 s. c o m
        }
    }
    Long[] fck = l.toArray(new Long[l.size()]);
    long[] r = new long[fck.length];
    for (int i = 0; i < fck.length; i++) {
        r[i] = fck[i];
    }
    return r;
}

From source file:com.tlabs.eve.api.EveRequest.java

protected static final long[] filter(Long[] ids) {
    List<Long> l = new ArrayList<Long>(ids.length);
    for (Long id : ids) {
        if (!l.contains(id)) {
            l.add(id);//from  w w w  .ja  va2 s.co  m
        }
    }
    Long[] fck = l.toArray(new Long[l.size()]);
    long[] r = new long[fck.length];
    for (int i = 0; i < fck.length; i++) {
        r[i] = fck[i].longValue();
    }
    return r;
}

From source file:com.adaptris.core.http.jetty.JettyConnection.java

protected static String[] asArray(String s) {
    if (s == null) {
        return new String[0];
    }//from  w  w  w. jav  a  2s.c om
    StringTokenizer st = new StringTokenizer(s, ",");
    List<String> l = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        String tok = st.nextToken().trim();
        if (!isEmpty(tok))
            l.add(tok);
    }
    return l.toArray(new String[0]);
}