KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

27     public PjEncoding(Hashtable h) {
28         super(h);
29     }
30
31     public void setBaseEncoding(PjName baseEncoding) {
32         _h.put(PjName.BASEENCODING, baseEncoding);
33     }
34
35     public void setBaseEncoding(PjReference baseEncoding) {
36         _h.put(PjName.BASEENCODING, baseEncoding);
37     }
38
39     public PjObject getBaseEncoding() throws InvalidPdfObjectException {
40         return hget(PjName.BASEENCODING);
41     }
42
43     public void setDifferences(PjArray differences) {
44         _h.put(PjName.DIFFERENCES, differences);
45     }
46
47     public void setDifferences(PjReference differences) {
48         _h.put(PjName.DIFFERENCES, differences);
49     }
50
51     public PjObject getDifferences() throws InvalidPdfObjectException {
52         return hget(PjName.DIFFERENCES);
53     }
54
55     /**
56        Examines a dictionary to see if it is a PDF font encoding
57        dictionary.
58        @param dictionary the dictionary to examine.
59        @return true if the dictionary could be interpreted as a
60        valid PjEncoding object.
61     */

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

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