]> _ Git - cubeextranet.git/blob
76cfa5511289a57417e94ac036ca6d016d11a0f5
[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 java.io.IOException;\r
20 \r
21 import org.apache.pdfbox.cos.COSBase;\r
22 import org.apache.pdfbox.cos.COSDictionary;\r
23 import org.apache.pdfbox.cos.COSString;\r
24 \r
25 import org.apache.pdfbox.pdmodel.common.COSObjectable;\r
26 \r
27 /**\r
28  * This represents a file specification.\r
29  *\r
30  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>\r
31  * @version $Revision: 1.4 $\r
32  */\r
33 public abstract class PDFileSpecification implements COSObjectable\r
34 {\r
35 \r
36     /**\r
37      * A file specfication can either be a COSString or a COSDictionary.  This\r
38      * will create the file specification either way.\r
39      *\r
40      * @param base The cos object that describes the fs.\r
41      *\r
42      * @return The file specification for the COSBase object.\r
43      *\r
44      * @throws IOException If there is an error creating the file spec.\r
45      */\r
46     public static PDFileSpecification createFS( COSBase base ) throws IOException\r
47     {\r
48         PDFileSpecification retval = null;\r
49         if( base == null )\r
50         {\r
51             //then simply return null\r
52         }\r
53         else if( base instanceof COSString )\r
54         {\r
55             retval = new PDSimpleFileSpecification( (COSString)base );\r
56         }\r
57         else if( base instanceof COSDictionary )\r
58         {\r
59             retval = new PDComplexFileSpecification( (COSDictionary)base );\r
60         }\r
61         else\r
62         {\r
63             throw new IOException( "Error: Unknown file specification " + base );\r
64         }\r
65         return retval;\r
66     }\r
67 \r
68     /**\r
69      * This will get the file name.\r
70      *\r
71      * @return The file name.\r
72      */\r
73     public abstract String getFile();\r
74 \r
75     /**\r
76      * This will set the file name.\r
77      *\r
78      * @param file The name of the file.\r
79      */\r
80     public abstract void setFile( String file );\r
81 }\r