/** * Constructor. If a positive "timeToLive" parameter is given, then the * expiration date is set accordingly. If "timeToLive" is equal to zero, * then the expiration date is set to the current date, meaning that it will * immediately expire on the client. If -1 is given, then no expiration date * is set. * * @param file * The represented file. * @param mediaType * The representation's media type. * @param timeToLive * The time to live before it expires (in seconds). */ public FileRepresentation(File file, MediaType mediaType, int timeToLive) { super(mediaType); this.file = file; setModificationDate(new Date(file.lastModified())); if (timeToLive == 0) { setExpirationDate(null); } else if (timeToLive > 0) { setExpirationDate(new Date(System.currentTimeMillis() + (1000L * timeToLive))); } setMediaType(mediaType); Disposition disposition = new Disposition(); disposition.setFilename(file.getName()); this.setDisposition(disposition); }