package de.ivu.elect.jee.servlet;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public class ByteArrayStaticResource implements StaticResource {

  private final String fileName;

  private final byte[] content;

  private final long lastModified;

  public ByteArrayStaticResource(String fileName, long lastModified, byte[] content) {
    this.fileName = fileName;
    this.lastModified = lastModified;
    this.content = content;
  }

  @Override
  public String getFileName() {
    return fileName;
  }

  @Override
  public long getLastModified() {
    return lastModified;
  }

  @Override
  public long getContentLength() {
    return content.length;
  }

  @Override
  public InputStream getInputStream() throws IOException {
    return new ByteArrayInputStream(content);
  }
}
