List of usage examples for java.util Vector toArray
@SuppressWarnings("unchecked") public synchronized <T> T[] toArray(T[] a)
From source file:org.martus.common.fieldspec.MiniFieldSpec.java
private String[] split(String codesAsString) { Vector codes = new Vector(); int nextCodeStart = 0; while (nextCodeStart < codesAsString.length()) { int nextSpace = codesAsString.indexOf(' ', nextCodeStart); if (nextSpace < 0) nextSpace = codesAsString.length(); String code = codesAsString.substring(nextCodeStart, nextSpace); codes.add(code);// w w w .ja v a 2 s . co m nextCodeStart = nextSpace + 1; } return (String[]) codes.toArray(new String[0]); }
From source file:org.thialfihar.android.apg.ui.SelectPublicKeyFragment.java
/** * Returns all selected user ids// w ww .j a v a 2 s . c om * * @return */ public String[] getSelectedUserIds() { Vector<String> userIds = new Vector<String>(); for (int i = 0; i < getListView().getCount(); ++i) { if (getListView().isItemChecked(i)) { userIds.add((String) mAdapter.getUserId(i)); } } // make empty array to not return null String userIdArray[] = new String[0]; return userIds.toArray(userIdArray); }
From source file:com.netpace.aims.controller.application.WapApplicationHelper.java
public static Double[] getWapVersionIds(Long wapAppsId) throws Exception { Double[] doubleIds = null;/*from w ww .j a v a 2 s . c o m*/ try { Collection wapAppVersions = WapApplicationManager.getWapAppVersions(wapAppsId); if (wapAppVersions != null) { Vector wapAppOldVersionIds = new Vector(); doubleIds = new Double[wapAppVersions.size()]; for (Iterator it = wapAppVersions.iterator(); it.hasNext();) { wapAppOldVersionIds.add(new Double((String) it.next())); } doubleIds = (Double[]) wapAppOldVersionIds.toArray(doubleIds); Arrays.sort(doubleIds); } } catch (Exception ex) { throw ex; } return doubleIds; }
From source file:edu.umn.cs.spatialHadoop.CommandLineArguments.java
public Point[] getPoints() { Vector<Point> points = new Vector<Point>(); for (String arg : args) { if (arg.startsWith("point:")) { Point point = new Point(); point.fromText(new Text(arg.substring(arg.indexOf(':') + 1))); points.add(point);/*from www. j ava 2 s. c om*/ } } return points.toArray(new Point[points.size()]); }
From source file:com.sshtools.common.ui.SessionProviderFactory.java
SessionProviderFactory() { ExtensionClassLoader classloader = ConfigurationLoader.getExtensionClassLoader(); try {// w w w .j av a2 s . com Enumeration enumr = classloader.getResources("session.provider"); URL url = null; Properties properties; InputStream in; SessionProvider provider; String name; String id; while (enumr.hasMoreElements()) { try { url = (URL) enumr.nextElement(); in = url.openStream(); properties = new Properties(); properties.load(in); IOUtil.closeStream(in); if (properties.containsKey("provider.class") && properties.containsKey("provider.name")) { Class cls = classloader.loadClass(properties.getProperty("provider.class")); String optionsClassName = properties.getProperty("provider.options"); Class optionsClass = optionsClassName == null || optionsClassName.equals("") ? null : classloader.loadClass(optionsClassName); String pageclass; int num = 1; Vector pages = new Vector(); do { pageclass = properties.getProperty("property.page." + String.valueOf(num), null); if (pageclass != null) { pages.add(classloader.loadClass(pageclass)); num++; } } while (pageclass != null); Class[] propertypages = new Class[pages.size()]; pages.toArray(propertypages); name = properties.getProperty("provider.name"); int weight = Integer.parseInt(properties.getProperty("provider.weight")); id = properties.getProperty("provider.id", name); provider = new SessionProvider(id, name, cls, properties.getProperty("provider.shortdesc"), properties.getProperty("provider.mnemonic"), properties.getProperty("provider.smallicon"), properties.getProperty("provider.largeicon"), optionsClass, propertypages, weight); providers.put(id, provider); log.info("Installed " + provider.getName() + " session provider"); } } catch (ClassNotFoundException ex) { log.warn("Session provider class not found", ex); } catch (IOException ex) { log.warn("Failed to read " + url.toExternalForm(), ex); } } } catch (IOException ex) { } }
From source file:org.mrgeo.format.AutoFeatureInputFormat.java
@Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Path[] paths = FileInputFormat.getInputPaths(context); List<InputSplit> result = new LinkedList<InputSplit>(); Configuration conf = context.getConfiguration(); // expand the wild cards and add up the total size by recursing. Vector<Path> expanded = new Vector<Path>(); long totalSize = 0; for (Path p : paths) { FileSystem fs = p.getFileSystem(conf); FileStatus[] status = fs.globStatus(p); for (FileStatus s : status) { totalSize += HadoopFileUtils.getPathSize(conf, s.getPath()); if (s.getPath() != null) { expanded.add(s.getPath()); }/*www.ja v a 2 s. c o m*/ } } paths = expanded.toArray(paths); // create the individual splits String inputs = conf.get("mapred.input.dir", ""); int totalSplits = conf.getInt("mapred.map.tasks", 2); for (Path p : paths) { double portion = HadoopFileUtils.getPathSize(conf, p) / totalSize; int splits = (int) Math.max(1, Math.round(portion * totalSplits)); conf.setInt("mapred.map.tasks", splits); conf.set("mapred.input.dir", p.toString()); InputFormat<LongWritable, Geometry> f = FeatureInputFormatFactory.getInstance() .createInputFormat(p.toString()); for (InputSplit s : f.getSplits(context)) { AutoInputSplit ais = new AutoInputSplit(conf, s, f); result.add(ais); } } conf.setInt("mapred.map.tasks", totalSplits); conf.set("mapred.input.dir", inputs); return result; }
From source file:com.anjlu.weighttracker.chart.LineFragment.java
private void compose(View v) { // init example series data Cursor cursor = getActivity().getContentResolver().query(WeightProvider.CONTENT_URI_WEIGHT, null, WeightProvider.WeightTracker.DATE_TRACK + " <= ?", new String[] { Utils.formatDate(Calendar.getInstance().getTime()) }, WeightProvider.WeightTracker._ID); int i = 0;//from w w w . j av a 2s. c o m Vector<GraphViewData> values = new Vector<GraphViewData>(); while (cursor.moveToNext()) { String dateTrack = cursor.getString(cursor.getColumnIndex(WeightProvider.WeightTracker.DATE_TRACK)); String weight = cursor.getString(cursor.getColumnIndex(WeightProvider.WeightTracker.WEIGHT)); Log.i(LineFragment.class.getCanonicalName(), "Date: " + dateTrack + "Weight: " + weight); values.add(new GraphViewData(i++, Double.parseDouble(weight))); } GraphViewData[] graphs = {}; graphs = values.toArray((GraphViewData[]) graphs); GraphViewSeries exampleSeries = new GraphViewSeries(graphs); GraphView graphView = new LineGraphView(getActivity() // context , "GraphViewDemo" // heading ); graphView.getGraphViewStyle().setNumHorizontalLabels(graphs.length); graphView.getGraphViewStyle().setGridColor(Color.WHITE); graphView.addSeries(exampleSeries); // data LinearLayout layout = (LinearLayout) v.findViewById(R.id.graph1); layout.addView(graphView); }
From source file:de.juwimm.cms.components.remote.ComponentsServiceSpringImpl.java
/** * @see de.juwimm.cms.components.remote.ComponentsServiceSpring#getDepartments4Name(java.lang.String) *//*from w w w . j av a 2 s. c o m*/ @Override protected DepartmentValue[] handleGetDepartments4Name(String name) throws Exception { UserHbm user = null; Iterator<DepartmentHbm> it = null; try { user = getUserHbmDao().load(AuthenticationHelper.getUserName()); it = getDepartmentHbmDao().findByName(user.getActiveSite().getSiteId(), name).iterator(); } catch (Exception e) { throw new UserException(e.getMessage()); } Vector<DepartmentValue> vec = new Vector<DepartmentValue>(); while (it.hasNext()) { vec.addElement(it.next().getDao(0)); } return vec.toArray(new DepartmentValue[0]); }
From source file:weka.core.old.NoNeighboursLinearNNSearch.java
/** * Gets the current settings.// w w w. ja v a 2 s . co m * * @return an array of strings suitable for passing to setOptions() */ public String[] getOptions() { Vector<String> result; String[] options; int i; result = new Vector<String>(); options = super.getOptions(); for (i = 0; i < options.length; i++) result.add(options[i]); if (getSkipIdentical()) result.add("-S"); return result.toArray(new String[result.size()]); }
From source file:com.ricemap.spateDB.util.CommandLineArguments.java
public Point3d[] getPoints() { Vector<Point3d> points = new Vector<Point3d>(); for (String arg : args) { if (arg.startsWith("point:")) { Point3d point = new Point3d(); point.fromText(new Text(arg.substring(arg.indexOf(':') + 1))); points.add(point);//from w w w . ja va2 s . c o m } } return points.toArray(new Point3d[points.size()]); }