import java.util.Vector; //Stores data to be uploaded //Instead of passing lots of data to a method, can store them all inside this class //Then loop through the collection public class scriptUploadData { private static final String JPG = "image/jpg"; //Instead of knowing the content type, can use scriptUploadData.JPG private static final String JPEG = "image/jpeg"; private static final String GIF = "image/gif"; private static final String HTML_XHTML = "text/html"; //HTML is reserved, so had to give it a different name private Vector vecData = null; private Vector vecRef = null; private Vector vecFileName = null; private Vector vecContentType = null; //Create a default object with room for two items public scriptUploadData () { vecData = new Vector(2); vecRef = new Vector(2); vecFileName = new Vector(2); vecContentType = new Vector(2); } //Create an object with room for n items public scriptUploadData (int amount) { vecData = new Vector(amount); vecRef = new Vector(amount); vecFileName = new Vector(amount); vecContentType = new Vector(amount); } public int size () { return vecData.size(); } private boolean isValidIndex (int index) { if (index < 0 || index > (size() - 1)) { return false; } return true; } public byte[] getDataAt (int index) { if (isValidIndex(index)) { return (byte[])vecData.elementAt(index); } return null; } public String getRefAt (int index) { if (isValidIndex(index)) { return (String)vecRef.elementAt(index); } return null; } public String getFileNameAt (int index) { if (isValidIndex(index)) { return (String)vecFileName.elementAt(index); } return null; } public String getContentTypeAt (int index) { if (isValidIndex(index)) { return (String)vecContentType.elementAt(index); } return null; } public void put (byte[] data, String strRef, String strFileName, String strContentType) { vecData.addElement(data); //The raw item vecRef.addElement(strRef); //The name that the script will use to reference this item vecFileName.addElement(strFileName); //The address of the file on the computer vecContentType.addElement(strContentType); //The content type (e.g. image/jpg) } }