001package com.box.sdk; 002 003import com.eclipsesource.json.JsonObject; 004import com.eclipsesource.json.JsonValue; 005 006/** 007 * Represents a part of the file that is uploaded. 008 */ 009public class BoxFileUploadSessionPart extends BoxJSONObject { 010 011 private String partId; 012 private long offset; 013 private long size; 014 private String sha1; 015 016 /** 017 * Constructs an BoxFileUploadSessionPart object using an already parsed JSON object. 018 * 019 * @param jsonObject the parsed JSON object. 020 */ 021 BoxFileUploadSessionPart(JsonObject jsonObject) { 022 super(jsonObject); 023 } 024 025 /** 026 * Constructs an empty BoxFileUploadSessionPart object. 027 */ 028 BoxFileUploadSessionPart() { 029 super(); 030 } 031 032 /** 033 * Gets the sha1 digest of the part. 034 * 035 * @return the sh1 digest 036 */ 037 public String getSha1() { 038 return this.sha1; 039 } 040 041 /** 042 * Sets the sh1 digest of the part. 043 * 044 * @param sha1 the sh1 digest of the part 045 */ 046 public void setSha1(String sha1) { 047 this.sha1 = sha1; 048 } 049 050 /** 051 * Gets the part id. 052 * 053 * @return the id of the part. 054 */ 055 public String getPartId() { 056 return this.partId; 057 } 058 059 /** 060 * Sets the part id. 061 * 062 * @param partId the id of the part. 063 */ 064 public void setPartId(String partId) { 065 this.partId = partId; 066 } 067 068 /** 069 * Gets the offset byte. 070 * 071 * @return the offset of the part. 072 */ 073 public long getOffset() { 074 return this.offset; 075 } 076 077 /** 078 * Sets the offset. 079 * 080 * @param offset the offset byte of the part. 081 */ 082 public void setOffset(long offset) { 083 this.offset = offset; 084 } 085 086 /** 087 * Gets the size of the part. 088 * 089 * @return the size of the part. 090 */ 091 public long getSize() { 092 return this.size; 093 } 094 095 /** 096 * Sets the size of the part. 097 * 098 * @param size the size of the part. 099 */ 100 public void setSize(long size) { 101 this.size = size; 102 } 103 104 @Override 105 protected void parseJSONMember(JsonObject.Member member) { 106 String memberName = member.getName(); 107 JsonValue value = member.getValue(); 108 if (memberName.equals("part_id")) { 109 this.partId = value.asString(); 110 } else if (memberName.equals("offset")) { 111 this.offset = Double.valueOf(value.toString()).longValue(); 112 } else if (memberName.equals("size")) { 113 this.size = Double.valueOf(value.toString()).longValue(); 114 } else if (memberName.equals("sha1")) { 115 this.sha1 = value.asString(); 116 } 117 } 118}