Source Code Cross Referenced for DocFlavor.java in  » Apache-Harmony-Java-SE » javax-package » javax » print » 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 » Apache Harmony Java SE » javax package » javax.print 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package javax.print;
019:
020:        import java.io.IOException;
021:        import java.io.ObjectInputStream;
022:        import java.io.ObjectOutputStream;
023:        import java.io.Serializable;
024:        import java.security.AccessController;
025:        import java.security.PrivilegedAction;
026:        import org.apache.harmony.x.print.MimeType;
027:
028:        /** 
029:         * Encapsulates an object that specifies the format to a DocPrintJob print 
030:         * data.
031:         * @author Irina A. Arkhipets
032:         */
033:        public class DocFlavor implements  Serializable, Cloneable {
034:            private static final long serialVersionUID = -4512080796965449721L;
035:
036:            public static final String hostEncoding;
037:            static {
038:                /*
039:                 * Host encoding. Need to change it to "hostEncoding =
040:                 * Charset.defaultCharset().toString"
041:                 */
042:                hostEncoding = AccessController
043:                        .doPrivileged(new PrivilegedAction<String>() {
044:                            public String run() {
045:                                return System.getProperty("file.encoding");
046:                            }
047:                        });
048:            }
049:
050:            // Document media type (as defined in RFC 2045,2046, 822)
051:            private transient MimeType aType;
052:
053:            private final String aClass; // Representation class name
054:
055:            public DocFlavor(String mimeType, String className) {
056:                if ((mimeType == null) || (className == null)) {
057:                    throw new NullPointerException();
058:                }
059:                aType = new MimeType(mimeType);
060:                aClass = className;
061:            }
062:
063:            @Override
064:            public boolean equals(Object obj) {
065:                return (obj != null)
066:                        && (obj instanceof  DocFlavor)
067:                        && (getCanonicalForm().equals(((DocFlavor) obj)
068:                                .getCanonicalForm()));
069:            }
070:
071:            public String getMediaSubtype() {
072:                return aType.getSubtype();
073:            }
074:
075:            public String getMediaType() {
076:                return aType.getType();
077:            }
078:
079:            public String getMimeType() {
080:                return aType.toString();
081:            }
082:
083:            public String getParameter(String paramName) {
084:                if (paramName == null) {
085:                    throw new NullPointerException();
086:                }
087:                return aType.getParameter(paramName);
088:            }
089:
090:            public String getRepresentationClassName() {
091:                return aClass;
092:            }
093:
094:            @Override
095:            public int hashCode() {
096:                return getCanonicalForm().hashCode();
097:            }
098:
099:            @Override
100:            public String toString() {
101:                return getCanonicalForm();
102:            }
103:
104:            // --------------------------------------------------------------
105:            private void readObject(ObjectInputStream s)
106:                    throws ClassNotFoundException, IOException {
107:                s.defaultReadObject();
108:                aType = new MimeType((String) (s.readObject()));
109:            }
110:
111:            private void writeObject(ObjectOutputStream s) throws IOException {
112:                s.defaultWriteObject();
113:                s.writeObject(aType.getCanonicalForm());
114:            }
115:
116:            private String getCanonicalForm() {
117:                return aType.toString() + "; class=\"" + aClass + "\"";
118:            }
119:
120:            // --------------------------------------------------------------
121:            public static class BYTE_ARRAY extends DocFlavor {
122:                private static final long serialVersionUID = -9065578006593857475L;
123:
124:                public BYTE_ARRAY(String mimeType) {
125:                    super (mimeType, "[B");
126:                }
127:
128:                public static final BYTE_ARRAY AUTOSENSE = new BYTE_ARRAY(
129:                        "application/octet-stream");
130:
131:                public static final BYTE_ARRAY GIF = new BYTE_ARRAY("image/gif");
132:
133:                public static final BYTE_ARRAY JPEG = new BYTE_ARRAY(
134:                        "image/jpeg");
135:
136:                public static final BYTE_ARRAY PCL = new BYTE_ARRAY(
137:                        "application/vnd.hp-pcl");
138:
139:                public static final BYTE_ARRAY PDF = new BYTE_ARRAY(
140:                        "application/pdf");
141:
142:                public static final BYTE_ARRAY PNG = new BYTE_ARRAY("image/png");
143:
144:                public static final BYTE_ARRAY POSTSCRIPT = new BYTE_ARRAY(
145:                        "application/postscript");
146:
147:                public static final BYTE_ARRAY TEXT_HTML_HOST = new BYTE_ARRAY(
148:                        "text/html;charset=" + hostEncoding);
149:
150:                public static final BYTE_ARRAY TEXT_HTML_US_ASCII = new BYTE_ARRAY(
151:                        "text/html;charset=us-ascii");
152:
153:                public static final BYTE_ARRAY TEXT_HTML_UTF_16 = new BYTE_ARRAY(
154:                        "text/html;charset=utf-16");
155:
156:                public static final BYTE_ARRAY TEXT_HTML_UTF_16BE = new BYTE_ARRAY(
157:                        "text/html;charset=utf-16be");
158:
159:                public static final BYTE_ARRAY TEXT_HTML_UTF_16LE = new BYTE_ARRAY(
160:                        "text/html;charset=utf-16le");
161:
162:                public static final BYTE_ARRAY TEXT_HTML_UTF_8 = new BYTE_ARRAY(
163:                        "text/html;charset=utf-8");
164:
165:                public static final BYTE_ARRAY TEXT_PLAIN_HOST = new BYTE_ARRAY(
166:                        "text/plain;charset=" + hostEncoding);
167:
168:                public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII = new BYTE_ARRAY(
169:                        "text/plain;charset=us-ascii");
170:
171:                public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 = new BYTE_ARRAY(
172:                        "text/plain;charset=utf-16");
173:
174:                public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE = new BYTE_ARRAY(
175:                        "text/plain;charset=utf-16be");
176:
177:                public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE = new BYTE_ARRAY(
178:                        "text/plain;charset=utf-16le");
179:
180:                public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 = new BYTE_ARRAY(
181:                        "text/plain;charset=utf-8");
182:            }
183:
184:            public static class CHAR_ARRAY extends DocFlavor {
185:                private static final long serialVersionUID = -8720590903724405128L;
186:
187:                public CHAR_ARRAY(String mimeType) {
188:                    super (mimeType, "[C");
189:                }
190:
191:                public static final CHAR_ARRAY TEXT_HTML = new CHAR_ARRAY(
192:                        "text/html;charset=utf-16");
193:
194:                public static final CHAR_ARRAY TEXT_PLAIN = new CHAR_ARRAY(
195:                        "text/plain;charset=utf-16");
196:            }
197:
198:            public static class INPUT_STREAM extends DocFlavor {
199:                private static final long serialVersionUID = -7045842700749194127L;
200:
201:                public INPUT_STREAM(String mimeType) {
202:                    super (mimeType, "java.io.InputStream");
203:                }
204:
205:                public static final INPUT_STREAM AUTOSENSE = new INPUT_STREAM(
206:                        "application/octet-stream");
207:
208:                public static final INPUT_STREAM GIF = new INPUT_STREAM(
209:                        "image/gif");
210:
211:                public static final INPUT_STREAM JPEG = new INPUT_STREAM(
212:                        "image/jpeg");
213:
214:                public static final INPUT_STREAM PCL = new INPUT_STREAM(
215:                        "application/vnd.hp-pcl");
216:
217:                public static final INPUT_STREAM PDF = new INPUT_STREAM(
218:                        "application/pdf");
219:
220:                public static final INPUT_STREAM PNG = new INPUT_STREAM(
221:                        "image/png");
222:
223:                public static final INPUT_STREAM POSTSCRIPT = new INPUT_STREAM(
224:                        "application/postscript");
225:
226:                public static final INPUT_STREAM TEXT_HTML_HOST = new INPUT_STREAM(
227:                        "text/html;charset=" + hostEncoding);
228:
229:                public static final INPUT_STREAM TEXT_HTML_US_ASCII = new INPUT_STREAM(
230:                        "text/html;charset=us-ascii");
231:
232:                public static final INPUT_STREAM TEXT_HTML_UTF_16 = new INPUT_STREAM(
233:                        "text/html;charset=utf-16");
234:
235:                public static final INPUT_STREAM TEXT_HTML_UTF_16BE = new INPUT_STREAM(
236:                        "text/html;charset=utf-16be");
237:
238:                public static final INPUT_STREAM TEXT_HTML_UTF_16LE = new INPUT_STREAM(
239:                        "text/html;charset=utf-16le");
240:
241:                public static final INPUT_STREAM TEXT_HTML_UTF_8 = new INPUT_STREAM(
242:                        "text/html;charset=utf-8");
243:
244:                public static final INPUT_STREAM TEXT_PLAIN_HOST = new INPUT_STREAM(
245:                        "text/plain;charset=" + hostEncoding);
246:
247:                public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = new INPUT_STREAM(
248:                        "text/plain;charset=us-ascii");
249:
250:                public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = new INPUT_STREAM(
251:                        "text/plain;charset=utf-16");
252:
253:                public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = new INPUT_STREAM(
254:                        "text/plain;charset=utf-16be");
255:
256:                public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = new INPUT_STREAM(
257:                        "text/plain;charset=utf-16le");
258:
259:                public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = new INPUT_STREAM(
260:                        "text/plain;charset=utf-8");
261:            }
262:
263:            public static class READER extends DocFlavor {
264:                private static final long serialVersionUID = 7100295812579351567L;
265:
266:                public READER(String mimeType) {
267:                    super (mimeType, "java.io.Reader");
268:                }
269:
270:                public static final READER TEXT_HTML = new READER(
271:                        "text/html;charset=utf-16");
272:
273:                public static final READER TEXT_PLAIN = new READER(
274:                        "text/plain;charset=utf-16");
275:            }
276:
277:            public static class SERVICE_FORMATTED extends DocFlavor {
278:                private static final long serialVersionUID = 6181337766266637256L;
279:
280:                public SERVICE_FORMATTED(String className) {
281:                    super ("application/x-java-jvm-local-objectref", className);
282:                }
283:
284:                public static final SERVICE_FORMATTED PAGEABLE = new SERVICE_FORMATTED(
285:                        "java.awt.print.Pageable");
286:
287:                public static final SERVICE_FORMATTED PRINTABLE = new SERVICE_FORMATTED(
288:                        "java.awt.print.Printable");
289:
290:                public static final SERVICE_FORMATTED RENDERABLE_IMAGE = new SERVICE_FORMATTED(
291:                        "java.awt.image.renderable.RenderableImage");
292:            }
293:
294:            public static class STRING extends DocFlavor {
295:                private static final long serialVersionUID = 4414407504887034035L;
296:
297:                public STRING(String mimeType) {
298:                    super (mimeType, "java.lang.String");
299:                }
300:
301:                public static final STRING TEXT_HTML = new STRING(
302:                        "text/html;charset=utf-16");
303:
304:                public static final STRING TEXT_PLAIN = new STRING(
305:                        "text/plain;charset=utf-16");
306:            }
307:
308:            public static class URL extends DocFlavor {
309:                private static final long serialVersionUID = 2936725788144902062L;
310:
311:                public URL(String mimeType) {
312:                    super (mimeType, "java.net.URL");
313:                }
314:
315:                public static final URL AUTOSENSE = new URL(
316:                        "application/octet-stream");
317:
318:                public static final URL GIF = new URL("image/gif");
319:
320:                public static final URL JPEG = new URL("image/jpeg");
321:
322:                public static final URL PCL = new URL("application/vnd.hp-pcl");
323:
324:                public static final URL PDF = new URL("application/pdf");
325:
326:                public static final URL PNG = new URL("image/png");
327:
328:                public static final URL POSTSCRIPT = new URL(
329:                        "application/postscript");
330:
331:                public static final URL TEXT_HTML_HOST = new URL(
332:                        "text/html;charset=" + hostEncoding);
333:
334:                public static final URL TEXT_HTML_US_ASCII = new URL(
335:                        "text/html;charset=us-ascii");
336:
337:                public static final URL TEXT_HTML_UTF_16 = new URL(
338:                        "text/html;charset=utf-16");
339:
340:                public static final URL TEXT_HTML_UTF_16BE = new URL(
341:                        "text/html;charset=utf-16be");
342:
343:                public static final URL TEXT_HTML_UTF_16LE = new URL(
344:                        "text/html;charset=utf-16le");
345:
346:                public static final URL TEXT_HTML_UTF_8 = new URL(
347:                        "text/html;charset=utf-8");
348:
349:                public static final URL TEXT_PLAIN_HOST = new URL(
350:                        "text/plain;charset=" + hostEncoding);
351:
352:                public static final URL TEXT_PLAIN_US_ASCII = new URL(
353:                        "text/plain;charset=us-ascii");
354:
355:                public static final URL TEXT_PLAIN_UTF_16 = new URL(
356:                        "text/plain;charset=utf-16");
357:
358:                public static final URL TEXT_PLAIN_UTF_16BE = new URL(
359:                        "text/plain;charset=utf-16be");
360:
361:                public static final URL TEXT_PLAIN_UTF_16LE = new URL(
362:                        "text/plain;charset=utf-16le");
363:
364:                public static final URL TEXT_PLAIN_UTF_8 = new URL(
365:                        "text/plain;charset=utf-8");
366:            }
367:        } /* End of DocFlavor class */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.