KickJava   Java API By Example, From Geeks To Geeks.

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


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 page dictionary.
10    @author Nassib Nassar
11 */

12 public class PjPage
13     extends PjPagesNode {
14
15     /**
16        Creates a new page dictionary.
17     */

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

27     public PjPage(Hashtable h) {
28         super(h);
29     }
30
31     public void setContents(PjArray contents) {
32         _h.put(PjName.CONTENTS, contents);
33     }
34
35     public void setContents(PjReference contents) {
36         _h.put(PjName.CONTENTS, contents);
37     }
38
39     public PjObject getContents() throws InvalidPdfObjectException {
40         return hget(PjName.CONTENTS);
41     }
42
43     public void setThumb(PjReference thumb) {
44         _h.put(PjName.THUMB, thumb);
45     }
46
47     public PjReference getThumb() throws InvalidPdfObjectException {
48         return hgetReference(PjName.THUMB);
49     }
50
51     public void setAnnots(PjArray annots) {
52         _h.put(PjName.ANNOTS, annots);
53     }
54
55     public void setAnnots(PjReference annots) {
56         _h.put(PjName.ANNOTS, annots);
57     }
58
59     public PjObject getAnnots() throws InvalidPdfObjectException {
60         return hget(PjName.ANNOTS);
61     }
62
63     public void setB(PjArray b) {
64         _h.put(PjName.B, b);
65     }
66
67     public void setB(PjReference b) {
68         _h.put(PjName.B, b);
69     }
70
71     public PjObject getB() throws InvalidPdfObjectException {
72         return hget(PjName.B);
73     }
74
75     /**
76        Examines a dictionary to see if it is a PDF page.
77        @param dictionary the dictionary to examine.
78        @return true if the dictionary could be interpreted as a
79        valid PjPage object.
80     */

81     public static boolean isLike(PjDictionary dictionary) {
82         Hashtable h = dictionary.getHashtable();
83         // check if the Type is Page
84
try {
85             PjName type = (PjName)(h.get(PjName.TYPE));
86             if (type == null) {
87                 return false;
88             }
89             if ( ! type.equals(PjName.PAGE) ) {
90                 return false;
91             }
92         }
93         catch (ClassCastException JavaDoc e) {
94             return false;
95         }
96         return true;
97     }
98
99     /**
100        Returns a deep copy of this object.
101        @return a deep copy of this object.
102        @exception CloneNotSupportedException if the instance can not be cloned.
103     */

104     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
105         return new PjPage(cloneHt());
106     }
107     
108 }
109
Popular Tags