]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.export.core/src/org/simantics/export/core/manager/Content.java
ImportPdfReader now implements Closeable
[simantics/platform.git] / bundles / org.simantics.export.core / src / org / simantics / export / core / manager / Content.java
1 package org.simantics.export.core.manager;
2
3 import java.io.File;
4
5 import org.simantics.databoard.util.URIUtil;
6
7 public class Content {
8
9         public String url;
10         public String contentTypeId;
11         public String formatId;
12         public String formatExt; 
13         public String label;
14         public String modelId;
15
16         /**
17          * Initially suggested and the later used filename.
18          */
19         public String filename;
20         
21         /**
22          * This is an optional field that is filled one export action has been completed.
23          * This value is used by the publisher.
24          */
25         public File tmpFile;
26         
27         public Content(String url, String contentTypeId, String formatId, String label, String formatExt, String modelId) {
28                 this.url = url;
29                 this.contentTypeId = contentTypeId;
30                 this.formatId = formatId;
31                 this.formatExt = formatExt;
32                 this.label = label;
33                 this.modelId = modelId;
34                 if ( label!=null && formatExt!=null ) {
35                         String filename = label+formatExt;
36                         filename = filename.replaceAll("/", "-");
37                         this.filename = URIUtil.encodeFilename( filename );
38                 }
39         }               
40         
41         @Override
42         public String toString() {
43                 return "url="+url+",formatId="+formatId;
44         }
45         
46         @Override
47         public int hashCode() {
48                 return url.hashCode()+13*formatId.hashCode();
49         }
50         
51         @Override
52         public boolean equals(Object o) {
53                 Content other = (Content) o;
54                 if ( !other.formatId.equals(formatId) ) return false;
55                 if ( !other.url.equals(url) ) return false;
56                 return true;
57         }
58
59 }