1 31 package org.pdfbox.pdmodel.common.filespecification; 32 33 import org.pdfbox.cos.COSBase; 34 import org.pdfbox.cos.COSDictionary; 35 import org.pdfbox.cos.COSStream; 36 37 43 public class PDComplexFileSpecification extends PDFileSpecification 44 { 45 private COSDictionary fs; 46 47 50 public PDComplexFileSpecification() 51 { 52 fs = new COSDictionary(); 53 fs.setName( "Type", "Filespec" ); 54 } 55 56 61 public PDComplexFileSpecification( COSDictionary dict ) 62 { 63 fs = dict; 64 } 65 66 71 public COSBase getCOSObject() 72 { 73 return fs; 74 } 75 76 81 public COSDictionary getCOSDictionary() 82 { 83 return fs; 84 } 85 86 91 public String getFile() 92 { 93 return fs.getString( "F" ); 94 } 95 96 101 public void setFile( String file ) 102 { 103 fs.setString( "F", file ); 104 } 105 106 111 public String getFileDos() 112 { 113 return fs.getString( "DOS" ); 114 } 115 116 121 public void setFileDos( String file ) 122 { 123 fs.setString( "DOS", file ); 124 } 125 126 131 public String getFileMac() 132 { 133 return fs.getString( "Mac" ); 134 } 135 136 141 public void setFileMac( String file ) 142 { 143 fs.setString( "Mac", file ); 144 } 145 146 151 public String getFileUnix() 152 { 153 return fs.getString( "Unix" ); 154 } 155 156 161 public void setFileUnix( String file ) 162 { 163 fs.setString( "Unix", file ); 164 } 165 166 172 public void setVolatile( boolean fileIsVolatile ) 173 { 174 fs.setBoolean( "V", fileIsVolatile ); 175 } 176 177 182 public boolean isVolatile() 183 { 184 return fs.getBoolean( "V", false ); 185 } 186 187 192 public PDEmbeddedFile getEmbeddedFile() 193 { 194 PDEmbeddedFile file = null; 195 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/F" ); 196 if( stream != null ) 197 { 198 file = new PDEmbeddedFile( stream ); 199 } 200 return file; 201 } 202 203 208 public void setEmbeddedFile( PDEmbeddedFile file ) 209 { 210 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "EF" ); 211 if( ef == null && file != null ) 212 { 213 ef = new COSDictionary(); 214 fs.setItem( "EF", ef ); 215 } 216 if( ef != null ) 217 { 218 ef.setItem( "F", file ); 219 } 220 } 221 222 227 public PDEmbeddedFile getEmbeddedFileDos() 228 { 229 PDEmbeddedFile file = null; 230 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/DOS" ); 231 if( stream != null ) 232 { 233 file = new PDEmbeddedFile( stream ); 234 } 235 return file; 236 } 237 238 243 public void setEmbeddedFileDos( PDEmbeddedFile file ) 244 { 245 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "DOS" ); 246 if( ef == null && file != null ) 247 { 248 ef = new COSDictionary(); 249 fs.setItem( "EF", ef ); 250 } 251 if( ef != null ) 252 { 253 ef.setItem( "DOS", file ); 254 } 255 } 256 257 262 public PDEmbeddedFile getEmbeddedFileMac() 263 { 264 PDEmbeddedFile file = null; 265 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Mac" ); 266 if( stream != null ) 267 { 268 file = new PDEmbeddedFile( stream ); 269 } 270 return file; 271 } 272 273 278 public void setEmbeddedFileMac( PDEmbeddedFile file ) 279 { 280 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Mac" ); 281 if( ef == null && file != null ) 282 { 283 ef = new COSDictionary(); 284 fs.setItem( "EF", ef ); 285 } 286 if( ef != null ) 287 { 288 ef.setItem( "Mac", file ); 289 } 290 } 291 292 297 public PDEmbeddedFile getEmbeddedFileUnix() 298 { 299 PDEmbeddedFile file = null; 300 COSStream stream = (COSStream)fs.getObjectFromPath( "EF/Unix" ); 301 if( stream != null ) 302 { 303 file = new PDEmbeddedFile( stream ); 304 } 305 return file; 306 } 307 308 313 public void setEmbeddedFileUnix( PDEmbeddedFile file ) 314 { 315 COSDictionary ef = (COSDictionary)fs.getDictionaryObject( "Unix" ); 316 if( ef == null && file != null ) 317 { 318 ef = new COSDictionary(); 319 fs.setItem( "EF", ef ); 320 } 321 if( ef != null ) 322 { 323 ef.setItem( "Unix", file ); 324 } 325 } 326 } | Popular Tags |