01: package com.etymon.pj.object;
02:
03: import java.io.*;
04: import java.util.*;
05: import com.etymon.pj.*;
06: import com.etymon.pj.exception.*;
07:
08: /**
09: A representation of a PDF Pages dictionary.
10: @author Nassib Nassar
11: */
12: public class PjPages extends PjPagesNode {
13:
14: /**
15: Creates a new Pages dictionary.
16: */
17: public PjPages() {
18: super ();
19: _h.put(PjName.TYPE, PjName.PAGES);
20: }
21:
22: /**
23: Creates a Pages dictionary as a wrapper around a Hashtable.
24: @param h the Hashtable to use for this dictionary.
25: */
26: public PjPages(Hashtable h) {
27: super (h);
28: }
29:
30: public void setKids(PjArray kids) {
31: _h.put(PjName.KIDS, kids);
32: }
33:
34: public void setKids(PjReference kids) {
35: _h.put(PjName.KIDS, kids);
36: }
37:
38: public PjObject getKids() throws InvalidPdfObjectException {
39: return hget(PjName.KIDS);
40: }
41:
42: public void setCount(PjNumber count) {
43: _h.put(PjName.COUNT, count);
44: }
45:
46: public void setCount(PjReference count) {
47: _h.put(PjName.COUNT, count);
48: }
49:
50: public PjObject getCount() throws InvalidPdfObjectException {
51: return hget(PjName.COUNT);
52: }
53:
54: /**
55: Examines a dictionary to see if it is a PDF Pages object.
56: @param dictionary the dictionary to examine.
57: @return true if the dictionary could be interpreted as a
58: valid PjPages object.
59: */
60: public static boolean isLike(PjDictionary dictionary) {
61: Hashtable h = dictionary.getHashtable();
62: // check if the Type is Pages
63: try {
64: PjName type = (PjName) (h.get(PjName.TYPE));
65: if (type == null) {
66: return false;
67: }
68: if (!type.equals(PjName.PAGES)) {
69: return false;
70: }
71: } catch (ClassCastException e) {
72: return false;
73: }
74: return true;
75: }
76:
77: /**
78: Returns a deep copy of this object.
79: @return a deep copy of this object.
80: @exception CloneNotSupportedException if the instance can not be cloned.
81: */
82: public Object clone() throws CloneNotSupportedException {
83: return new PjPages(cloneHt());
84: }
85:
86: }
|