code
public class Manager {
public final class Container {
private final int maxImageLen = 1024;
private int imageLen;
public final byte[] image = new byte[maxImageLen];
public int getImageLen() {
return imageLen;
}
public void setImageLen(int imageLen) throws Exception {
if (imageLen < 0 || imageLen > maxImageLen)
throw new Exception("imageLen is invalid!");
this.imageLen = imageLen;
}
public void setImage(byte[] image) throws Exception {
if (image == null || image.length > maxImageLen) {
throw new Exception("image is invalid!");
}
System.arraycopy(image, 0, this.image, 0, image.length);
}
}
}