Example usage for java.util Vector toArray

List of usage examples for java.util Vector toArray

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public synchronized <T> T[] toArray(T[] a) 

Source Link

Document

Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.

Usage

From source file:com.rp.podemu.BaudRateDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //PackageManager pm = super.getPackageManager();
    Vector<String> appNames = new Vector<String>();
    for (Integer i : baudRateList) {
        appNames.add(i.toString());/*from   w  w  w  . j  a v a2  s.c  om*/
    }

    // converting Vector appNames to String[] appNamesStr
    String[] appNamesStr = appNames.toArray(new String[appNames.size()]);

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Select Baud Rate").setItems(appNamesStr, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // The 'which' argument contains the index position
            // of the selected item
            mListener.onBaudRateSelected(dialog, which);
        }
    });
    // Create the AlertDialog object and return it
    return builder.create();
}

From source file:com.headstrong.npi.raas.Utils.java

public static String[] insertSection(int index, String insertStr, String[] strArray) {
    // strArray==null assign a new array
    strArray = strArray != null ? strArray : new String[0];

    Vector<String> arrayVector = new Vector<String>(Arrays.asList(strArray));
    arrayVector.add(index, insertStr);/*from   ww w  . jav a  2s.c o m*/
    String[] returnStr = (String[]) arrayVector.toArray(new String[0]);
    return returnStr;
}

From source file:com.rp.podemu.ControlledAppDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //PackageManager pm = super.getPackageManager();
    Vector<String> appNames = new Vector<String>();
    for (ApplicationInfo appInfo : applicationInfos) {
        appNames.add(new String(appInfo.name));
    }//from  w w w.  j  ava2  s  .c om

    // converting Vector appNames to String[] appNamesStr
    String[] appNamesStr = appNames.toArray(new String[appNames.size()]);

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_select_controlled_app).setItems(appNamesStr,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // The 'which' argument contains the index position
                    // of the selected item
                    mListener.onCtrlAppSelected(dialog, which);
                }
            });
    // Create the AlertDialog object and return it
    return builder.create();
}

From source file:de.betterform.agent.web.WebUtil.java

/**
 * stores cookies that may exist in request and passes them on to processor for usage in
 * HTTPConnectors. Instance loading and submission then uses these cookies. Important for
 * applications using auth.//  www .  j  a  v a  2 s .co  m
 * <p/>
 * NOTE: this method should be called *before* the Adapter is initialized cause the cookies may
 * already be needed for setup (e.g. loading of XForms via Http)
 */
public static void storeCookies(List<Cookie> requestCookies, XFormsProcessor processor) {
    Vector<BasicClientCookie> commonsCookies = new Vector<BasicClientCookie>();

    if (requestCookies != null && requestCookies.size() > 0) {
        commonsCookies = saveAsBasicClientCookie(requestCookies.iterator(), commonsCookies);
    }

    /*
    if (responseCookies != null && responseCookies.size() > 0) {
    commonsCookies= saveAsBasicClientCookie(responseCookies.iterator(), commonsCookies);
    }
    */
    if (commonsCookies.size() == 0) {
        BasicClientCookie sessionCookie = new BasicClientCookie("JSESSIONID",
                ((WebProcessor) processor).httpSession.getId());
        sessionCookie.setSecure(false);
        sessionCookie.setDomain(null);
        sessionCookie.setPath(null);

        commonsCookies.add(sessionCookie);

    }
    processor.setContextParam(AbstractHTTPConnector.REQUEST_COOKIE,
            commonsCookies.toArray(new BasicClientCookie[0]));
}

From source file:ch.rgw.tools.StringTool.java

/**
 * Split a String into a String Arry//from  w ww  . ja v  a2s . co  m
 * 
 * @deprecated obsoleted by java 1.4x 's {@link String#split(String) String.split} method.
 */
@Deprecated
@SuppressWarnings("unchecked")
public static String[] split(final String m, final String delim) {
    Vector v = splitV(m, delim);
    if (v == null) {
        return null;
    }
    String[] ret = (String[]) v.toArray(new String[1]);
    return ret;
}

From source file:edu.umn.cs.spatialHadoop.operations.Indexer.java

private static void indexLocal(Path inPath, Path outPath, OperationsParams params) throws IOException {
    JobConf job = new JobConf(params);
    String sindex = params.get("sindex");
    Partitioner partitioner = createPartitioner(inPath, outPath, job, sindex);

    // Start reading input file
    Vector<InputSplit> splits = new Vector<InputSplit>();
    final ShapeIterInputFormat inputFormat = new ShapeIterInputFormat();
    FileSystem inFs = inPath.getFileSystem(params);
    FileStatus inFStatus = inFs.getFileStatus(inPath);
    if (inFStatus != null && !inFStatus.isDir()) {
        // One file, retrieve it immediately.
        // This is useful if the input is a hidden file which is automatically
        // skipped by FileInputFormat. We need to plot a hidden file for the case
        // of plotting partition boundaries of a spatial index
        splits.add(new FileSplit(inPath, 0, inFStatus.getLen(), new String[0]));
    } else {//from   w ww .ja v a  2s.c o m
        ShapeIterInputFormat.addInputPath(job, inPath);
        for (InputSplit s : inputFormat.getSplits(job, 1))
            splits.add(s);
    }

    // Copy splits to a final array to be used in parallel
    final FileSplit[] fsplits = splits.toArray(new FileSplit[splits.size()]);
    boolean replicate = job.getBoolean("replicate", false);

    final IndexRecordWriter<Shape> recordWriter = new IndexRecordWriter<Shape>(partitioner, replicate, sindex,
            outPath, params);

    for (FileSplit fsplit : fsplits) {
        RecordReader<Rectangle, Iterable<? extends Shape>> reader = inputFormat.getRecordReader(fsplit, job,
                null);
        Rectangle partitionMBR = reader.createKey();
        Iterable<? extends Shape> shapes = reader.createValue();

        final IntWritable partitionID = new IntWritable();

        while (reader.next(partitionMBR, shapes)) {
            if (replicate) {
                // Replicate each shape to all overlapping partitions
                for (final Shape s : shapes) {
                    partitioner.overlapPartitions(s, new ResultCollector<Integer>() {
                        @Override
                        public void collect(Integer id) {
                            partitionID.set(id);
                            try {
                                recordWriter.write(partitionID, s);
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    });
                }
            } else {
                for (Shape s : shapes) {
                    partitionID.set(partitioner.overlapPartition(s));
                    recordWriter.write(partitionID, s);
                }
            }
        }
        reader.close();
    }

    recordWriter.close(null);
}

From source file:net.rim.ejde.internal.model.BlackBerryPropertiesFactory.java

/**
 * Gets the icons./* ww  w  .  j  a  va  2 s .c o  m*/
 *
 * @param project
 *            the project
 * @param iProject
 *            the i project
 *
 * @return the icons
 */
protected static Icon[] getIcons(final Project project, final IProject iProject) {
    IJavaProject javaProject = JavaCore.create(iProject);
    final Vector<Icon> newIcons = new Vector<Icon>();
    Icon icon = null, rooloverIcon;

    Vector<File> iconFiles = project.getIcons();
    // we only get the first icon
    if ((iconFiles != null) && (iconFiles.size() > 0)) {
        final File iconFile = iconFiles.get(0);
        if (iconFile.exists()) {
            icon = new Icon(getTargetRelFilePath(iconFile, project, javaProject));
            newIcons.add(icon);
        }
    }

    iconFiles = project.getRolloverIcons();
    // we only get the first rollover icon
    if ((iconFiles != null) && (iconFiles.size() > 0)) {
        final File iconFile = iconFiles.get(0);
        if (iconFile.exists()) {
            // If there is only 1 icon it cannot be a focus icon, so set focus status based on existence of first icon
            rooloverIcon = new Icon(getTargetRelFilePath(iconFile, project, javaProject),
                    Boolean.valueOf(icon != null));
            newIcons.add(rooloverIcon);
        }
    }

    return newIcons.toArray(new Icon[newIcons.size()]);
}

From source file:com.linkbubble.MainApplication.java

public static void checkRestoreCurrentTabs(Context _context) {
    // Don't restore tabs if we've already got tabs open, #389
    final Context context = _context.getApplicationContext();
    if (MainController.get() == null) {
        final Vector<String> urls = Settings.get().loadCurrentTabs();
        int urlCount = urls.size();
        if (urlCount > 0) {
            String message = context.getResources()
                    .getQuantityString(R.plurals.restore_tabs_from_previous_session, urlCount, urlCount);
            Prompt.show(message, context.getResources().getString(android.R.string.ok), Prompt.LENGTH_LONG,
                    new Prompt.OnPromptEventListener() {

                        boolean mOnActionClicked = false;

                        @Override
                        public void onActionClick() {
                            MainApplication.restoreLinks(context, urls.toArray(new String[urls.size()]));
                            mOnActionClicked = true;
                        }/*from  w w w. j  a  v a2 s.co m*/

                        @Override
                        public void onClose() {
                            if (mOnActionClicked == false) {
                                Settings.get().saveCurrentTabs(null);
                            }
                        }
                    });
        }
    }
}

From source file:pt.lsts.neptus.plugins.pddl.MVPlannerTask.java

@Override
public DefaultProperty[] getProperties() {
    Vector<DefaultProperty> props = new Vector<DefaultProperty>();
    for (PayloadRequirement pr : PayloadRequirement.values()) {
        props.add(PropertiesEditor.getPropertyInstance(pr.name(), "Payload Requirements", Boolean.class,
                requiredPayloads.contains(pr), true));
    }//  w w  w .ja  v  a 2  s  . com

    return props.toArray(new DefaultProperty[0]);
}

From source file:org.kchine.rpf.db.DBLayer.java

public static String[] getPrefixes(String prefixes) {
    StringTokenizer st = new StringTokenizer(prefixes, ",");
    Vector<String> pv = new Vector<String>();
    while (st.hasMoreElements())
        pv.add((String) st.nextElement());
    return pv.toArray(new String[0]);
}