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