Source Code Cross Referenced for PDFileSpecification.java in  » PDF » jPod » de » intarsys » pdf » pd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » jPod » de.intarsys.pdf.pd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.pdf.pd;
031:
032:        import de.intarsys.pdf.cos.COSBasedObject;
033:        import de.intarsys.pdf.cos.COSDictionary;
034:        import de.intarsys.pdf.cos.COSName;
035:        import de.intarsys.pdf.cos.COSObject;
036:        import de.intarsys.pdf.cos.COSString;
037:
038:        /**
039:         * Repesents the PDF's FileSpecification-type
040:         * 
041:         */
042:        public class PDFileSpecification extends PDObject {
043:            // todo 2 review file system attribute
044:
045:            /**
046:             * The meta class implementation
047:             */
048:            static public class MetaClass extends PDObject.MetaClass {
049:                protected MetaClass(Class instanceClass) {
050:                    super (instanceClass);
051:                }
052:
053:                public Class getRootClass() {
054:                    return PDFileSpecification.class;
055:                }
056:
057:                /*
058:                 * (non-Javadoc)
059:                 * 
060:                 * @see de.intarsys.pdf.cos.COSBasedObject.MetaClass#doDetermineClass(de.intarsys.pdf.cos.COSObject)
061:                 */
062:                protected COSBasedObject.MetaClass doDetermineClass(
063:                        COSObject object) {
064:                    // Type entry is optional!
065:                    // COSName type = ((COSDictionary) object).get(DK_Type).asName();
066:                    // if (!CN_Type_Filespec.equals(type)) {
067:                    // throw new IllegalArgumentException(
068:                    // "not a File Specification Dictionary");
069:                    // }
070:                    COSName fileSystem = ((COSDictionary) object).get(DK_FS)
071:                            .asName();
072:                    if (CN_FS_URL.equals(fileSystem)) {
073:                        return PDFileSpecificationURL.META;
074:                    }
075:                    return PDFileSpecification.META;
076:                }
077:            }
078:
079:            static public final COSName CN_Type_Filespec = COSName
080:                    .constant("Filespec");
081:
082:            static public final COSName CN_Type_Alt_Filespec = COSName
083:                    .constant("F");
084:
085:            /** The meta class instance */
086:            static public final MetaClass META = new MetaClass(MetaClass.class
087:                    .getDeclaringClass());
088:
089:            /** Name of the file system. */
090:            static public final COSName DK_FS = COSName.constant("FS");
091:
092:            /** File */
093:            static public final COSName DK_F = COSName.constant("F");
094:
095:            /** File specification string for DOS files */
096:            static public final COSName CN_F_DOS = COSName.constant("DOS");
097:
098:            /** File specification string for Macintosh files */
099:            static public final COSName CN_F_Mac = COSName.constant("Mac");
100:
101:            /** File specification string for UNIX files */
102:            static public final COSName CN_F_Unix = COSName.constant("Unix");
103:
104:            /** File URL */
105:            static public final COSName CN_FS_URL = COSName.constant("URL");
106:
107:            /** Embedded file dict */
108:            static public final COSName DK_EF = COSName.constant("EF");
109:
110:            /** Embedded file array dict. */
111:            static public final COSName DK_RF = COSName.constant("RF");
112:
113:            private COSName fileSystem = null;
114:
115:            protected PDFileSpecification(COSObject object) {
116:                super (object);
117:            }
118:
119:            public void setFileSystem(COSName bs) {
120:                fileSystem = bs;
121:            }
122:
123:            public COSName getFileSystem() {
124:                return fileSystem;
125:            }
126:
127:            /*
128:             * (non-Javadoc)
129:             * 
130:             * @see de.intarsys.pdf.pd.PDObject#cosGetExpectedType()
131:             */
132:            protected COSName cosGetExpectedType() {
133:                return CN_Type_Filespec;
134:            }
135:
136:            /**
137:             * provide some hook for initialization after creation based on a cos object
138:             */
139:            protected void initializeFromCos() {
140:                super .initializeFromCos();
141:            }
142:
143:            /**
144:             * provide some hook for initialization after creation from scratch
145:             */
146:            protected void initializeFromScratch() {
147:                super .initializeFromScratch();
148:                cosSetField(DK_FS, getFileSystem());
149:            }
150:
151:            public String getFile() {
152:                COSString cosFile = cosGetField(DK_F).asString();
153:                if (cosFile == null) {
154:                    return null;
155:                }
156:                return cosFile.stringValue();
157:            }
158:
159:            /**
160:             * The embedded file of a specific flavor (one of F, DOS, Mac, Unix),
161:             * 
162:             * @param flavor
163:             *            One of F, DOC, Mac, Unix
164:             * @return the embedded file of this flavor, if any, or null.
165:             */
166:            public PDEmbeddedFile getEmbeddedFile(COSName flavor) {
167:                COSDictionary embeddedFileDict = getEmbeddedFiles();
168:                if (embeddedFileDict == null) {
169:                    return null;
170:                }
171:                return (PDEmbeddedFile) PDEmbeddedFile.META
172:                        .createFromCos(embeddedFileDict.get(flavor));
173:            }
174:
175:            public void setEmbeddedFile(COSName flavor,
176:                    PDEmbeddedFile embeddedFile) {
177:                COSDictionary embeddedFileDict = getEmbeddedFiles();
178:                if (embeddedFileDict == null) {
179:                    embeddedFileDict = COSDictionary.create();
180:                    cosSetField(DK_EF, embeddedFileDict);
181:                }
182:                embeddedFileDict.put(flavor, embeddedFile.cosGetObject());
183:            }
184:
185:            public String getFileSpecificationString(COSName flavor) {
186:                return cosGetField(flavor).stringValue();
187:            }
188:
189:            public void setFileSpecificationString(COSName flavor, String spec) {
190:                setFieldString(flavor, spec);
191:            }
192:
193:            /**
194:             * The dictionary mapping the F/DOC/Mac/Unix entries of the file spec to
195:             * embedded file dictionaries.
196:             */
197:            public COSDictionary getEmbeddedFiles() {
198:                return cosGetField(DK_EF).asDictionary();
199:            }
200:
201:            public void setFile(String file) {
202:                setFieldString(DK_F, file);
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.