KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

27     public PjPages(Hashtable h) {
28         super(h);
29     }
30
31     public void setKids(PjArray kids) {
32         _h.put(PjName.KIDS, kids);
33     }
34
35     public void setKids(PjReference kids) {
36         _h.put(PjName.KIDS, kids);
37     }
38
39     public PjObject getKids() throws InvalidPdfObjectException {
40         return hget(PjName.KIDS);
41     }
42
43     public void setCount(PjNumber count) {
44         _h.put(PjName.COUNT, count);
45     }
46
47     public void setCount(PjReference count) {
48         _h.put(PjName.COUNT, count);
49     }
50
51     public PjObject getCount() throws InvalidPdfObjectException {
52         return hget(PjName.COUNT);
53     }
54
55     /**
56        Examines a dictionary to see if it is a PDF Pages object.
57        @param dictionary the dictionary to examine.
58        @return true if the dictionary could be interpreted as a
59        valid PjPages object.
60     */

61     public static boolean isLike(PjDictionary dictionary) {
62         Hashtable h = dictionary.getHashtable();
63         // check if the Type is Pages
64
try {
65             PjName type = (PjName)(h.get(PjName.TYPE));
66             if (type == null) {
67                 return false;
68             }
69             if ( ! type.equals(PjName.PAGES) ) {
70                 return false;
71             }
72         }
73         catch (ClassCastException JavaDoc e) {
74             return false;
75         }
76         return true;
77     }
78
79     /**
80        Returns a deep copy of this object.
81        @return a deep copy of this object.
82        @exception CloneNotSupportedException if the instance can not be cloned.
83     */

84     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
85         return new PjPages(cloneHt());
86     }
87     
88 }
89
Popular Tags