Source Code Cross Referenced for PjDictionary.java in  » PDF » pjx » com » etymon » pj » object » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » pjx » com.etymon.pj.object 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.etymon.pj.object;
002:
003:        import java.io.*;
004:        import java.util.*;
005:        import com.etymon.pj.*;
006:        import com.etymon.pj.exception.*;
007:
008:        /**
009:         A representation of the PDF dictionary type.
010:         @author Nassib Nassar
011:         */
012:        public class PjDictionary extends PjObject {
013:
014:            /**
015:               Creates an empty dictionary.
016:             */
017:            public PjDictionary() {
018:                _h = new Hashtable();
019:            }
020:
021:            /**
022:               Creates a dictionary as a wrapper around a Hashtable.
023:               @param h the Hashtable to use for this dictionary.
024:             */
025:            public PjDictionary(Hashtable h) {
026:                _h = h;
027:            }
028:
029:            /**
030:               Returns the Hashtable used to represent this dictionary.
031:               @return the Hashtable used to represent this dictionary.
032:             */
033:            public Hashtable getHashtable() {
034:                return _h;
035:            }
036:
037:            /**
038:               Writes this dictionary to a stream in PDF format.
039:               @param os the stream to write to.
040:               @return the number of bytes written.
041:               @exception IOException if an I/O error occurs.
042:             */
043:            public long writePdf(OutputStream os) throws IOException {
044:		long z = writeln(os, "<<");
045:		PjName name;
046:		for (Enumeration enum = _h.keys();
047:		     enum.hasMoreElements();) {
048:			name = ((PjName)(enum.nextElement()));
049:			z = z + name.writePdf(os);
050:			z = z + write(os, " ");
051:			z = z + ((PjObject)(_h.get(name))).writePdf(os);
052:			z = z + writeln(os, "");
053:		}
054:		z = z + write(os, ">>");
055:		return z;
056:	}
057:
058:            /**
059:               Returns a string representation of this dictionary in PDF format.
060:               @return the string representation.
061:            public String toString() {
062:            	StringBuffer sb = new StringBuffer("<<");
063:            	sb.append(PjConst.PDF_EOL);
064:            	PjName name;
065:            	for (Enumeration enum = _h.keys();
066:            	     enum.hasMoreElements();) {
067:            		name = ((PjName)(enum.nextElement()));
068:            		sb.append(name.toString());
069:            		sb.append(" ");
070:            		sb.append(((PjObject)(_h.get(name))).toString());
071:            		sb.append(PjConst.PDF_EOL);
072:            	}
073:            	sb.append(">>");
074:            	return sb.toString();
075:            }
076:             */
077:
078:            /**
079:               Returns a deep copy of this object.
080:               @return a deep copy of this object.
081:               @exception CloneNotSupportedException if the instance can not be cloned.
082:             */
083:            public Object clone() throws CloneNotSupportedException {
084:                return new PjDictionary(cloneHt());
085:            }
086:
087:            protected Hashtable cloneHt() throws CloneNotSupportedException {
088:                Hashtable ht = new Hashtable(Math.max(_h.size(), 1));
089:                Object key;
090:                Object value;
091:                for (Enumeration m = _h.keys(); m.hasMoreElements();) {
092:                    key = m.nextElement();
093:                    value = _h.get(key);
094:                    if (value instanceof  PjObject) {
095:                        ht.put(key, ((PjObject) value).clone());
096:                    } else {
097:                        throw new CloneNotSupportedException(
098:                                "Object in dictionary is not a PjObject.");
099:                    }
100:                }
101:                return ht;
102:            }
103:
104:            /**
105:               Renumbers object references within this object.  This
106:               method calls itself recursively to comprehensively renumber
107:               all objects contained within this object.
108:               @param map the table of object number mappings.  Each
109:               object number is looked up by key in the hash table, and
110:               the associated value is assigned as the new object number.
111:               The map hash table should consist of PjNumber keys and
112:               PjReference values.
113:             */
114:            public void renumber(Hashtable map) {
115:                Object key;
116:                PjObject obj;
117:                Object r;
118:                for (Enumeration m = _h.keys(); m.hasMoreElements();) {
119:                    key = m.nextElement();
120:                    try {
121:                        obj = (PjObject) (_h.get(key));
122:                        if (obj instanceof  PjReference) {
123:                            r = map.get(((PjReference) obj).getObjNumber());
124:                            if (r != null) {
125:                                _h.put(key, r);
126:                            }
127:                        } else {
128:                            obj.renumber(map);
129:                        }
130:                    } catch (ClassCastException e) {
131:                        // ignore bad objects
132:                    }
133:                }
134:            }
135:
136:            protected PjObject hget(PjName name)
137:                    throws InvalidPdfObjectException {
138:                Object obj = _h.get(name);
139:                if (obj != null) {
140:                    if (obj instanceof  PjObject) {
141:                        return (PjObject) obj;
142:                    } else {
143:                        throw new InvalidPdfObjectException(name.getString()
144:                                + " is not a PDF object.");
145:                    }
146:                } else {
147:                    return null;
148:                }
149:            }
150:
151:            protected PjReference hgetReference(PjName name)
152:                    throws InvalidPdfObjectException {
153:                Object obj = _h.get(name);
154:                if (obj != null) {
155:                    if (obj instanceof  PjReference) {
156:                        return (PjReference) obj;
157:                    } else {
158:                        throw new InvalidPdfObjectException(name.getString()
159:                                + " is not a reference.");
160:                    }
161:                } else {
162:                    return null;
163:                }
164:            }
165:
166:            protected Hashtable _h;
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.