1 23 24 package com.sun.enterprise.admin.common; 25 26 import java.io.Serializable ; 28 29 42 43 public class ByteChunk implements Serializable 44 { 45 46 public static final long serialVersionUID = 9100504074948693275L; 47 public static final int kChunkMaxSize = 10485760; 48 public static final int kChunkMinSize = 0; 50 private int mSize; 51 private boolean mIsLast; 52 private boolean mIsFirst; 53 private byte[] mBytes; 54 private String mChunkedFileName; 55 private String mTargetDir; 56 private String mUniqueId; 57 private long mTotalFileSize; 58 59 74 75 public ByteChunk(byte[] byteArray, String forFileName, 76 boolean isFirst, boolean isLast, String uniqueId, long totalFileSize) 77 { 78 int size =0; 79 if (byteArray != null) { 80 size = byteArray.length; 81 if ( size < kChunkMinSize || size > kChunkMaxSize) 82 { 83 throw new IllegalArgumentException (size + ""); 84 } 85 } 86 mSize = size; 87 mIsFirst = isFirst; 88 mIsLast = isLast; 89 mBytes = byteArray; 90 mChunkedFileName = forFileName; 91 mUniqueId = uniqueId; 92 mTotalFileSize = totalFileSize; 93 } 94 95 107 108 public ByteChunk(byte[] byteArray, String forFileName, 109 boolean isFirst, boolean isLast) 110 { 111 this(byteArray,forFileName,isFirst,isLast,forFileName, -1); 112 } 113 114 119 120 public boolean isLast() 121 { 122 return ( mIsLast ); 123 } 124 125 130 131 public boolean isFirst() 132 { 133 return ( mIsFirst ); 134 } 135 136 142 public int getSize() 143 { 144 return ( mSize ); 145 } 146 151 public byte[] getBytes() 152 { 153 return mBytes; 154 } 155 156 161 public String getChunkedFileName() 162 { 163 return ( mChunkedFileName ); 164 } 165 166 170 public String getTargetDir() 171 { 172 return ( mTargetDir ); 173 } 174 175 178 public void setTargetDir(String targetDir) 179 { 180 mTargetDir = targetDir; 181 } 182 183 186 public String getId() { 187 return mUniqueId; 188 } 189 190 193 public long getTotalFileSize() { 194 return mTotalFileSize; 195 } 196 } 197 | Popular Tags |