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 font encoding dictionary.
10: @author Nassib Nassar
11: */
12: public class PjEncoding extends PjDictionary {
13:
14: /**
15: Creates a new encoding dictionary.
16: */
17: public PjEncoding() {
18: super ();
19: _h.put(PjName.TYPE, PjName.ENCODING);
20: }
21:
22: /**
23: Creates an encoding dictionary as a wrapper around a Hashtable.
24: @param h the Hashtable to use for this dictionary.
25: */
26: public PjEncoding(Hashtable h) {
27: super (h);
28: }
29:
30: public void setBaseEncoding(PjName baseEncoding) {
31: _h.put(PjName.BASEENCODING, baseEncoding);
32: }
33:
34: public void setBaseEncoding(PjReference baseEncoding) {
35: _h.put(PjName.BASEENCODING, baseEncoding);
36: }
37:
38: public PjObject getBaseEncoding() throws InvalidPdfObjectException {
39: return hget(PjName.BASEENCODING);
40: }
41:
42: public void setDifferences(PjArray differences) {
43: _h.put(PjName.DIFFERENCES, differences);
44: }
45:
46: public void setDifferences(PjReference differences) {
47: _h.put(PjName.DIFFERENCES, differences);
48: }
49:
50: public PjObject getDifferences() throws InvalidPdfObjectException {
51: return hget(PjName.DIFFERENCES);
52: }
53:
54: /**
55: Examines a dictionary to see if it is a PDF font encoding
56: dictionary.
57: @param dictionary the dictionary to examine.
58: @return true if the dictionary could be interpreted as a
59: valid PjEncoding object.
60: */
61: public static boolean isLike(PjDictionary dictionary) {
62: Hashtable h = dictionary.getHashtable();
63: // check if the Type is Encoding
64: try {
65: PjName type = (PjName) (h.get(PjName.TYPE));
66: if (type == null) {
67: return false;
68: }
69: if (!type.equals(PjName.ENCODING)) {
70: return false;
71: }
72: } catch (ClassCastException e) {
73: return false;
74: }
75: return true;
76: }
77:
78: /**
79: Returns a deep copy of this object.
80: @return a deep copy of this object.
81: @exception CloneNotSupportedException if the instance can not be cloned.
82: */
83: public Object clone() throws CloneNotSupportedException {
84: return new PjEncoding(cloneHt());
85: }
86:
87: }
|