code
stringlengths
73
34.1k
label
stringclasses
1 value
public BoxRequestsFile.GetCollaborations getCollaborationsRequest(String id) { BoxRequestsFile.GetCollaborations request = new BoxRequestsFile.GetCollaborations(id, getFileCollaborationsUrl(id), mSession); return request; }
java
public BoxRequestsFile.GetFileVersions getVersionsRequest(String id) { BoxRequestsFile.GetFileVersions request = new BoxRequestsFile.GetFileVersions(id, getFileVersionsUrl(id), mSession); return request; }
java
public BoxRequestsFile.DeleteFileVersion getDeleteVersionRequest(String id, String versionId) { BoxRequestsFile.DeleteFileVersion request = new BoxRequestsFile.DeleteFileVersion(versionId, getDeleteFileVersionUrl(id, versionId), mSession); return request; }
java
public BoxRequestsFile.AddFileToCollection getAddToCollectionRequest(String fileId, String collectionId) { BoxRequestsFile.AddFileToCollection request = new BoxRequestsFile.AddFileToCollection(fileId, collectionId, getFileInfoUrl(fileId), mSession); return request; }
java
public BoxRequestsFile.DeleteFileFromCollection getDeleteFromCollectionRequest(String id) { BoxRequestsFile.DeleteFileFromCollection request = new BoxRequestsFile.DeleteFileFromCollection(id, getFileInfoUrl(id), mSession); return request; }
java
public BoxRequestsFile.FilePreviewed getFilePreviewedRequest(String fileId) { return new BoxRequestsFile.FilePreviewed(fileId, getPreviewFileUrl(), mSession); }
java
public BoxRequestsFile.GetUploadSession getUploadSession(String uploadSessionId) { return new BoxRequestsFile.GetUploadSession(uploadSessionId, getUploadSessionInfoUrl(uploadSessionId), mSession); }
java
public R setLimit(final int limit){ mQueryMap.put(FIELD_LIMIT, Integer.toString(limit)); return (R)this; }
java
public R setPreviousListEvents(E listEvents){ mListEvents = listEvents; this.setStreamPosition(((IStreamPosition)mListEvents).getNextStreamPosition().toString()); return (R)this; }
java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out capacity and any hidden stuff s.defaultWriteObject(); }
java
public static BoxFolder createFromIdAndName(String folderId, String name) { JsonObject object = new JsonObject(); object.add(BoxItem.FIELD_ID, folderId); object.add(BoxItem.FIELD_TYPE, BoxFolder.TYPE); if (!TextUtils.isEmpty(name)) { object.add(BoxItem.FIELD_NAME, name); ...
java
public static BoxBookmark createFromId(String bookmarkId) { JsonObject object = new JsonObject(); object.add(FIELD_ID, bookmarkId); object.add(FIELD_TYPE, TYPE); return new BoxBookmark(object); }
java
public BoxHttpRequest addHeader(String key, String value) { mUrlConnection.addRequestProperty(key, value); return this; }
java
public BoxHttpRequest setBody(InputStream body) throws IOException { mUrlConnection.setDoOutput(true); OutputStream output = mUrlConnection.getOutputStream(); int b = body.read(); while (b != -1) { output.write(b); b = body.read(); } output.close()...
java
public BoxRequestsUser.GetUserInfo getCurrentUserInfoRequest() { BoxRequestsUser.GetUserInfo request = new BoxRequestsUser.GetUserInfo(getUserInformationUrl("me"), mSession); return request; }
java
public BoxRequestsUser.GetUserInfo getUserInfoRequest(String id) { BoxRequestsUser.GetUserInfo request = new BoxRequestsUser.GetUserInfo(getUserInformationUrl(id), mSession); return request; }
java
public BoxRequestsUser.GetEnterpriseUsers getEnterpriseUsersRequest() { BoxRequestsUser.GetEnterpriseUsers request = new BoxRequestsUser.GetEnterpriseUsers(getUsersUrl(), mSession); return request; }
java
public BoxRequestsUser.CreateEnterpriseUser getCreateEnterpriseUserRequest(String login, String name) { BoxRequestsUser.CreateEnterpriseUser request = new BoxRequestsUser.CreateEnterpriseUser(getUsersUrl(), mSession, login, name); return request; }
java
public BoxRequestsUser.DeleteEnterpriseUser getDeleteEnterpriseUserRequest(String userId) { BoxRequestsUser.DeleteEnterpriseUser request = new BoxRequestsUser.DeleteEnterpriseUser(getUserInformationUrl(userId), mSession, userId); return request; }
java
public BoxRequestsFile.DownloadAvatar getDownloadAvatarRequest(File target, String userId) throws IOException{ if (!target.exists()){ throw new FileNotFoundException(); } BoxRequestsFile.DownloadAvatar request = new BoxRequestsFile.DownloadAvatar(userId, target, getAvatarDownloadUrl(...
java
public BoxRequestsFile.DownloadFile getDownloadAvatarRequest(OutputStream outputStream, String userId) { BoxRequestsFile.DownloadFile request = new BoxRequestsFile.DownloadFile(userId, outputStream, getAvatarDownloadUrl(userId), mSession); return request; }
java
public R setName(String name) { mBodyMap.put(BoxUser.FIELD_NAME, name); return (R) this; }
java
public R setRole(BoxUser.Role role) { mBodyMap.put(BoxUser.FIELD_ROLE, role); return (R) this; }
java
public R setJobTitle(String jobTitle) { mBodyMap.put(BoxUser.FIELD_JOB_TITLE, jobTitle); return (R) this; }
java
public R setPhone(String phone) { mBodyMap.put(BoxUser.FIELD_PHONE, phone); return (R) this; }
java
public R setAddress(String address) { mBodyMap.put(BoxUser.FIELD_ADDRESS, address); return (R) this; }
java
public R setStatus(BoxUser.Status status) { mBodyMap.put(BoxUser.FIELD_STATUS, status); return (R) this; }
java
public R setTimezone(String timezone) { mBodyMap.put(BoxUser.FIELD_TIMEZONE, timezone); return (R) this; }
java
public BoxRequestRecentItems.GetRecentItems getRecentItemsRequest() { BoxRequestRecentItems.GetRecentItems request = new BoxRequestRecentItems.GetRecentItems(getRecentItemsUrl(), mSession); return request; }
java
public boolean isEmbedLinkUrlExpired(){ Long urlCreationTime = getUrlCreationTime(); if (urlCreationTime == null){ return true; } return (System.currentTimeMillis() - urlCreationTime) < (60 * 1000); }
java
public boolean isPreviewSessionExpired(){ Long urlCreationTime = getUrlCreationTime(); if (urlCreationTime == null){ return true; } return (System.currentTimeMillis() - urlCreationTime) < (60 * 60 * 1000); }
java
public BoxRequestsBookmark.GetBookmarkInfo getInfoRequest(final String id) { BoxRequestsBookmark.GetBookmarkInfo request = new BoxRequestsBookmark.GetBookmarkInfo(id, getBookmarkInfoUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.CreateBookmark getCreateRequest(String parentId, String url) { BoxRequestsBookmark.CreateBookmark request = new BoxRequestsBookmark.CreateBookmark(parentId, url, getBookmarksUrl(), mSession); return request; }
java
public BoxRequestsBookmark.UpdateBookmark getUpdateRequest(String id) { BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.CopyBookmark getCopyRequest(String id, String parentId) { BoxRequestsBookmark.CopyBookmark request = new BoxRequestsBookmark.CopyBookmark(id, parentId, getBookmarkCopyUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.UpdateBookmark getRenameRequest(String id, String newName) { BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession); request.setName(newName); return request; }
java
public BoxRequestsBookmark.UpdateBookmark getMoveRequest(String id, String parentId) { BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession); request.setParentId(parentId); return request; }
java
public BoxRequestsBookmark.DeleteBookmark getDeleteRequest(String id) { BoxRequestsBookmark.DeleteBookmark request = new BoxRequestsBookmark.DeleteBookmark(id, getBookmarkInfoUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.UpdateSharedBookmark getCreateSharedLinkRequest(String id) { BoxRequestsBookmark.UpdateSharedBookmark request = new BoxRequestsBookmark.UpdateSharedBookmark(id, getBookmarkInfoUrl(id), mSession) .setAccess(null); return request; }
java
public BoxRequestsBookmark.UpdateBookmark getDisableSharedLinkRequest(String id) { BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession) .setSharedLink(null); return request; }
java
public BoxRequestsBookmark.AddCommentToBookmark getAddCommentRequest(String bookmarkId, String message) { BoxRequestsBookmark.AddCommentToBookmark request = new BoxRequestsBookmark.AddCommentToBookmark(bookmarkId, message, getCommentUrl(), mSession); return request; }
java
public BoxRequestsBookmark.GetTrashedBookmark getTrashedBookmarkRequest(String id) { BoxRequestsBookmark.GetTrashedBookmark request = new BoxRequestsBookmark.GetTrashedBookmark(id, getTrashedBookmarkUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.DeleteTrashedBookmark getDeleteTrashedBookmarkRequest(String id) { BoxRequestsBookmark.DeleteTrashedBookmark request = new BoxRequestsBookmark.DeleteTrashedBookmark(id, getTrashedBookmarkUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.RestoreTrashedBookmark getRestoreTrashedBookmarkRequest(String id) { BoxRequestsBookmark.RestoreTrashedBookmark request = new BoxRequestsBookmark.RestoreTrashedBookmark(id, getBookmarkInfoUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.GetBookmarkComments getCommentsRequest(String id) { BoxRequestsBookmark.GetBookmarkComments request = new BoxRequestsBookmark.GetBookmarkComments(id, getBookmarkCommentsUrl(id), mSession); return request; }
java
public BoxRequestsBookmark.AddBookmarkToCollection getAddToCollectionRequest(String bookmarkId, String collectionId) { BoxRequestsBookmark.AddBookmarkToCollection request = new BoxRequestsBookmark.AddBookmarkToCollection(bookmarkId, collectionId, getBookmarkInfoUrl(bookmarkId), mSession); return request...
java
public BoxRequestsBookmark.DeleteBookmarkFromCollection getDeleteFromCollectionRequest(String id) { BoxRequestsBookmark.DeleteBookmarkFromCollection request = new BoxRequestsBookmark.DeleteBookmarkFromCollection(id, getBookmarkInfoUrl(id), mSession); return request; }
java
public BoxSimpleMessage connect() { mRetries = 0; try { BoxIteratorRealTimeServers servers = (BoxIteratorRealTimeServers)mRequest.send(); mBoxRealTimeServer = servers.get(0); } catch (BoxException e){ mChangeListener.onException(e, this); return nu...
java
public void putField(String key, Date value) { this.fields.put(key, BoxDateFormat.format(value)); }
java
public void setFile(InputStream inputStream, String filename, long fileSize) { this.setFile(inputStream, filename); this.fileSize = fileSize; }
java
public static String getRepresentationHintString(String repType, String repSize) { StringBuffer sb = new StringBuffer(repType); if(TYPE_JPG.equals(repType) || TYPE_PNG.equals(repType)) { if(TextUtils.isEmpty(repSize)) { throw new InvalidParameterException("Size is not optiona...
java
public Long getNextStreamPosition() { String longValue = getPropertyAsString(FIELD_NEXT_STREAM_POSITION); return Long.parseLong(longValue.replace("\"", "")); }
java
public static BoxFile createFromIdAndName(String fileId, String name) { JsonObject object = new JsonObject(); object.add(BoxItem.FIELD_ID, fileId); object.add(BoxItem.FIELD_TYPE, BoxFile.TYPE); if (!TextUtils.isEmpty(name)) { object.add(BoxItem.FIELD_NAME, name); } ...
java
private void loadRootFolder() { new Thread() { @Override public void run() { try { //Api to fetch root folder final BoxIteratorItems folderItems = mFolderApi.getItemsRequest(BoxConstants.ROOT_FOLDER_ID).send(); r...
java
private void uploadSampleFile() { mDialog = ProgressDialog.show(MainActivity.this, getText(R.string.boxsdk_Please_wait), getText(R.string.boxsdk_Please_wait)); new Thread() { @Override public void run() { try { String uploadFileName = "box_logo...
java
private void uploadNewVersion(final BoxFile file) { new Thread() { @Override public void run() { try { String uploadFileName = "box_logo.png"; InputStream uploadStream = getResources().getAssets().open(uploadFileName); ...
java
public static void copyStream(final InputStream inputStream, final OutputStream outputStream) throws IOException, InterruptedException { copyStream(inputStream, outputStream, null); }
java
public static String copyStreamAndComputeSha1(final InputStream inputStream, final OutputStream outputStream) throws NoSuchAlgorithmException, IOException, InterruptedException { MessageDigest md = MessageDigest.getInstance("SHA-1"); copyStream(inputStream, outputStream, md); return ...
java
private static void copyStream(final InputStream inputStream, final OutputStream outputStream, MessageDigest messageDigest) throws IOException, InterruptedException { // Read the rest of the stream and write to the destination OutputStream. final byte[] buffer = new byte[BUFFER_SIZE]; ...
java
public static OutputStream createArrayOutputStream(final OutputStream[] outputStreams) { return new OutputStream() { @Override public void close() throws IOException { for (OutputStream o : outputStreams) { o.close(); } ...
java
public static String sha1(final InputStream inputStream) throws IOException, NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] bytes = new byte[8192]; int byteCount; while ((byteCount = inputStream.read(bytes)) > 0) { md.update(bytes, 0,...
java
public static long parseJsonValueToLong(JsonValue value) { try { return value.asLong(); } catch (UnsupportedOperationException e) { String s = value.asString().replace("\"", ""); return Long.parseLong(s); } }
java
public static long parseJsonValueToInteger(JsonValue value) { try { return value.asInt(); } catch (UnsupportedOperationException e) { String s = value.asString().replace("\"", ""); return Integer.parseInt(s); } }
java
public static String concatStringWithDelimiter(String[] strings, String delimiter) { StringBuilder sbr = new StringBuilder(); int size = strings.length; for (int i = 0; i < size - 1; i++) { sbr.append(strings[i]).append(delimiter); } sbr.append(strings[size - 1]); ...
java
public static <T extends Object> T cloneSerializable(T source) { ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; ByteArrayInputStream bais = null; ObjectInputStream ois = null; try { baos = new ByteArrayOutputStream(); oos = new ObjectOut...
java
public static String convertSerializableToString(Serializable obj) { ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(obj); return new S...
java
public static boolean deleteFolderRecursive(final File f) { if (f.isDirectory()) { File[] files = f.listFiles(); if (files == null) { return false; } for (File c : files) { deleteFolderRecursive(c); } } r...
java
public static boolean isInternetAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return isInternetAvailable...
java
public static String getAssetFile(final Context context, final String assetName) { // if the file is not found create it and return that. // if we do not have a file we copy our asset out to create one. AssetManager assetManager = context.getAssets(); BufferedReader in = null; tr...
java
public static void toastSafely(final Context context, final int resId, final int duration) { Long lastToastTime = LAST_TOAST_TIME.get(resId); if (lastToastTime != null && (lastToastTime + TOAST_MIN_REPEAT_DELAY) < System.currentTimeMillis()) { return; } Looper mainLooper = Lo...
java
public static void setInitialsThumb(Context context, TextView initialsView, String fullName) { char initial1 = '\u0000'; char initial2 = '\u0000'; if (fullName != null) { String[] nameParts = fullName.split(" "); if (nameParts[0].length() > 0) { initial1 =...
java
public static void setCollabNumberThumb(Context context, TextView initialsView, int collabNumber) { String collabNumberDisplay = (collabNumber >= 100) ? "+99" : "+" + Integer.toString(collabNumber); setColorForCollabNumberThumb(initialsView); initialsView.setTextColor(COLLAB_NUMBER_THUMB_COLOR);...
java
public static void setColorsThumb(TextView initialsView, int backgroundColor, int strokeColor) { GradientDrawable drawable = (GradientDrawable) initialsView.getResources().getDrawable(R.drawable.boxsdk_thumb_background); drawable.setColorFilter(backgroundColor, PorterDuff.Mode.MULTIPLY); if (Bui...
java
public static void setColorForInitialsThumb(TextView initialsView, int position) { int backgroundColor = THUMB_COLORS[(position) % THUMB_COLORS.length]; setColorsThumb(initialsView, backgroundColor, Color.WHITE); }
java
public static String getLocalizedFileSize(final Context context, double numSize) { String localeLanguage = Locale.getDefault().getLanguage(); if (!SIZE_LANGUAGE.equals(localeLanguage) && context != null && context.getResources() != null) { Resources resources = context.getResources(); ...
java
protected R setCollectionId(String id) { JsonArray jsonArray = new JsonArray(); if (!TextUtils.isEmpty(id)) { BoxCollection col = BoxCollection.createFromId(id); jsonArray.add(col.toJsonObject()); } mBodyMap.put(FIELD_COLLECTIONS, jsonArray); return (R) th...
java
public BoxRequestsFolder.GetFolderInfo getInfoRequest(String id) { BoxRequestsFolder.GetFolderInfo request = new BoxRequestsFolder.GetFolderInfo(id, getFolderInfoUrl(id), mSession); return request; }
java
public BoxRequestsFolder.GetFolderItems getItemsRequest(String id) { BoxRequestsFolder.GetFolderItems request = new BoxRequestsFolder.GetFolderItems(id, getFolderItemsUrl(id), mSession); return request; }
java
public BoxRequestsFolder.CreateFolder getCreateRequest(String parentId, String name) { BoxRequestsFolder.CreateFolder request = new BoxRequestsFolder.CreateFolder(parentId, name, getFoldersUrl(), mSession); return request; }
java
public BoxRequestsFolder.UpdateFolder getUpdateRequest(String id) { BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession); return request; }
java
public BoxRequestsFolder.UpdateFolder getRenameRequest(String id, String newName) { BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession) .setName(newName); return request; }
java
public BoxRequestsFolder.UpdateFolder getMoveRequest(String id, String parentId) { BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession) .setParentId(parentId); return request; }
java
public BoxRequestsFolder.CopyFolder getCopyRequest(String id, String parentId) { BoxRequestsFolder.CopyFolder request = new BoxRequestsFolder.CopyFolder(id, parentId, getFolderCopyUrl(id), mSession); return request; }
java
public BoxRequestsFolder.GetCollaborations getCollaborationsRequest(String id) { BoxRequestsFolder.GetCollaborations request = new BoxRequestsFolder.GetCollaborations(id, getFolderCollaborationsUrl(id), mSession); return request; }
java
public BoxRequestsFolder.UpdateSharedFolder getCreateSharedLinkRequest(String id) { BoxRequestsFolder.UpdateSharedFolder request = new BoxRequestsFolder.UpdateSharedFolder(id, getFolderInfoUrl(id), mSession) .setAccess(null); return request; }
java
public BoxRequestsFolder.AddFolderToCollection getAddToCollectionRequest(String folderId, String collectionId) { BoxRequestsFolder.AddFolderToCollection request = new BoxRequestsFolder.AddFolderToCollection(folderId, collectionId, getFolderInfoUrl(folderId), mSession); return request; }
java
public BoxRequestsFolder.DeleteFolderFromCollection getDeleteFromCollectionRequest(String id) { BoxRequestsFolder.DeleteFolderFromCollection request = new BoxRequestsFolder.DeleteFolderFromCollection(id, getFolderInfoUrl(id), mSession); return request; }
java
public BoxRequestsFolder.GetTrashedItems getTrashedItemsRequest() { BoxRequestsFolder.GetTrashedItems request = new BoxRequestsFolder.GetTrashedItems(getTrashedItemsUrl(), mSession); return request; }
java
public BoxRequestsFolder.GetTrashedFolder getTrashedFolderRequest(String id) { BoxRequestsFolder.GetTrashedFolder request = new BoxRequestsFolder.GetTrashedFolder(id, getTrashedFolderUrl(id), mSession); return request; }
java
public BoxRequestsFolder.DeleteTrashedFolder getDeleteTrashedFolderRequest(String id) { BoxRequestsFolder.DeleteTrashedFolder request = new BoxRequestsFolder.DeleteTrashedFolder(id, getTrashedFolderUrl(id), mSession); return request; }
java
public BoxRequestsFolder.RestoreTrashedFolder getRestoreTrashedFolderRequest(String id) { BoxRequestsFolder.RestoreTrashedFolder request = new BoxRequestsFolder.RestoreTrashedFolder(id, getFolderInfoUrl(id), mSession); return request; }
java
public BoxRequestsShare.GetCollaborationInfo getInfoRequest(String collaborationId) { BoxRequestsShare.GetCollaborationInfo collab = new BoxRequestsShare.GetCollaborationInfo(collaborationId, getCollaborationInfoUrl(collaborationId), mSession); return collab; }
java
public BoxRequestsShare.AddCollaboration getAddRequest(BoxCollaborationItem collaborationItem, BoxCollaboration.Role role, String login) { BoxRequestsShare.AddCollaboration collab = new BoxRequestsShare.AddCollaboration(getCollaborationsUrl(), createStubItem(collaborationItem), role, login, mSes...
java
public BoxRequestsShare.GetPendingCollaborations getPendingCollaborationsRequest() { BoxRequestsShare.GetPendingCollaborations request = new BoxRequestsShare.GetPendingCollaborations(getCollaborationsUrl(), mSession); return request; }
java
public BoxRequestsShare.DeleteCollaboration getDeleteRequest(String collaborationId) { BoxRequestsShare.DeleteCollaboration collab = new BoxRequestsShare.DeleteCollaboration(collaborationId, getCollaborationInfoUrl(collaborationId), mSession); return collab; }
java
public BoxRequestsShare.UpdateOwner getUpdateOwnerRequest(String collaborationId) { BoxRequestsShare.UpdateOwner collab = new BoxRequestsShare.UpdateOwner(collaborationId, getCollaborationInfoUrl(collaborationId), mSession); return collab; }
java
public static String format(Date date) { String format = LOCAL_DATE_FORMAT.format(date); // Java 6 does not have a convenient way of having the colon in the timezone offset return format.substring(0,22) + ":" + format.substring(22); }
java
public static String getTimeRangeString(Date fromDate, Date toDate) { if (fromDate == null && toDate == null) { return null; } StringBuilder sbr = new StringBuilder(); if (fromDate != null) { sbr.append(format(fromDate)); } sbr.append(","); ...
java
public BoxError getAsBoxError() { try { BoxError error = new BoxError(); error.createFromJson(getResponse()); return error; } catch (Exception e) { return null; } }
java
public String getDescription() { return mBodyMap.containsKey(BoxItem.FIELD_DESCRIPTION) ? (String) mBodyMap.get(BoxItem.FIELD_DESCRIPTION) : null; }
java