001: package com.etymon.pj.object;
002:
003: import java.io.*;
004: import java.util.*;
005: import com.etymon.pj.*;
006: import com.etymon.pj.exception.*;
007:
008: /**
009: A representation of a PDF Catalog dictionary.
010: @author Nassib Nassar
011: */
012: public class PjCatalog extends PjDictionary {
013:
014: /**
015: Creates a new Catalog dictionary.
016: */
017: public PjCatalog() {
018: super ();
019: _h.put(PjName.TYPE, PjName.CATALOG);
020: }
021:
022: /**
023: Creates a Catalog dictionary as a wrapper around a Hashtable.
024: @param h the Hashtable to use for this dictionary.
025: */
026: public PjCatalog(Hashtable h) {
027: super (h);
028: }
029:
030: public void setPages(PjReference pages) {
031: _h.put(PjName.PAGES, pages);
032: }
033:
034: public PjObject getPages() throws InvalidPdfObjectException {
035: return hget(PjName.PAGES);
036: }
037:
038: public void setOutlines(PjReference outlines) {
039: _h.put(PjName.OUTLINES, outlines);
040: }
041:
042: public PjObject getOutlines() throws InvalidPdfObjectException {
043: return hget(PjName.OUTLINES);
044: }
045:
046: public void setPageMode(PjName pageMode) {
047: _h.put(PjName.PAGEMODE, pageMode);
048: }
049:
050: public void setPageMode(PjReference pageMode) {
051: _h.put(PjName.PAGEMODE, pageMode);
052: }
053:
054: public PjObject getPageMode() throws InvalidPdfObjectException {
055: return hget(PjName.PAGEMODE);
056: }
057:
058: public void setOpenAction(PjArray openAction) {
059: _h.put(PjName.OPENACTION, openAction);
060: }
061:
062: public void setOpenAction(PjDictionary openAction) {
063: _h.put(PjName.OPENACTION, openAction);
064: }
065:
066: public void setOpenAction(PjReference openAction) {
067: _h.put(PjName.OPENACTION, openAction);
068: }
069:
070: public PjObject getOpenAction() throws InvalidPdfObjectException {
071: return hget(PjName.OPENACTION);
072: }
073:
074: public void setThreads(PjReference threads) {
075: _h.put(PjName.THREADS, threads);
076: }
077:
078: public PjObject getThreads() throws InvalidPdfObjectException {
079: return hget(PjName.THREADS);
080: }
081:
082: public void setDests(PjReference dests) {
083: _h.put(PjName.DESTS, dests);
084: }
085:
086: public PjObject getDests() throws InvalidPdfObjectException {
087: return hget(PjName.DESTS);
088: }
089:
090: public void setNames(PjDictionary names) {
091: _h.put(PjName.NAMES, names);
092: }
093:
094: public void setNames(PjReference names) {
095: _h.put(PjName.NAMES, names);
096: }
097:
098: public PjObject getNames() throws InvalidPdfObjectException {
099: return hget(PjName.NAMES);
100: }
101:
102: public void setURI(PjDictionary uri) {
103: _h.put(PjName.URI, uri);
104: }
105:
106: public void setURI(PjReference uri) {
107: _h.put(PjName.URI, uri);
108: }
109:
110: public PjObject getURI() throws InvalidPdfObjectException {
111: return hget(PjName.URI);
112: }
113:
114: public void setAA(PjDictionary aa) {
115: _h.put(PjName.URI, aa);
116: }
117:
118: public void setAA(PjReference aa) {
119: _h.put(PjName.URI, aa);
120: }
121:
122: public PjObject getAA() throws InvalidPdfObjectException {
123: return hget(PjName.AA);
124: }
125:
126: public void setViewerPreferences(PjDictionary viewerPreferences) {
127: _h.put(PjName.VIEWERPREFERENCES, viewerPreferences);
128: }
129:
130: public void setViewerPreferences(PjReference viewerPreferences) {
131: _h.put(PjName.VIEWERPREFERENCES, viewerPreferences);
132: }
133:
134: public PjObject getViewerPreferences()
135: 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: } catch (ClassCastException e) {
169: return false;
170: }
171: return true;
172: }
173:
174: /**
175: Returns a deep copy of this object.
176: @return a deep copy of this object.
177: @exception CloneNotSupportedException if the instance can not be cloned.
178: */
179: public Object clone() throws CloneNotSupportedException {
180: return new PjCatalog(cloneHt());
181: }
182:
183: }
|