Source Code Cross Referenced for JobAttributes.java in  » Apache-Harmony-Java-SE » java-package » java » awt » 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 » java package » java.awt 
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:         * @author Igor A. Pyankov
019:         * @version $Revision$
020:         */package java.awt;
021:
022:        import org.apache.harmony.awt.internal.nls.Messages;
023:
024:        public final class JobAttributes implements  Cloneable {
025:
026:            private int copies;
027:            private int fromPage;
028:            private int maxPage;
029:            private int minPage;
030:            private int pageRanges[][];
031:            private int firstPage;
032:            private int lastPage;
033:            private int toPage;
034:            private String fileName;
035:            private String printer;
036:            private DefaultSelectionType defaultSelection;
037:            private DestinationType destination;
038:            private MultipleDocumentHandlingType multiDocHandling;
039:            private DialogType dialog;
040:            private SidesType sides;
041:
042:            /* section of the nested classes */
043:            public static final class DefaultSelectionType {
044:                public static final DefaultSelectionType ALL = new DefaultSelectionType(
045:                        0);
046:                public static final DefaultSelectionType RANGE = new DefaultSelectionType(
047:                        1);
048:                public static final DefaultSelectionType SELECTION = new DefaultSelectionType(
049:                        2);
050:
051:                private DefaultSelectionType(int i) {
052:                    super ();
053:                }
054:
055:                private DefaultSelectionType() {
056:                    this (0);
057:                }
058:            }
059:
060:            public static final class DestinationType {
061:                public static final DestinationType FILE = new DestinationType(
062:                        0);
063:                public static final DestinationType PRINTER = new DestinationType(
064:                        1);
065:
066:                private DestinationType(int i) {
067:                    super ();
068:                }
069:
070:                private DestinationType() {
071:                    this (0);
072:                }
073:            }
074:
075:            public static final class DialogType {
076:                public static final DialogType COMMON = new DialogType(0);
077:                public static final DialogType NATIVE = new DialogType(1);
078:                public static final DialogType NONE = new DialogType(2);
079:
080:                private DialogType(int i) {
081:                    super ();
082:                }
083:
084:                private DialogType() {
085:                    this (0);
086:                }
087:
088:            }
089:
090:            public static final class MultipleDocumentHandlingType {
091:                public static final MultipleDocumentHandlingType SEPARATE_DOCUMENTS_COLLATED_COPIES = new MultipleDocumentHandlingType(
092:                        0);
093:                public static final MultipleDocumentHandlingType SEPARATE_DOCUMENTS_UNCOLLATED_COPIES = new MultipleDocumentHandlingType(
094:                        1);
095:
096:                private MultipleDocumentHandlingType(int i) {
097:                    super ();
098:                }
099:
100:                private MultipleDocumentHandlingType() {
101:                    this (0);
102:                }
103:            }
104:
105:            public static final class SidesType {
106:                public static final SidesType ONE_SIDED = new SidesType(0);
107:                public static final SidesType TWO_SIDED_LONG_EDGE = new SidesType(
108:                        1);
109:                public static final SidesType TWO_SIDED_SHORT_EDGE = new SidesType(
110:                        2);
111:
112:                private SidesType(int i) {
113:                    super ();
114:                }
115:
116:                private SidesType() {
117:                    this (0);
118:                }
119:            }
120:
121:            /* end of the nested classes */
122:
123:            public JobAttributes() {
124:                setDefaultSelection(DefaultSelectionType.ALL);
125:                setDestination(DestinationType.PRINTER);
126:                setDialog(DialogType.NATIVE);
127:                setMultipleDocumentHandlingToDefault();
128:                setSidesToDefault();
129:                setCopiesToDefault();
130:                setMaxPage(0x7fffffff);
131:                setMinPage(1);
132:            }
133:
134:            public JobAttributes(JobAttributes obj) {
135:                set(obj);
136:            }
137:
138:            public JobAttributes(
139:                    int copies,
140:                    JobAttributes.DefaultSelectionType defaultSelection,
141:                    JobAttributes.DestinationType destination,
142:                    JobAttributes.DialogType dialog,
143:                    String fileName,
144:                    int maxPage,
145:                    int minPage,
146:                    JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling,
147:                    int[][] pageRanges, String printer,
148:                    JobAttributes.SidesType sides) {
149:
150:                setCopies(copies);
151:                setDefaultSelection(defaultSelection);
152:                setDestination(destination);
153:                setDialog(dialog);
154:                setFileName(fileName);
155:                setMinPage(minPage);
156:                setMaxPage(maxPage);
157:                setMultipleDocumentHandling(multipleDocumentHandling);
158:                setPageRanges(pageRanges);
159:                setPrinter(printer);
160:                setSides(sides);
161:            }
162:
163:            public void setCopiesToDefault() {
164:                setCopies(1);
165:            }
166:
167:            public void setMultipleDocumentHandlingToDefault() {
168:                setMultipleDocumentHandling(MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES);
169:            }
170:
171:            public void setSidesToDefault() {
172:                setSides(SidesType.ONE_SIDED);
173:            }
174:
175:            public int getCopies() {
176:                return copies;
177:            }
178:
179:            public void setCopies(int copies) {
180:                if (copies <= 0) {
181:                    // awt.152=Invalid number of copies
182:                    throw new IllegalArgumentException(Messages
183:                            .getString("awt.152")); //$NON-NLS-1$
184:                }
185:                this .copies = copies;
186:            }
187:
188:            public int getMaxPage() {
189:                return maxPage;
190:            }
191:
192:            public void setMaxPage(int imaxPage) {
193:                if (imaxPage <= 0 || imaxPage < minPage) {
194:                    // awt.153=Invalid value for maxPage
195:                    throw new IllegalArgumentException(Messages
196:                            .getString("awt.153")); //$NON-NLS-1$
197:                }
198:                maxPage = imaxPage;
199:            }
200:
201:            public int getMinPage() {
202:                return minPage;
203:            }
204:
205:            public void setMinPage(int iminPage) {
206:                if (iminPage <= 0 || iminPage > maxPage) {
207:                    // awt.154=Invalid value for minPage
208:                    throw new IllegalArgumentException(Messages
209:                            .getString("awt.154")); //$NON-NLS-1$
210:                }
211:                minPage = iminPage;
212:            }
213:
214:            public int getFromPage() {
215:                if (fromPage != 0) {
216:                    return fromPage;
217:                }
218:                if (toPage != 0) {
219:                    return getMinPage();
220:                }
221:                if (pageRanges != null) {
222:                    return firstPage;
223:                }
224:                return getMinPage();
225:            }
226:
227:            public void setFromPage(int ifromPage) {
228:                if (ifromPage <= 0 || ifromPage > toPage || ifromPage < minPage
229:                        || ifromPage > maxPage) {
230:                    // awt.155=Invalid value for fromPage
231:                    throw new IllegalArgumentException(Messages
232:                            .getString("awt.155")); //$NON-NLS-1$
233:                }
234:                fromPage = ifromPage;
235:            }
236:
237:            public int getToPage() {
238:                if (toPage != 0) {
239:                    return toPage;
240:                }
241:                if (fromPage != 0) {
242:                    return fromPage;
243:                }
244:                if (pageRanges != null) {
245:                    return lastPage;
246:                }
247:                return getMinPage();
248:            }
249:
250:            public void setToPage(int itoPage) {
251:                if (itoPage <= 0 || itoPage < fromPage || itoPage < minPage
252:                        || itoPage > maxPage) {
253:                    // awt.156=Invalid value for toPage
254:                    throw new IllegalArgumentException(Messages
255:                            .getString("awt.156")); //$NON-NLS-1$
256:                }
257:                toPage = itoPage;
258:            }
259:
260:            public String getPrinter() {
261:                return printer;
262:            }
263:
264:            public void setPrinter(String printer) {
265:                this .printer = printer;
266:            }
267:
268:            public void setFileName(String fileName) {
269:                this .fileName = fileName;
270:            }
271:
272:            public String getFileName() {
273:                return fileName;
274:            }
275:
276:            public int[][] getPageRanges() {
277:                int prl = pageRanges.length;
278:                int pr[][];
279:                if (pageRanges != null) {
280:                    pr = new int[prl][2];
281:                    for (int i = 0; i < prl; i++) {
282:                        pr[i][0] = pageRanges[i][0];
283:                        pr[i][1] = pageRanges[i][1];
284:                    }
285:                    return pr;
286:                }
287:                pr = new int[1][2];
288:                if (fromPage != 0 || toPage != 0) {
289:                    pr[0][0] = fromPage;
290:                    pr[0][1] = toPage;
291:                } else {
292:                    pr[0][0] = minPage;
293:                    pr[0][1] = minPage;
294:                }
295:                return pr;
296:            }
297:
298:            public void setPageRanges(int[][] pr) {
299:                // awt.157=Invalid value for pageRanges
300:                String msg = Messages.getString("awt.157"); //$NON-NLS-1$
301:                int n1 = 0;
302:                int n2 = 0;
303:                int prl = pr.length;
304:
305:                if (pr == null) {
306:                    throw new IllegalArgumentException(msg);
307:                }
308:
309:                for (int k = 0; k < prl; k++) {
310:                    if (pr[k] == null || pr[k].length != 2 || pr[k][0] <= n2
311:                            || pr[k][1] < pr[k][0]) {
312:                        throw new IllegalArgumentException(msg);
313:                    }
314:
315:                    n2 = pr[k][1];
316:                    if (n1 == 0) {
317:                        n1 = pr[k][0];
318:                    }
319:                }
320:
321:                if (n1 < minPage || n2 > maxPage) {
322:                    throw new IllegalArgumentException(msg);
323:                }
324:
325:                pageRanges = new int[prl][2];
326:
327:                for (int k = 0; k < prl; k++) {
328:                    pageRanges[k][0] = pr[k][0];
329:                    pageRanges[k][1] = pr[k][1];
330:                }
331:                firstPage = n1;
332:                lastPage = n2;
333:            }
334:
335:            public DestinationType getDestination() {
336:                return destination;
337:            }
338:
339:            public void setDestination(JobAttributes.DestinationType destination) {
340:                if (destination == null) {
341:                    // awt.158=Invalid value for destination
342:                    throw new IllegalArgumentException(Messages
343:                            .getString("awt.158")); //$NON-NLS-1$
344:                }
345:                this .destination = destination;
346:            }
347:
348:            public DialogType getDialog() {
349:                return dialog;
350:            }
351:
352:            public void setDialog(JobAttributes.DialogType dialog) {
353:                if (dialog == null) {
354:                    // awt.159=Invalid value for dialog
355:                    throw new IllegalArgumentException(Messages
356:                            .getString("awt.159")); //$NON-NLS-1$
357:                }
358:                this .dialog = dialog;
359:            }
360:
361:            public JobAttributes.DefaultSelectionType getDefaultSelection() {
362:                return defaultSelection;
363:            }
364:
365:            public void setDefaultSelection(
366:                    JobAttributes.DefaultSelectionType a_defaultSelection) {
367:                if (a_defaultSelection == null) {
368:                    // awt.15A=Invalid value for defaultSelection
369:                    throw new IllegalArgumentException(Messages
370:                            .getString("awt.15A")); //$NON-NLS-1$
371:                }
372:                this .defaultSelection = a_defaultSelection;
373:            }
374:
375:            public JobAttributes.MultipleDocumentHandlingType getMultipleDocumentHandling() {
376:                return multiDocHandling;
377:            }
378:
379:            public void setMultipleDocumentHandling(
380:                    JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling) {
381:
382:                if (multipleDocumentHandling == null) {
383:                    // awt.15B=Invalid value for multipleDocumentHandling
384:                    throw new IllegalArgumentException(Messages
385:                            .getString("awt.15B")); //$NON-NLS-1$
386:                }
387:                multiDocHandling = multipleDocumentHandling;
388:            }
389:
390:            public JobAttributes.SidesType getSides() {
391:                return sides;
392:            }
393:
394:            public void setSides(JobAttributes.SidesType sides) {
395:
396:                if (sides == null) {
397:                    // awt.15C=Invalid value for attribute sides
398:                    throw new IllegalArgumentException(Messages
399:                            .getString("awt.15C")); //$NON-NLS-1$
400:                }
401:                this .sides = sides;
402:            }
403:
404:            public void set(JobAttributes obj) {
405:                copies = obj.copies;
406:                defaultSelection = obj.defaultSelection;
407:                destination = obj.destination;
408:                dialog = obj.dialog;
409:                fileName = obj.fileName;
410:                printer = obj.printer;
411:                multiDocHandling = obj.multiDocHandling;
412:                firstPage = obj.firstPage;
413:                lastPage = obj.lastPage;
414:                sides = obj.sides;
415:                fromPage = obj.fromPage;
416:                toPage = obj.toPage;
417:                maxPage = obj.maxPage;
418:                minPage = obj.minPage;
419:                if (obj.pageRanges == null) {
420:                    pageRanges = null;
421:                } else {
422:                    setPageRanges(obj.pageRanges);
423:                }
424:            }
425:
426:            @Override
427:            public String toString() {
428:                /* The format is based on 1.5 release behavior 
429:                 * which can be revealed by the following code:
430:                 * System.out.println(new JobAttributes());
431:                 */
432:
433:                String s = "Page-ranges ["; //$NON-NLS-1$
434:                int k = pageRanges.length - 1;
435:                for (int i = 0; i <= k; i++) {
436:                    s += pageRanges[i][0] + "-" //$NON-NLS-1$
437:                            + pageRanges[i][1] + ((i < k) ? "," : ""); //$NON-NLS-1$ //$NON-NLS-2$
438:                }
439:                s += "], copies=" + getCopies() //$NON-NLS-1$
440:                        + ",defSelection=" + getDefaultSelection() //$NON-NLS-1$
441:                        + ",dest=" + getDestination() //$NON-NLS-1$
442:                        + ",fromPg=" + getFromPage() //$NON-NLS-1$
443:                        + ",toPg=" + getToPage() //$NON-NLS-1$
444:                        + ",minPg=" + getMinPage() //$NON-NLS-1$
445:                        + ",maxPg=" + getMaxPage() //$NON-NLS-1$
446:                        + ",multiple-document-handling=" //$NON-NLS-1$
447:                        + getMultipleDocumentHandling()
448:                        + ",fileName=" + getFileName() //$NON-NLS-1$
449:                        + ",printer=" + getPrinter() //$NON-NLS-1$
450:                        + ",dialog=" + getDialog() //$NON-NLS-1$
451:                        + ",sides=" + getSides(); //$NON-NLS-1$
452:                return s;
453:            }
454:
455:            @Override
456:            public int hashCode() {
457:                int hash = this .toString().hashCode();
458:                return hash;
459:            }
460:
461:            @Override
462:            public Object clone() {
463:                JobAttributes ja = new JobAttributes(this );
464:                return ja;
465:            }
466:
467:            @Override
468:            public boolean equals(Object obj) {
469:                if (!(obj instanceof  JobAttributes)) {
470:                    return false;
471:                }
472:                JobAttributes ja = (JobAttributes) obj;
473:
474:                if (fileName == null) {
475:                    if (ja.fileName != null) {
476:                        return false;
477:                    }
478:                } else {
479:                    if (!fileName.equals(ja.fileName)) {
480:                        return false;
481:                    }
482:                }
483:
484:                if (printer == null) {
485:                    if (ja.printer != null) {
486:                        return false;
487:                    }
488:                } else {
489:                    if (!printer.equals(ja.printer)) {
490:                        return false;
491:                    }
492:                }
493:
494:                if (pageRanges == null) {
495:                    if (ja.pageRanges != null) {
496:                        return false;
497:                    }
498:                } else {
499:                    if (ja.pageRanges == null) {
500:                        return false;
501:                    }
502:                    if (pageRanges.length != ja.pageRanges.length) {
503:                        return false;
504:                    }
505:                    for (int[] element : pageRanges) {
506:                        if (element[0] != element[0]
507:                                || element[1] != element[1]) {
508:                            return false;
509:                        }
510:                    }
511:                }
512:                if (copies != ja.copies) {
513:                    return false;
514:                }
515:                if (defaultSelection != ja.defaultSelection) {
516:                    return false;
517:                }
518:                if (destination != ja.destination) {
519:                    return false;
520:                }
521:                if (dialog != ja.dialog) {
522:                    return false;
523:                }
524:                if (maxPage != ja.maxPage) {
525:                    return false;
526:                }
527:                if (minPage != ja.minPage) {
528:                    return false;
529:                }
530:                if (multiDocHandling != ja.multiDocHandling) {
531:                    return false;
532:                }
533:                if (firstPage != ja.firstPage) {
534:                    return false;
535:                }
536:                if (lastPage != ja.lastPage) {
537:                    return false;
538:                }
539:                if (sides != ja.sides) {
540:                    return false;
541:                }
542:                if (toPage != ja.toPage) {
543:                    return false;
544:                }
545:                if (fromPage != ja.fromPage) {
546:                    return false;
547:                }
548:                return true;
549:            }
550:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.