2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org.apache.pdfbox.pdmodel.common.filespecification;
19 import org.apache.pdfbox.cos.COSBase;
20 import org.apache.pdfbox.cos.COSDictionary;
21 import org.apache.pdfbox.cos.COSStream;
24 * This represents a file specification.
26 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
27 * @version $Revision: 1.4 $
29 public class PDComplexFileSpecification extends PDFileSpecification
31 private COSDictionary fs;
34 * Default Constructor.
36 public PDComplexFileSpecification()
38 fs = new COSDictionary();
39 fs.setName( "Type", "Filespec" );
45 * @param dict The dictionary that fulfils this file specification.
47 public PDComplexFileSpecification( COSDictionary dict )
53 * Convert this standard java object to a COS object.
55 * @return The cos object that matches this Java object.
57 public COSBase getCOSObject()
63 * Convert this standard java object to a COS object.
65 * @return The cos object that matches this Java object.
67 public COSDictionary getCOSDictionary()
73 * This will get the file name.
75 * @return The file name.
77 public String getFile()
79 return fs.getString( "F" );
83 * This will set the file name.
85 * @param file The name of the file.
87 public void setFile( String file )
89 fs.setString( "F", file );
93 * This will get the name representing a Dos file.
95 * @return The file name.
97 public String getFileDos()
99 return fs.getString( "DOS" );
103 * This will set name representing a dos file.
105 * @param file The name of the file.
107 public void setFileDos( String file )
109 fs.setString( "DOS", file );
113 * This will get the name representing a Mac file.
115 * @return The file name.
117 public String getFileMac()
119 return fs.getString( "Mac" );
123 * This will set name representing a Mac file.
125 * @param file The name of the file.
127 public void setFileMac( String file )
129 fs.setString( "Mac", file );
133 * This will get the name representing a Unix file.
135 * @return The file name.
137 public String getFileUnix()
139 return fs.getString( "Unix" );
143 * This will set name representing a Unix file.
145 * @param file The name of the file.
147 public void setFileUnix( String file )
149 fs.setString( "Unix", file );
153 * Tell if the underlying file is volatile and should not be cached by the
154 * reader application. Default: false
156 * @param fileIsVolatile The new value for the volatility of the file.
158 public void setVolatile( boolean fileIsVolatile )
160 fs.setBoolean( "V", fileIsVolatile );
164 * Get if the file is volatile. Default: false
166 * @return True if the file is volatile attribute is set.
168 public boolean isVolatile()
170 return fs.getBoolean( "V", false );
174 * Get the embedded file.
176 * @return The embedded file for this file spec.
178 public PDEmbeddedFile getEmbeddedFile()
180 PDEmbeddedFile file = null;
181 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/F" );
184 file = new PDEmbeddedFile( stream );
190 * Set the embedded file for this spec.
192 * @param file The file to be embedded.
194 public void setEmbeddedFile( PDEmbeddedFile file )
196 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "EF" );
197 if( ef == null && file != null )
199 ef = new COSDictionary();
200 fs.setItem( "EF", ef );
204 ef.setItem( "F", file );
209 * Get the embedded dos file.
211 * @return The embedded file for this file spec.
213 public PDEmbeddedFile getEmbeddedFileDos()
215 PDEmbeddedFile file = null;
216 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/DOS" );
219 file = new PDEmbeddedFile( stream );
225 * Set the embedded dos file for this spec.
227 * @param file The dos file to be embedded.
229 public void setEmbeddedFileDos( PDEmbeddedFile file )
231 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "DOS" );
232 if( ef == null && file != null )
234 ef = new COSDictionary();
235 fs.setItem( "EF", ef );
239 ef.setItem( "DOS", file );
244 * Get the embedded Mac file.
246 * @return The embedded file for this file spec.
248 public PDEmbeddedFile getEmbeddedFileMac()
250 PDEmbeddedFile file = null;
251 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Mac" );
254 file = new PDEmbeddedFile( stream );
260 * Set the embedded Mac file for this spec.
262 * @param file The Mac file to be embedded.
264 public void setEmbeddedFileMac( PDEmbeddedFile file )
266 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Mac" );
267 if( ef == null && file != null )
269 ef = new COSDictionary();
270 fs.setItem( "EF", ef );
274 ef.setItem( "Mac", file );
279 * Get the embedded Unix file.
281 * @return The embedded file for this file spec.
283 public PDEmbeddedFile getEmbeddedFileUnix()
285 PDEmbeddedFile file = null;
286 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Unix" );
289 file = new PDEmbeddedFile( stream );
295 * Set the embedded Unix file for this spec.
297 * @param file The Unix file to be embedded.
299 public void setEmbeddedFileUnix( PDEmbeddedFile file )
301 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Unix" );
302 if( ef == null && file != null )
304 ef = new COSDictionary();
305 fs.setItem( "EF", ef );
309 ef.setItem( "Unix", file );