Source Code Cross Referenced for PDFXref.java in  » PDF » PDF-Renderer » com » sun » pdfview » 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 » PDF Renderer » com.sun.pdfview 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PDFXref.java,v 1.2 2007/12/20 18:17:41 rbair Exp $
003:         *
004:         * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005:         * Santa Clara, California 95054, U.S.A. All rights reserved.
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020:         */
021:
022:        package com.sun.pdfview;
023:
024:        import java.lang.ref.SoftReference;
025:
026:        /**
027:         * a cross reference representing a line in the PDF cross referencing
028:         * table.
029:         * <p>
030:         * There are two forms of the PDFXref, destinguished by absolutely nothing.
031:         * The first type of PDFXref is used as indirect references in a PDFObject.
032:         * In this type, the id is an index number into the object cross reference
033:         * table.  The id will range from 0 to the size of the cross reference
034:         * table.
035:         * <p>
036:         * The second form is used in the Java representation of the cross reference
037:         * table.  In this form, the id is the file position of the start of the
038:         * object in the PDF file.  See the use of both of these in the 
039:         * PDFFile.dereference() method, which takes a PDFXref of the first form,
040:         * and uses (internally) a PDFXref of the second form.
041:         * <p>
042:         * This is an unhappy state of affairs, and should be fixed.  Fortunatly,
043:         * the two uses have already been factored out as two different methods.
044:         *
045:         * @author Mike Wessler
046:         */
047:        public class PDFXref {
048:            private int id;
049:            private int generation;
050:
051:            // this field is only used in PDFFile.objIdx
052:            private SoftReference reference = null;
053:
054:            /**
055:             * create a new PDFXref, given a parsed id and generation.
056:             */
057:            public PDFXref(int id, int gen) {
058:                this .id = id;
059:                this .generation = gen;
060:            }
061:
062:            /**
063:             * create a new PDFXref, given a sequence of bytes representing the
064:             * fixed-width cross reference table line
065:             */
066:            public PDFXref(byte[] line) {
067:                if (line == null) {
068:                    id = -1;
069:                    generation = -1;
070:                } else {
071:                    id = Integer.parseInt(new String(line, 0, 10));
072:                    generation = Integer.parseInt(new String(line, 11, 5));
073:                }
074:            }
075:
076:            /**
077:             * get the character index into the file of the start of this object
078:             */
079:            public int getFilePos() {
080:                return id;
081:            }
082:
083:            /**
084:             * get the generation of this object
085:             */
086:            public int getGeneration() {
087:                return generation;
088:            }
089:
090:            /**
091:             * get the object number of this object
092:             */
093:            public int getID() {
094:                return id;
095:            }
096:
097:            /**
098:             * Get the object this reference refers to, or null if it hasn't been
099:             * set.
100:             * @return the object if it exists, or null if not
101:             */
102:            public PDFObject getObject() {
103:                if (reference != null) {
104:                    return (PDFObject) reference.get();
105:                }
106:
107:                return null;
108:            }
109:
110:            /**
111:             * Set the object this reference refers to.
112:             */
113:            public void setObject(PDFObject obj) {
114:                this .reference = new SoftReference(obj);
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.