List of usage examples for java.util AbstractList size
int size();
From source file:com.oltpbenchmark.util.CollectionUtil.java
/** * Return the last item in an Iterable/*from ww w . jav a 2 s . c o m*/ * @param <T> * @param items * @return */ public static <T> T last(Iterable<T> items) { T last = null; if (items instanceof AbstractList<?>) { AbstractList<T> list = (AbstractList<T>) items; last = (list.isEmpty() ? null : list.get(list.size() - 1)); } else { for (T t : items) { last = t; } } return (last); }
From source file:org.apache.hadoop.hive.metastore.Warehouse.java
/** * Extracts values from partition name without the column names. * @param name Partition name./* ww w . j av a2 s . c o m*/ * @param result The result. Must be pre-sized to the expected number of columns. */ public static AbstractList<String> makeValsFromName(String name, AbstractList<String> result) throws MetaException { assert name != null; String[] parts = slash.split(name, 0); if (result == null) { result = new ArrayList<>(parts.length); for (int i = 0; i < parts.length; ++i) { result.add(null); } } else if (parts.length != result.size()) { throw new MetaException( "Expected " + result.size() + " components, got " + parts.length + " (" + name + ")"); } for (int i = 0; i < parts.length; ++i) { int eq = parts[i].indexOf('='); if (eq <= 0) { throw new MetaException("Unexpected component " + parts[i]); } result.set(i, unescapePathName(parts[i].substring(eq + 1))); } return result; }
From source file:eu.linda.analytics.formats.TXTOutputFormat.java
@Override public void exportData(Analytics analytics, AbstractList dataToExport) { if (dataToExport.size() != 0) { helpfulFuncions.nicePrintMessage("Export to TXT"); String[] splitedSourceFileName = analytics.getDocument().split("\\."); String targetFileName = (splitedSourceFileName[0] + "_" + analytics.getAlgorithm_name() + "_resultdocument.txt").replace("datasets", "results"); String targetFileNameFullPath = Configuration.docroot + targetFileName; helpfulFuncions.saveFile(targetFileNameFullPath, dataToExport.toString()); connectionController.updateLindaAnalytics(targetFileName, "resultdocument", analytics.getId()); connectionController.updateLindaAnalyticsVersion(analytics.getVersion(), analytics.getId()); } else {// w w w . ja v a 2 s.c o m helpfulFuncions.nicePrintMessage("There are no data to be exported to TXT"); if (!analytics.getResultdocument().equalsIgnoreCase("")) { helpfulFuncions.cleanPreviousInfo(analytics); } } }
From source file:com.digitalarx.android.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * // ww w . ja v a 2 s . c om * New downloads are added calling to startService(), resulting in a call to this method. This ensures the service will keep on working * although the caller activity goes away. */ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE) /*!intent.hasExtra(EXTRA_FILE_PATH) || !intent.hasExtra(EXTRA_REMOTE_PATH)*/ ) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection) String downloadKey = buildRemoteName(account, file); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); mPendingDownloads.putIfAbsent(downloadKey, newDownload); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); requestedDownloads.add(downloadKey); sendBroadcastNewDownload(newDownload); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } return START_NOT_STICKY; }
From source file:com.owncloud.android.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. *///from w w w .j a v a 2 s. co m @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<String>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); String downloadKey = putResult.first; requestedDownloads.add(downloadKey); sendBroadcastNewDownload(newDownload, putResult.second); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:com.cerema.cloud2.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. *//*from w w w .j av a2 s .c o m*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<String>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); if (putResult != null) { String downloadKey = putResult.first; requestedDownloads.add(downloadKey); sendBroadcastNewDownload(newDownload, putResult.second); } // else, file already in the queue of downloads; don't repeat the request } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:net.gaast.giggity.ScheduleViewActivity.java
public void showItem(Schedule.Item item, final AbstractList<Schedule.Item> others, boolean new_activity) { /* No cleanup required for non-tablet view. */ if (tabletView) { bigScreen.removeView(eventDialogView); eventDialogView = null;// w ww . ja v a 2 s . co m } /* And nothing else to do if we're cleaning up only. */ if (item == null) { return; } if (tabletView && !new_activity) { eventDialogView = new EventDialogPager(this, item, others); eventDialogView.setTitleClick(new View.OnClickListener() { @Override public void onClick(View v) { showItem(eventDialogView.getShownItem(), others, true); } }); bigScreen.addView(eventDialogView, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 4)); } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.getUrl()), this, ScheduleItemActivity.class); if (others != null) { String[] ids = new String[others.size()]; int i = 0; for (Schedule.Item o : others) { ids[i++] = o.getId(); } intent.putExtra("others", ids); } startActivityForResult(intent, 0); } }
From source file:com.synox.android.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * <p/>//from www . ja v a 2 s. c o m * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. */ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); String downloadKey = putResult.first; requestedDownloads.add(downloadKey); // Store file on db with state 'downloading' /* TODO - check if helps with UI responsiveness, letting only folders use FileDownloaderBinder to check FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver()); file.setDownloading(true); storageManager.saveFile(file); */ sendBroadcastNewDownload(newDownload, putResult.second); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:com.digitalarx.android.files.services.FileUploader.java
/** * Entry point to add one or several files to the queue of uploads. * /* w ww. j a va 2 s. co m*/ * New uploads are added calling to startService(), resulting in a call to * this method. This ensures the service will keep on working although the * caller activity goes away. */ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE) || !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) { Log_OC.e(TAG, "Not enough information provided in intent"); return Service.START_NOT_STICKY; } int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1); if (uploadType == -1) { Log_OC.e(TAG, "Incorrect upload type provided"); return Service.START_NOT_STICKY; } Account account = intent.getParcelableExtra(KEY_ACCOUNT); String[] localPaths = null, remotePaths = null, mimeTypes = null; OCFile[] files = null; if (uploadType == UPLOAD_SINGLE_FILE) { if (intent.hasExtra(KEY_FILE)) { files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) }; } else { localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) }; remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) }; mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) }; } } else { // mUploadType == UPLOAD_MULTIPLE_FILES if (intent.hasExtra(KEY_FILE)) { files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE); // TODO // will // this // casting // work // fine? } else { localPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE); remotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE); mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE); } } FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver()); boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false); boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false); int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_COPY); if (intent.hasExtra(KEY_FILE) && files == null) { Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent"); return Service.START_NOT_STICKY; } else if (!intent.hasExtra(KEY_FILE)) { if (localPaths == null) { Log_OC.e(TAG, "Incorrect array for local paths provided in upload intent"); return Service.START_NOT_STICKY; } if (remotePaths == null) { Log_OC.e(TAG, "Incorrect array for remote paths provided in upload intent"); return Service.START_NOT_STICKY; } if (localPaths.length != remotePaths.length) { Log_OC.e(TAG, "Different number of remote paths and local paths!"); return Service.START_NOT_STICKY; } files = new OCFile[localPaths.length]; for (int i = 0; i < localPaths.length; i++) { files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], ((mimeTypes != null) ? mimeTypes[i] : (String) null), storageManager); if (files[i] == null) { // TODO @andomaex add failure Notification return Service.START_NOT_STICKY; } } } AccountManager aMgr = AccountManager.get(this); String version = aMgr.getUserData(account, Constants.KEY_OC_VERSION); OwnCloudVersion ocv = new OwnCloudVersion(version); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList<String> requestedUploads = new Vector<String>(); String uploadKey = null; UploadFileOperation newUpload = null; try { for (int i = 0; i < files.length; i++) { uploadKey = buildRemoteName(account, files[i].getRemotePath()); newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite, localAction, getApplicationContext()); if (isInstant) { newUpload.setRemoteFolderToBeCreated(); } mPendingUploads.putIfAbsent(uploadKey, newUpload); // Grants that the file only upload once time newUpload.addDatatransferProgressListener(this); newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder); requestedUploads.add(uploadKey); } } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (IllegalStateException e) { Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (Exception e) { Log_OC.e(TAG, "Unexpected exception while processing upload intent", e); return START_NOT_STICKY; } if (requestedUploads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedUploads; mServiceHandler.sendMessage(msg); } Log_OC.i(TAG, "mPendingUploads size:" + mPendingUploads.size()); return Service.START_NOT_STICKY; }
From source file:com.owncloud.android.files.services.FileUploader.java
/** * Entry point to add one or several files to the queue of uploads. * * New uploads are added calling to startService(), resulting in a call to * this method. This ensures the service will keep on working although the * caller activity goes away./*from w w w. ja v a 2 s. c o m*/ */ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE) || !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) { Log_OC.e(TAG, "Not enough information provided in intent"); return Service.START_NOT_STICKY; } int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1); if (uploadType == -1) { Log_OC.e(TAG, "Incorrect upload type provided"); return Service.START_NOT_STICKY; } Account account = intent.getParcelableExtra(KEY_ACCOUNT); if (!AccountUtils.exists(account, getApplicationContext())) { return Service.START_NOT_STICKY; } String[] localPaths = null, remotePaths = null, mimeTypes = null; OCFile[] files = null; if (uploadType == UPLOAD_SINGLE_FILE) { if (intent.hasExtra(KEY_FILE)) { files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) }; } else { localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) }; remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) }; mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) }; } } else { // mUploadType == UPLOAD_MULTIPLE_FILES if (intent.hasExtra(KEY_FILE)) { files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE); // TODO // will // this // casting // work // fine? } else { localPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE); remotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE); mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE); } } FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver()); boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false); boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false); int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_COPY); if (intent.hasExtra(KEY_FILE) && files == null) { Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent"); return Service.START_NOT_STICKY; } else if (!intent.hasExtra(KEY_FILE)) { if (localPaths == null) { Log_OC.e(TAG, "Incorrect array for local paths provided in upload intent"); return Service.START_NOT_STICKY; } if (remotePaths == null) { Log_OC.e(TAG, "Incorrect array for remote paths provided in upload intent"); return Service.START_NOT_STICKY; } if (localPaths.length != remotePaths.length) { Log_OC.e(TAG, "Different number of remote paths and local paths!"); return Service.START_NOT_STICKY; } files = new OCFile[localPaths.length]; for (int i = 0; i < localPaths.length; i++) { files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], ((mimeTypes != null) ? mimeTypes[i] : null)); if (files[i] == null) { // TODO @andomaex add failure Notification return Service.START_NOT_STICKY; } } } OwnCloudVersion ocv = AccountUtils.getServerVersion(account); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList<String> requestedUploads = new Vector<String>(); String uploadKey = null; UploadFileOperation newUpload = null; try { for (int i = 0; i < files.length; i++) { newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite, localAction, getApplicationContext()); if (isInstant) { newUpload.setRemoteFolderToBeCreated(); } newUpload.addDatatransferProgressListener(this); newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder); Pair<String, String> putResult = mPendingUploads.putIfAbsent(account, files[i].getRemotePath(), newUpload); uploadKey = putResult.first; requestedUploads.add(uploadKey); } } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (IllegalStateException e) { Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (Exception e) { Log_OC.e(TAG, "Unexpected exception while processing upload intent", e); return START_NOT_STICKY; } if (requestedUploads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedUploads; mServiceHandler.sendMessage(msg); } return Service.START_NOT_STICKY; }