View Javadoc

1   /*
2    *  Copyright (C) 2003-2005 SINTEF
3    *  Author:  fredrik dot vraalsen at sintef dot no
4    *  Webpage: http://coras.sourceforge.net/
5    *
6    *  This program is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public License
8    *  as published by the Free Software Foundation; either version 2.1
9    *  of the License, or (at your option) any later version.
10   *
11   *  This program is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this program; if not, write to the Free
18   *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19   *  02111-1307 USA
20   */
21  package no.sintef.assetrepository;
22  
23  import java.util.Calendar;
24  
25  import no.sintef.assetrepository.interfaces.AssetRepresentationValue;
26  import no.sintef.file.MimeTypeEnum;
27  
28  /***
29   * @author fvr
30   *
31   * TODO To change the template for this generated type comment go to
32   * Window - Preferences - Java - Code Style - Code Templates
33   */
34  public class Representation {
35  
36      private AssetRepresentationValue representation;
37  
38      /***
39       * @param string
40       * @param name
41       * @param mimeType
42       * @param content
43       * @param instance
44       * @return
45       */
46      public static Representation create(String type, String name, MimeTypeEnum mimeType, Object content, Calendar instance) {
47          AssetRepresentationValue representationValue = new AssetRepresentationValue();
48          representationValue.setType(type);
49          representationValue.setName(name);
50          representationValue.setMimeType(mimeType);
51          representationValue.setContent(content);
52          representationValue.setCreationDate(Calendar.getInstance());
53          return new Representation(representationValue);
54      }
55  
56      protected Representation(AssetRepresentationValue representation) {
57          super();
58          if (representation == null) {
59              throw new IllegalArgumentException("representation value is null");
60          }
61          this.representation = representation;
62      }
63      
64      public String getFilename() {
65          return representation.getName();
66      }
67      
68      public MimeTypeEnum getMimeType() {
69          return representation.getMimeType();
70      }
71      
72      public Calendar getCreationDate() {
73          return representation.getCreationDate();
74      }
75  
76      public String getType() {
77          return representation.getType();
78      }
79      
80      public Object getContent() {
81          return representation.getContent();
82      }
83      
84      protected AssetRepresentationValue getRepresentation() {
85          return representation;
86      }
87  
88  }