KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > etymon > pj > object > PjCatalog


1 package com.etymon.pj.object;
2
3 import java.io.*;
4 import java.util.*;
5 import com.etymon.pj.*;
6 import com.etymon.pj.exception.*;
7
8 /**
9    A representation of a PDF Catalog dictionary.
10    @author Nassib Nassar
11 */

12 public class PjCatalog
13     extends PjDictionary {
14
15     /**
16        Creates a new Catalog dictionary.
17     */

18     public PjCatalog() {
19         super();
20         _h.put(PjName.TYPE, PjName.CATALOG);
21     }
22
23     /**
24        Creates a Catalog dictionary as a wrapper around a Hashtable.
25        @param h the Hashtable to use for this dictionary.
26     */

27     public PjCatalog(Hashtable h) {
28         super(h);
29     }
30
31     public void setPages(PjReference pages) {
32         _h.put(PjName.PAGES, pages);
33     }
34
35     public PjObject getPages() throws InvalidPdfObjectException {
36         return hget(PjName.PAGES);
37     }
38
39     public void setOutlines(PjReference outlines) {
40         _h.put(PjName.OUTLINES, outlines);
41     }
42
43     public PjObject getOutlines() throws InvalidPdfObjectException {
44         return hget(PjName.OUTLINES);
45     }
46     
47     public void setPageMode(PjName pageMode) {
48         _h.put(PjName.PAGEMODE, pageMode);
49     }
50
51     public void setPageMode(PjReference pageMode) {
52         _h.put(PjName.PAGEMODE, pageMode);
53     }
54
55     public PjObject getPageMode() throws InvalidPdfObjectException {
56         return hget(PjName.PAGEMODE);
57     }
58
59     public void setOpenAction(PjArray openAction) {
60         _h.put(PjName.OPENACTION, openAction);
61     }
62
63     public void setOpenAction(PjDictionary openAction) {
64         _h.put(PjName.OPENACTION, openAction);
65     }
66
67     public void setOpenAction(PjReference openAction) {
68         _h.put(PjName.OPENACTION, openAction);
69     }
70
71     public PjObject getOpenAction() throws InvalidPdfObjectException {
72         return hget(PjName.OPENACTION);
73     }
74
75     public void setThreads(PjReference threads) {
76         _h.put(PjName.THREADS, threads);
77     }
78
79     public PjObject getThreads() throws InvalidPdfObjectException {
80         return hget(PjName.THREADS);
81     }
82
83     public void setDests(PjReference dests) {
84         _h.put(PjName.DESTS, dests);
85     }
86
87     public PjObject getDests() throws InvalidPdfObjectException {
88         return hget(PjName.DESTS);
89     }
90
91     public void setNames(PjDictionary names) {
92         _h.put(PjName.NAMES, names);
93     }
94
95     public void setNames(PjReference names) {
96         _h.put(PjName.NAMES, names);
97     }
98
99     public PjObject getNames() throws InvalidPdfObjectException {
100         return hget(PjName.NAMES);
101     }
102
103     public void setURI(PjDictionary uri) {
104         _h.put(PjName.URI, uri);
105     }
106
107     public void setURI(PjReference uri) {
108         _h.put(PjName.URI, uri);
109     }
110
111     public PjObject getURI() throws InvalidPdfObjectException {
112         return hget(PjName.URI);
113     }
114
115     public void setAA(PjDictionary aa) {
116         _h.put(PjName.URI, aa);
117     }
118
119     public void setAA(PjReference aa) {
120         _h.put(PjName.URI, aa);
121     }
122
123     public PjObject getAA() throws InvalidPdfObjectException {
124         return hget(PjName.AA);
125     }
126
127     public void setViewerPreferences(PjDictionary viewerPreferences) {
128         _h.put(PjName.VIEWERPREFERENCES, viewerPreferences);
129     }
130
131     public void setViewerPreferences(PjReference viewerPreferences) {
132         _h.put(PjName.VIEWERPREFERENCES, viewerPreferences);
133     }
134
135     public PjObject getViewerPreferences() throws InvalidPdfObjectException {
136         return hget(PjName.VIEWERPREFERENCES);
137     }
138
139     public void setAcroForm(PjDictionary acroForm) {
140         _h.put(PjName.ACROFORM, acroForm);
141     }
142
143     public void setAcroForm(PjReference acroForm) {
144         _h.put(PjName.ACROFORM, acroForm);
145     }
146
147     public PjObject getAcroForm() throws InvalidPdfObjectException {
148         return hget(PjName.ACROFORM);
149     }
150
151     /**
152        Examines a dictionary to see if it is a PDF Catalog object.
153        @param dictionary the dictionary to examine.
154        @return true if the dictionary could be interpreted as a
155        valid PjCatalog object.
156     */

157     public static boolean isLike(PjDictionary dictionary) {
158         Hashtable h = dictionary.getHashtable();
159         // check if the Type is Catalog
160
try {
161             PjName type = (PjName)(h.get(PjName.TYPE));
162             if (type == null) {
163                 return false;
164             }
165             if ( ! type.equals(PjName.CATALOG) ) {
166                 return false;
167             }
168         }
169         catch (ClassCastException JavaDoc e) {
170             return false;
171         }
172         return true;
173     }
174
175     /**
176        Returns a deep copy of this object.
177        @return a deep copy of this object.
178        @exception CloneNotSupportedException if the instance can not be cloned.
179     */

180     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
181         return new PjCatalog(cloneHt());
182     }
183     
184 }
185
Popular Tags