View Javadoc

1   /*
2    * Copyright (c) 2002-2004
3    * All rights reserved.
4    */
5   
6   package com.atlassian.core.util.thumbnail;
7   
8   // Thumbnail image of image attachments.
9   public class Thumbnail
10  {
11      private final int height;
12      private final int width;
13  
14      private final String filename;
15      private final long attachmentId;
16  
17      private final MimeType mimeType;
18  
19      public enum MimeType
20      {
21          JPG("image/jpeg"),
22          PNG("image/png");
23  
24          private final String name;
25  
26          private MimeType(String name)
27          {
28              this.name = name;
29          }
30  
31          @Override
32          public String toString()
33          {
34              return name;
35          }
36      }
37  
38      public Thumbnail(int height, int width, String fileName, long attachmentId)
39      {
40          this(height, width, fileName, attachmentId, MimeType.JPG);
41      }
42  
43      public Thumbnail(final int height, final int width, final String filename, final long attachmentId, final MimeType mimeType)
44      {
45          this.height = height;
46          this.width = width;
47          this.mimeType = mimeType;
48          this.filename = filename;
49          this.attachmentId = attachmentId;
50      }
51  
52      public int getHeight()
53      {
54          return height;
55      }
56  
57      public int getWidth()
58      {
59          return width;
60      }
61  
62      /**
63       * Get the filename of the file this thumbnail represents.
64       */
65      public String getFilename()
66      {
67          return filename;
68      }
69  
70      /**
71       * the id of the attachment for which this is a thumbnail of
72       * @return
73       */
74      public long getAttachmentId()
75      {
76          return attachmentId;
77      }
78  
79      public MimeType getMimeType()
80      {
81          return mimeType;
82      }
83  
84      public String toString()
85      {
86          return "Thumbnail " + mimeType + " " + filename + " width:" + width + " height:" + height;
87      }
88  }