List of usage examples for java.util ArrayList toArray
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a)
From source file:com.wakatime.intellij.plugin.WakaTime.java
private static String[] buildCliCommand(Heartbeat heartbeat, ArrayList<Heartbeat> extraHeartbeats) { ArrayList<String> cmds = new ArrayList<String>(); cmds.add(Dependencies.getPythonLocation()); cmds.add(Dependencies.getCLILocation()); cmds.add("--entity"); cmds.add(heartbeat.entity);//w w w. ja v a2 s.c o m cmds.add("--time"); cmds.add(heartbeat.timestamp.toPlainString()); cmds.add("--key"); cmds.add(ApiKey.getApiKey()); if (heartbeat.project != null) { cmds.add("--project"); cmds.add(heartbeat.project); } cmds.add("--plugin"); cmds.add(IDE_NAME + "/" + IDE_VERSION + " " + IDE_NAME + "-wakatime/" + VERSION); if (heartbeat.isWrite) cmds.add("--write"); if (extraHeartbeats.size() > 0) cmds.add("--extra-heartbeats"); return cmds.toArray(new String[cmds.size()]); }
From source file:nl.tue.gale.ae.config.GaleContextLoader.java
@Override protected void customizeContext(ServletContext sc, ConfigurableWebApplicationContext ac) { super.customizeContext(sc, ac); ArrayList<String> locations = new ArrayList<String>(); locations.addAll(Arrays.asList(ac.getConfigLocations())); findLocations(sc, locations);//from www . j a v a2 s. c o m ac.setConfigLocations(locations.toArray(new String[] {})); }
From source file:com.jetyun.pgcd.rpc.reflect.ClassAnalyzer.java
/** * Analyze a class and create a ClassData object containing all of the * public methods (both static and non-static) in the class. * /* w w w . ja va 2 s . c o m*/ * @param clazz * class to be analyzed. * * @return a ClassData object containing all the public static and * non-static methods that can be invoked on the class. */ private static ClassData analyzeClass(Class clazz) { log.info("analyzing " + clazz.getName()); Method methods[] = clazz.getMethods(); ClassData cd = new ClassData(); cd.clazz = clazz; // Create temporary method map HashMap staticMethodMap = new HashMap(); HashMap methodMap = new HashMap(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getDeclaringClass() == Object.class) { continue; } int mod = methods[i].getModifiers(); if (!Modifier.isPublic(mod)) { continue; } Class param[] = method.getParameterTypes(); // don't count locally resolved args int argCount = 0; for (int n = 0; n < param.length; n++) { if (LocalArgController.isLocalArg(param[n])) { continue; } argCount++; } MethodKey mk = new MethodKey(method.getName(), argCount); ArrayList marr = (ArrayList) methodMap.get(mk); if (marr == null) { marr = new ArrayList(); methodMap.put(mk, marr); } marr.add(method); if (Modifier.isStatic(mod)) { marr = (ArrayList) staticMethodMap.get(mk); if (marr == null) { marr = new ArrayList(); staticMethodMap.put(mk, marr); } marr.add(method); } } cd.methodMap = new HashMap(); cd.staticMethodMap = new HashMap(); // Convert ArrayLists to arrays Iterator i = methodMap.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); MethodKey mk = (MethodKey) entry.getKey(); ArrayList marr = (ArrayList) entry.getValue(); if (marr.size() == 1) { cd.methodMap.put(mk, marr.get(0)); } else { cd.methodMap.put(mk, marr.toArray(new Method[0])); } } i = staticMethodMap.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); MethodKey mk = (MethodKey) entry.getKey(); ArrayList marr = (ArrayList) entry.getValue(); if (marr.size() == 1) { cd.staticMethodMap.put(mk, marr.get(0)); } else { cd.staticMethodMap.put(mk, marr.toArray(new Method[0])); } } return cd; }
From source file:graph.module.OntologyEdgeModule.java
@Override protected Object[] asIndexed(Node... nodes) { ArrayList<Object> args = recurseIndexed(nodes, ""); return args.toArray(new Object[args.size()]); }
From source file:com.seafile.seadroid2.provider.SeafileProvider.java
/** * Reduce column list to what we support. * * @param requested requested columns//from ww w .j ava 2 s.c o m * @param supported supported columns * @return common elements of both. */ private static String[] netProjection(String[] requested, String[] supported) { if (requested == null) { return (supported); } ArrayList<String> result = new ArrayList<String>(); for (String request : requested) { for (String support : supported) { if (request.equals(support)) { result.add(request); break; } } } return (result.toArray(new String[0])); }
From source file:com.intel.cosbench.driver.generator.HistogramIntGenerator.java
private static HistogramIntGenerator tryParse(String pattern) { pattern = StringUtils.substringBetween(pattern, "(", ")"); String[] args = StringUtils.split(pattern, ','); ArrayList<Bucket> bucketsList = new ArrayList<Bucket>(); for (String arg : args) { int v1 = StringUtils.indexOf(arg, '|'); int v2 = StringUtils.lastIndexOf(arg, '|'); boolean isOpenRange = ((v2 - v1) == 1) ? true : false; String[] values = StringUtils.split(arg, '|'); int lower, upper, weight; if (isOpenRange) { lower = Integer.parseInt(values[0]); upper = UniformIntGenerator.getMAXupper(); weight = Integer.parseInt(values[1]); } else if (values.length != 3) { throw new IllegalArgumentException(); } else {/* ww w .j a v a 2s .c o m*/ lower = Integer.parseInt(values[0]); upper = Integer.parseInt(values[1]); weight = Integer.parseInt(values[2]); } bucketsList.add(new Bucket(lower, upper, weight)); } if (bucketsList.isEmpty()) { throw new IllegalArgumentException(); } Collections.sort(bucketsList, new LowerComparator()); final Bucket[] buckets = bucketsList.toArray(new Bucket[0]); int cumulativeWeight = 0; for (Bucket bucket : buckets) { cumulativeWeight += bucket.weight; bucket.cumulativeWeight = cumulativeWeight; } return new HistogramIntGenerator(buckets); }
From source file:com.theelix.libreexplorer.FileManager.java
public static void createDestFiles() { ArrayList<String> destFiles = new ArrayList<>(); for (File selectedFile : selectedFiles) { String origFileName;//from w ww . j ava2s.co m String extension; try { origFileName = selectedFile.getName().substring(0, selectedFile.getName().lastIndexOf(".")); } catch (IndexOutOfBoundsException e) { origFileName = selectedFile.getName(); } String fileName = selectedFile.getName(); try { extension = fileName.substring(fileName.lastIndexOf(".")); } catch (IndexOutOfBoundsException e) { extension = ""; } int lastIndex = 1; while (new File(getCurrentDirectory() + File.separator + fileName).exists()) { fileName = origFileName + " (" + lastIndex + ")" + extension; lastIndex++; } destFiles.add(fileName); FileManager.destFiles = destFiles.toArray(new String[destFiles.size()]); } PasteTask task = new PasteTask(mContext); task.execute(); }
From source file:de.zib.gndms.gritserv.delegation.DelegationAux.java
public static EndpointReferenceType extractDelegationEPR(ContextT con) throws Exception { ContextTEntry[] entries = con.getEntry(); ArrayList<ContextTEntry> al = new ArrayList<ContextTEntry>(entries.length); EndpointReferenceType epr = null;/*from www . j a v a 2 s .c o m*/ for (ContextTEntry e : entries) { if (e.getKey().equals(DELEGATION_EPR_KEY)) { //epr = eprFormXML( e.get_value().toString( ) ); final String uuepr = e.get_value().toString(); logger.debug("encoded delegation epr: " + uuepr); final Base64 b64 = new Base64(4000, new byte[] {}, true); byte[] ba = b64.decode(uuepr); ByteArrayInputStream bis = new ByteArrayInputStream(ba); ObjectInputStream ois = new ObjectInputStream(bis); String eprs = (String) ois.readObject(); InputSource is = new InputSource(new StringReader(eprs)); epr = (EndpointReferenceType) ObjectDeserializer.deserialize(is, EndpointReferenceType.class); } else al.add(e); } ContextTEntry[] r = al.toArray(new ContextTEntry[al.size()]); con.setEntry(r); return epr; }
From source file:com.github.lynxdb.server.core.repository.EntryRepo.java
public void insertBulk(Vhost _vhost, List<Metric> _metricList) { ArrayList<Insert> inserts = new ArrayList<>(); _metricList.stream().forEach((m) -> { processMetric(_vhost, inserts, m); });//from w ww. j a v a 2 s . c o m ct.execute(QueryBuilder.batch(inserts.toArray(new Insert[inserts.size()]))); monitor.queryBatchCount.incrementAndGet(); monitor.queryPutCount.addAndGet(inserts.size()); }
From source file:cm.aptoide.ptdev.ScreenshotsViewer.java
@Override protected void onCreate(Bundle arg0) { Aptoide.getThemePicker().setAptoideTheme(this); super.onCreate(arg0); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.page_screenshots_viewer); if (arg0 == null) { currentItem = getIntent().getIntExtra("position", 0); } else {//from w w w . ja va 2s. c o m currentItem = arg0.getInt("position", 0); } getIntent().getIntExtra("position", 0); // getSupportActionBar().hide(); context = this; final ViewPager screenshots = (ViewPager) findViewById(R.id.screenShotsPager); // final CirclePageIndicator pi = (CirclePageIndicator) findViewById(R.id.indicator); // pi.setCentered(true); // pi.setSnap(true); // pi.setRadius(7.5f); // TypedValue a = new TypedValue(); // getTheme().resolveAttribute(R.attr.custom_color, a, true); // pi.setFillColor(a.data); ArrayList<String> uri = getIntent().getStringArrayListExtra("url"); hashCode = getIntent().getStringExtra("hashCode"); if (uri != null) { images = uri.toArray(images); } if (images != null && images.length > 0) { screenshots.setAdapter(new ViewPagerAdapterScreenshots(context, uri, hashCode, true)); screenshots.setCurrentItem(currentItem); } }