List of usage examples for java.util Vector toArray
@SuppressWarnings("unchecked") public synchronized <T> T[] toArray(T[] a)
From source file:com.example.android.myargmenuplanner.data.FetchJsonDataTask.java
private void getDataIngrFromJson(String JsonStr) throws JSONException { final String JSON_LIST = "ingredients"; final String JSON_NAME = "name"; final String JSON_QTY = "qty"; final String JSON_UNIT = "unit"; final String JSON_ID_FOOD = "id_food"; try {/* w ww . ja v a 2 s .co m*/ JSONObject dataJson = new JSONObject(JsonStr); JSONArray ingrArray = dataJson.getJSONArray(JSON_LIST); Vector<ContentValues> cVVector = new Vector<ContentValues>(ingrArray.length()); for (int i = 0; i < ingrArray.length(); i++) { JSONObject ingr = ingrArray.getJSONObject(i); String id_food = ingr.getString(JSON_ID_FOOD); String name = ingr.getString(JSON_NAME); String qty = ingr.getString(JSON_QTY); String unit = ingr.getString(JSON_UNIT); ContentValues values = new ContentValues(); values.put(IngrEntry.COLUMN_ID_FOOD, id_food); values.put(IngrEntry.COLUMN_NAME, name); values.put(IngrEntry.COLUMN_QTY, qty); values.put(IngrEntry.COLUMN_UNIT, unit); cVVector.add(values); } int inserted = 0; // delete database int rowdeleted = mContext.getContentResolver().delete(IngrEntry.CONTENT_URI, null, null); // // add to database Log.i(LOG_TAG, "Creando registros en base de datos. Tabla Ingredientes "); if (cVVector.size() > 0) { ContentValues[] cvArray = new ContentValues[cVVector.size()]; cVVector.toArray(cvArray); inserted = mContext.getContentResolver().bulkInsert(IngrEntry.CONTENT_URI, cvArray); Log.i(LOG_TAG, "Registros nuevos creados en Tabla Ingredientes: " + inserted); } } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); e.printStackTrace(); } }
From source file:net.rim.ejde.internal.ui.editors.locale.ResourceEditor.java
public IEditorReference[] getOpenEditorReferences() { Vector<IEditorReference> openEditorReferences = new Vector<IEditorReference>(0); IWorkbenchPage[] workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages(); int workbenchPageCount = workbenchPage.length; for (int i = 0; i < workbenchPageCount; i++) { Collection<IEditorReference> editorReferences = Arrays.asList(workbenchPage[i].getEditorReferences()); openEditorReferences.addAll(editorReferences); }/*from www.ja va 2 s.c om*/ return openEditorReferences.toArray(new IEditorReference[1]); }
From source file:org.dhatim.cdr.SmooksResourceConfigurationList.java
/** * Get all SmooksResourceConfiguration entries targeted at the specified profile set. * @param profileSet The profile set to searh against. * @return All SmooksResourceConfiguration entries targeted at the specified profile set. *///w w w . j ava2 s . c om public SmooksResourceConfiguration[] getTargetConfigurations(ProfileSet profileSet) { Vector<SmooksResourceConfiguration> matchingSmooksResourceConfigurationsColl = new Vector<SmooksResourceConfiguration>(); SmooksResourceConfiguration[] matchingSmooksResourceConfigurations; // Iterate over the SmooksResourceConfigurations defined on this list. for (int i = 0; i < size(); i++) { SmooksResourceConfiguration resourceConfig = get(i); ProfileTargetingExpression[] profileTargetingExpressions = resourceConfig .getProfileTargetingExpressions(); for (int expIndex = 0; expIndex < profileTargetingExpressions.length; expIndex++) { ProfileTargetingExpression expression = profileTargetingExpressions[expIndex]; if (expression.isMatch(profileSet)) { matchingSmooksResourceConfigurationsColl.addElement(resourceConfig); break; } else { logger.debug("Resource [" + resourceConfig + "] not targeted at profile [" + profileSet.getBaseProfile() + "]. Sub Profiles: [" + profileSet + "]"); } } } matchingSmooksResourceConfigurations = new SmooksResourceConfiguration[matchingSmooksResourceConfigurationsColl .size()]; matchingSmooksResourceConfigurationsColl.toArray(matchingSmooksResourceConfigurations); return matchingSmooksResourceConfigurations; }
From source file:org.cytobank.acs.core.TableOfContents.java
/** * Returns an array of all the <code>FileResourceIdentifier</code>s contained within this <code>TableOfContents</code> instance that are associated to * another FileResourceIdentifier./* www. ja v a 2 s . c om*/ * <p> * This method essentially takes all <code>FileResourceIdentifier</code>s and filters them down to the results that have an association with the specified * <code>associatedTo</code> <code>FileResourceIdentifier</code>. This is particularly useful if all <code>FileResourceIdentifier</code>s are needed for a specific workspace. * * @return an array of all the <code>FileResourceIdentifier</code>s */ public FileResourceIdentifier[] getFileResourceIdentifiersAssociatedTo(FileResourceIdentifier associatedTo) throws InvalidAssociationException, InvalidIndexException, URISyntaxException { if (associatedTo == null) return null; Vector<FileResourceIdentifier> associatedFileResourceIdentifiers = new Vector<FileResourceIdentifier>(); for (FileResourceIdentifier fileResource : fileResourceIdentifiers) { for (Association association : fileResource.associations) { if (associatedTo.equals(association.getAssociatedTo())) { associatedFileResourceIdentifiers.add(fileResource); break; } } } FileResourceIdentifier[] results = new FileResourceIdentifier[associatedFileResourceIdentifiers.size()]; associatedFileResourceIdentifiers.toArray(results); return results; }
From source file:org.cytobank.acs.core.TableOfContents.java
/** * Returns an array of all the <code>FileResourceIdentifier</code>s contained within this <code>TableOfContents</code> instance * that represent FCS files with an association to a particular <code>FileResourceIdentifier</code>. * <p>/*from www. j a v a 2s . com*/ * This method is particularly useful when all FCS files associated with a given workspace FileResourceIdentifier are needed. * * @return an array of all the <code>FileResourceIdentifier</code>s that are FCS files, or <code>null</code> if <code>associatedTo</code> parameter * is <code>null</code>. * @throws InvalidIndexException If there is a problem with the <code>TableOfContents</code> * @throws URISyntaxException If there is a problem with any of the URIs contained within the <code>TableOfContents</code> or if the URI is a duplicate * @throws InvalidAssociationException if there is an invalid association */ public FileResourceIdentifier[] getFcsFilesAssociatedTo(FileResourceIdentifier associatedTo) throws InvalidAssociationException, InvalidIndexException, URISyntaxException { if (associatedTo == null) return null; Vector<FileResourceIdentifier> fcsFiles = new Vector<FileResourceIdentifier>(); for (FileResourceIdentifier fileResource : fileResourceIdentifiers) { if (fileResource.isFcsFile()) { for (Association association : fileResource.associations) { if (associatedTo.equals(association.getAssociatedTo())) { fcsFiles.add(fileResource); break; } } } } FileResourceIdentifier[] results = new FileResourceIdentifier[fcsFiles.size()]; fcsFiles.toArray(results); return results; }
From source file:gda.scan.ScanDataPoint.java
/** * Just returns array of positions. Strings will be an empty element. * /*from w w w.j a v a 2s. co m*/ * @return all scannable positions. */ @Override public Double[] getPositionsAsDoubles() { Vector<Double> vals = new Vector<Double>(); if (getPositions() != null) { for (Object data : getPositions()) { PlottableDetectorData wrapper = new DetectorDataWrapper(data); Double[] dvals = wrapper.getDoubleVals(); vals.addAll(Arrays.asList(dvals)); } } if (vals.size() != getPositionHeader().size()) { throw new IllegalArgumentException("Position data does not hold the expected number of fields"); } return vals.toArray(new Double[] {}); }
From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtp.java
@Override public String[] getFilelist(final String folder, final String regexp, final int flag, final boolean flgRecurseSubFolder) { // TODO vecDirectoryListing = null; prfen, ob notwendig vecDirectoryListing = null;// w w w . ja v a 2 s.c o m if (vecDirectoryListing == null) { vecDirectoryListing = nList(folder, flgRecurseSubFolder); } Vector<String> strB = new Vector<String>(); Pattern pattern = Pattern.compile(regexp, 0); for (String strFile : vecDirectoryListing) { /** * the file_spec has to be compared to the filename only ... excluding the path */ String strFileName = new File(strFile).getName(); Matcher matcher = pattern.matcher(strFileName); if (matcher.find() == true) { strB.add(strFile); } } return strB.toArray(new String[strB.size()]); }
From source file:org.jafer.zclient.AbstractClient.java
/** @todo throw exception if databases param is null? */ public void setDatabases(String[] databases) { if (databases != null) { Vector v = new Vector(); for (int i = 0; i < databases.length; i++) { if (databases[i] != null) v.add(databases[i]);/*ww w.j a v a 2 s . c o m*/ } this.dataBases = (String[]) v.toArray(new String[] {}); this.searchExceptions = new Hashtable(this.dataBases.length); this.resultsByDB = new Hashtable(this.dataBases.length); } }
From source file:edu.umn.cs.spatialHadoop.OperationsParams.java
public void initialize(String... args) { // TODO if the argument shape is set to a class in a third party jar // file/*from w w w . j a v a 2 s. com*/ // add that jar file to the archives Vector<Path> paths = new Vector<Path>(); for (String arg : args) { String argl = arg.toLowerCase(); if (arg.startsWith("-no-")) { this.setBoolean(argl.substring(4), false); } else if (argl.startsWith("-")) { this.setBoolean(argl.substring(1), true); } else if (argl.contains(":") && !argl.contains(":/")) { String[] parts = arg.split(":", 2); String key = parts[0].toLowerCase(); String value = parts[1]; String previousValue = this.get(key); if (previousValue == null) this.set(key, value); else this.set(key, previousValue + "\n" + value); } else { paths.add(new Path(arg)); } } this.allPaths = paths.toArray(new Path[paths.size()]); }
From source file:com.example.android.popularmoviesist2.data.FetchMovieTask.java
private void getMoviesDataFromJson(String moviesJsonStr) throws JSONException { final String JSON_LIST = "results"; final String JSON_POSTER = "poster_path"; final String JSON_TITLE = "original_title"; final String JSON_OVERVIEW = "overview"; final String JSON_VOTE = "vote_average"; final String JSON_RELEASE = "release_date"; final String JSON_ID = "id"; try {/*from w w w. ja v a 2 s . c o m*/ JSONObject moviesJson = new JSONObject(moviesJsonStr); JSONArray moviesArray = moviesJson.getJSONArray(JSON_LIST); Vector<ContentValues> cVVector = new Vector<ContentValues>(moviesArray.length()); for (int i = 0; i < moviesArray.length(); i++) { JSONObject movie = moviesArray.getJSONObject(i); String overview = movie.getString(JSON_OVERVIEW); String release = movie.getString(JSON_RELEASE); String poster = movie.getString(JSON_POSTER); String id = movie.getString(JSON_ID); String title = movie.getString(JSON_TITLE); String vote = movie.getString(JSON_VOTE); ContentValues movieValues = new ContentValues(); movieValues.put(MovieEntry.COLUMN_ID, id); movieValues.put(MovieEntry.COLUMN_POSTER, poster); movieValues.put(MovieEntry.COLUMN_TITLE, title); movieValues.put(MovieEntry.COLUMN_OVERVIEW, overview); movieValues.put(MovieEntry.COLUMN_VOTE, vote); movieValues.put(MovieEntry.COLUMN_RELEASE, release); cVVector.add(movieValues); } int inserted = 0; //delete database int rowdeleted = mContext.getContentResolver().delete(MovieEntry.CONTENT_URI, null, null); // add to database if (cVVector.size() > 0) { ContentValues[] cvArray = new ContentValues[cVVector.size()]; cVVector.toArray(cvArray); inserted = mContext.getContentResolver().bulkInsert(MovieEntry.CONTENT_URI, cvArray); } } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); e.printStackTrace(); } }