Source Code Cross Referenced for PDFObject.java in  » PDF » gnujpdf » gnu » jpdf » 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 » gnujpdf » gnu.jpdf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * 
003:         * $Id: PDFObject.java,v 1.1.1.1 2001/10/29 19:51:08 ezb Exp $
004:         *
005:         * $Date: 2001/10/29 19:51:08 $
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public 
009:         * License as published by the Free Software Foundation; either 
010:         * version 2.1 of the License, or (at your option) any later version. 
011:         * 
012:         * This library is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
015:         * Lesser General Public License for more details. 
016:         * 
017:         * You should have received a copy of the GNU Lesser General Public 
018:         * License along with this library; if not, write to the Free Software 
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
020:         */
021:        package gnu.jpdf;
022:
023:        import java.io.*;
024:        import java.util.*;
025:
026:        /**
027:         * This is the base class for all Objects that form the PDF document.
028:         *
029:         * @author Peter T Mount, http://www.retep.org.uk/pdf/
030:         * @author Eric Z. Beard, ericzbeard@hotmail.com
031:         * @author $Author: ezb $
032:         * @version $Revision: 1.1.1.1 $, $Date: 2001/10/29 19:51:08 $
033:         */
034:        public abstract class PDFObject implements  Serializable {
035:
036:            /*
037:             * NOTE: The original class is the work of Peter T. Mount, who released it 
038:             * in the uk.org.retep.pdf package.  It was modified by Eric Z. Beard as 
039:             * follows: 
040:             * The package name was changed to gnu.pdf.  
041:             * The formatting was changed a little bit.
042:             * It is still licensed under the LGPL.
043:             */
044:
045:            /**
046:             * This is the object's PDF Type
047:             */
048:            private String type;
049:
050:            /**
051:             * This is the unique serial number for this object.
052:             */
053:            protected int objser;
054:
055:            /**
056:             * This allows any PDF object to refer to the document being constructed.
057:             */
058:            protected PDFDocument pdfDocument;
059:
060:            /**
061:             * This is usually called by extensors to this class, and sets the
062:             * PDF Object Type
063:             */
064:            public PDFObject(String type) {
065:                this .type = type;
066:            }
067:
068:            /**
069:             * Returns the PDF Type of this object
070:             * @return The PDF Type of this object
071:             */
072:            public String getType() {
073:                return type;
074:            }
075:
076:            /**
077:             * Returns the unique serial number of this object.
078:             * @return Unique serial number of this object.
079:             */
080:            public final int getSerialID() {
081:                return objser;
082:            }
083:
084:            /**
085:             * Returns the PDF document this object belongs to.
086:             * @return PDF containing this object
087:             */
088:            public final PDFDocument getPDFDocument() {
089:                return pdfDocument;
090:            }
091:
092:            /**
093:             * <p>Writes the object to the output stream.
094:             * This method must be overidden.</p>
095:             *
096:             * <p><b>Note:</b> It should not write any other objects, even if they are
097:             * it's Kids, as they will be written by the calling routine.</p>
098:             *
099:             * @param os OutputStream to send the object to
100:             * @exception IOException on error
101:             */
102:            public abstract void write(OutputStream os) throws IOException;
103:
104:            /**
105:             * The write method should call this before writing anything to the
106:             * OutputStream. This will send the standard header for each object.
107:             *
108:             * <p>Note: There are a few rare cases where this method is not called.
109:             *
110:             * @param os OutputStream to write to
111:             * @exception IOException on error
112:             */
113:            public final void writeStart(OutputStream os) throws IOException {
114:                os.write(Integer.toString(objser).getBytes());
115:                os.write(" 0 obj\n<<\n".getBytes());
116:                if (type != null) {
117:                    os.write("/Type ".getBytes());
118:                    os.write(type.getBytes());
119:                    os.write("\n".getBytes());
120:                }
121:            }
122:
123:            /**
124:             * The write method should call this after writing anything to the
125:             * OutputStream. This will send the standard footer for each object.
126:             *
127:             * <p>Note: There are a few rare cases where this method is not called.
128:             *
129:             * @param os OutputStream to write to
130:             * @exception IOException on error
131:             */
132:            public final void writeEnd(OutputStream os) throws IOException {
133:                os.write(">>\nendobj\n".getBytes());
134:            }
135:
136:            /**
137:             * Returns the unique serial number in PDF format
138:             * @return the serial number in PDF format
139:             */
140:            public String toString() {
141:                return "" + objser + " 0 R";
142:            }
143:
144:            /**
145:             * This utility method returns a String containing an array definition
146:             * based on a Vector containing PDFObjects
147:             * @param v Vector containing PDFObjects
148:             * @return String containing a PDF array
149:             */
150:            public static String toArray(Vector v) {
151:                if (v.size() == 0)
152:                    return "";
153:
154:                StringBuffer b = new StringBuffer();
155:                String bs = "[";
156:                for (Enumeration en = v.elements(); en.hasMoreElements();) {
157:                    b.append(bs);
158:                    b.append(en.nextElement().toString());
159:                    bs = " ";
160:                }
161:                b.append("]");
162:                return b.toString();
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.