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
9 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 package org.apache.pdfbox.pdmodel.common.filespecification;
\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
24 * This represents a file specification.
\r
26 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
\r
27 * @version $Revision: 1.4 $
\r
29 public class PDComplexFileSpecification extends PDFileSpecification
\r
31 private COSDictionary fs;
\r
34 * Default Constructor.
\r
36 public PDComplexFileSpecification()
\r
38 fs = new COSDictionary();
\r
39 fs.setName( "Type", "Filespec" );
\r
45 * @param dict The dictionary that fulfils this file specification.
\r
47 public PDComplexFileSpecification( COSDictionary dict )
\r
53 * Convert this standard java object to a COS object.
\r
55 * @return The cos object that matches this Java object.
\r
57 public COSBase getCOSObject()
\r
63 * Convert this standard java object to a COS object.
\r
65 * @return The cos object that matches this Java object.
\r
67 public COSDictionary getCOSDictionary()
\r
73 * This will get the file name.
\r
75 * @return The file name.
\r
77 public String getFile()
\r
79 return fs.getString( "F" );
\r
83 * This will set the file name.
\r
85 * @param file The name of the file.
\r
87 public void setFile( String file )
\r
89 fs.setString( "F", file );
\r
93 * This will get the name representing a Dos file.
\r
95 * @return The file name.
\r
97 public String getFileDos()
\r
99 return fs.getString( "DOS" );
\r
103 * This will set name representing a dos file.
\r
105 * @param file The name of the file.
\r
107 public void setFileDos( String file )
\r
109 fs.setString( "DOS", file );
\r
113 * This will get the name representing a Mac file.
\r
115 * @return The file name.
\r
117 public String getFileMac()
\r
119 return fs.getString( "Mac" );
\r
123 * This will set name representing a Mac file.
\r
125 * @param file The name of the file.
\r
127 public void setFileMac( String file )
\r
129 fs.setString( "Mac", file );
\r
133 * This will get the name representing a Unix file.
\r
135 * @return The file name.
\r
137 public String getFileUnix()
\r
139 return fs.getString( "Unix" );
\r
143 * This will set name representing a Unix file.
\r
145 * @param file The name of the file.
\r
147 public void setFileUnix( String file )
\r
149 fs.setString( "Unix", file );
\r
153 * Tell if the underlying file is volatile and should not be cached by the
\r
154 * reader application. Default: false
\r
156 * @param fileIsVolatile The new value for the volatility of the file.
\r
158 public void setVolatile( boolean fileIsVolatile )
\r
160 fs.setBoolean( "V", fileIsVolatile );
\r
164 * Get if the file is volatile. Default: false
\r
166 * @return True if the file is volatile attribute is set.
\r
168 public boolean isVolatile()
\r
170 return fs.getBoolean( "V", false );
\r
174 * Get the embedded file.
\r
176 * @return The embedded file for this file spec.
\r
178 public PDEmbeddedFile getEmbeddedFile()
\r
180 PDEmbeddedFile file = null;
\r
181 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/F" );
\r
182 if( stream != null )
\r
184 file = new PDEmbeddedFile( stream );
\r
190 * Set the embedded file for this spec.
\r
192 * @param file The file to be embedded.
\r
194 public void setEmbeddedFile( PDEmbeddedFile file )
\r
196 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "EF" );
\r
197 if( ef == null && file != null )
\r
199 ef = new COSDictionary();
\r
200 fs.setItem( "EF", ef );
\r
204 ef.setItem( "F", file );
\r
209 * Get the embedded dos file.
\r
211 * @return The embedded file for this file spec.
\r
213 public PDEmbeddedFile getEmbeddedFileDos()
\r
215 PDEmbeddedFile file = null;
\r
216 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/DOS" );
\r
217 if( stream != null )
\r
219 file = new PDEmbeddedFile( stream );
\r
225 * Set the embedded dos file for this spec.
\r
227 * @param file The dos file to be embedded.
\r
229 public void setEmbeddedFileDos( PDEmbeddedFile file )
\r
231 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "DOS" );
\r
232 if( ef == null && file != null )
\r
234 ef = new COSDictionary();
\r
235 fs.setItem( "EF", ef );
\r
239 ef.setItem( "DOS", file );
\r
244 * Get the embedded Mac file.
\r
246 * @return The embedded file for this file spec.
\r
248 public PDEmbeddedFile getEmbeddedFileMac()
\r
250 PDEmbeddedFile file = null;
\r
251 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Mac" );
\r
252 if( stream != null )
\r
254 file = new PDEmbeddedFile( stream );
\r
260 * Set the embedded Mac file for this spec.
\r
262 * @param file The Mac file to be embedded.
\r
264 public void setEmbeddedFileMac( PDEmbeddedFile file )
\r
266 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Mac" );
\r
267 if( ef == null && file != null )
\r
269 ef = new COSDictionary();
\r
270 fs.setItem( "EF", ef );
\r
274 ef.setItem( "Mac", file );
\r
279 * Get the embedded Unix file.
\r
281 * @return The embedded file for this file spec.
\r
283 public PDEmbeddedFile getEmbeddedFileUnix()
\r
285 PDEmbeddedFile file = null;
\r
286 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Unix" );
\r
287 if( stream != null )
\r
289 file = new PDEmbeddedFile( stream );
\r
295 * Set the embedded Unix file for this spec.
\r
297 * @param file The Unix file to be embedded.
\r
299 public void setEmbeddedFileUnix( PDEmbeddedFile file )
\r
301 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Unix" );
\r
302 if( ef == null && file != null )
\r
304 ef = new COSDictionary();
\r
305 fs.setItem( "EF", ef );
\r
309 ef.setItem( "Unix", file );
\r