]> _ Git - cubeextranet.git/blob
d357812df54ace927b5840abef11358e9211c4fd
[cubeextranet.git] /
1 /*\r
2  * Licensed to the Apache Software Foundation (ASF) under one or more\r
3  * contributor license agreements.  See the NOTICE file distributed with\r
4  * this work for additional information regarding copyright ownership.\r
5  * The ASF licenses this file to You under the Apache License, Version 2.0\r
6  * (the "License"); you may not use this file except in compliance with\r
7  * the License.  You may obtain a copy of the License at\r
8  *\r
9  *      http://www.apache.org/licenses/LICENSE-2.0\r
10  *\r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 package org.apache.pdfbox.pdmodel.common.filespecification;\r
18 \r
19 import org.apache.pdfbox.cos.COSBase;\r
20 import org.apache.pdfbox.cos.COSDictionary;\r
21 import org.apache.pdfbox.cos.COSStream;\r
22 \r
23 /**\r
24  * This represents a file specification.\r
25  *\r
26  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>\r
27  * @version $Revision: 1.4 $\r
28  */\r
29 public class PDComplexFileSpecification extends PDFileSpecification\r
30 {\r
31     private COSDictionary fs;\r
32 \r
33     /**\r
34      * Default Constructor.\r
35      */\r
36     public PDComplexFileSpecification()\r
37     {\r
38         fs = new COSDictionary();\r
39         fs.setName( "Type", "Filespec" );\r
40     }\r
41 \r
42     /**\r
43      * Constructor.\r
44      *\r
45      * @param dict The dictionary that fulfils this file specification.\r
46      */\r
47     public PDComplexFileSpecification( COSDictionary dict )\r
48     {\r
49         fs = dict;\r
50     }\r
51 \r
52     /**\r
53      * Convert this standard java object to a COS object.\r
54      *\r
55      * @return The cos object that matches this Java object.\r
56      */\r
57     public COSBase getCOSObject()\r
58     {\r
59         return fs;\r
60     }\r
61 \r
62     /**\r
63      * Convert this standard java object to a COS object.\r
64      *\r
65      * @return The cos object that matches this Java object.\r
66      */\r
67     public COSDictionary getCOSDictionary()\r
68     {\r
69         return fs;\r
70     }\r
71 \r
72     /**\r
73      * This will get the file name.\r
74      *\r
75      * @return The file name.\r
76      */\r
77     public String getFile()\r
78     {\r
79         return fs.getString( "F" );\r
80     }\r
81 \r
82     /**\r
83      * This will set the file name.\r
84      *\r
85      * @param file The name of the file.\r
86      */\r
87     public void setFile( String file )\r
88     {\r
89         fs.setString( "F", file );\r
90     }\r
91 \r
92     /**\r
93      * This will get the name representing a Dos file.\r
94      *\r
95      * @return The file name.\r
96      */\r
97     public String getFileDos()\r
98     {\r
99         return fs.getString( "DOS" );\r
100     }\r
101 \r
102     /**\r
103      * This will set name representing a dos file.\r
104      *\r
105      * @param file The name of the file.\r
106      */\r
107     public void setFileDos( String file )\r
108     {\r
109         fs.setString( "DOS", file );\r
110     }\r
111 \r
112     /**\r
113      * This will get the name representing a Mac file.\r
114      *\r
115      * @return The file name.\r
116      */\r
117     public String getFileMac()\r
118     {\r
119         return fs.getString( "Mac" );\r
120     }\r
121 \r
122     /**\r
123      * This will set name representing a Mac file.\r
124      *\r
125      * @param file The name of the file.\r
126      */\r
127     public void setFileMac( String file )\r
128     {\r
129         fs.setString( "Mac", file );\r
130     }\r
131 \r
132     /**\r
133      * This will get the name representing a Unix file.\r
134      *\r
135      * @return The file name.\r
136      */\r
137     public String getFileUnix()\r
138     {\r
139         return fs.getString( "Unix" );\r
140     }\r
141 \r
142     /**\r
143      * This will set name representing a Unix file.\r
144      *\r
145      * @param file The name of the file.\r
146      */\r
147     public void setFileUnix( String file )\r
148     {\r
149         fs.setString( "Unix", file );\r
150     }\r
151 \r
152     /**\r
153      * Tell if the underlying file is volatile and should not be cached by the\r
154      * reader application.  Default: false\r
155      *\r
156      * @param fileIsVolatile The new value for the volatility of the file.\r
157      */\r
158     public void setVolatile( boolean fileIsVolatile )\r
159     {\r
160         fs.setBoolean( "V", fileIsVolatile );\r
161     }\r
162 \r
163     /**\r
164      * Get if the file is volatile.  Default: false\r
165      *\r
166      * @return True if the file is volatile attribute is set.\r
167      */\r
168     public boolean isVolatile()\r
169     {\r
170         return fs.getBoolean( "V", false );\r
171     }\r
172 \r
173     /**\r
174      * Get the embedded file.\r
175      *\r
176      * @return The embedded file for this file spec.\r
177      */\r
178     public PDEmbeddedFile getEmbeddedFile()\r
179     {\r
180         PDEmbeddedFile file = null;\r
181         COSStream stream = (COSStream)fs.getObjectFromPath( "EF/F" );\r
182         if( stream != null )\r
183         {\r
184             file = new PDEmbeddedFile( stream );\r
185         }\r
186         return file;\r
187     }\r
188 \r
189     /**\r
190      * Set the embedded file for this spec.\r
191      *\r
192      * @param file The file to be embedded.\r
193      */\r
194     public void setEmbeddedFile( PDEmbeddedFile file )\r
195     {\r
196         COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "EF" );\r
197         if( ef == null && file != null )\r
198         {\r
199             ef = new COSDictionary();\r
200             fs.setItem( "EF", ef );\r
201         }\r
202         if( ef != null )\r
203         {\r
204             ef.setItem( "F", file );\r
205         }\r
206     }\r
207 \r
208     /**\r
209      * Get the embedded dos file.\r
210      *\r
211      * @return The embedded file for this file spec.\r
212      */\r
213     public PDEmbeddedFile getEmbeddedFileDos()\r
214     {\r
215         PDEmbeddedFile file = null;\r
216         COSStream stream = (COSStream)fs.getObjectFromPath( "EF/DOS" );\r
217         if( stream != null )\r
218         {\r
219             file = new PDEmbeddedFile( stream );\r
220         }\r
221         return file;\r
222     }\r
223 \r
224     /**\r
225      * Set the embedded dos file for this spec.\r
226      *\r
227      * @param file The dos file to be embedded.\r
228      */\r
229     public void setEmbeddedFileDos( PDEmbeddedFile file )\r
230     {\r
231         COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "DOS" );\r
232         if( ef == null && file != null )\r
233         {\r
234             ef = new COSDictionary();\r
235             fs.setItem( "EF", ef );\r
236         }\r
237         if( ef != null )\r
238         {\r
239             ef.setItem( "DOS", file );\r
240         }\r
241     }\r
242 \r
243     /**\r
244      * Get the embedded Mac file.\r
245      *\r
246      * @return The embedded file for this file spec.\r
247      */\r
248     public PDEmbeddedFile getEmbeddedFileMac()\r
249     {\r
250         PDEmbeddedFile file = null;\r
251         COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Mac" );\r
252         if( stream != null )\r
253         {\r
254             file = new PDEmbeddedFile( stream );\r
255         }\r
256         return file;\r
257     }\r
258 \r
259     /**\r
260      * Set the embedded Mac file for this spec.\r
261      *\r
262      * @param file The Mac file to be embedded.\r
263      */\r
264     public void setEmbeddedFileMac( PDEmbeddedFile file )\r
265     {\r
266         COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Mac" );\r
267         if( ef == null && file != null )\r
268         {\r
269             ef = new COSDictionary();\r
270             fs.setItem( "EF", ef );\r
271         }\r
272         if( ef != null )\r
273         {\r
274             ef.setItem( "Mac", file );\r
275         }\r
276     }\r
277 \r
278     /**\r
279      * Get the embedded Unix file.\r
280      *\r
281      * @return The embedded file for this file spec.\r
282      */\r
283     public PDEmbeddedFile getEmbeddedFileUnix()\r
284     {\r
285         PDEmbeddedFile file = null;\r
286         COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Unix" );\r
287         if( stream != null )\r
288         {\r
289             file = new PDEmbeddedFile( stream );\r
290         }\r
291         return file;\r
292     }\r
293 \r
294     /**\r
295      * Set the embedded Unix file for this spec.\r
296      *\r
297      * @param file The Unix file to be embedded.\r
298      */\r
299     public void setEmbeddedFileUnix( PDEmbeddedFile file )\r
300     {\r
301         COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Unix" );\r
302         if( ef == null && file != null )\r
303         {\r
304             ef = new COSDictionary();\r
305             fs.setItem( "EF", ef );\r
306         }\r
307         if( ef != null )\r
308         {\r
309             ef.setItem( "Unix", file );\r
310         }\r
311     }\r
312 }\r